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
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 -
Method Summary
Modifier and TypeMethodDescriptionlonglonglongbooleanstatic voidSimple 'main' to facilitate manual testing of the pause monitor.protected voidserviceInit(Configuration conf) All initialization code needed by a service.protected voidActions called during the INITED to STARTED transition.protected voidActions 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
-
Constructor Details
-
JvmPauseMonitor
public JvmPauseMonitor()
-
-
Method Details
-
serviceInit
Description copied from class:AbstractServiceAll 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 inAbstractService.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:
serviceInitin classAbstractService- Parameters:
conf- configuration- Throws:
Exception- on a failure -these will be caught, possibly wrapped, and will trigger a service stop
-
serviceStart
Description copied from class:AbstractServiceActions 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 inAbstractService.start()prevents re-entrancy.- Overrides:
serviceStartin classAbstractService- Throws:
Exception- if needed -these will be caught, wrapped, and trigger a service stop
-
serviceStop
Description copied from class:AbstractServiceActions 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 inAbstractService.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:
serviceStopin classAbstractService- 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
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.
-