aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_common.go
diff options
context:
space:
mode:
authorLisandro Pin <lisandro.pin@proton.ch>2024-12-15 22:36:23 +0100
committerGitHub <noreply@github.com>2024-12-15 13:36:23 -0800
commit9b48ce0613ec135715edd626418cdf812f4ad854 (patch)
tree4c596038bf75c5f0af8606dec47bc3abd5752a17 /weed/shell/command_ec_common.go
parent926cfea3dca8f836e5133b2e56007fdec9e13b34 (diff)
downloadseaweedfs-9b48ce0613ec135715edd626418cdf812f4ad854.tar.xz
seaweedfs-9b48ce0613ec135715edd626418cdf812f4ad854.zip
Parallelize EC shards balancing within racks (#6354)
Parallelize EC shards balancing within racks.
Diffstat (limited to 'weed/shell/command_ec_common.go')
-rw-r--r--weed/shell/command_ec_common.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go
index fff3db429..c73e342db 100644
--- a/weed/shell/command_ec_common.go
+++ b/weed/shell/command_ec_common.go
@@ -786,13 +786,13 @@ func (ecb *ecBalancer) pickRackToBalanceShardsInto(rackToEcNodes map[RackId]*EcR
return targets[rand.IntN(len(targets))], nil
}
-// TODO: enable parallelization
func (ecb *ecBalancer) balanceEcShardsWithinRacks(collection string) error {
// collect vid => []ecNode, since previous steps can change the locations
vidLocations := ecb.collectVolumeIdToEcNodes(collection)
racks := ecb.racks()
// spread the ec shards evenly
+ ecb.wgInit()
for vid, locations := range vidLocations {
// see the volume's shards are in how many racks, and how many in each rack
@@ -811,12 +811,12 @@ func (ecb *ecBalancer) balanceEcShardsWithinRacks(collection string) error {
}
sourceEcNodes := rackEcNodesWithVid[rackId]
averageShardsPerEcNode := ceilDivide(rackToShardCount[rackId], len(possibleDestinationEcNodes))
- if err := ecb.doBalanceEcShardsWithinOneRack(averageShardsPerEcNode, collection, vid, sourceEcNodes, possibleDestinationEcNodes); err != nil {
- return err
- }
+ ecb.wgAdd(func() error {
+ return ecb.doBalanceEcShardsWithinOneRack(averageShardsPerEcNode, collection, vid, sourceEcNodes, possibleDestinationEcNodes)
+ })
}
}
- return nil
+ return ecb.wgWait()
}
func (ecb *ecBalancer) doBalanceEcShardsWithinOneRack(averageShardsPerEcNode int, collection string, vid needle.VolumeId, existingLocations, possibleDestinationEcNodes []*EcNode) error {