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/branches/branch-2@1361777 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a016d8e9a9
commit
5685eb30bb
|
@ -30,7 +30,7 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
public final class ExitUtil {
|
public final class ExitUtil {
|
||||||
private final static Log LOG = LogFactory.getLog(ExitUtil.class.getName());
|
private final static Log LOG = LogFactory.getLog(ExitUtil.class.getName());
|
||||||
private static volatile boolean systemExitDisabled = false;
|
private static volatile boolean systemExitDisabled = false;
|
||||||
private static volatile boolean terminateCalled = false;
|
private static volatile ExitException firstExitException;
|
||||||
|
|
||||||
public static class ExitException extends RuntimeException {
|
public static class ExitException extends RuntimeException {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -53,7 +53,15 @@ public final class ExitUtil {
|
||||||
* @return true if terminate has been called
|
* @return true if terminate has been called
|
||||||
*/
|
*/
|
||||||
public static boolean terminateCalled() {
|
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 final class ExitUtil {
|
||||||
*/
|
*/
|
||||||
public static void terminate(int status, String msg) throws ExitException {
|
public static void terminate(int status, String msg) throws ExitException {
|
||||||
LOG.info("Exiting with status " + status);
|
LOG.info("Exiting with status " + status);
|
||||||
terminateCalled = true;
|
|
||||||
if (systemExitDisabled) {
|
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);
|
System.exit(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,6 +148,9 @@ Release 2.0.1-alpha - UNRELEASED
|
||||||
HDFS-3610. fuse_dfs: Provide a way to use the default (configured) NN URI.
|
HDFS-3610. fuse_dfs: Provide a way to use the default (configured) NN URI.
|
||||||
(Colin Patrick McCabe via eli)
|
(Colin Patrick McCabe via eli)
|
||||||
|
|
||||||
|
HDFS-3663. MiniDFSCluster should capture the code path that led to
|
||||||
|
the first ExitException. (eli)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-2982. Startup performance suffers when there are many edit log
|
HDFS-2982. Startup performance suffers when there are many edit log
|
||||||
|
|
|
@ -1292,6 +1292,8 @@ public class MiniDFSCluster {
|
||||||
LOG.info("Shutting down the Mini HDFS Cluster");
|
LOG.info("Shutting down the Mini HDFS Cluster");
|
||||||
if (checkExitOnShutdown) {
|
if (checkExitOnShutdown) {
|
||||||
if (ExitUtil.terminateCalled()) {
|
if (ExitUtil.terminateCalled()) {
|
||||||
|
LOG.fatal("Test resulted in an unexpected exit",
|
||||||
|
ExitUtil.getFirstExitException());
|
||||||
throw new AssertionError("Test resulted in an unexpected exit");
|
throw new AssertionError("Test resulted in an unexpected exit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue