diff options
Diffstat (limited to 'weed/shell/command_ec_common.go')
| -rw-r--r-- | weed/shell/command_ec_common.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go index 4b672b2ef..30667896a 100644 --- a/weed/shell/command_ec_common.go +++ b/weed/shell/command_ec_common.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math/rand/v2" + "sort" "time" "github.com/seaweedfs/seaweedfs/weed/glog" @@ -182,6 +183,46 @@ func collectEcNodes(commandEnv *CommandEnv) (ecNodes []*EcNode, totalFreeEcSlots return collectEcNodesForDC(commandEnv, "") } +func collectCollectionsForVolumeIds(t *master_pb.TopologyInfo, vids []needle.VolumeId) []string { + if len(vids) == 0 { + return nil + } + + found := map[string]bool{} + for _, dc := range t.DataCenterInfos { + for _, r := range dc.RackInfos { + for _, dn := range r.DataNodeInfos { + for _, diskInfo := range dn.DiskInfos { + for _, vi := range diskInfo.VolumeInfos { + for _, vid := range vids { + if needle.VolumeId(vi.Id) == vid && vi.Collection != "" { + found[vi.Collection] = true + } + } + } + for _, ecs := range diskInfo.EcShardInfos { + for _, vid := range vids { + if needle.VolumeId(ecs.Id) == vid && ecs.Collection != "" { + found[ecs.Collection] = true + } + } + } + } + } + } + } + if len(found) == 0 { + return nil + } + + collections := []string{} + for k, _ := range found { + collections = append(collections, k) + } + sort.Strings(collections) + return collections +} + func moveMountedShardToEcNode(commandEnv *CommandEnv, existingLocation *EcNode, collection string, vid needle.VolumeId, shardId erasure_coding.ShardId, destinationEcNode *EcNode, applyBalancing bool) (err error) { if !commandEnv.isLocked() { |
