Explorar o código

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/trunk@658035 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy %!s(int64=17) %!d(string=hai) anos
pai
achega
87bee2d55e

+ 3 - 0
CHANGES.txt

@@ -291,6 +291,9 @@ Trunk (unreleased changes)
     hierarchy. This also adds a new counter to track cache hits at levels
     greater than two. (Amar Kamat via cdouglas)
 
+    HADOOP-3370. Ensure that the TaskTracker.runningJobs data-structure is
+    correctly cleaned-up on task completion. (Zheng Shao via acmurthy) 
+
 Release 0.17.0 - 2008-05-18
 
   INCOMPATIBLE CHANGES

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

@@ -352,9 +352,6 @@ public class TaskTracker
       } else {
         synchronized (rjob) {
           rjob.tasks.remove(tip);
-          if (rjob.tasks.isEmpty()) {
-            runningJobs.remove(jobId);
-          }
         }
       }
     }
@@ -1725,6 +1722,7 @@ public class TaskTracker
       //
       if (needCleanup) {
         try {
+          removeTaskFromJob(task.getJobID(), this);
           cleanup();
         } catch (IOException ie) {
         }
@@ -2206,6 +2204,24 @@ 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 <JobID, 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