diff options
| author | chrislu <chris.lu@gmail.com> | 2022-10-09 22:30:59 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-10-09 22:30:59 -0700 |
| commit | 98dc1e5c15d0a7e3b7c9dc946f360f236d1c9fc4 (patch) | |
| tree | 75c341eb156918f9a4396587c3a149d043d540e2 /weed/shell/command_volume_server_evacuate.go | |
| parent | 049f040c3c6b2f5404244f110784a2f75cb5a58f (diff) | |
| download | seaweedfs-98dc1e5c15d0a7e3b7c9dc946f360f236d1c9fc4.tar.xz seaweedfs-98dc1e5c15d0a7e3b7c9dc946f360f236d1c9fc4.zip | |
move volume: find target volume server by exiting/max ratio
Diffstat (limited to 'weed/shell/command_volume_server_evacuate.go')
| -rw-r--r-- | weed/shell/command_volume_server_evacuate.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/weed/shell/command_volume_server_evacuate.go b/weed/shell/command_volume_server_evacuate.go index b6d702e3a..c9c0033c1 100644 --- a/weed/shell/command_volume_server_evacuate.go +++ b/weed/shell/command_volume_server_evacuate.go @@ -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) { - fn := capacityByFreeVolumeCount(types.ToDiskType(vol.DiskType)) + freeVolumeCountfn := capacityByFreeVolumeCount(types.ToDiskType(vol.DiskType)) + maxVolumeCountFn := capacityByMaxVolumeCount(types.ToDiskType(vol.DiskType)) for _, n := range otherNodes { n.selectVolumes(func(v *master_pb.VolumeInformationMessage) bool { return v.DiskType == vol.DiskType }) } + // most empty one is in the front 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++ { emptyNode := otherNodes[i] + if freeVolumeCountfn(emptyNode.info) < 0 { + continue + } hasMoved, err = maybeMoveOneVolume(commandEnv, volumeReplicas, thisNode, vol, emptyNode, applyChange) if err != nil { return |
