Pārlūkot izejas kodu

HADOOP-3875. Change the time period between heartbeats to be relative to
the end of the heartbeat rpc, rather than the start. This causes better
behavior if the JobTracker is overloaded. (acmurthy via omalley)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@684142 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 gadi atpakaļ
vecāks
revīzija
ed7fda98bf
2 mainītis faili ar 12 papildinājumiem un 4 dzēšanām
  1. 4 0
      CHANGES.txt
  2. 8 4
      src/mapred/org/apache/hadoop/mapred/TaskTracker.java

+ 4 - 0
CHANGES.txt

@@ -148,6 +148,10 @@ Trunk (unreleased changes)
     
     HADOOP-3892. Include unix group name in JobConf. (Matei Zaharia via johan)
 
+    HADOOP-3875. Change the time period between heartbeats to be relative to
+    the end of the heartbeat rpc, rather than the start. This causes better
+    behavior if the JobTracker is overloaded. (acmurthy via omalley)
+
   OPTIMIZATIONS
 
     HADOOP-3556. Removed lock contention in MD5Hash by changing the 

+ 8 - 4
src/mapred/org/apache/hadoop/mapred/TaskTracker.java

@@ -909,7 +909,12 @@ public class TaskTracker
         }
         
         // Send the heartbeat and process the jobtracker's directives
-        HeartbeatResponse heartbeatResponse = transmitHeartBeat();
+        HeartbeatResponse heartbeatResponse = transmitHeartBeat(now);
+
+        // Note the time when the heartbeat returned, use this to decide when to send the
+        // next heartbeat   
+        lastHeartbeat = System.currentTimeMillis();
+        
         TaskTrackerAction[] actions = heartbeatResponse.getActions();
         if(LOG.isDebugEnabled()) {
           LOG.debug("Got heartbeatResponse from JobTracker with responseId: " + 
@@ -920,7 +925,6 @@ public class TaskTracker
           return State.STALE;
         }
             
-        lastHeartbeat = now;
         // resetting heartbeat interval from the response.
         heartbeatInterval = heartbeatResponse.getHeartbeatInterval();
         justStarted = false;
@@ -972,12 +976,12 @@ public class TaskTracker
 
   /**
    * Build and transmit the heart beat to the JobTracker
+   * @param now current time
    * @return false if the tracker was unknown
    * @throws IOException
    */
-  private HeartbeatResponse transmitHeartBeat() throws IOException {
+  private HeartbeatResponse transmitHeartBeat(long now) throws IOException {
     // Send Counters in the status once every COUNTER_UPDATE_INTERVAL
-    long now = System.currentTimeMillis();
     boolean sendCounters;
     if (now > (previousUpdate + COUNTER_UPDATE_INTERVAL)) {
       sendCounters = true;