mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-25 06:20:42 +01:00
add sortEcNodesByFreeslotsDecending and sortEcNodesByFreeslotsAscending
addressing https://github.com/chrislusf/seaweedfs/issues/1111
This commit is contained in:
1 parent
f056baa384
commit
40514c5362
3 files changed
+11
-5
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user