Browse Source

HADOOP-1592. Log error messages to the client console when tasks fail. Contributed by Amar Kamat.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@575450 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 17 years ago
parent
commit
a16f99ead3

+ 3 - 0
CHANGES.txt

@@ -223,6 +223,9 @@ Trunk (unreleased changes)
     second jobtracker doesn't trash one that's already running.
     (omalley via cutting)
 
+    HADOOP-1592.  Log error messages to the client console when tasks
+    fail.  (Amar Kamat via cutting)
+
 
 Release 0.14.1 - 2007-09-04
 

+ 11 - 0
src/java/org/apache/hadoop/mapred/JobClient.java

@@ -54,6 +54,7 @@ import org.apache.hadoop.io.retry.RetryPolicies;
 import org.apache.hadoop.io.retry.RetryPolicy;
 import org.apache.hadoop.io.retry.RetryProxy;
 import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.mapred.TaskInProgress;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
@@ -641,6 +642,16 @@ public class JobClient extends Configured implements MRConstants, Tool  {
                 if (event.getTaskStatus() == 
                     TaskCompletionEvent.Status.FAILED){
                   LOG.info(event.toString());
+                  // Displaying the task diagnostic information
+                  String taskId = event.getTaskId();
+                  String tipId = TaskInProgress.getTipId(taskId);
+                  String[] taskDiagnostics = 
+                	  jc.jobSubmitClient.getTaskDiagnostics(jobId, tipId, 
+                			                                taskId); 
+                  for(String diagnostics : taskDiagnostics){
+                   	System.err.println(diagnostics);
+                  }
+                  // Displaying the task logs
                   displayTaskLogs(event.getTaskId(), event.getTaskTrackerHttp());
                 }
                 break; 

+ 8 - 0
src/java/org/apache/hadoop/mapred/JobSubmissionProtocol.java

@@ -121,4 +121,12 @@ public interface JobSubmissionProtocol extends VersionedProtocol {
   public TaskCompletionEvent[] getTaskCompletionEvents(
                                                        String jobid, int fromEventId, int maxEvents) throws IOException;
     
+  /**
+   * Get the diagnostics for a given task in a given job
+   * @param jobId the id of the job
+   * @return an array of the diagnostic messages
+   */
+  public String[] getTaskDiagnostics(String jobId, String tipId, String taskId) 
+  throws IOException;  
+  
 }

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

@@ -1651,11 +1651,11 @@ public class JobTracker implements MRConstants, InterTrackerProtocol, JobSubmiss
    * @param jobId the id of the job
    * @param tipId the id of the tip 
    * @param taskId the id of the task
-   * @return a list of the diagnostic messages
+   * @return an array of the diagnostic messages
    */
-  public synchronized List<String> getTaskDiagnostics(String jobId,
+  public synchronized String[] getTaskDiagnostics(String jobId,
                                                       String tipId,
-                                                      String taskId) {
+                                                      String taskId) throws IOException {
     JobInProgress job = jobs.get(jobId);
     if (job == null) {
       throw new IllegalArgumentException("Job " + jobId + " not found.");
@@ -1664,7 +1664,7 @@ public class JobTracker implements MRConstants, InterTrackerProtocol, JobSubmiss
     if (tip == null) {
       throw new IllegalArgumentException("TIP " + tipId + " not found.");
     }
-    return tip.getDiagnosticInfo(taskId);
+    return tip.getDiagnosticInfo(taskId).toArray(new String[0]);
   }
     
   /** Get all the TaskStatuses from the tipid. */

+ 8 - 0
src/java/org/apache/hadoop/mapred/LocalJobRunner.java

@@ -335,4 +335,12 @@ class LocalJobRunner implements JobSubmissionProtocol {
     idFormat.setGroupingUsed(false);
   }
   
+  /**
+   * Returns the diagnostic information for a particular task in the given job.
+   * To be implemented
+   */
+  public String[] getTaskDiagnostics(String jobid, String tipId, String taskid)
+  		throws IOException{
+	  return new String [0];
+  }
 }

+ 7 - 0
src/java/org/apache/hadoop/mapred/TaskInProgress.java

@@ -785,4 +785,11 @@ class TaskInProgress {
   public int getSuccessEventNumber() {
     return successEventNumber;
   }
+  
+  /**
+   * Gets the tip id for the given taskid
+   * */
+  public static String getTipId(String taskId){
+	  return taskId.substring(0, taskId.lastIndexOf('_')).replace("task", "tip");
+  }
 }

+ 4 - 4
src/webapps/job/jobfailures.jsp

@@ -40,15 +40,15 @@
         }
         out.print("<td>" + taskState + "</td>");
         out.print("<td><pre>");
-        List<String> failures = 
+        String[] failures = 
                      tracker.getTaskDiagnostics(jobId, tipId, 
                                                 statuses[i].getTaskId());
         if (failures == null) {
           out.print("&nbsp;");
         } else {
-          for(Iterator<String> itr = failures.iterator(); itr.hasNext(); ) {
-            out.print(itr.next());
-            if (itr.hasNext()) {
+          for(int j = 0 ; j < failures.length ; j++){
+            out.print(failures[j]);
+            if (j < (failures.length - 1)) {
               out.print("\n-------\n");
             }
           }

+ 5 - 5
src/webapps/job/taskdetails.jsp

@@ -123,15 +123,15 @@
           .getFinishTime(), status.getStartTime()) + "</td>");
 
         out.print("<td><pre>");
-        List<String> failures = tracker.getTaskDiagnostics(jobid, tipid,
+        String [] failures = tracker.getTaskDiagnostics(jobid, tipid,
           status.getTaskId());
         if (failures == null) {
           out.print("&nbsp;");
         } else {
-          for (Iterator<String> itr = failures.iterator(); itr.hasNext();) {
-            out.print(itr.next());
-            if (itr.hasNext()) {
-                out.print("\n-------\n");
+          for(int j = 0 ; j < failures.length ; j++){
+            out.print(failures[j]);
+            if (j < (failures.length - 1)) {
+              out.print("\n-------\n");
             }
           }
         }