浏览代码

HADOOP-1940. TestDFSUpgradeFromImage must shut down its MiniDFSCluster. Contributed by Chris.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@579334 13f79535-47bb-0310-9956-ffa450edef68
Nigel Daley 18 年之前
父节点
当前提交
aaa4cea64e
共有 2 个文件被更改,包括 24 次插入17 次删除
  1. 3 0
      CHANGES.txt
  2. 21 17
      src/test/org/apache/hadoop/dfs/TestDFSUpgradeFromImage.java

+ 3 - 0
CHANGES.txt

@@ -188,6 +188,9 @@ Trunk (unreleased changes)
     HADOOP-1925.  Make pipes' autoconf script look for libsocket and libnsl, so
     that it can compile under Solaris. (omalley)
 
+    HADOOP-1940.  TestDFSUpgradeFromImage must shut down its MiniDFSCluster.
+    (Chris Douglas via nigel)
+
   IMPROVEMENTS
 
     HADOOP-1921. Save the configuration of completed/failed jobs and make them

+ 21 - 17
src/test/org/apache/hadoop/dfs/TestDFSUpgradeFromImage.java

@@ -175,23 +175,27 @@ public class TestDFSUpgradeFromImage extends TestCase {
   }
   
   public void testUpgradeFromImage() throws IOException {
-    
-    Configuration conf = new Configuration();
-    MiniDFSCluster cluster = new MiniDFSCluster(0, conf, numDataNodes, false,
-                                                true, StartupOption.UPGRADE,
-                                                null);
-    cluster.waitActive();
-    DFSClient dfsClient = new DFSClient(new InetSocketAddress("localhost", 
-                                                  cluster.getNameNodePort()),
-                                        conf);
-    //Safemode will be off only after upgrade is complete. Wait for it.
-    while ( dfsClient.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET) ) {
-      LOG.info("Waiting for SafeMode to be OFF.");
-      try {
-        Thread.sleep(1000);
-      } catch (InterruptedException ignored) {}
-    }
+    MiniDFSCluster cluster = null;
+    try {
+      Configuration conf = new Configuration();
+      cluster = new MiniDFSCluster(0, conf, numDataNodes, false,
+                                                  true, StartupOption.UPGRADE,
+                                                  null);
+      cluster.waitActive();
+      DFSClient dfsClient = new DFSClient(new InetSocketAddress("localhost",
+                                                    cluster.getNameNodePort()),
+                                          conf);
+      //Safemode will be off only after upgrade is complete. Wait for it.
+      while ( dfsClient.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET) ) {
+        LOG.info("Waiting for SafeMode to be OFF.");
+        try {
+          Thread.sleep(1000);
+        } catch (InterruptedException ignored) {}
+      }
 
-    verifyFileSystem(dfsClient);
+      verifyFileSystem(dfsClient);
+    } finally {
+      if (cluster != null) { cluster.shutdown(); }
+    }
   }
 }