/** * Inner termination: either exit with the exception's exit code, * or, if system exits are disabled, rethrow the exception. * @param ee exit exception */ public static synchronized void terminate(ExitException ee) throws ExitException { int status = ee.getExitCode(); String msg = ee.getMessage(); if (status != 0) { //exit indicates a problem, log it LOG.debug("Exiting with status {}: {}", status, msg, ee); LOG.info("Exiting with status {}: {}", status, msg); } if (systemExitDisabled) { LOG.error("Terminate called", ee); if (!terminateCalled()) { firstExitException = ee; } throw ee; } System.exit(status); }
/** * Shutdown all the nodes in the cluster. */ public void shutdown(boolean deleteDfsDir) { LOG.info("Shutting down the Mini HDFS Cluster"); if (checkExitOnShutdown) { if (ExitUtil.terminateCalled()) { LOG.fatal("Test resulted in an unexpected exit", ExitUtil.getFirstExitException()); ExitUtil.resetFirstExitException(); throw new AssertionError("Test resulted in an unexpected exit"); } } shutdownDataNodes(); for (NameNodeInfo nnInfo : nameNodes) { if (nnInfo == null) continue; NameNode nameNode = nnInfo.nameNode; if (nameNode != null) { nameNode.stop(); nameNode.join(); nameNode = null; } } if (deleteDfsDir) { base_dir.delete(); } else { base_dir.deleteOnExit(); } }
ExitUtil.terminateCalled()); Assert.assertEquals("Expected shutDownJob to exit with status code of 0.", 0, ExitUtil.getFirstExitException().status);