Package org.apache.flink.runtime.util
Class JvmShutdownSafeguard
java.lang.Object
java.lang.Thread
org.apache.flink.runtime.util.JvmShutdownSafeguard
- All Implemented Interfaces:
Runnable
A utility that guards against blocking shutdown hooks that block JVM shutdown.
When the JVM shuts down cleanly (SIGTERM or System.exit(int)) it runs all
installed shutdown hooks. It is possible that any of the shutdown hooks blocks, which causes the
JVM to get stuck and not exit at all.
This utility installs a shutdown hook that forcibly terminates the JVM if it is still alive a certain time after clean shutdown was initiated. Even if some shutdown hooks block, the JVM will terminate within a certain time.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinstallAsShutdownHook(org.slf4j.Logger logger) Installs the safeguard shutdown hook.static voidinstallAsShutdownHook(org.slf4j.Logger logger, long delayMillis) Installs the safeguard shutdown hook.voidrun()Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Method Details
-
run
public void run() -
installAsShutdownHook
public static void installAsShutdownHook(org.slf4j.Logger logger) Installs the safeguard shutdown hook. The maximum time that the JVM is allowed to spend on shutdown before being killed is five seconds.- Parameters:
logger- The logger to log errors to.
-
installAsShutdownHook
public static void installAsShutdownHook(org.slf4j.Logger logger, long delayMillis) Installs the safeguard shutdown hook. The maximum time that the JVM is allowed to spend on shutdown before being killed is the given number of milliseconds.- Parameters:
logger- The logger to log errors to.delayMillis- The delay (in milliseconds) to wait after clean shutdown was stared, before forcibly terminating the JVM.
-