register ec shards to topology
This commit is contained in:
@@ -18,23 +18,23 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
|
||||
// prepare the new ec shard map
|
||||
actualEcShardMap := make(map[needle.VolumeId]*erasure_coding.EcVolumeInfo)
|
||||
for _, ecShards := range actualShards {
|
||||
actualEcShardMap[ecShards.VolumeId]= ecShards
|
||||
actualEcShardMap[ecShards.VolumeId] = ecShards
|
||||
}
|
||||
|
||||
// found out the newShards and deletedShards
|
||||
dn.ecShardsLock.RLock()
|
||||
for vid, ecShards := range dn.ecShards{
|
||||
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)
|
||||
} else {
|
||||
// found, but maybe the actual shard could be missing
|
||||
a := actualEcShards.Minus(ecShards)
|
||||
if len(a.ShardIds())>0 {
|
||||
if len(a.ShardIds()) > 0 {
|
||||
newShards = append(newShards, a)
|
||||
}
|
||||
d := ecShards.Minus(actualEcShards)
|
||||
if len(d.ShardIds())>0 {
|
||||
if len(d.ShardIds()) > 0 {
|
||||
deletedShards = append(deletedShards, d)
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (dn *DataNode) UpdateEcShards(actualShards []*erasure_coding.EcVolumeInfo)
|
||||
}
|
||||
dn.ecShardsLock.RUnlock()
|
||||
|
||||
if len(newShards)>0 || len(deletedShards)>0{
|
||||
if len(newShards) > 0 || len(deletedShards) > 0 {
|
||||
// if changed, set to the new ec shard map
|
||||
dn.ecShardsLock.Lock()
|
||||
dn.ecShards = actualEcShardMap
|
||||
|
||||
Reference in New Issue
Block a user