aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-06-05 01:58:37 -0700
committerChris Lu <chris.lu@gmail.com>2019-06-05 01:58:37 -0700
commit6b08db65b0cf38a865cecbc104134b413c0f9c83 (patch)
treeb53bf05c6e895ba24d6066d222cb84579eec2fc9
parent784141c5e6e66ce349cf6d39d0bbf7848545548f (diff)
downloadseaweedfs-6b08db65b0cf38a865cecbc104134b413c0f9c83.tar.xz
seaweedfs-6b08db65b0cf38a865cecbc104134b413c0f9c83.zip
fix shard count reporting
-rw-r--r--weed/topology/data_node_ec.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/weed/topology/data_node_ec.go b/weed/topology/data_node_ec.go
index 3df9394da..75c8784fe 100644
--- a/weed/topology/data_node_ec.go
+++ b/weed/topology/data_node_ec.go
@@ -22,26 +22,31 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
}
// found out the newShards and deletedShards
+ var newShardCount, deletedShardCount int
dn.ecShardsLock.RLock()
for vid, ecShards := range dn.ecShards {
if actualEcShards, ok := actualEcShardMap[vid]; !ok {
// dn registered ec shards not found in the new set of ec shards
deletedShards = append(deletedShards, ecShards)
+ deletedShardCount += ecShards.ShardIdCount()
} else {
// found, but maybe the actual shard could be missing
a := actualEcShards.Minus(ecShards)
if a.ShardIdCount() > 0 {
newShards = append(newShards, a)
+ newShardCount += a.ShardIdCount()
}
d := ecShards.Minus(actualEcShards)
if d.ShardIdCount() > 0 {
deletedShards = append(deletedShards, d)
+ deletedShardCount += d.ShardIdCount()
}
}
}
for _, ecShards := range actualShards {
if _, found := dn.ecShards[ecShards.VolumeId]; !found {
newShards = append(newShards, ecShards)
+ newShardCount += ecShards.ShardIdCount()
}
}
dn.ecShardsLock.RUnlock()
@@ -50,7 +55,7 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
// if changed, set to the new ec shard map
dn.ecShardsLock.Lock()
dn.ecShards = actualEcShardMap
- dn.UpAdjustEcShardCountDelta(int64(len(newShards) - len(deletedShards)))
+ dn.UpAdjustEcShardCountDelta(int64(newShardCount - deletedShardCount))
dn.ecShardsLock.Unlock()
}