SLIDER-5 registry CLI adds int exit code and fails if there is no configs of the given scope (internal/external)
git-svn-id: https://svn.apache.org/repos/asf/incubator/slider/trunk@1594909 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index 8c4a67c..0e01941 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -246,7 +246,7 @@
exitCode = actionList(clusterName);
break;
case ACTION_REGISTRY:
- actionRegistry(
+ exitCode = actionRegistry(
serviceArgs.getActionRegistryArgs());
break;
case ACTION_STATUS:
@@ -1941,11 +1941,13 @@
* Registry operation
*
* @param registryArgs registry Arguments
+ * @return 0 for success, -1 for some issues that aren't errors, just failures
+ * to retrieve information (e.g. no configurations for that entry)
* @throws YarnException YARN problems
* @throws IOException Network or other problems
*/
@VisibleForTesting
- public void actionRegistry(ActionRegistryArgs registryArgs) throws
+ public int actionRegistry(ActionRegistryArgs registryArgs) throws
YarnException,
IOException {
// as this is also a test entry point, validate
@@ -1955,7 +1957,11 @@
actionRegistryList(registryArgs);
} else if (registryArgs.listConf) {
// list the configurations
- actionRegistryListConfigs(registryArgs);
+ try {
+ actionRegistryListConfigs(registryArgs);
+ } catch (FileNotFoundException e) {
+ return EXIT_FALSE;
+ }
} else if (SliderUtils.isSet(registryArgs.getConf)) {
// get a configuration
try {
@@ -1969,10 +1975,11 @@
}
} else {
- // its an unknown command
+ // it's an unknown command
throw new BadCommandArgumentsException(
"Bad command arguments for "+ ACTION_REGISTRY +" " + registryArgs);
}
+ return EXIT_SUCCESS;
}
/**
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy
index a114abf..73ffb86 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneRegistryAM.groovy
@@ -294,12 +294,7 @@
registryArgs.listConf = true
registryArgs.internal = true
describe registryArgs.toString()
- try {
- client.actionRegistry(registryArgs)
- fail("expected a failure")
- } catch (FileNotFoundException expected) {
- //expected
- }
+ assert 0 != client.actionRegistry(registryArgs)
registryArgs.list = false;
registryArgs.listConf = false