org.apache.hive.common.util
Class ShutdownHookManager

java.lang.Object
  extended by org.apache.hive.common.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. Originally taken from o.a.hadoop.util.ShutdownHookManager


Method Summary
static void addShutdownHook(Runnable shutdownHook, int priority)
          Adds a shutdownHook with a priority, the higher the priority the earlier will run.
static boolean hasShutdownHook(Runnable shutdownHook)
          Indicates if a shutdownHook is registered or not.
 boolean hasShutdownHookInternal(Runnable shutdownHook)
           
static boolean isShutdownInProgress()
          Indicates if shutdown is in progress or not.
static 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

addShutdownHook

public static 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 static 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 static 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.

hasShutdownHookInternal

public boolean hasShutdownHookInternal(Runnable shutdownHook)

isShutdownInProgress

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

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


Copyright © 2013 The Apache Software Foundation