Class InterruptEscalator

java.lang.Object
org.apache.hadoop.service.launcher.InterruptEscalator
All Implemented Interfaces:
IrqHandler.Interrupted

@Private @Unstable public class InterruptEscalator extends Object implements IrqHandler.Interrupted
Handles interrupts by shutting down a service, escalating if the service does not shut down in time, or when other interrupts are received.
  1. The service is given a time in milliseconds to stop: if it exceeds this it the process exits anyway.
  2. the exit operation used is ServiceLauncher.exit(int, String) with the exit code LauncherExitCodes.EXIT_INTERRUPTED
  3. If a second shutdown signal is received during the shutdown process, ExitUtil.halt(int) is invoked. This handles the problem of blocking shutdown hooks.
  • Constructor Details

    • InterruptEscalator

      public InterruptEscalator(ServiceLauncher owner, int shutdownTimeMillis)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • interrupted

      public void interrupted(IrqHandler.InterruptData interruptData)
      Description copied from interface: IrqHandler.Interrupted
      Handle an interrupt.
      Specified by:
      interrupted in interface IrqHandler.Interrupted
      Parameters:
      interruptData - data
    • register

      public void register(String signalName)
      Register an interrupt handler.
      Parameters:
      signalName - signal name
      Throws:
      IllegalArgumentException - if the registration failed
    • lookup

      public IrqHandler lookup(String signalName)
      Look up the handler for a signal.
      Parameters:
      signalName - signal name
      Returns:
      a handler if found
    • isForcedShutdownTimedOut

      public boolean isForcedShutdownTimedOut()
      Flag set if forced shut down timed out.
      Returns:
      true if a shutdown was attempted and it timed out
    • isSignalAlreadyReceived

      public boolean isSignalAlreadyReceived()
      Flag set if a signal has been received.
      Returns:
      true if there has been one interrupt already.