Repository: incubator-slider Updated Branches: refs/heads/develop e0c440107 -> 4dcb62cf2
SLIDER-523 renumber some exit codes to match "well known" http exit codes Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/4dcb62cf Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/4dcb62cf Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/4dcb62cf Branch: refs/heads/develop Commit: 4dcb62cf2949b1105c7017e2c64866cc34eb65e8 Parents: e0c4401 Author: Steve Loughran <ste...@apache.org> Authored: Thu Oct 16 13:22:27 2014 -0700 Committer: Steve Loughran <ste...@apache.org> Committed: Thu Oct 16 13:22:27 2014 -0700 ---------------------------------------------------------------------- .../apache/slider/common/SliderExitCodes.java | 35 ++--- .../slider/core/main/LauncherExitCodes.java | 141 +++++++++++++++++-- .../slider/core/main/ServiceLauncher.java | 6 +- .../TestStandaloneYarnRegistryAM.groovy | 15 +- .../funtest/FunctionalHBaseClusterIT.groovy | 1 - 5 files changed, 149 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4dcb62cf/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java b/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java index b115d98..5758f79 100644 --- a/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java +++ b/slider-core/src/main/java/org/apache/slider/common/SliderExitCodes.java @@ -26,72 +26,63 @@ public interface SliderExitCodes extends LauncherExitCodes { * starting point for exit codes; not an exception itself */ int _EXIT_CODE_BASE = 64; - - /** - * internal error: {@value} - */ - int EXIT_INTERNAL_ERROR = _EXIT_CODE_BASE; - - /** - * Unimplemented feature: {@value} - */ - int EXIT_UNIMPLEMENTED = 65; /** * service entered the failed state: {@value} */ - int EXIT_YARN_SERVICE_FAILED = 66; + int EXIT_YARN_SERVICE_FAILED = 65; /** * service was killed: {@value} */ - int EXIT_YARN_SERVICE_KILLED = 67; + int EXIT_YARN_SERVICE_KILLED = 66; /** * timeout on monitoring client: {@value} */ - int EXIT_TIMED_OUT = 68; + int EXIT_TIMED_OUT = 67; /** * service finished with an error: {@value} */ - int EXIT_YARN_SERVICE_FINISHED_WITH_ERROR = 69; + int EXIT_YARN_SERVICE_FINISHED_WITH_ERROR = 68; /** * the application instance is unknown: {@value} */ - int EXIT_UNKNOWN_INSTANCE = 70; + int EXIT_UNKNOWN_INSTANCE = 69; /** * the application instance is in the wrong state for that operation: {@value} */ - int EXIT_BAD_STATE = 71; + int EXIT_BAD_STATE = 70; /** * A spawned master process failed */ - int EXIT_PROCESS_FAILED = 72; + int EXIT_PROCESS_FAILED = 71; /** * The instance failed -too many containers were * failing or some other threshold was reached */ - int EXIT_DEPLOYMENT_FAILED = 73; + int EXIT_DEPLOYMENT_FAILED = 72; /** * The application is live -and the requested operation * does not work if the cluster is running */ - int EXIT_APPLICATION_IN_USE = 74; + int EXIT_APPLICATION_IN_USE = 73; /** * There already is an application instance of that name * when an attempt is made to create a new instance */ - int EXIT_INSTANCE_EXISTS = 75; + int EXIT_INSTANCE_EXISTS = 75; /** - * The resource was not found + * Exit code when the configurations in valid/incomplete: {@value} */ - int EXIT_NOT_FOUND = 77; + int EXIT_BAD_CONFIGURATION = 77; + } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4dcb62cf/slider-core/src/main/java/org/apache/slider/core/main/LauncherExitCodes.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/core/main/LauncherExitCodes.java b/slider-core/src/main/java/org/apache/slider/core/main/LauncherExitCodes.java index 6fdebcd..3ffacd0 100644 --- a/slider-core/src/main/java/org/apache/slider/core/main/LauncherExitCodes.java +++ b/slider-core/src/main/java/org/apache/slider/core/main/LauncherExitCodes.java @@ -18,14 +18,27 @@ package org.apache.slider.core.main; - /* * Common Exit codes - * Exit codes from 32 up are relative to a base value that - * we put a fair way up from the the base numbers, so that - * applications can have their own set of failures + * <p> + * Exit codes from 64 up are application specific. + * <p> + * Many of the exit codes are designed to resemble HTTP error codes, + * squashed into a single byte. e.g 44 , "not found" is the equivalent + * of 404 + * <pre> + * 0-10: general command issues + * 30-39: equivalent to the 3XX responses, where those responses are + * considered errors by the application. + * 40-49: request-related errors + * 50-59: server-side problems. These may be triggered by the request. + * 64- : application specific error codes + * </pre> + * + * */ public interface LauncherExitCodes { + /** * 0: success */ @@ -48,40 +61,138 @@ public interface LauncherExitCodes { int EXIT_TASK_LAUNCH_FAILURE = 2; /** - * Exit code when an exception was thrown from the service: {@value} + * Exit code when a control-C, kill -3, signal was picked up: {@value} */ - int EXIT_EXCEPTION_THROWN = 32; + int EXIT_INTERRUPTED = 3; /** * Exit code when a usage message was printed: {@value} */ - int EXIT_USAGE = 33; + int EXIT_USAGE = 4; /** * Exit code when something happened but we can't be specific: {@value} */ - int EXIT_OTHER_FAILURE = 34; + int EXIT_OTHER_FAILURE = 5; /** - * Exit code when a control-C, kill -3, signal was picked up: {@value} + * Exit code on connectivity problems: {@value} */ + int EXIT_MOVED = 31; + + /** + * found: {@value}. + * <p> + * This is low value as in HTTP it is normally a success/redirect; + * whereas on the command line 0 is the sole success code. + * <p> + * <code>302 Found</code> + */ + int EXIT_FOUND = 32; - int EXIT_INTERRUPTED = 35; + /** + * Exit code on a request where the destination has not changed + * and (somehow) the command specified that this is an error. + * That is, this exit code is somehow different from a "success" + * : {@value} + * <p> + * <code>304 Not Modified </code> + */ + int EXIT_NOT_MODIFIED = 34; /** * Exit code when the command line doesn't parse: {@value}, or * when it is otherwise invalid. + * <p> + * <code>400 BAD REQUEST</code> + */ + int EXIT_COMMAND_ARGUMENT_ERROR = 40; + + /** + * The request requires user authentication: {@value} + * <p> + * <code>401 Unauthorized</code> + */ + int EXIT_UNAUTHORIZE = 41; + + /** + * Forbidden action: {@value} + * <p> + * <code>403: Forbidden</code> + */ + int EXIT_FORBIDDEN = 43; + + /** + * Something was not found: {@value} + * <p> + * <code>404: NOT FOUND</code> + */ + int EXIT_NOT_FOUND = 44; + + /** + * The operation is not allowed: {@value} + * <p> + * <code>405: NOT ALLOWED</code> + */ + int EXIT_OPERATION_NOT_ALLOWED = 45; + + /** + * The command is somehow not acceptable: {@value} + * <p> + * <code>406: NOT ACCEPTABLE</code> + */ + int EXIT_NOT_ACCEPTABLE = 46; + + /** + * Exit code on connectivity problems: {@value} + * <p> + * <code>408: Request Timeout</code> + */ + int EXIT_CONNECTIVITY_PROBLEM = 48; + + /** + * The request could not be completed due to a conflict with the current + * state of the resource. {@value} + * <p> + * <code>409: conflict</code> + */ + int EXIT_CONFLICT = 49; + + /** + * internal error: {@value} + * <p> + * <code>500 Internal Server Error</code> + */ + int EXIT_INTERNAL_ERROR = 50; + + /** + * Unimplemented feature: {@value} + * <p> + * <code>501: Not Implemented</code> */ - int EXIT_COMMAND_ARGUMENT_ERROR = 36; + int EXIT_UNIMPLEMENTED = 51; /** - * Exit code when the configurations in valid/incomplete: {@value} + * Service Unavailable; it may be available later: {@value} + * <p> + * <code>503 Service Unavailable</code> */ - int EXIT_BAD_CONFIGURATION = 37; + int EXIT_SERVICE_UNAVAILABLE = 53; /** - * Exit code when the configurations in valid/incomplete: {@value} + * The application does not support, or refuses to support this version: {@value}. + * If raised, this is expected to be raised server-side and likely due + * to client/server version incompatibilities. + * <p> + * <code> 505: Version Not Supported</code> + */ + int EXIT_UNSUPPORTED_VERSION = 55; + + /** + * Exit code when an exception was thrown from the service: {@value} + * <p> + * <code>5XX</code> */ - int EXIT_CONNECTIVITY_PROBLEM = 38; + int EXIT_EXCEPTION_THROWN = 56; } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4dcb62cf/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java b/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java index df12849..29b1d4e 100644 --- a/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java +++ b/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java @@ -80,11 +80,13 @@ public class ServiceLauncher<S extends Service> public static final String ARG_CONF = "--conf"; public static final String USAGE_MESSAGE = - "Usage: " + NAME + " classname ["+ARG_CONF + "<conf file>] <service arguments> | "; + "Usage: " + NAME + " classname [" + ARG_CONF + + "<conf file>] <service arguments> | "; static final int SHUTDOWN_TIME_ON_INTERRUPT = 30 * 1000; private volatile S service; private int serviceExitCode; + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private final List<IrqHandler> interruptHandlers = new ArrayList<IrqHandler>(1); private Configuration configuration; private String serviceClassName; @@ -220,7 +222,7 @@ public class ServiceLauncher<S extends Service> Object instance = serviceClass.getConstructor().newInstance(); if (!(instance instanceof Service)) { //not a service - throw new ExitUtil.ExitException(EXIT_BAD_CONFIGURATION, + throw new ExitUtil.ExitException(EXIT_COMMAND_ARGUMENT_ERROR, "Not a Service class: " + serviceClassName); } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4dcb62cf/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneYarnRegistryAM.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneYarnRegistryAM.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneYarnRegistryAM.groovy index 771df90..59494e4 100644 --- a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneYarnRegistryAM.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneYarnRegistryAM.groovy @@ -18,12 +18,10 @@ package org.apache.slider.agent.standalone -import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import org.apache.hadoop.fs.FileUtil import org.apache.hadoop.fs.PathNotFoundException import org.apache.hadoop.registry.client.binding.RegistryPathUtils -import org.apache.hadoop.registry.client.binding.RegistryUtils import org.apache.hadoop.yarn.api.records.ApplicationReport import org.apache.hadoop.yarn.api.records.YarnApplicationState import org.apache.hadoop.yarn.conf.YarnConfiguration @@ -43,7 +41,6 @@ import static org.apache.hadoop.registry.client.binding.RegistryUtils.* 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.main.ServiceLauncher @@ -226,7 +223,7 @@ class TestStandaloneYarnRegistryAM extends AgentMiniClusterTestBase { path: recordsPath +"/unknown", list: true) // the record is not there, even if the path is - assert SliderExitCodes.EXIT_NOT_FOUND == client.actionResolve( + assert LauncherExitCodes.EXIT_NOT_FOUND == client.actionResolve( listUnknownPath) @@ -235,7 +232,7 @@ class TestStandaloneYarnRegistryAM extends AgentMiniClusterTestBase { path: recordsPath, list: false) // the record is not there, even if the path is - assert SliderExitCodes.EXIT_NOT_FOUND == client.actionResolve( + assert LauncherExitCodes.EXIT_NOT_FOUND == client.actionResolve( resolveRecordAtListPath) // look at a single record @@ -450,7 +447,7 @@ class TestStandaloneYarnRegistryAM extends AgentMiniClusterTestBase { registryArgs.listConf = true registryArgs.internal = true describe registryArgs.toString() - assert SliderExitCodes.EXIT_NOT_FOUND == client.actionRegistry(registryArgs) + assert LauncherExitCodes.EXIT_NOT_FOUND == client.actionRegistry(registryArgs) registryArgs.list = false; registryArgs.listConf = false @@ -487,7 +484,7 @@ class TestStandaloneYarnRegistryAM extends AgentMiniClusterTestBase { def unknownFilename = "undefined-file" registryArgs.getConf = unknownFilename - assert SliderExitCodes.EXIT_NOT_FOUND == client.actionRegistry(registryArgs) + assert LauncherExitCodes.EXIT_NOT_FOUND == client.actionRegistry(registryArgs) //look for a different user try { @@ -520,11 +517,11 @@ class TestStandaloneYarnRegistryAM extends AgentMiniClusterTestBase { // only check this if the YARN registry renaming logic is in if (!hbase.contains("@")) { - assert SliderExitCodes.EXIT_NOT_FOUND == client.actionResolve( + assert LauncherExitCodes.EXIT_NOT_FOUND == client.actionResolve( new ActionResolveArgs( path: hbaseServices, list: true)) - assert SliderExitCodes.EXIT_NOT_FOUND == client.actionResolve( + assert LauncherExitCodes.EXIT_NOT_FOUND == client.actionResolve( new ActionResolveArgs(path: hbaseServices)) } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4dcb62cf/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/FunctionalHBaseClusterIT.groovy ---------------------------------------------------------------------- diff --git a/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/FunctionalHBaseClusterIT.groovy b/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/FunctionalHBaseClusterIT.groovy index 936c616..d520471 100644 --- a/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/FunctionalHBaseClusterIT.groovy +++ b/slider-providers/hbase/hbase-funtests/src/test/groovy/org/apache/slider/providers/hbase/funtest/FunctionalHBaseClusterIT.groovy @@ -28,7 +28,6 @@ import org.apache.slider.api.RoleKeys import org.apache.slider.client.SliderClient import org.apache.slider.common.SliderExitCodes import org.apache.slider.common.SliderKeys -import org.apache.slider.common.SliderXmlConfKeys import org.apache.slider.common.params.Arguments import org.apache.slider.common.tools.ConfigHelper