diff options
| author | Lisandro Pin <lisandro.pin@proton.ch> | 2024-12-10 22:30:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-10 13:30:13 -0800 |
| commit | 8c82c037b9b99b5514010267755745ca19eae8f4 (patch) | |
| tree | 9da8a041ac9e0fe16e2edd2291c6a05ae048087b /weed/shell/command_ec_balance.go | |
| parent | ff1392f7f4a854d17dea13f6738a219d7bb2cf96 (diff) | |
| download | seaweedfs-8c82c037b9b99b5514010267755745ca19eae8f4.tar.xz seaweedfs-8c82c037b9b99b5514010267755745ca19eae8f4.zip | |
Unify the re-balancing logic for `ec.encode` with `ec.balance`. (#6339)
Among others, this enables recent changes related to topology aware
re-balancing at EC encoding time.
Diffstat (limited to 'weed/shell/command_ec_balance.go')
| -rw-r--r-- | weed/shell/command_ec_balance.go | 68 |
1 files changed, 1 insertions, 67 deletions
diff --git a/weed/shell/command_ec_balance.go b/weed/shell/command_ec_balance.go index 81d214fcc..9e27f40ce 100644 --- a/weed/shell/command_ec_balance.go +++ b/weed/shell/command_ec_balance.go @@ -24,73 +24,7 @@ func (c *commandEcBalance) Help() string { ec.balance [-c EACH_COLLECTION|<collection_name>] [-force] [-dataCenter <data_center>] [-shardReplicaPlacement <replica_placement>] Algorithm: - - func EcBalance() { - for each collection: - balanceEcVolumes(collectionName) - for each rack: - balanceEcRack(rack) - } - - func balanceEcVolumes(collectionName){ - for each volume: - doDeduplicateEcShards(volumeId) - - tracks rack~shardCount mapping - for each volume: - doBalanceEcShardsAcrossRacks(volumeId) - - for each volume: - doBalanceEcShardsWithinRacks(volumeId) - } - - // spread ec shards into more racks - func doBalanceEcShardsAcrossRacks(volumeId){ - tracks rack~volumeIdShardCount mapping - averageShardsPerEcRack = totalShardNumber / numRacks // totalShardNumber is 14 for now, later could varies for each dc - ecShardsToMove = select overflown ec shards from racks with ec shard counts > averageShardsPerEcRack - for each ecShardsToMove { - destRack = pickOneRack(rack~shardCount, rack~volumeIdShardCount, ecShardReplicaPlacement) - destVolumeServers = volume servers on the destRack - pickOneEcNodeAndMoveOneShard(destVolumeServers) - } - } - - func doBalanceEcShardsWithinRacks(volumeId){ - racks = collect all racks that the volume id is on - for rack, shards := range racks - doBalanceEcShardsWithinOneRack(volumeId, shards, rack) - } - - // move ec shards - func doBalanceEcShardsWithinOneRack(volumeId, shards, rackId){ - tracks volumeServer~volumeIdShardCount mapping - averageShardCount = len(shards) / numVolumeServers - volumeServersOverAverage = volume servers with volumeId's ec shard counts > averageShardsPerEcRack - ecShardsToMove = select overflown ec shards from volumeServersOverAverage - for each ecShardsToMove { - destVolumeServer = pickOneVolumeServer(volumeServer~shardCount, volumeServer~volumeIdShardCount, ecShardReplicaPlacement) - pickOneEcNodeAndMoveOneShard(destVolumeServers) - } - } - - // move ec shards while keeping shard distribution for the same volume unchanged or more even - func balanceEcRack(rack){ - averageShardCount = total shards / numVolumeServers - for hasMovedOneEcShard { - sort all volume servers ordered by the number of local ec shards - pick the volume server A with the lowest number of ec shards x - pick the volume server B with the highest number of ec shards y - if y > averageShardCount and x +1 <= averageShardCount { - if B has a ec shard with volume id v that A does not have { - move one ec shard v from B to A - hasMovedOneEcShard = true - } - } - } - } - -` + ` + ecBalanceAlgorithmDescription } func (c *commandEcBalance) HasTag(CommandTag) bool { |
