JvmPauseMonitor (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: JvmPauseMonitor

Package org.apache.hadoop.util

# Class JvmPauseMonitor

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.util.JvmPauseMonitor

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `Service`

@Private public class JvmPauseMonitor extends AbstractService
Class which sets up a simple thread which runs in a loop sleeping for a short interval of time. If the sleep takes significantly longer than its target time, it implies that the JVM or host machine has paused processing, which may cause other problems. If such a pause is detected, the thread logs a message.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service

  `Service.STATE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JvmPauseMonitor()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getNumGcInfoThresholdExceeded()`
  `long`
  `getNumGcWarnThresholdExceeded()`
  `long`
  `getTotalGcExtraSleepTime()`
  `boolean`
  `isStarted()`
  `static void`
  `main(String[] args)`
  Simple 'main' to facilitate manual testing of the pause monitor.
  `protected void`
  `serviceInit(Configuration conf)`
  All initialization code needed by a service.
  `protected void`
  `serviceStart()`
  Actions called during the INITED to STARTED transition.
  `protected void`
  `serviceStop()`
  Actions called during the transition to the STOPPED state.

  ### Methods inherited from class org.apache.hadoop.service.AbstractService

  `close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop`

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

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

- ## Constructor Details

  - ### JvmPauseMonitor

    public JvmPauseMonitor()

- ## Method Details

  - ### serviceInit

    protected void serviceInit(Configuration conf) throws Exception
    Description copied from class: `AbstractService`
    All initialization code needed by a service. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic in `AbstractService.init(Configuration)` prevents re-entrancy. The base implementation checks to see if the subclass has created a new configuration instance, and if so, updates the base class value
    Overrides:
      `serviceInit` in class `AbstractService`
    Parameters:
      `conf` - configuration
    Throws:
      `Exception` - on a failure -these will be caught, possibly wrapped, and will trigger a service stop

  - ### serviceStart

    protected void serviceStart() throws Exception
    Description copied from class: `AbstractService`
    Actions called during the INITED to STARTED transition. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic in `AbstractService.start()` prevents re-entrancy.
    Overrides:
      `serviceStart` in class `AbstractService`
    Throws:
      `Exception` - if needed -these will be caught, wrapped, and trigger a service stop

  - ### serviceStop

    protected void serviceStop() throws Exception
    Description copied from class: `AbstractService`
    Actions called during the transition to the STOPPED state. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic in `AbstractService.stop()` prevents re-entrancy. Implementations MUST write this to be robust against failures, including checks for null references -and for the first failure to not stop other attempts to shut down parts of the service.
    Overrides:
      `serviceStop` in class `AbstractService`
    Throws:
      `Exception` - if needed -these will be caught and logged.

  - ### isStarted

    public boolean isStarted()

  - ### getNumGcWarnThresholdExceeded

    public long getNumGcWarnThresholdExceeded()

  - ### getNumGcInfoThresholdExceeded

    public long getNumGcInfoThresholdExceeded()

  - ### getTotalGcExtraSleepTime

    public long getTotalGcExtraSleepTime()

  - ### main

    public static void main(String[] args) throws Exception
    Simple 'main' to facilitate manual testing of the pause monitor. This main function just leaks memory into a list. Running this class with a 1GB heap will very quickly go into "GC hell" and result in log messages about the GC pauses.
    Parameters:
      `args` - args.
    Throws:
      `Exception` - Exception.