Explorar o código

HADOOP-1501. Better randomize sending of block reports to namenode. Contributed by Dhruba.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@549268 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting %!s(int64=18) %!d(string=hai) anos
pai
achega
1b4b38743f
Modificáronse 2 ficheiros con 12 adicións e 1 borrados
  1. 3 0
      CHANGES.txt
  2. 9 1
      src/java/org/apache/hadoop/dfs/DataNode.java

+ 3 - 0
CHANGES.txt

@@ -223,6 +223,9 @@ Trunk (unreleased changes)
  67. HADOOP-1455.  Permit specification of arbitrary job options on
      pipes command line.  (Devaraj Das via cutting)
 
+ 68. HADOOP-1501.  Better randomize sending of block reports to
+     namenode, so reduce load spikes.  (Dhruba Borthakur via cutting)
+
 
 Release 0.13.0 - 2007-06-08
 

+ 9 - 1
src/java/org/apache/hadoop/dfs/DataNode.java

@@ -483,7 +483,15 @@ public class DataNode implements FSConstants, Runnable {
           //
           DatanodeCommand cmd = namenode.blockReport(dnRegistration,
                                                      data.getBlockReport());
-          lastBlockReport = now;
+          //
+          // If we have sent the first block report, then wait a random
+          // time before we start the periodic block reports.
+          //
+          if (lastBlockReport == 0) {
+            lastBlockReport = now - new Random().nextInt((int)(blockReportInterval));
+          } else {
+            lastBlockReport = now;
+          }
           processCommand(cmd);
         }