Browse Source

HADOOP-3370. Ensure that the TaskTracker.runningJobs data-structure is correctly cleaned-up on task completion. Contributed by Zheng Shao.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.17@679591 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 17 years ago
parent
commit
e7d8ee5369
3 changed files with 44 additions and 3 deletions
  1. 3 0
      CHANGES.txt
  2. 18 3
      src/java/org/apache/hadoop/mapred/TaskTracker.java
  3. 23 0
      src/webapps/task/tasktracker.jsp

+ 3 - 0
CHANGES.txt

@@ -28,6 +28,9 @@ Release 0.17.2 - Unreleased
     HADOOP-3633. Correct exception handling in DataXceiveServer, and throttle
     the number of xceiver threads in a data-node. (shv)
 
+    HADOOP-3370. Ensure that the TaskTracker.runningJobs data-structure is
+    correctly cleaned-up on task completion. (Zheng Shao via acmurthy) 
+
 Release 0.17.1 - 2008-06-23
 
   INCOMPATIBLE CHANGES

+ 18 - 3
src/java/org/apache/hadoop/mapred/TaskTracker.java

@@ -353,9 +353,6 @@ public class TaskTracker
       } else {
         synchronized (rjob) {
           rjob.tasks.remove(tip);
-          if (rjob.tasks.isEmpty()) {
-            runningJobs.remove(jobId);
-          }
         }
       }
     }
@@ -1714,6 +1711,7 @@ public class TaskTracker
       //
       if (needCleanup) {
         try {
+          removeTaskFromJob(task.getJobId(), this);
           cleanup();
         } catch (IOException ie) {
         }
@@ -2193,6 +2191,23 @@ public class TaskTracker
     return result;
   }
 
+  /**
+   * Get the list of tasks from running jobs on this task tracker.
+   * @return a copy of the list of TaskStatus objects
+  */
+  synchronized List<TaskStatus> getTasksFromRunningJobs() {
+    List<TaskStatus> result = new ArrayList<TaskStatus>(tasks.size());
+    for (Map.Entry <String, RunningJob> item : runningJobs.entrySet()) {
+      RunningJob rjob = item.getValue();
+      synchronized (rjob) {
+        for (TaskInProgress tip : rjob.tasks) {
+          result.add(tip.getStatus());
+        }
+      }
+    }
+    return result;
+  }
+
   /**
    * Get the default job conf for this tracker.
    */

+ 23 - 0
src/webapps/task/tasktracker.jsp

@@ -57,6 +57,29 @@
   %>
 </table>
 
+
+<h2>Tasks from Running Jobs</h2>
+<center>
+<table border=2 cellpadding="5" cellspacing="2">
+<tr><td align="center">Task Attempts</td><td>Status</td>
+    <td>Progress</td><td>Errors</td></tr>
+
+  <%
+     itr = tracker.getTasksFromRunningJobs().iterator();
+     while (itr.hasNext()) {
+       TaskStatus status = (TaskStatus) itr.next();
+       out.print("<tr><td>" + status.getTaskId());
+       out.print("</td><td>" + status.getRunState()); 
+       out.print("</td><td>" + 
+                 StringUtils.formatPercent(status.getProgress(), 2));
+       out.print("</td><td><pre>" + status.getDiagnosticInfo() + "</pre></td>");
+       out.print("</tr>\n");
+     }
+  %>
+</table>
+</center>
+
+
 <h2>Local Logs</h2>
 <a href="/logs/">Log</a> directory