InterruptEscalator (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.service.launcher, class: InterruptEscalator

Package org.apache.hadoop.service.launcher

# 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected static class`
  `InterruptEscalator.ServiceForcedShutdown`
  Forced shutdown runnable.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InterruptEscalator(ServiceLauncher owner, int shutdownTimeMillis)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `interrupted(IrqHandler.InterruptData interruptData)`
  Handle an interrupt.
  `boolean`
  `isForcedShutdownTimedOut()`
  Flag set if forced shut down timed out.
  `boolean`
  `isSignalAlreadyReceived()`
  Flag set if a signal has been received.
  `IrqHandler`
  `lookup(String signalName)`
  Look up the handler for a signal.
  `void`
  `register(String signalName)`
  Register an interrupt handler.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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.