You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/05/15 17:31:42 UTC

svn commit: r1594949 - in /incubator/slider/trunk: slider-core/src/main/java/org/apache/slider/client/ slider-core/src/main/java/org/apache/slider/common/ slider-core/src/test/groovy/org/apache/slider/agent/standalone/ src/site/markdown/

Author: stevel
Date: Thu May 15 15:31:41 2014
New Revision: 1594949

URL: http://svn.apache.org/r1594949
Log:
SLIDER-63 registry CLI to return new NOT_FOUND exit code if there was no registry entry

Modified:
    incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
    incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java
    incubator/slider/trunk/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy
    incubator/slider/trunk/src/site/markdown/exitcodes.md
    incubator/slider/trunk/src/site/markdown/manpage.md

Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java?rev=1594949&r1=1594948&r2=1594949&view=diff
==============================================================================
--- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java (original)
+++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/client/SliderClient.java Thu May 15 15:31:41 2014
@@ -1960,7 +1960,7 @@ public class SliderClient extends Abstra
       try {
         actionRegistryListConfigs(registryArgs);
       } catch (FileNotFoundException e) {
-        return EXIT_FALSE;
+        return EXIT_NOT_FOUND;
       }
     } else if (SliderUtils.isSet(registryArgs.getConf)) {
       // get a configuration
@@ -1970,10 +1970,10 @@ public class SliderClient extends Abstra
         outputConfig(publishedConfiguration, registryArgs);
       } catch (FileNotFoundException e) {
         //there's no configuration here, so raise an error
-        throw new BadCommandArgumentsException(e, "Unknown configuration \"%s\"",
+        throw new SliderException(EXIT_NOT_FOUND,  e,
+            "Unknown configuration \"%s\"",
             registryArgs.getConf);
       }
-
     } else {
       // it's an unknown command
       throw new BadCommandArgumentsException(

Modified: incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java
URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java?rev=1594949&r1=1594948&r2=1594949&view=diff
==============================================================================
--- incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java (original)
+++ incubator/slider/trunk/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java Thu May 15 15:31:41 2014
@@ -90,4 +90,8 @@ public interface SliderExitCodes extends
    */
   int EXIT_INSTANCE_EXISTS = 75;
 
+  /**
+   * The resource was not found
+   */
+  int EXIT_NOT_FOUND = 77;
 }

Modified: incubator/slider/trunk/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy
URL: http://svn.apache.org/viewvc/incubator/slider/trunk/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy?rev=1594949&r1=1594948&r2=1594949&view=diff
==============================================================================
--- incubator/slider/trunk/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy (original)
+++ incubator/slider/trunk/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy Thu May 15 15:31:41 2014
@@ -26,9 +26,10 @@ import org.apache.hadoop.yarn.conf.YarnC
 import org.apache.slider.agent.AgentMiniClusterTestBase
 import org.apache.slider.api.ClusterNode
 import org.apache.slider.client.SliderClient
+import org.apache.slider.common.SliderExitCodes
 import org.apache.slider.common.SliderKeys
 import org.apache.slider.common.params.ActionRegistryArgs
-import org.apache.slider.core.exceptions.BadCommandArgumentsException
+import org.apache.slider.core.exceptions.SliderException
 import org.apache.slider.core.exceptions.UnknownApplicationInstanceException
 import org.apache.slider.core.main.ServiceLauncher
 import org.apache.slider.core.persist.JsonSerDeser
@@ -294,7 +295,7 @@ class TestStandaloneRegistryAM extends A
     registryArgs.listConf = true
     registryArgs.internal = true
     describe registryArgs.toString()
-    assert 0 != client.actionRegistry(registryArgs)
+    assert SliderExitCodes.EXIT_NOT_FOUND == client.actionRegistry(registryArgs)
 
     registryArgs.list = false;
     registryArgs.listConf = false
@@ -327,8 +328,9 @@ class TestStandaloneRegistryAM extends A
     try {
       client.actionRegistry(registryArgs)
       fail("attempt to retrieve the file $unknownFilename succeeded")
-    } catch (BadCommandArgumentsException expected) {
-      assert expected.toString().contains(unknownFilename)
+    } catch (SliderException expected) {
+      assertExceptionDetails(expected, SliderExitCodes.EXIT_NOT_FOUND,
+          unknownFilename)
     }
 
 

Modified: incubator/slider/trunk/src/site/markdown/exitcodes.md
URL: http://svn.apache.org/viewvc/incubator/slider/trunk/src/site/markdown/exitcodes.md?rev=1594949&r1=1594948&r2=1594949&view=diff
==============================================================================
--- incubator/slider/trunk/src/site/markdown/exitcodes.md (original)
+++ incubator/slider/trunk/src/site/markdown/exitcodes.md Thu May 15 15:31:41 2014
@@ -145,7 +145,12 @@ no. 72.
      * when an attempt is made to create a new instance
      */
     int EXIT_INSTANCE_EXISTS = 75;
-
+    
+    /**
+     * The resource was not found
+     */
+    int EXIT_NOT_FOUND = 77;
+    
 ## Other exit codes
 
 YARN itself can fail containers, here are some of the causes we've seen

Modified: incubator/slider/trunk/src/site/markdown/manpage.md
URL: http://svn.apache.org/viewvc/incubator/slider/trunk/src/site/markdown/manpage.md?rev=1594949&r1=1594948&r2=1594949&view=diff
==============================================================================
--- incubator/slider/trunk/src/site/markdown/manpage.md (original)
+++ incubator/slider/trunk/src/site/markdown/manpage.md Thu May 15 15:31:41 2014
@@ -363,15 +363,20 @@ The `--internal` flag indicates the conf
 are from the "internal" list of configuration data provided for use within a
 deployed application. 
 
+There are two common exit codes, the exact values being documented
+in [Exit Codes](exitcodes.md)
+
+1. If there is no matching service then the operation fails with the
+`EXIT_UNKNOWN_INSTANCE` code (70).
+2. If there are no configurations in a listing, or the named configuration
+is not found, the command returns the exit code `EXIT_NOT_FOUND` (77)
+
 Operations:
 
 #### `registry --list  [--servicetype <servicetype>] [--name <name>] [--verbose]`
 
 List all services of the service type and optionally the name. 
  
-If there were no matches then the operation fails with the `EXIT_UNKNOWN_INSTANCE` code
-
- 
  
  
 #### `registry --listconf [--name <name>]  [--internal] [--servicetype <servicetype>]`