ec shard balancing

This commit is contained in:
Chris Lu
2019-06-10 21:32:56 -07:00
parent 9d9162ca35
commit f9d8bd51ad
6 changed files with 630 additions and 164 deletions

View File

@@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io"
"math"
"os"
"sort"
"time"
@@ -41,7 +40,7 @@ func (c *commandVolumeBalance) Help() string {
func balanceWritableVolumes(){
idealWritableVolumes = totalWritableVolumes / numVolumeServers
for {
for hasMovedOneVolume {
sort all volume servers ordered by the number of local writable volumes
pick the volume server A with the lowest number of writable volumes x
pick the volume server B with the highest number of writable volumes y
@@ -187,13 +186,14 @@ func balanceSelectedVolume(commandEnv *CommandEnv, nodes []*Node, sortCandidates
selectedVolumeCount += len(dn.selectedVolumes)
}
idealSelectedVolumes := int(math.Ceil(float64(selectedVolumeCount) / float64(len(nodes))))
idealSelectedVolumes := ceilDivide(selectedVolumeCount, len(nodes))
hasMove := true
for hasMove {
hasMove = false
sort.Slice(nodes, func(i, j int) bool {
// TODO sort by free volume slots???
return len(nodes[i].selectedVolumes) < len(nodes[j].selectedVolumes)
})
emptyNode, fullNode := nodes[0], nodes[len(nodes)-1]