mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-06-30 14:21:00 +02:00
move volume: find target volume server by exiting/max ratio
This commit is contained in:
parent
049f040c3c
commit
98dc1e5c15
|
@ -208,17 +208,22 @@ func (c *commandVolumeServerEvacuate) moveAwayOneEcVolume(commandEnv *CommandEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveAwayOneNormalVolume(commandEnv *CommandEnv, volumeReplicas map[uint32][]*VolumeReplica, vol *master_pb.VolumeInformationMessage, thisNode *Node, otherNodes []*Node, applyChange bool) (hasMoved bool, err error) {
|
func moveAwayOneNormalVolume(commandEnv *CommandEnv, volumeReplicas map[uint32][]*VolumeReplica, vol *master_pb.VolumeInformationMessage, thisNode *Node, otherNodes []*Node, applyChange bool) (hasMoved bool, err error) {
|
||||||
fn := capacityByFreeVolumeCount(types.ToDiskType(vol.DiskType))
|
freeVolumeCountfn := capacityByFreeVolumeCount(types.ToDiskType(vol.DiskType))
|
||||||
|
maxVolumeCountFn := capacityByMaxVolumeCount(types.ToDiskType(vol.DiskType))
|
||||||
for _, n := range otherNodes {
|
for _, n := range otherNodes {
|
||||||
n.selectVolumes(func(v *master_pb.VolumeInformationMessage) bool {
|
n.selectVolumes(func(v *master_pb.VolumeInformationMessage) bool {
|
||||||
return v.DiskType == vol.DiskType
|
return v.DiskType == vol.DiskType
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// most empty one is in the front
|
||||||
slices.SortFunc(otherNodes, func(a, b *Node) bool {
|
slices.SortFunc(otherNodes, func(a, b *Node) bool {
|
||||||
return a.localVolumeRatio(fn) < b.localVolumeRatio(fn)
|
return a.localVolumeRatio(maxVolumeCountFn) < b.localVolumeRatio(maxVolumeCountFn)
|
||||||
})
|
})
|
||||||
for i := 0; i < len(otherNodes); i++ {
|
for i := 0; i < len(otherNodes); i++ {
|
||||||
emptyNode := otherNodes[i]
|
emptyNode := otherNodes[i]
|
||||||
|
if freeVolumeCountfn(emptyNode.info) < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
hasMoved, err = maybeMoveOneVolume(commandEnv, volumeReplicas, thisNode, vol, emptyNode, applyChange)
|
hasMoved, err = maybeMoveOneVolume(commandEnv, volumeReplicas, thisNode, vol, emptyNode, applyChange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue