浏览代码

HDFS-7603. The background replication queue initialization may not let others run. Contributed by Kihwal Lee.

Kihwal Lee 10 年之前
父节点
当前提交
89b07490f8

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -561,6 +561,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.

+ 5 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java

@@ -2612,6 +2612,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();
@@ -2668,6 +2671,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()) {