diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java index 3c768a53270..4dd340a6358 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java @@ -80,6 +80,24 @@ import com.google.common.annotations.VisibleForTesting; public class NodeManager extends CompositeService implements EventHandler { + /** + * Node manager return status codes. + */ + public enum NodeManagerStatus { + NO_ERROR(0), + EXCEPTION(1); + + private int exitCode; + + NodeManagerStatus(int exitCode) { + this.exitCode = exitCode; + } + + public int getExitCode() { + return exitCode; + } + } + /** * Priority of the NodeManager shutdown hook. */ @@ -408,7 +426,7 @@ public class NodeManager extends CompositeService return "NodeManager"; } - protected void shutDown() { + protected void shutDown(final int exitCode) { new Thread() { @Override public void run() { @@ -419,7 +437,7 @@ public class NodeManager extends CompositeService } finally { if (shouldExitOnShutdownEvent && !ShutdownHookManager.get().isShutdownInProgress()) { - ExitUtil.terminate(-1); + ExitUtil.terminate(exitCode); } } } @@ -444,7 +462,7 @@ public class NodeManager extends CompositeService .rebootNodeStatusUpdaterAndRegisterWithRM(); } catch (YarnRuntimeException e) { LOG.fatal("Error while rebooting NodeStatusUpdater.", e); - shutDown(); + shutDown(NodeManagerStatus.EXCEPTION.getExitCode()); } } }.start(); @@ -700,7 +718,7 @@ public class NodeManager extends CompositeService public void handle(NodeManagerEvent event) { switch (event.getType()) { case SHUTDOWN: - shutDown(); + shutDown(NodeManagerStatus.NO_ERROR.getExitCode()); break; case RESYNC: resyncWithRM(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java index 04cfae9f390..5ab5c3754f1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java @@ -638,7 +638,7 @@ public class TestNodeManagerResync { } @Override - protected void shutDown() { + protected void shutDown(int exitCode) { synchronized (isNMShutdownCalled) { isNMShutdownCalled.set(true); isNMShutdownCalled.notify();