hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r950493 - in /hadoop/mapreduce/branches/branch-0.21: CHANGES.txt src/java/org/apache/hadoop/mapred/TaskTracker.java src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerSlotManagement.java
Date Wed, 02 Jun 2010 11:07:04 GMT
Author: vinodkv
Date: Wed Jun  2 11:07:04 2010
New Revision: 950493

URL: http://svn.apache.org/viewvc?rev=950493&view=rev
Log:
MAPREDUCE-913. Merge from mapreduce trunk revision #950485.

Added:
    hadoop/mapreduce/branches/branch-0.21/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerSlotManagement.java
      - copied unchanged from r950485, hadoop/mapreduce/trunk/src/test/mapred/org/apache/hadoop/mapred/TestTaskTrackerSlotManagement.java
Modified:
    hadoop/mapreduce/branches/branch-0.21/CHANGES.txt
    hadoop/mapreduce/branches/branch-0.21/src/java/org/apache/hadoop/mapred/TaskTracker.java

Modified: hadoop/mapreduce/branches/branch-0.21/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/branch-0.21/CHANGES.txt?rev=950493&r1=950492&r2=950493&view=diff
==============================================================================
--- hadoop/mapreduce/branches/branch-0.21/CHANGES.txt (original)
+++ hadoop/mapreduce/branches/branch-0.21/CHANGES.txt Wed Jun  2 11:07:04 2010
@@ -1575,3 +1575,7 @@ Release 0.21.0 - Unreleased
     (Dick King and Amareshwari Sriramadasu via tomwhite)
 
     MAPREDUCE-118. Fix Job.getJobID(). (Amareshwari Sriramadasu via sharad)
+
+    MAPREDUCE-913. TaskRunner crashes with NPE resulting in held up slots,
+    UNINITIALIZED tasks and hung TaskTracker. (Amareshwari Sriramadasu and
+    Sreekanth Ramakrishnan via vinodkv)

Modified: hadoop/mapreduce/branches/branch-0.21/src/java/org/apache/hadoop/mapred/TaskTracker.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/branch-0.21/src/java/org/apache/hadoop/mapred/TaskTracker.java?rev=950493&r1=950492&r2=950493&view=diff
==============================================================================
--- hadoop/mapreduce/branches/branch-0.21/src/java/org/apache/hadoop/mapred/TaskTracker.java
(original)
+++ hadoop/mapreduce/branches/branch-0.21/src/java/org/apache/hadoop/mapred/TaskTracker.java
Wed Jun  2 11:07:04 2010
@@ -2091,7 +2091,16 @@ public class TaskTracker 
       reduceLauncher.addToTaskQueue(action);
     }
   }
-  
+
+  // This method is called from unit tests
+  int getFreeSlots(boolean isMap) {
+    if (isMap) {
+      return mapLauncher.numFreeSlots.get();
+    } else {
+      return reduceLauncher.numFreeSlots.get();
+    }
+  }
+
   class TaskLauncher extends Thread {
     private IntWritable numFreeSlots;
     private final int maxSlots;
@@ -2642,8 +2651,11 @@ public class TaskTracker 
      */
     void reportTaskFinished(boolean commitPending) {
       if (!commitPending) {
-        taskFinished();
-        releaseSlot();
+        try {
+          taskFinished(); 
+        } finally {
+          releaseSlot();
+        }
       }
       notifyTTAboutTaskCompletion();
     }
@@ -2713,7 +2725,15 @@ public class TaskTracker 
             setTaskFailState(true);
             // call the script here for the failed tasks.
             if (debugCommand != null) {
-              runDebugScript();
+              try {
+                runDebugScript();
+              } catch (Exception e) {
+                String msg =
+                    "Debug-script could not be run successfully : "
+                        + StringUtils.stringifyException(e);
+                LOG.warn(msg);
+                reportDiagnosticInfo(msg);
+              }
             }
           }
           taskStatus.setProgress(0.0f);
@@ -2734,14 +2754,17 @@ public class TaskTracker 
       if (needCleanup) {
         removeTaskFromJob(task.getJobID(), this);
       }
-      try {
-        cleanup(needCleanup);
-      } catch (IOException ie) {
-      }
 
+      cleanup(needCleanup);
     }
-    
-    private void runDebugScript() {
+
+    /**
+     * Run the debug-script now. Because debug-script can be user code, we use
+     * {@link TaskController} to execute the debug script.
+     * 
+     * @throws IOException
+     */
+    private void runDebugScript() throws IOException {
       String taskStdout ="";
       String taskStderr ="";
       String taskSyslog ="";
@@ -2759,23 +2782,14 @@ public class TaskTracker 
         taskSyslog = FileUtil
             .makeShellPath(TaskLog.getRealTaskLogFileLocation(task.getTaskID(),
                 task.isTaskCleanupTask(), TaskLog.LogName.SYSLOG));
-      } catch(IOException e){
-        LOG.warn("Exception finding task's stdout/err/syslog files");
-      }
-      File workDir = null;
-      try {
-        workDir =
-            new File(lDirAlloc.getLocalPathToRead(
-                TaskTracker.getLocalTaskDir(task.getUser(), task
-                    .getJobID().toString(), task.getTaskID()
-                    .toString(), task.isTaskCleanupTask())
-                    + Path.SEPARATOR + MRConstants.WORKDIR,
-                localJobConf).toString());
-      } catch (IOException e) {
-        LOG.warn("Working Directory of the task " + task.getTaskID() +
-                        " doesnt exist. Caught exception " +
-                  StringUtils.stringifyException(e));
+      } catch(Exception e){
+        LOG.warn("Exception finding task's stdout/err/syslog files", e);
       }
+      File workDir = new File(lDirAlloc.getLocalPathToRead(
+          TaskTracker.getLocalTaskDir(task.getUser(), task.getJobID()
+              .toString(), task.getTaskID().toString(), task
+              .isTaskCleanupTask())
+              + Path.SEPARATOR + MRConstants.WORKDIR, localJobConf).toString());
       // Build the command  
       File stdout = TaskLog.getTaskLogFile(task.getTaskID(), task
           .isTaskCleanupTask(), TaskLog.LogName.DEBUGOUT);
@@ -2805,21 +2819,10 @@ public class TaskTracker 
       context.stdout = stdout;
       context.workDir = workDir;
       context.task = task;
-      try {
-        getTaskController().runDebugScript(context);
-        // add all lines of debug out to diagnostics
-        try {
-          int num = localJobConf.getInt(MRJobConfig.TASK_DEBUGOUT_LINES,
-              -1);
-          addDiagnostics(FileUtil.makeShellPath(stdout),num,
-              "DEBUG OUT");
-        } catch(IOException ioe) {
-          LOG.warn("Exception in add diagnostics!");
-        }
-      } catch (IOException ie) {
-        LOG.warn("runDebugScript failed with: " + StringUtils.
-                                              stringifyException(ie));
-      }
+      getTaskController().runDebugScript(context);
+      // add the lines of debug out to diagnostics
+      int num = localJobConf.getInt(MRJobConfig.TASK_DEBUGOUT_LINES, -1);
+      addDiagnostics(FileUtil.makeShellPath(stdout), num, "DEBUG OUT");
     }
 
     /**
@@ -2983,7 +2986,7 @@ public class TaskTracker 
      * otherwise the current working directory of the task 
      * i.e. <taskid>/work is cleaned up.
      */
-    void cleanup(boolean needCleanup) throws IOException {
+    void cleanup(boolean needCleanup) {
       TaskAttemptID taskId = task.getTaskID();
       LOG.debug("Cleaning up " + taskId);
 



Mime
View raw message