Просмотр исходного кода

HADOOP-4785. Fixes theJobTracker heartbeat to not make two calls to System.currentTimeMillis(). Contributed by Amareshwari Sriramadasu.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@723801 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 16 лет назад
Родитель
Сommit
23fe1ff0e2

+ 3 - 0
CHANGES.txt

@@ -295,6 +295,9 @@ Trunk (unreleased changes)
     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

+ 6 - 4
src/mapred/org/apache/hadoop/mapred/JobTracker.java

@@ -551,13 +551,14 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
      * 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 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
 
     // 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 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
       
     // 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 @@ public class JobTracker implements MRConstants, InterTrackerProtocol,
                                  TaskTrackerStatus trackerStatus, 
                                  boolean restarted) {
     String trackerName = trackerStatus.getTrackerName();
-    trackerStatus.setLastSeen(System.currentTimeMillis());
 
     synchronized (taskTrackers) {
       synchronized (trackerExpiryQueue) {

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

@@ -1847,8 +1847,10 @@ public class TaskTracker
       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();