mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-19 05:27:50 +08:00
Parallelize EC shards balancing across racks. (#6352)
This commit is contained in:
parent
b81def5e5c
commit
926cfea3dc
@ -679,17 +679,18 @@ func (ecb *ecBalancer) doDeduplicateEcShards(collection string, vid needle.Volum
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: enable parallelization
|
|
||||||
func (ecb *ecBalancer) balanceEcShardsAcrossRacks(collection string) error {
|
func (ecb *ecBalancer) balanceEcShardsAcrossRacks(collection string) error {
|
||||||
// collect vid => []ecNode, since previous steps can change the locations
|
// collect vid => []ecNode, since previous steps can change the locations
|
||||||
vidLocations := ecb.collectVolumeIdToEcNodes(collection)
|
vidLocations := ecb.collectVolumeIdToEcNodes(collection)
|
||||||
|
|
||||||
// spread the ec shards evenly
|
// spread the ec shards evenly
|
||||||
|
ecb.wgInit()
|
||||||
for vid, locations := range vidLocations {
|
for vid, locations := range vidLocations {
|
||||||
if err := ecb.doBalanceEcShardsAcrossRacks(collection, vid, locations); err != nil {
|
ecb.wgAdd(func() error {
|
||||||
return err
|
return ecb.doBalanceEcShardsAcrossRacks(collection, vid, locations)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
return ecb.wgWait()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func countShardsByRack(vid needle.VolumeId, locations []*EcNode) map[string]int {
|
func countShardsByRack(vid needle.VolumeId, locations []*EcNode) map[string]int {
|
||||||
|
Loading…
Reference in New Issue
Block a user