|
@ -120,7 +120,7 @@ func balanceVolumeServers(commandEnv *CommandEnv, diskTypes []types.DiskType, vo |
|
|
|
|
|
|
|
|
func balanceVolumeServersByDiskType(commandEnv *CommandEnv, diskType types.DiskType, volumeReplicas map[uint32][]*VolumeReplica, nodes []*Node, volumeSizeLimit uint64, collection string, applyBalancing bool) error { |
|
|
func balanceVolumeServersByDiskType(commandEnv *CommandEnv, diskType types.DiskType, volumeReplicas map[uint32][]*VolumeReplica, nodes []*Node, volumeSizeLimit uint64, collection string, applyBalancing bool) error { |
|
|
|
|
|
|
|
|
// balance writable volumes
|
|
|
|
|
|
|
|
|
// balance readable volumes
|
|
|
for _, n := range nodes { |
|
|
for _, n := range nodes { |
|
|
n.selectVolumes(func(v *master_pb.VolumeInformationMessage) bool { |
|
|
n.selectVolumes(func(v *master_pb.VolumeInformationMessage) bool { |
|
|
if collection != "ALL_COLLECTIONS" { |
|
|
if collection != "ALL_COLLECTIONS" { |
|
@ -128,14 +128,14 @@ func balanceVolumeServersByDiskType(commandEnv *CommandEnv, diskType types.DiskT |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return v.DiskType == string(diskType) && (!v.ReadOnly && v.Size < volumeSizeLimit) |
|
|
|
|
|
|
|
|
return v.DiskType == string(diskType) && (v.ReadOnly || v.Size >= volumeSizeLimit) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
if err := balanceSelectedVolume(commandEnv, volumeReplicas, nodes, capacityByMaxVolumeCount(diskType), sortWritableVolumes, applyBalancing); err != nil { |
|
|
|
|
|
|
|
|
if err := balanceSelectedVolume(commandEnv, volumeReplicas, nodes, capacityByMaxVolumeCount(diskType), sortReadOnlyVolumes, applyBalancing); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// balance readable volumes
|
|
|
|
|
|
|
|
|
// balance writable volumes
|
|
|
for _, n := range nodes { |
|
|
for _, n := range nodes { |
|
|
n.selectVolumes(func(v *master_pb.VolumeInformationMessage) bool { |
|
|
n.selectVolumes(func(v *master_pb.VolumeInformationMessage) bool { |
|
|
if collection != "ALL_COLLECTIONS" { |
|
|
if collection != "ALL_COLLECTIONS" { |
|
@ -143,10 +143,10 @@ func balanceVolumeServersByDiskType(commandEnv *CommandEnv, diskType types.DiskT |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return v.DiskType == string(diskType) && (v.ReadOnly || v.Size >= volumeSizeLimit) |
|
|
|
|
|
|
|
|
return v.DiskType == string(diskType) && (!v.ReadOnly && v.Size < volumeSizeLimit) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
if err := balanceSelectedVolume(commandEnv, volumeReplicas, nodes, capacityByMaxVolumeCount(diskType), sortReadOnlyVolumes, applyBalancing); err != nil { |
|
|
|
|
|
|
|
|
if err := balanceSelectedVolume(commandEnv, volumeReplicas, nodes, capacityByMaxVolumeCount(diskType), sortWritableVolumes, applyBalancing); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|