Class AbstractLaunchableService

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.launcher.AbstractLaunchableService
All Implemented Interfaces:
Closeable, AutoCloseable, LaunchableService, Service

@Public @Evolving public abstract class AbstractLaunchableService extends AbstractService implements LaunchableService
Subclass of AbstractService that provides basic implementations of the LaunchableService methods.
  • Constructor Details

    • AbstractLaunchableService

      protected AbstractLaunchableService(String name)
      Construct an instance with the given name.
      Parameters:
      name - input name.
  • Method Details

    • bindArgs

      public Configuration bindArgs(Configuration config, List<String> args) throws Exception
      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 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.

      Specified by:
      bindArgs in interface LaunchableService
      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

      public int execute() throws Exception
      Run a service. This method is called after Service.start().

      The return value becomes the exit code of the launched process.

      If an exception is raised, the policy is:

      1. Any subset of ExitUtil.ExitException: the exception is passed up unmodified.
      2. Any exception which implements ExitCodeProvider: A new ServiceLaunchException is created with the exit code and message of the thrown exception; the thrown exception becomes the cause.
      3. Any other exception: a new 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.

      Specified by:
      execute in interface LaunchableService
      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.