@InterfaceAudience.Public @InterfaceStability.Evolving public abstract class AbstractLaunchableService extends AbstractService implements LaunchableService
AbstractService
that provides basic implementations
of the LaunchableService
methods.Modifier | Constructor and Description |
---|---|
protected |
AbstractLaunchableService(String name)
Construct an instance with the given name.
|
Modifier and Type | Method and Description |
---|---|
Configuration |
bindArgs(Configuration config,
List<String> args)
Propagate the command line arguments.
|
int |
execute()
Run a service.
|
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, waitForServiceToStop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, registerServiceListener, start, stop, unregisterServiceListener, waitForServiceToStop
protected AbstractLaunchableService(String name)
public Configuration bindArgs(Configuration config, List<String> args) throws Exception
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 that Service.init(Configuration)
operation.
This permits implementations to change the configuration before
the init operation. As the ServiceLauncher only creates
an instance of the base Configuration
class, 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.
bindArgs
in interface LaunchableService
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.Exception
- any problempublic int execute() throws Exception
Service.start()
.
The return value becomes the exit code of the launched process.
If an exception is raised, the policy is:
ExitUtil.ExitException
:
the exception is passed up unmodified.
ExitCodeProvider
:
A new ServiceLaunchException
is created with the exit code
and message of the thrown exception; the thrown exception becomes the
cause.ServiceLaunchException
is created
with the exit code LauncherExitCodes.EXIT_EXCEPTION_THROWN
and
the message of the original exception (which becomes the cause).The action is to signal success by returning the exit code 0.
execute
in interface LaunchableService
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.Copyright © 2022 Apache Software Foundation. All rights reserved.