Browse Source

Merge -r 709039:709040 from trunk to branch-0.18 to fix HADOOP-4340.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.18@709042 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 16 years ago
parent
commit
0f20c0020f

+ 3 - 0
CHANGES.txt

@@ -53,6 +53,9 @@ Release 0.18.2 - Unreleased
     HADOOP-4483 Honor the max parameter in DatanodeDescriptor.getBlockArray(..)
     (Ahad Rana and Hairong Kuang via szetszwo)
 
+    HADOOP-4340. Correctly set the exit code from JobShell.main so that the
+    'hadoop jar' command returns the right code to the user. (acmurthy)
+
   NEW FEATURES
 
     HADOOP-2421.  Add jdiff output to documentation, listing all API

+ 4 - 2
src/core/org/apache/hadoop/util/ProgramDriver.java

@@ -120,7 +120,8 @@ public class ProgramDriver {
       System.out.println("An example program must be given as the" + 
                          " first argument.");
       printUsage(programs);
-      return;
+      throw new IllegalArgumentException("An example program must be given " +
+      		                               "as the first argument.");
     }
 	
     // And that it is good.
@@ -128,7 +129,8 @@ public class ProgramDriver {
     if (pgm == null) {
       System.out.println("Unknown program '" + args[0] + "' chosen.");
       printUsage(programs);
-      return;
+      throw new IllegalArgumentException("Unknown program '" + args[0] + 
+                                         "' chosen.");
     }
 	
     // Remove the leading argument and call main

+ 6 - 0
src/examples/org/apache/hadoop/examples/ExampleDriver.java

@@ -28,6 +28,7 @@ import org.apache.hadoop.util.ProgramDriver;
 public class ExampleDriver {
   
   public static void main(String argv[]){
+    int exitCode = -1;
     ProgramDriver pgd = new ProgramDriver();
     try {
       pgd.addClass("wordcount", WordCount.class, 
@@ -51,10 +52,15 @@ public class ExampleDriver {
       pgd.addClass("join", Join.class, "A job that effects a join over sorted, equally partitioned datasets");
       pgd.addClass("multifilewc", MultiFileWordCount.class, "A job that counts words from several files.");
       pgd.driver(argv);
+      
+      // Success
+      exitCode = 0;
     }
     catch(Throwable e){
       e.printStackTrace();
     }
+    
+    System.exit(exitCode);
   }
 }
 	

+ 2 - 1
src/mapred/org/apache/hadoop/mapred/JobShell.java

@@ -65,6 +65,7 @@ public class JobShell extends Configured implements Tool {
   
   public static void main(String[] argv) throws Exception {
     JobShell jshell = new JobShell();
-    ToolRunner.run(jshell, argv);
+    int status = ToolRunner.run(jshell, argv);
+    System.exit(status);
   }
 }