aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_common.go
diff options
context:
space:
mode:
authorLisandro Pin <lisandro.pin@proton.ch>2024-12-12 17:41:33 +0100
committerGitHub <noreply@github.com>2024-12-12 08:41:33 -0800
commit23ffbb083c4bcc9d723ce5857e08f85e7205140a (patch)
tree09f03ef1a87703f0ebfdeb5af20501bfcd4d4e70 /weed/shell/command_ec_common.go
parent6320036c567bb3d2bde32824574233aee817cd53 (diff)
downloadseaweedfs-23ffbb083c4bcc9d723ce5857e08f85e7205140a.tar.xz
seaweedfs-23ffbb083c4bcc9d723ce5857e08f85e7205140a.zip
Limit EC re-balancing for `ec.encode` to relevant collections when a volume ID argument is provided. (#6347)
Limit EC re-balancing for `ec.encode` to relevant collections when a volume ID is provided.
Diffstat (limited to 'weed/shell/command_ec_common.go')
-rw-r--r--weed/shell/command_ec_common.go41
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() {