You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by dd...@apache.org on 2008/12/05 18:35:44 UTC

svn commit: r723801 - in /hadoop/core/trunk: CHANGES.txt src/mapred/org/apache/hadoop/mapred/JobTracker.java src/mapred/org/apache/hadoop/mapred/TaskTracker.java

Author: ddas
Date: Fri Dec  5 09:35:43 2008
New Revision: 723801

URL: http://svn.apache.org/viewvc?rev=723801&view=rev
Log:
HADOOP-4785. Fixes theJobTracker heartbeat to not make two calls to System.currentTimeMillis(). Contributed by Amareshwari Sriramadasu.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java
    hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=723801&r1=723800&r2=723801&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri Dec  5 09:35:43 2008
@@ -295,6 +295,9 @@
     HADOOP-4786. Fix broken compilation error in 
     TestTrackerBlacklistAcrossJobs. (yhemanth)
 
+    HADOOP-4785. Fixes theJobTracker heartbeat to not make two calls to 
+    System.currentTimeMillis(). (Amareshwari Sriramadasu via ddas)
+
 Release 0.19.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java?rev=723801&r1=723800&r2=723801&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobTracker.java Fri Dec  5 09:35:43 2008
@@ -551,13 +551,14 @@
      * chance again to run tasks of a job.
      * 
      * @param hostName The tracker name
+     * @param now The current time
+     * 
      * @return true if the tracker is blacklisted 
      *         false otherwise
      */
-    boolean shouldAssignTasksToTracker(String hostName) {
+    boolean shouldAssignTasksToTracker(String hostName, long now) {
       synchronized (potentiallyFaultyTrackers) {
         FaultInfo fi = potentiallyFaultyTrackers.get(hostName);
-        long now = System.currentTimeMillis(); 
         if (fi != null &&
             (now - fi.getLastUpdated()) > UPDATE_FAULTY_TRACKER_INTERVAL) {
           int numFaults = fi.getFaultCount() - 1;
@@ -2159,12 +2160,13 @@
 
     // First check if the last heartbeat response got through
     String trackerName = status.getTrackerName();
+    long now = System.currentTimeMillis();
     boolean isBlacklisted = false;
     if (restarted) {
       faultyTrackers.markTrackerHealthy(status.getHost());
     } else {
       isBlacklisted = 
-        faultyTrackers.shouldAssignTasksToTracker(status.getHost());
+        faultyTrackers.shouldAssignTasksToTracker(status.getHost(), now);
     }
     
     HeartbeatResponse prevHeartbeatResponse =
@@ -2208,6 +2210,7 @@
       
     // Process this heartbeat 
     short newResponseId = (short)(responseId + 1);
+    status.setLastSeen(now);
     if (!processHeartbeat(status, restarted)) {
       return new HeartbeatResponse(newResponseId, 
                    new TaskTrackerAction[] {new ReinitTrackerAction()});
@@ -2372,7 +2375,6 @@
                                  TaskTrackerStatus trackerStatus, 
                                  boolean restarted) {
     String trackerName = trackerStatus.getTrackerName();
-    trackerStatus.setLastSeen(System.currentTimeMillis());
 
     synchronized (taskTrackers) {
       synchronized (trackerExpiryQueue) {

Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java?rev=723801&r1=723800&r2=723801&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskTracker.java Fri Dec  5 09:35:43 2008
@@ -1847,8 +1847,10 @@
       task.setJobFile(localTaskFile.toString());
       localJobConf.set("mapred.local.dir",
                        fConf.get("mapred.local.dir"));
-      localJobConf.set("slave.host.name",
-                       fConf.get("slave.host.name"));
+      if (fConf.get("slave.host.name") != null) {
+        localJobConf.set("slave.host.name",
+                         fConf.get("slave.host.name"));
+      }
             
       localJobConf.set("mapred.task.id", task.getTaskID().toString());
       keepFailedTaskFiles = localJobConf.getKeepFailedTaskFiles();