Class ServiceStateException

All Implemented Interfaces:
Serializable, org.apache.hadoop.util.ExitCodeProvider

@Public @Evolving public class ServiceStateException extends RuntimeException implements org.apache.hadoop.util.ExitCodeProvider
Exception that can be raised on state change operations, whose exit code can be explicitly set, determined from that of any nested cause, or a default value of LauncherExitCodes.EXIT_SERVICE_LIFECYCLE_EXCEPTION.
See Also:
  • Constructor Details

    • ServiceStateException

      public ServiceStateException(String message)
      Instantiate
      Parameters:
      message - error message
    • ServiceStateException

      public ServiceStateException(String message, Throwable cause)
      Instantiate with a message and cause; if the cause has an exit code then it is used, otherwise the generic LauncherExitCodes.EXIT_SERVICE_LIFECYCLE_EXCEPTION exit code is used.
      Parameters:
      message - exception message
      cause - optional inner cause
    • ServiceStateException

      public ServiceStateException(int exitCode, String message, Throwable cause)
      Instantiate, using the specified exit code as the exit code of the exception, irrespetive of any exit code supplied by any inner cause.
      Parameters:
      exitCode - exit code to declare
      message - exception message
      cause - inner cause
    • ServiceStateException

      public ServiceStateException(Throwable cause)
  • Method Details

    • getExitCode

      public int getExitCode()
      Description copied from interface: org.apache.hadoop.util.ExitCodeProvider
      Method to get the exit code.
      Specified by:
      getExitCode in interface org.apache.hadoop.util.ExitCodeProvider
      Returns:
      the exit code
    • convert

      public static RuntimeException convert(Throwable fault)
      Convert any exception into a RuntimeException. All other exception types are wrapped in a new instance of ServiceStateException.
      Parameters:
      fault - exception or throwable
      Returns:
      a RuntimeException to rethrow
    • convert

      public static RuntimeException convert(String text, Throwable fault)
      Convert any exception into a RuntimeException. If the caught exception is already of that type, it is typecast to a RuntimeException and returned. All other exception types are wrapped in a new instance of ServiceStateException.
      Parameters:
      text - text to use if a new exception is created
      fault - exception or throwable
      Returns:
      a RuntimeException to rethrow