diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-09-17 10:29:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-17 10:29:32 +0800 |
| commit | f71f7fcf99ba6d64bfa49fd7411e06bdc2b9d591 (patch) | |
| tree | e0e98625edaab040eed21fd1a8b277f2c0546ad3 /weed/shell/command_ec_common.go | |
| parent | 23baa3c36ce468a36d89abae59f4411cdc446043 (diff) | |
| parent | 5eee4983f36f55a2a01381e8af278b28919dbe90 (diff) | |
| download | seaweedfs-f71f7fcf99ba6d64bfa49fd7411e06bdc2b9d591.tar.xz seaweedfs-f71f7fcf99ba6d64bfa49fd7411e06bdc2b9d591.zip | |
Merge pull request #15 from chrislusf/master
sync
Diffstat (limited to 'weed/shell/command_ec_common.go')
| -rw-r--r-- | weed/shell/command_ec_common.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go index 0db119d3c..a808335eb 100644 --- a/weed/shell/command_ec_common.go +++ b/weed/shell/command_ec_common.go @@ -173,6 +173,16 @@ type EcNode struct { freeEcSlot int } +func (ecNode *EcNode) localShardIdCount(vid uint32) int { + for _, ecShardInfo := range ecNode.info.EcShardInfos { + if vid == ecShardInfo.Id { + shardBits := erasure_coding.ShardBits(ecShardInfo.EcIndexBits) + return shardBits.ShardIdCount() + } + } + return 0 +} + type EcRack struct { ecNodes map[EcNodeId]*EcNode freeEcSlot int @@ -191,7 +201,15 @@ func collectEcNodes(commandEnv *CommandEnv, selectedDataCenter string) (ecNodes } // find out all volume servers with one slot left. - eachDataNode(resp.TopologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) { + ecNodes, totalFreeEcSlots = collectEcVolumeServersByDc(resp.TopologyInfo, selectedDataCenter) + + sortEcNodesByFreeslotsDecending(ecNodes) + + return +} + +func collectEcVolumeServersByDc(topo *master_pb.TopologyInfo, selectedDataCenter string) (ecNodes []*EcNode, totalFreeEcSlots int) { + eachDataNode(topo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) { if selectedDataCenter != "" && selectedDataCenter != dc { return } @@ -205,9 +223,6 @@ func collectEcNodes(commandEnv *CommandEnv, selectedDataCenter string) (ecNodes }) totalFreeEcSlots += freeEcSlots }) - - sortEcNodesByFreeslotsDecending(ecNodes) - return } @@ -253,6 +268,10 @@ 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))) } |
