From 3b030731a066a06c8374327975771b60b7cfc6f0 Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Thu, 29 Jan 2015 12:37:34 -0600 Subject: [PATCH] HDFS-7603. The background replication queue initialization may not let others run. Contributed by Kihwal Lee. (cherry picked from commit 89b07490f8354bb83a67b7ffc917bfe99708e615) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/blockmanagement/BlockManager.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 18b4fea06e2..efe7b492ccf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -275,6 +275,9 @@ Release 2.7.0 - UNRELEASED HDFS-7675. Remove unused member DFSClient#spanReceiverHost (cmccabe) + HDFS-7603. The background replication queue initialization may not let + others run (kihwal) + OPTIMIZATIONS HDFS-7454. Reduce memory footprint for AclEntries in NameNode. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index 4ac04ec8c62..ec085d75896 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -2615,6 +2615,9 @@ public class BlockManager { long totalBlocks = blocksMap.size(); replicationQueuesInitProgress = 0; long totalProcessed = 0; + long sleepDuration = + Math.max(1, Math.min(numBlocksPerIteration/1000, 10000)); + while (namesystem.isRunning() && !Thread.currentThread().isInterrupted()) { int processed = 0; namesystem.writeLockInterruptibly(); @@ -2671,6 +2674,8 @@ public class BlockManager { } } finally { namesystem.writeUnlock(); + // Make sure it is out of the write lock for sufficiently long time. + Thread.sleep(sleepDuration); } } if (Thread.currentThread().isInterrupted()) {