diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-11-12 13:47:36 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-11-12 13:47:36 -0800 |
| commit | 40514c53622fded6681f91d1c7d54045a5ef44c8 (patch) | |
| tree | ad96bbc923859f7c8a50b953f2377037f5feb717 /weed/shell/command_ec_common.go | |
| parent | f056baa384f7c561574a7439d39b9746e52d7e23 (diff) | |
| download | seaweedfs-40514c53622fded6681f91d1c7d54045a5ef44c8.tar.xz seaweedfs-40514c53622fded6681f91d1c7d54045a5ef44c8.zip | |
add sortEcNodesByFreeslotsDecending and sortEcNodesByFreeslotsAscending
addressing https://github.com/chrislusf/seaweedfs/issues/1111
Diffstat (limited to 'weed/shell/command_ec_common.go')
| -rw-r--r-- | weed/shell/command_ec_common.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go index cdd687d13..cfe14fed5 100644 --- a/weed/shell/command_ec_common.go +++ b/weed/shell/command_ec_common.go @@ -112,12 +112,18 @@ func eachDataNode(topo *master_pb.TopologyInfo, fn func(dc string, rack RackId, } } -func sortEcNodes(ecNodes []*EcNode) { +func sortEcNodesByFreeslotsDecending(ecNodes []*EcNode) { sort.Slice(ecNodes, func(i, j int) bool { return ecNodes[i].freeEcSlot > ecNodes[j].freeEcSlot }) } +func sortEcNodesByFreeslotsAscending(ecNodes []*EcNode) { + sort.Slice(ecNodes, func(i, j int) bool { + return ecNodes[i].freeEcSlot < ecNodes[j].freeEcSlot + }) +} + type CandidateEcNode struct { ecNode *EcNode shardCount int @@ -202,7 +208,7 @@ func collectEcNodes(ctx context.Context, commandEnv *CommandEnv, selectedDataCen totalFreeEcSlots += freeEcSlots }) - sortEcNodes(ecNodes) + sortEcNodesByFreeslotsDecending(ecNodes) return } |
