|
@@ -38,6 +38,7 @@ import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
|
|
import org.apache.hadoop.security.Credentials;
|
|
|
import org.apache.hadoop.security.SecurityUtil;
|
|
|
import org.apache.hadoop.service.CompositeService;
|
|
|
+import org.apache.hadoop.util.ExitUtil;
|
|
|
import org.apache.hadoop.util.GenericOptionsParser;
|
|
|
import org.apache.hadoop.util.NodeHealthScriptRunner;
|
|
|
import org.apache.hadoop.util.ReflectionUtils;
|
|
@@ -94,6 +95,7 @@ public class NodeManager extends CompositeService
|
|
|
|
|
|
private AtomicBoolean isStopping = new AtomicBoolean(false);
|
|
|
private boolean rmWorkPreservingRestartEnabled;
|
|
|
+ private boolean shouldExitOnShutdownEvent = false;
|
|
|
|
|
|
public NodeManager() {
|
|
|
super(NodeManager.class.getName());
|
|
@@ -344,7 +346,16 @@ public class NodeManager extends CompositeService
|
|
|
new Thread() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- NodeManager.this.stop();
|
|
|
+ try {
|
|
|
+ NodeManager.this.stop();
|
|
|
+ } catch (Throwable t) {
|
|
|
+ LOG.error("Error while shutting down NodeManager", t);
|
|
|
+ } finally {
|
|
|
+ if (shouldExitOnShutdownEvent
|
|
|
+ && !ShutdownHookManager.get().isShutdownInProgress()) {
|
|
|
+ ExitUtil.terminate(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}.start();
|
|
|
}
|
|
@@ -530,7 +541,9 @@ public class NodeManager extends CompositeService
|
|
|
nodeManagerShutdownHook = new CompositeServiceShutdownHook(this);
|
|
|
ShutdownHookManager.get().addShutdownHook(nodeManagerShutdownHook,
|
|
|
SHUTDOWN_HOOK_PRIORITY);
|
|
|
-
|
|
|
+ // System exit should be called only when NodeManager is instantiated from
|
|
|
+ // main() funtion
|
|
|
+ this.shouldExitOnShutdownEvent = true;
|
|
|
this.init(conf);
|
|
|
this.start();
|
|
|
} catch (Throwable t) {
|