소스 검색

HADOOP-9108. Add a method to clear terminateCalled to ExitUtil for test cases (Kihwal Lee via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1415489 13f79535-47bb-0310-9956-ffa450edef68
Thomas Graves 12 년 전
부모
커밋
0db6cd37a8

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -10,6 +10,9 @@ Release 0.23.6 - UNRELEASED
 
     HADOOP-8931. Add Java version to startup message. (eli)
 
+    HADOOP-9108. Add a method to clear terminateCalled to ExitUtil for test 
+    cases (Kihwal Lee via tgraves)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 8 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ExitUtil.java

@@ -49,6 +49,13 @@ public final class ExitUtil {
     systemExitDisabled = true;
   }
 
+  /**
+   * Clear the previous exit record.
+   */
+  public static void clearTerminateCalled() {
+    terminateCalled = false;
+  }
+
   /**
    * @return true if terminate has been called
    */
@@ -80,4 +87,4 @@ public final class ExitUtil {
   public static void terminate(int status) throws ExitException {
     terminate(status, "ExitException");
   }
-}
+}

+ 4 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java

@@ -1146,11 +1146,14 @@ public class MiniDFSCluster {
    */
   public void shutdown() {
     LOG.info("Shutting down the Mini HDFS Cluster");
+    boolean hasExitError = ExitUtil.terminateCalled();
+    ExitUtil.clearTerminateCalled();
     if (checkExitOnShutdown)  {
-     if (ExitUtil.terminateCalled()) {
+     if (hasExitError) {
        throw new AssertionError("Test resulted in an unexpected exit");
      }
     }
+    
     shutdownDataNodes();
     for (NameNodeInfo nnInfo : nameNodes) {
       NameNode nameNode = nnInfo.nameNode;