瀏覽代碼

HADOOP-1580. Improve contrib/streaming so that subprocess exit status is shown for errors. Contributed by John Heidemann.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@555371 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 年之前
父節點
當前提交
d1afd9b8b2

+ 3 - 0
CHANGES.txt

@@ -293,6 +293,9 @@ Trunk (unreleased changes)
      permits coordinated upgrade of datanode data.
      (Konstantin Shvachko via cutting)
 
+ 91. HADOOP-1580.  Improve contrib/streaming so that subprocess exit
+     status is displayed for errors.  (John Heidemann via cutting)
+
 
 Release 0.13.0 - 2007-06-08
 

+ 5 - 1
src/contrib/streaming/src/java/org/apache/hadoop/streaming/PipeMapRed.java

@@ -286,7 +286,11 @@ public abstract class PipeMapRed {
 
   void waitOutputThreads() {
     try {
-      sim.waitFor();
+      int exitVal = sim.waitFor();
+      // how'd it go?
+      if (exitVal != 0) {
+	  logprintln("PipeMapRed.waitOutputThreads(): subprocess failed with code " + exitVal + " in " + PipeMapRed.class.getName());
+      };
       if (outThread_ != null) {
         outThread_.join(joinDelay_);
       }

+ 15 - 1
src/contrib/streaming/src/java/org/apache/hadoop/streaming/PipeReducer.java

@@ -86,9 +86,23 @@ public class PipeReducer extends PipeMapRed implements Reducer {
         }
       }
     } catch (IOException io) {
+      // a common reason to get here is failure of the subprocess.
+      // Document that fact, if possible.
+      String extraInfo = "";
+      try {
+        int exitVal = sim.exitValue();
+	if (exitVal == 0) {
+	  extraInfo = "subprocess exited successfully\n";
+	} else {
+	  extraInfo = "subprocess exited with error code " + exitVal + "\n";
+	};
+      } catch (IllegalThreadStateException e) {
+        // hmm, but child is still running.  go figure.
+	extraInfo = "subprocess still running\n";
+      };
       appendLogToJobLog("failure");
       mapRedFinished();
-      throw new IOException(getContext() + io.getMessage());
+      throw new IOException(extraInfo + getContext() + io.getMessage());
     }
   }