aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_common.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-06-07 00:25:01 -0700
committerChris Lu <chris.lu@gmail.com>2019-06-07 00:25:05 -0700
commit9d9162ca356932fb8c9ec0322f3a771bbbcc47f5 (patch)
tree25edb35a41372da7a98570c5d81ee5cbeacb91ca /weed/shell/command_ec_common.go
parent7912a812f1ca81305793812af657a7947f43a34c (diff)
downloadseaweedfs-9d9162ca356932fb8c9ec0322f3a771bbbcc47f5.tar.xz
seaweedfs-9d9162ca356932fb8c9ec0322f3a771bbbcc47f5.zip
ec.balance: collect dc rack info
Diffstat (limited to 'weed/shell/command_ec_common.go')
-rw-r--r--weed/shell/command_ec_common.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go
index 041715908..7787f4e9f 100644
--- a/weed/shell/command_ec_common.go
+++ b/weed/shell/command_ec_common.go
@@ -98,11 +98,11 @@ func oneServerCopyAndMountEcShardsFromSource(ctx context.Context, grpcDialOption
return
}
-func eachDataNode(topo *master_pb.TopologyInfo, fn func(*master_pb.DataNodeInfo)) {
+func eachDataNode(topo *master_pb.TopologyInfo, fn func(dc, rack string, dn *master_pb.DataNodeInfo)) {
for _, dc := range topo.DataCenterInfos {
for _, rack := range dc.RackInfos {
for _, dn := range rack.DataNodeInfos {
- fn(dn)
+ fn(dc.Id, rack.Id, dn)
}
}
}
@@ -128,6 +128,8 @@ func countFreeShardSlots(dn *master_pb.DataNodeInfo) (count int) {
type EcNode struct {
info *master_pb.DataNodeInfo
+ dc string
+ rack string
freeEcSlot int
}
@@ -144,10 +146,12 @@ func collectEcNodes(ctx context.Context, commandEnv *CommandEnv) (ecNodes []*EcN
}
// find out all volume servers with one slot left.
- eachDataNode(resp.TopologyInfo, func(dn *master_pb.DataNodeInfo) {
+ eachDataNode(resp.TopologyInfo, func(dc, rack string, dn *master_pb.DataNodeInfo) {
if freeEcSlots := countFreeShardSlots(dn); freeEcSlots > 0 {
ecNodes = append(ecNodes, &EcNode{
info: dn,
+ dc: dc,
+ rack: rack,
freeEcSlot: int(freeEcSlots),
})
totalFreeEcSlots += freeEcSlots