Ver Fonte

HADOOP-514. Make DFS heartbeat interval configurable. Contributed by Milind.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@464716 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting há 19 anos atrás
pai
commit
a54a0b963a

+ 3 - 0
CHANGES.txt

@@ -17,6 +17,9 @@ Trunk (unreleased changes)
  4. HADOOP-586.  Use the jar name for otherwise un-named jobs.
     (Sanjay Dahiya via cutting)
 
+ 5. HADOOP-514.  Make DFS heartbeat interval configurable.
+    (Milind Bhandarkar via cutting)
+
 
 Release 0.7.1 - 2006-10-11
 

+ 7 - 1
conf/hadoop-default.xml

@@ -244,7 +244,13 @@ creations/deletions), or "all".</description>
 <property>
   <name>dfs.blockreport.intervalMsec</name>
   <value>3600000</value>
-  <description>Determines block reporting interval.</description>
+  <description>Determines block reporting interval in milliseconds.</description>
+</property>
+
+<property>
+  <name>dfs.heartbeat.interval</name>
+  <value>3</value>
+  <description>Determines datanode heartbeat interval in seconds.</description>
 </property>
 
 <property>

+ 4 - 2
src/java/org/apache/hadoop/dfs/DataNode.java

@@ -95,6 +95,7 @@ public class DataNode implements FSConstants, Runnable {
     int xmitsInProgress = 0;
     Daemon dataXceiveServer = null;
     long blockReportInterval;
+    long heartBeatInterval;
     private DataStorage storage = null;
     private StatusHttpServer infoServer;
     private static InetSocketAddress nameNodeAddr;
@@ -231,6 +232,7 @@ public class DataNode implements FSConstants, Runnable {
         conf.getLong("dfs.blockreport.intervalMsec", BLOCKREPORT_INTERVAL);
       this.blockReportInterval =
         blockReportIntervalBasis - new Random().nextInt((int)(blockReportIntervalBasis/10));
+      this.heartBeatInterval = conf.getLong("dfs.heartbeat.interval", HEARTBEAT_INTERVAL) * 1000L;
       this.nameNodeAddr = nameNodeAddr;
     }
 
@@ -330,7 +332,7 @@ public class DataNode implements FSConstants, Runnable {
           //
           // Every so often, send heartbeat or block-report
           //
-          if (now - lastHeartbeat > HEARTBEAT_INTERVAL) {
+          if (now - lastHeartbeat > heartBeatInterval) {
             //
             // All heartbeat messages include following info:
             // -- Datanode name
@@ -426,7 +428,7 @@ public class DataNode implements FSConstants, Runnable {
           // There is no work to do;  sleep until hearbeat timer elapses, 
           // or work arrives, and then iterate again.
           //
-          long waitTime = HEARTBEAT_INTERVAL - (System.currentTimeMillis() - lastHeartbeat);
+          long waitTime = heartBeatInterval - (System.currentTimeMillis() - lastHeartbeat);
           synchronized( receivedBlockList ) {
             if (waitTime > 0 && receivedBlockList.size() == 0) {
               try {

+ 1 - 1
src/java/org/apache/hadoop/dfs/FSConstants.java

@@ -100,7 +100,7 @@ public interface FSConstants {
     //
     // Timeouts, constants
     //
-    public static long HEARTBEAT_INTERVAL = 3 * 1000;
+    public static long HEARTBEAT_INTERVAL = 3;
     public static long EXPIRE_INTERVAL = 10 * 60 * 1000;
     public static long BLOCKREPORT_INTERVAL = 60 * 60 * 1000;
     public static long LEASE_PERIOD = 60 * 1000;