mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix shard count reporting
This commit is contained in:
parent
784141c5e6
commit
6b08db65b0
|
@ -22,26 +22,31 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// found out the newShards and deletedShards
|
// found out the newShards and deletedShards
|
||||||
|
var newShardCount, deletedShardCount int
|
||||||
dn.ecShardsLock.RLock()
|
dn.ecShardsLock.RLock()
|
||||||
for vid, ecShards := range dn.ecShards {
|
for vid, ecShards := range dn.ecShards {
|
||||||
if actualEcShards, ok := actualEcShardMap[vid]; !ok {
|
if actualEcShards, ok := actualEcShardMap[vid]; !ok {
|
||||||
// dn registered ec shards not found in the new set of ec shards
|
// dn registered ec shards not found in the new set of ec shards
|
||||||
deletedShards = append(deletedShards, ecShards)
|
deletedShards = append(deletedShards, ecShards)
|
||||||
|
deletedShardCount += ecShards.ShardIdCount()
|
||||||
} else {
|
} else {
|
||||||
// found, but maybe the actual shard could be missing
|
// found, but maybe the actual shard could be missing
|
||||||
a := actualEcShards.Minus(ecShards)
|
a := actualEcShards.Minus(ecShards)
|
||||||
if a.ShardIdCount() > 0 {
|
if a.ShardIdCount() > 0 {
|
||||||
newShards = append(newShards, a)
|
newShards = append(newShards, a)
|
||||||
|
newShardCount += a.ShardIdCount()
|
||||||
}
|
}
|
||||||
d := ecShards.Minus(actualEcShards)
|
d := ecShards.Minus(actualEcShards)
|
||||||
if d.ShardIdCount() > 0 {
|
if d.ShardIdCount() > 0 {
|
||||||
deletedShards = append(deletedShards, d)
|
deletedShards = append(deletedShards, d)
|
||||||
|
deletedShardCount += d.ShardIdCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, ecShards := range actualShards {
|
for _, ecShards := range actualShards {
|
||||||
if _, found := dn.ecShards[ecShards.VolumeId]; !found {
|
if _, found := dn.ecShards[ecShards.VolumeId]; !found {
|
||||||
newShards = append(newShards, ecShards)
|
newShards = append(newShards, ecShards)
|
||||||
|
newShardCount += ecShards.ShardIdCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dn.ecShardsLock.RUnlock()
|
dn.ecShardsLock.RUnlock()
|
||||||
|
@ -50,7 +55,7 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
|
||||||
// if changed, set to the new ec shard map
|
// if changed, set to the new ec shard map
|
||||||
dn.ecShardsLock.Lock()
|
dn.ecShardsLock.Lock()
|
||||||
dn.ecShards = actualEcShardMap
|
dn.ecShards = actualEcShardMap
|
||||||
dn.UpAdjustEcShardCountDelta(int64(len(newShards) - len(deletedShards)))
|
dn.UpAdjustEcShardCountDelta(int64(newShardCount - deletedShardCount))
|
||||||
dn.ecShardsLock.Unlock()
|
dn.ecShardsLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue