avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r894499 - in /hadoop/avro/trunk: ./ src/java/org/apache/avro/reflect/ src/java/org/apache/avro/specific/ src/java/org/apache/avro/tool/ src/test/bin/
Date Tue, 29 Dec 2009 22:32:05 GMT
Author: cutting
Date: Tue Dec 29 22:32:04 2009
New Revision: 894499

URL: http://svn.apache.org/viewvc?rev=894499&view=rev
Log:
AVRO-263.  Change avroj command line tools to return exit codes.  Contributed by Todd Lipcon.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/java/org/apache/avro/reflect/InduceSchemaTool.java
    hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java
    hadoop/avro/trunk/src/java/org/apache/avro/tool/Main.java
    hadoop/avro/trunk/src/java/org/apache/avro/tool/Tool.java
    hadoop/avro/trunk/src/test/bin/test_avroj.sh

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=894499&r1=894498&r2=894499&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Dec 29 22:32:04 2009
@@ -137,6 +137,9 @@
     AVRO-257. Remove some dead Java code and un-needed casts.
     (Kevin Oliver via cutting)
 
+    AVRO-263. Change avroj command line tools to return exit codes.
+    (Todd Lipcon via cutting)
+
   OPTIMIZATIONS
 
     AVRO-172. More efficient schema processing (massie)

Modified: hadoop/avro/trunk/src/java/org/apache/avro/reflect/InduceSchemaTool.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/reflect/InduceSchemaTool.java?rev=894499&r1=894498&r2=894499&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/reflect/InduceSchemaTool.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/reflect/InduceSchemaTool.java Tue Dec 29 22:32:04
2009
@@ -32,11 +32,11 @@
 public class InduceSchemaTool implements Tool {
 
   @Override
-  public void run(InputStream in, PrintStream out, PrintStream err,
+  public int run(InputStream in, PrintStream out, PrintStream err,
       List<String> args) throws Exception {
     if (args.size() == 0 || args.size() > 2) {
       System.err.println("Usage: [colon-delimited-classpath] classname");
-      return;
+      return 1;
     }
     ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
     String className;
@@ -61,6 +61,7 @@
     } else {
       System.out.println(ReflectData.get().getSchema(klass).toString(true));
     }
+    return 0;
   }
 
   @Override

Modified: hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java?rev=894499&r1=894498&r2=894499&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/specific/SpecificCompiler.java Tue Dec 29 22:32:04
2009
@@ -371,11 +371,11 @@
    */
   public static class SpecificCompilerTool implements Tool {
     @Override
-    public void run(InputStream in, PrintStream out, PrintStream err,
+    public int run(InputStream in, PrintStream out, PrintStream err,
         List<String> args) throws Exception {
       if (args.size() != 3) {
         System.err.println("Expected 3 arguments: (schema|protocol) inputfile outputdir");
-        return;
+        return 1;
       }
       String method = args.get(0);
       File input = new File(args.get(1));
@@ -386,8 +386,9 @@
         compileProtocol(input, output);
       } else {
         System.err.println("Expected \"schema\" or \"protocol\".");
-        return;
+        return 1;
       }
+      return 0;
     }
 
     @Override

Modified: hadoop/avro/trunk/src/java/org/apache/avro/tool/Main.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/tool/Main.java?rev=894499&r1=894498&r2=894499&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/tool/Main.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/tool/Main.java Tue Dec 29 22:32:04 2009
@@ -49,23 +49,25 @@
   }
 
   public static void main(String[] args) throws Exception {
-    new Main().run(args);
+    int rc = new Main().run(args);
+    System.exit(rc);
   }
 
   /**
    * Delegates to tool specified on the command-line.
    */
-  private void run(String[] args) throws Exception {
+  private int run(String[] args) throws Exception {
     if (args.length != 0) {
       Tool tool = tools.get(args[0]);
       if (tool != null) {
-        tool.run(System.in, System.out, System.err, Arrays.asList(args).subList(1, args.length));
-        return;
+        return tool.run(
+          System.in, System.out, System.err, Arrays.asList(args).subList(1, args.length));
       }
     }
     System.err.println("Available tools:");
     for (Tool k : tools.values()) {
       System.err.printf("%" + maxLen + "s  %s\n", k.getName(), k.getShortDescription());
     }
+    return 1;
   }
 }

Modified: hadoop/avro/trunk/src/java/org/apache/avro/tool/Tool.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/tool/Tool.java?rev=894499&r1=894498&r2=894499&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/tool/Tool.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/tool/Tool.java Tue Dec 29 22:32:04 2009
@@ -34,9 +34,10 @@
    * @param out Output of tool (typically System.out).
    * @param err Error stream (typically System.err).
    * @param args Non-null list of arguments.
+   * @return result code (0 for success)
    * @throws Exception Just like main(), tools may throw Exception.
    */
-  void run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws
Exception;
+  int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws
Exception;
 
   /**
    * Name of tool, to be used in listings.

Modified: hadoop/avro/trunk/src/test/bin/test_avroj.sh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/bin/test_avroj.sh?rev=894499&r1=894498&r2=894499&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/bin/test_avroj.sh (original)
+++ hadoop/avro/trunk/src/test/bin/test_avroj.sh Tue Dec 29 22:32:04 2009
@@ -64,3 +64,5 @@
 ######################################################################
 $CMD 2>&1 | grep -q "Available tools:"
 $CMD doesnotexist 2>&1 | grep -q "Available tools:"
+! $CMD 2>&1 > /dev/null
+! $CMD 2>&1 doesnotexist 2>&1 > /dev/null
\ No newline at end of file



Mime
View raw message