diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/BlockPoolSlice.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/BlockPoolSlice.java index b9b581fedca..4a4fef9d1fe 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/BlockPoolSlice.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/BlockPoolSlice.java @@ -183,8 +183,10 @@ class BlockPoolSlice { .setConf(conf) .setInitialUsed(loadDfsUsed()) .build(); - // initialize add replica fork join pool - initializeAddReplicaPool(conf); + if (addReplicaThreadPool == null) { + // initialize add replica fork join pool + initializeAddReplicaPool(conf); + } // Make the dfs usage to be saved during shutdown. shutdownHook = new Runnable() { @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaMap.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaMap.java index c630b951a81..73d3c600b9c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaMap.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/ReplicaMap.java @@ -154,7 +154,7 @@ class ReplicaMap { if (oldReplicaInfo != null) { return oldReplicaInfo; } else { - set.add(replicaInfo); + set.addOrReplace(replicaInfo); } return replicaInfo; }