|
|
@ -388,7 +388,10 @@ func doBalanceEcRack(commandEnv *CommandEnv, ecRack *EcRack, applyBalancing bool |
|
|
|
} |
|
|
|
|
|
|
|
ecNodeIdToShardCount := groupByCount(rackEcNodes, func(ecNode *EcNode) (id string, count int) { |
|
|
|
diskInfo := ecNode.info.DiskInfos[string(types.HardDriveType)] |
|
|
|
diskInfo, found := ecNode.info.DiskInfos[string(types.HardDriveType)] |
|
|
|
if !found { |
|
|
|
return |
|
|
|
} |
|
|
|
for _, ecShardInfo := range diskInfo.EcShardInfos { |
|
|
|
count += erasure_coding.ShardBits(ecShardInfo.EcIndexBits).ShardIdCount() |
|
|
|
} |
|
|
@ -413,11 +416,12 @@ func doBalanceEcRack(commandEnv *CommandEnv, ecRack *EcRack, applyBalancing bool |
|
|
|
if fullNodeShardCount > averageShardCount && emptyNodeShardCount+1 <= averageShardCount { |
|
|
|
|
|
|
|
emptyNodeIds := make(map[uint32]bool) |
|
|
|
emptyDiskInfo := emptyNode.info.DiskInfos[string(types.HardDriveType)] |
|
|
|
if emptyDiskInfo, found := emptyNode.info.DiskInfos[string(types.HardDriveType)]; found { |
|
|
|
for _, shards := range emptyDiskInfo.EcShardInfos { |
|
|
|
emptyNodeIds[shards.Id] = true |
|
|
|
} |
|
|
|
fullDiskInfo := fullNode.info.DiskInfos[string(types.HardDriveType)] |
|
|
|
} |
|
|
|
if fullDiskInfo, found := fullNode.info.DiskInfos[string(types.HardDriveType)]; found { |
|
|
|
for _, shards := range fullDiskInfo.EcShardInfos { |
|
|
|
if _, found := emptyNodeIds[shards.Id]; !found { |
|
|
|
for _, shardId := range erasure_coding.ShardBits(shards.EcIndexBits).ShardIds() { |
|
|
@ -439,6 +443,7 @@ func doBalanceEcRack(commandEnv *CommandEnv, ecRack *EcRack, applyBalancing bool |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
@ -515,7 +520,10 @@ func pickNEcShardsToMoveFrom(ecNodes []*EcNode, vid needle.VolumeId, n int) map[ |
|
|
|
func collectVolumeIdToEcNodes(allEcNodes []*EcNode) map[needle.VolumeId][]*EcNode { |
|
|
|
vidLocations := make(map[needle.VolumeId][]*EcNode) |
|
|
|
for _, ecNode := range allEcNodes { |
|
|
|
diskInfo := ecNode.info.DiskInfos[string(types.HardDriveType)] |
|
|
|
diskInfo, found := ecNode.info.DiskInfos[string(types.HardDriveType)] |
|
|
|
if !found { |
|
|
|
continue |
|
|
|
} |
|
|
|
for _, shardInfo := range diskInfo.EcShardInfos { |
|
|
|
vidLocations[needle.VolumeId(shardInfo.Id)] = append(vidLocations[needle.VolumeId(shardInfo.Id)], ecNode) |
|
|
|
} |
|
|
|