Browse Source

HADOOP-3694. Improve unit test performance by changing MiniDFSCluster to only listen on 127.0.0.1.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@681429 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 17 years ago
parent
commit
c631f5892f

+ 3 - 0
CHANGES.txt

@@ -127,6 +127,9 @@ Trunk (unreleased changes)
     HADOOP-3791. Introduce generics into ReflectionUtils. (Chris Smith via
     cdouglas)
 
+    HADOOP-3694. Improve unit test performance by changing
+    MiniDFSCluster to listen only on 127.0.0.1.  (cutting)
+
   OPTIMIZATIONS
 
     HADOOP-3556. Removed lock contention in MD5Hash by changing the 

+ 2 - 2
src/test/org/apache/hadoop/hdfs/MiniDFSCluster.java

@@ -243,7 +243,7 @@ public class MiniDFSCluster {
     
     // Setup the NameNode configuration
     FileSystem.setDefaultUri(conf, "hdfs://localhost:"+ Integer.toString(nameNodePort));
-    conf.set("dfs.http.address", "0.0.0.0:0");  
+    conf.set("dfs.http.address", "127.0.0.1:0");  
     if (manageDfsDirs) {
       conf.set("dfs.name.dir", new File(base_dir, "name1").getPath()+","+
                new File(base_dir, "name2").getPath());
@@ -363,7 +363,7 @@ public class MiniDFSCluster {
     // Set up the right ports for the datanodes
     conf.set("dfs.datanode.address", "127.0.0.1:0");
     conf.set("dfs.datanode.http.address", "127.0.0.1:0");
-    conf.set("dfs.datanode.ipc.address", "0.0.0.0:0");
+    conf.set("dfs.datanode.ipc.address", "127.0.0.1:0");
     
     String[] args = (operation == null ||
                      operation == StartupOption.FORMAT ||

+ 5 - 1
src/test/org/apache/hadoop/hdfs/TestFileCreation.java

@@ -743,6 +743,8 @@ public class TestFileCreation extends junit.framework.TestCase {
           slowwriters[i].start();
         }
 
+        Thread.sleep(1000);                       // let writers get started
+
         //stop a datanode, it should have least recover.
         cluster.stopDataNode(new Random().nextInt(REPLICATION));
         
@@ -753,6 +755,7 @@ public class TestFileCreation extends junit.framework.TestCase {
       finally {
         for(int i = 0; i < slowwriters.length; i++) {
           if (slowwriters[i] != null) {
+            slowwriters[i].running = false;
             slowwriters[i].interrupt();
           }
         }
@@ -787,6 +790,7 @@ public class TestFileCreation extends junit.framework.TestCase {
   static class SlowWriter extends Thread {
     final FileSystem fs;
     final Path filepath;
+    boolean running = true;
     
     SlowWriter(FileSystem fs, Path filepath) {
       super(SlowWriter.class.getSimpleName() + ":" + filepath);
@@ -799,7 +803,7 @@ public class TestFileCreation extends junit.framework.TestCase {
       int i = 0;
       try {
         out = fs.create(filepath);
-        for(; ; i++) {
+        for(; running; i++) {
           System.out.println(getName() + " writes " + i);
           out.write(i);
           out.sync();