Class AbstractLaunchableService
- All Implemented Interfaces:
Closeable,AutoCloseable,LaunchableService,Service
AbstractService that provides basic implementations
of the LaunchableService methods.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
Service.STATE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstruct an instance with the given name. -
Method Summary
Modifier and TypeMethodDescriptionbindArgs(Configuration config, List<String> args) Propagate the command line arguments.intexecute()Run a service.Methods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceInit, serviceStart, serviceStop, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.service.Service
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, registerServiceListener, start, stop, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
AbstractLaunchableService
Construct an instance with the given name.- Parameters:
name- input name.
-
-
Method Details
-
bindArgs
Propagate the command line arguments.This method is called before
Service.init(Configuration); Any non-null configuration that is returned from this operation becomes the one that is passed on to thatService.init(Configuration)operation.This permits implementations to change the configuration before the init operation. As the ServiceLauncher only creates an instance of the base
Configurationclass, it is recommended to instantiate any subclass (such as YarnConfiguration) that injects new resources.The base implementation logs all arguments at the debug level, then returns the passed in config unchanged.
- Specified by:
bindArgsin interfaceLaunchableService- Parameters:
config- the initial configuration build up by the service launcher.args- list of arguments passed to the command line after any launcher-specific commands have been stripped.- Returns:
- the configuration to init the service with. Recommended: pass down the config parameter with any changes
- Throws:
Exception- any problem
-
execute
Run a service. This method is called afterService.start().The return value becomes the exit code of the launched process.
If an exception is raised, the policy is:
- Any subset of
ExitUtil.ExitException: the exception is passed up unmodified. - Any exception which implements
ExitCodeProvider: A newServiceLaunchExceptionis created with the exit code and message of the thrown exception; the thrown exception becomes the cause. - Any other exception: a new
ServiceLaunchExceptionis created with the exit codeLauncherExitCodes.EXIT_EXCEPTION_THROWNand the message of the original exception (which becomes the cause).
The action is to signal success by returning the exit code 0.
- Specified by:
executein interfaceLaunchableService- Returns:
- the exit code
- Throws:
org.apache.hadoop.util.ExitUtil.ExitException- an exception passed up as the exit code and error text.Exception- any exception to report. If it provides an exit code this is used in a wrapping exception.
- Any subset of
-