MAPREDUCE-4031. Prevent a Node Manager hang during shutdown. (Contributed by Devaraj K)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1353038 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Siddharth Seth 2012-06-22 21:40:35 +00:00
parent d1138f0914
commit a945336368
3 changed files with 17 additions and 3 deletions

View File

@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* The <code>ShutdownHookManager</code> enables running shutdownHook * The <code>ShutdownHookManager</code> enables running shutdownHook
* in a determistic order, higher priority first. * in a deterministic order, higher priority first.
* <p/> * <p/>
* The JVM runs ShutdownHooks in a non-deterministic order or in parallel. * The JVM runs ShutdownHooks in a non-deterministic order or in parallel.
* This class registers a single JVM shutdownHook and run all the * This class registers a single JVM shutdownHook and run all the
@ -169,7 +169,7 @@ public class ShutdownHookManager {
} }
/** /**
* Indicates if a shutdownHook is registered or nt. * Indicates if a shutdownHook is registered or not.
* *
* @param shutdownHook shutdownHook to check if registered. * @param shutdownHook shutdownHook to check if registered.
* @return TRUE/FALSE depending if the shutdownHook is is registered. * @return TRUE/FALSE depending if the shutdownHook is is registered.
@ -177,5 +177,14 @@ public class ShutdownHookManager {
public boolean hasShutdownHook(Runnable shutdownHook) { public boolean hasShutdownHook(Runnable shutdownHook) {
return hooks.contains(new HookEntry(shutdownHook, 0)); return hooks.contains(new HookEntry(shutdownHook, 0));
} }
/**
* Indicates if shutdown is in progress or not.
*
* @return TRUE if the shutdown is in progress, otherwise FALSE.
*/
public boolean isShutdownInProgress() {
return shutdownInProgress.get();
}
} }

View File

@ -605,6 +605,9 @@ Release 0.23.3 - UNRELEASED
MAPREDUCE-4295. RM crashes due to DNS issue (tgraves) MAPREDUCE-4295. RM crashes due to DNS issue (tgraves)
MAPREDUCE-4031. Prevent a Node Manager hang during shutdown.
(Devaraj K via sseth)
Release 0.23.2 - UNRELEASED Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -28,6 +28,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.ShutdownHookManager;
import org.apache.hadoop.yarn.YarnException; import org.apache.hadoop.yarn.YarnException;
import org.apache.hadoop.yarn.service.AbstractService; import org.apache.hadoop.yarn.service.AbstractService;
@ -127,7 +128,8 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher {
catch (Throwable t) { catch (Throwable t) {
//TODO Maybe log the state of the queue //TODO Maybe log the state of the queue
LOG.fatal("Error in dispatcher thread", t); LOG.fatal("Error in dispatcher thread", t);
if (exitOnDispatchException) { if (exitOnDispatchException
&& (ShutdownHookManager.get().isShutdownInProgress()) == false) {
LOG.info("Exiting, bbye.."); LOG.info("Exiting, bbye..");
System.exit(-1); System.exit(-1);
} }