SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
refactor to change capacity data type
chrisluf9383aa72677
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.goindex 325e504c49..5ca77785f3 100644--- a/weed/shell/command_ec_common.go+++ b/weed/shell/command_ec_common.go@@ -282,10 +282,6 @@ func mountEcShards(grpcDialOption grpc.DialOption, collection string, volumeId n})}-func divide(total, n int) float64 {- return float64(total) / float64(n)-}-func ceilDivide(total, n int) int {return int(math.Ceil(float64(total) / float64(n)))}diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.goindex bc0adfc5ff..980a8d7d1a 100644--- a/weed/shell/command_volume_balance.go+++ b/weed/shell/command_volume_balance.go@@ -183,34 +183,34 @@ type Node struct {rack string}-type CapacityFunc func(*master_pb.DataNodeInfo) int+type CapacityFunc func(*master_pb.DataNodeInfo) float64func capacityByMaxVolumeCount(diskType types.DiskType) CapacityFunc {- return func(info *master_pb.DataNodeInfo) int {+ return func(info *master_pb.DataNodeInfo) float64 {diskInfo, found := info.DiskInfos[string(diskType)]if !found {return 0}- return int(diskInfo.MaxVolumeCount)+ return float64(diskInfo.MaxVolumeCount)}}func capacityByFreeVolumeCount(diskType types.DiskType) CapacityFunc {- return func(info *master_pb.DataNodeInfo) int {+ return func(info *master_pb.DataNodeInfo) float64 {diskInfo, found := info.DiskInfos[string(diskType)]if !found {return 0}- return int(diskInfo.MaxVolumeCount - diskInfo.VolumeCount)+ return float64(diskInfo.MaxVolumeCount - diskInfo.VolumeCount)}}func (n *Node) localVolumeRatio(capacityFunc CapacityFunc) float64 {- return divide(len(n.selectedVolumes), capacityFunc(n.info))+ return float64(len(n.selectedVolumes)) / capacityFunc(n.info)}func (n *Node) localVolumeNextRatio(capacityFunc CapacityFunc) float64 {- return divide(len(n.selectedVolumes)+1, capacityFunc(n.info))+ return float64(len(n.selectedVolumes)+1) / capacityFunc(n.info)}func (n *Node) isOneVolumeOnly() bool {@@ -243,7 +243,7 @@ func sortWritableVolumes(volumes []*master_pb.VolumeInformationMessage) {}func balanceSelectedVolume(commandEnv *CommandEnv, diskType types.DiskType, volumeReplicas map[uint32][]*VolumeReplica, nodes []*Node, capacityFunc CapacityFunc, sortCandidatesFn func(volumes []*master_pb.VolumeInformationMessage), applyBalancing bool) (err error) {- selectedVolumeCount, volumeMaxCount := 0, 0+ selectedVolumeCount, volumeMaxCount := 0, float64(0)var nodesWithCapacity []*Nodefor _, dn := range nodes {selectedVolumeCount += len(dn.selectedVolumes)@@ -254,7 +254,7 @@ func balanceSelectedVolume(commandEnv *CommandEnv, diskType types.DiskType, voluvolumeMaxCount += capacity}- idealVolumeRatio := divide(selectedVolumeCount, volumeMaxCount)+ idealVolumeRatio := float64(selectedVolumeCount) / volumeMaxCounthasMoved := true