HDFS-3663. MiniDFSCluster should capture the code path that led to the first ExitException. Contributed by Eli Collins
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1361775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7351a01259
commit
64fc2cb03d
@ -30,7 +30,7 @@
|
||||
public final class ExitUtil {
|
||||
private final static Log LOG = LogFactory.getLog(ExitUtil.class.getName());
|
||||
private static volatile boolean systemExitDisabled = false;
|
||||
private static volatile boolean terminateCalled = false;
|
||||
private static volatile ExitException firstExitException;
|
||||
|
||||
public static class ExitException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -53,7 +53,15 @@ public static void disableSystemExit() {
|
||||
* @return true if terminate has been called
|
||||
*/
|
||||
public static boolean terminateCalled() {
|
||||
return terminateCalled;
|
||||
// Either we set this member or we actually called System#exit
|
||||
return firstExitException != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the first ExitException thrown, null if none thrown yet
|
||||
*/
|
||||
public static ExitException getFirstExitException() {
|
||||
return firstExitException;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,9 +73,13 @@ public static boolean terminateCalled() {
|
||||
*/
|
||||
public static void terminate(int status, String msg) throws ExitException {
|
||||
LOG.info("Exiting with status " + status);
|
||||
terminateCalled = true;
|
||||
if (systemExitDisabled) {
|
||||
throw new ExitException(status, msg);
|
||||
ExitException ee = new ExitException(status, msg);
|
||||
LOG.fatal("Terminate called", ee);
|
||||
if (null == firstExitException) {
|
||||
firstExitException = ee;
|
||||
}
|
||||
throw ee;
|
||||
}
|
||||
System.exit(status);
|
||||
}
|
||||
|
@ -327,6 +327,9 @@ Branch-2 ( Unreleased changes )
|
||||
HDFS-3610. fuse_dfs: Provide a way to use the default (configured) NN URI.
|
||||
(Colin Patrick McCabe via eli)
|
||||
|
||||
HDFS-3663. MiniDFSCluster should capture the code path that led to
|
||||
the first ExitException. (eli)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-2982. Startup performance suffers when there are many edit log
|
||||
|
@ -1316,9 +1316,11 @@ public int getNameNodeServicePort(int nnIndex) {
|
||||
public void shutdown() {
|
||||
LOG.info("Shutting down the Mini HDFS Cluster");
|
||||
if (checkExitOnShutdown) {
|
||||
if (ExitUtil.terminateCalled()) {
|
||||
throw new AssertionError("Test resulted in an unexpected exit");
|
||||
}
|
||||
if (ExitUtil.terminateCalled()) {
|
||||
LOG.fatal("Test resulted in an unexpected exit",
|
||||
ExitUtil.getFirstExitException());
|
||||
throw new AssertionError("Test resulted in an unexpected exit");
|
||||
}
|
||||
}
|
||||
shutdownDataNodes();
|
||||
for (NameNodeInfo nnInfo : nameNodes) {
|
||||
|
Loading…
Reference in New Issue
Block a user