mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
adjust replica placement after move
This commit is contained in:
parent
2a0925590c
commit
e2c741f76f
|
@ -40,12 +40,12 @@ func (c *commandVolumeBalance) Help() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balanceWritableVolumes(){
|
func balanceWritableVolumes(){
|
||||||
idealWritableVolumes = totalWritableVolumes / numVolumeServers
|
idealWritableVolumeRatio = totalWritableVolumes / totalNumberOfMaxVolumes
|
||||||
for hasMovedOneVolume {
|
for hasMovedOneVolume {
|
||||||
sort all volume servers ordered by the number of local writable volumes
|
sort all volume servers ordered by the localWritableVolumeRatio = localWritableVolumes to localVolumeMax
|
||||||
pick the volume server B with the highest number of writable volumes y
|
pick the volume server B with the highest localWritableVolumeRatio y
|
||||||
for any the volume server A with the number of writable volumes x +1 <= idealWritableVolume {
|
for any the volume server A with the number of writable volumes x + 1 <= idealWritableVolumeRatio * localVolumeMax {
|
||||||
if y > idealWritableVolumes and x +1 <= idealWritableVolumes {
|
if y > localWritableVolumeRatio {
|
||||||
if B has a writable volume id v that A does not have, and satisfy v replication requirements {
|
if B has a writable volume id v that A does not have, and satisfy v replication requirements {
|
||||||
move writable volume v from A to B
|
move writable volume v from A to B
|
||||||
}
|
}
|
||||||
|
@ -242,8 +242,7 @@ func attemptToMoveOneVolume(commandEnv *CommandEnv, volumeReplicas map[uint32][]
|
||||||
}
|
}
|
||||||
if _, found := emptyNode.selectedVolumes[v.Id]; !found {
|
if _, found := emptyNode.selectedVolumes[v.Id]; !found {
|
||||||
if err = moveVolume(commandEnv, v, fullNode, emptyNode, applyBalancing); err == nil {
|
if err = moveVolume(commandEnv, v, fullNode, emptyNode, applyBalancing); err == nil {
|
||||||
delete(fullNode.selectedVolumes, v.Id)
|
adjustAfterMove(v, volumeReplicas, fullNode, emptyNode)
|
||||||
emptyNode.selectedVolumes[v.Id] = v
|
|
||||||
hasMoved = true
|
hasMoved = true
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
|
@ -312,3 +311,19 @@ func isGoodMove(placement *super_block.ReplicaPlacement, existingReplicas []*Vol
|
||||||
return true
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func adjustAfterMove(v *master_pb.VolumeInformationMessage, volumeReplicas map[uint32][]*VolumeReplica, fullNode *Node, emptyNode *Node) {
|
||||||
|
delete(fullNode.selectedVolumes, v.Id)
|
||||||
|
emptyNode.selectedVolumes[v.Id] = v
|
||||||
|
existingReplicas := volumeReplicas[v.Id]
|
||||||
|
for _, replica := range existingReplicas {
|
||||||
|
if replica.location.dataNode.Id == fullNode.info.Id &&
|
||||||
|
replica.location.rack == fullNode.rack &&
|
||||||
|
replica.location.dc == fullNode.dc {
|
||||||
|
replica.location.dc = emptyNode.dc
|
||||||
|
replica.location.rack = emptyNode.rack
|
||||||
|
replica.location.dataNode = emptyNode.info
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue