org.apache.hadoop.util
Class ShutdownHookManager

java.lang.Object
  extended by org.apache.hadoop.util.ShutdownHookManager

public class ShutdownHookManager
extends Object

The ShutdownHookManager enables running shutdownHook in a deterministic order, higher priority first.

The JVM runs ShutdownHooks in a non-deterministic order or in parallel. This class registers a single JVM shutdownHook and run all the shutdownHooks registered to it (to this class) in order based on their priority.


Method Summary
 void addShutdownHook(Runnable shutdownHook, int priority)
          Adds a shutdownHook with a priority, the higher the priority the earlier will run.
static ShutdownHookManager get()
          Return ShutdownHookManager singleton.
 boolean hasShutdownHook(Runnable shutdownHook)
          Indicates if a shutdownHook is registered or not.
 boolean isShutdownInProgress()
          Indicates if shutdown is in progress or not.
 boolean removeShutdownHook(Runnable shutdownHook)
          Removes a shutdownHook.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static ShutdownHookManager get()
Return ShutdownHookManager singleton.

Returns:
ShutdownHookManager singleton.

addShutdownHook

public void addShutdownHook(Runnable shutdownHook,
                            int priority)
Adds a shutdownHook with a priority, the higher the priority the earlier will run. ShutdownHooks with same priority run in a non-deterministic order.

Parameters:
shutdownHook - shutdownHook Runnable
priority - priority of the shutdownHook.

removeShutdownHook

public boolean removeShutdownHook(Runnable shutdownHook)
Removes a shutdownHook.

Parameters:
shutdownHook - shutdownHook to remove.
Returns:
TRUE if the shutdownHook was registered and removed, FALSE otherwise.

hasShutdownHook

public boolean hasShutdownHook(Runnable shutdownHook)
Indicates if a shutdownHook is registered or not.

Parameters:
shutdownHook - shutdownHook to check if registered.
Returns:
TRUE/FALSE depending if the shutdownHook is is registered.

isShutdownInProgress

public boolean isShutdownInProgress()
Indicates if shutdown is in progress or not.

Returns:
TRUE if the shutdown is in progress, otherwise FALSE.


Copyright © 2013 Apache Software Foundation. All Rights Reserved.