HDFS-16909. Improve ReplicaMap#mergeAll method. (#5353). Contributed by ZhangHB.

Reviewed-by: zhangshuyan <zqingchai@gmail.com>
Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
hfutatzhanghb 2023-05-21 19:08:58 +08:00 committed by GitHub
parent af933f3a4f
commit 5b22dc6ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,13 +178,13 @@ void mergeAll(ReplicaMap other) {
for (ReplicaInfo replicaInfo : replicaInfos) {
replicaSet.add(replicaInfo);
}
for (ReplicaInfo replicaInfo : replicaSet) {
checkBlock(replicaInfo);
if (curSet == null) {
if (curSet == null && !replicaSet.isEmpty()) {
// Add an entry for block pool if it does not exist already
curSet = new LightWeightResizableGSet<>();
map.put(bp, curSet);
}
for (ReplicaInfo replicaInfo : replicaSet) {
checkBlock(replicaInfo);
curSet.put(replicaInfo);
}
}