hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rang...@apache.org
Subject svn commit: r636621 - in /hadoop/core/trunk: CHANGES.txt src/java/org/apache/hadoop/net/NetUtils.java src/test/org/apache/hadoop/ipc/TestIPC.java src/test/org/apache/hadoop/ipc/TestIPCServerResponder.java src/test/org/apache/hadoop/ipc/TestRPC.java
Date Thu, 13 Mar 2008 03:31:17 GMT
Author: rangadi
Date: Wed Mar 12 20:31:14 2008
New Revision: 636621

URL: http://svn.apache.org/viewvc?rev=636621&view=rev
Log:
HADOOP-2974. IPC unit tests used "0.0.0.0" to connect to server, which
is not always supported. (rangadi)

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/java/org/apache/hadoop/net/NetUtils.java
    hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java
    hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPCServerResponder.java
    hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=636621&r1=636620&r2=636621&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed Mar 12 20:31:14 2008
@@ -181,6 +181,9 @@
     HADOOP-2657. A flush call on the DFSOutputStream flushes the last
     partial CRC chunk too.  (dhruba)
 
+    HADOOP-2974. IPC unit tests used "0.0.0.0" to connect to server, which
+    is not always supported. (rangadi)
+
 Release 0.16.1 - 2008-03-13
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/net/NetUtils.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/net/NetUtils.java?rev=636621&r1=636620&r2=636621&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/net/NetUtils.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/net/NetUtils.java Wed Mar 12 20:31:14 2008
@@ -32,6 +32,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.ipc.VersionedProtocol;
 import org.apache.hadoop.util.ReflectionUtils;
 
@@ -227,6 +228,23 @@
       }
     return l;
     }
+  }
+  
+  /**
+   * Returns InetSocketAddress that a client can use to 
+   * connect to the server. Server.getListenerAddress() is not correct when
+   * the server binds to "0.0.0.0". This returns "127.0.0.1:port" when
+   * the getListenerAddress() returns "0.0.0.0:port".
+   * 
+   * @param server
+   * @return socket address that a client can use to connect to the server.
+   */
+  public static InetSocketAddress getConnectAddress(Server server) {
+    InetSocketAddress addr = server.getListenerAddress();
+    if (addr.getAddress().getHostAddress().equals("0.0.0.0")) {
+      addr = new InetSocketAddress("127.0.0.1", addr.getPort());
+    }
+    return addr;
   }
   
   /**

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java?rev=636621&r1=636620&r2=636621&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java Wed Mar 12 20:31:14 2008
@@ -22,6 +22,7 @@
 
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.net.NetUtils;
 
 import java.util.Random;
 import java.io.IOException;
@@ -140,7 +141,7 @@
                          int clientCount, int callerCount, int callCount)
     throws Exception {
     Server server = new TestServer(handlerCount, handlerSleep);
-    InetSocketAddress addr = server.getListenerAddress();
+    InetSocketAddress addr = NetUtils.getConnectAddress(server);
     server.start();
 
     Client[] clients = new Client[clientCount];
@@ -179,7 +180,7 @@
 
     InetSocketAddress[] addresses = new InetSocketAddress[addressCount];
     for (int i = 0; i < addressCount; i++) {
-      addresses[i] = servers[i%serverCount].getListenerAddress();
+      addresses[i] = NetUtils.getConnectAddress(servers[i%serverCount]);
     }
 
     Client[] clients = new Client[clientCount];

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPCServerResponder.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPCServerResponder.java?rev=636621&r1=636620&r2=636621&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPCServerResponder.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestIPCServerResponder.java Wed Mar 12
20:31:14 2008
@@ -29,6 +29,7 @@
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.BytesWritable;
 import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.net.NetUtils;
 
 /**
  * This test provokes partial writes in the server, which is 
@@ -127,7 +128,7 @@
     Server server = new TestServer(handlerCount, handlerSleep);
     server.start();
 
-    InetSocketAddress address = server.getListenerAddress();
+    InetSocketAddress address = NetUtils.getConnectAddress(server);
     Client[] clients = new Client[clientCount];
     for (int i = 0; i < clientCount; i++) {
       clients[i] = new Client(BytesWritable.class, conf);

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java?rev=636621&r1=636620&r2=636621&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java Wed Mar 12 20:31:14 2008
@@ -33,6 +33,7 @@
 import org.apache.hadoop.io.Writable;
 
 import org.apache.hadoop.ipc.VersionedProtocol;
+import org.apache.hadoop.net.NetUtils;
 
 /** Unit tests for RPC. */
 public class TestRPC extends TestCase {
@@ -190,7 +191,7 @@
     try {
     server.start();
 
-    InetSocketAddress addr = server.getListenerAddress();
+    InetSocketAddress addr = NetUtils.getConnectAddress(server);
 
     // create a client
     proxy = (TestProtocol)RPC.getProxy(
@@ -231,7 +232,7 @@
     try {
     server.start();
 
-    InetSocketAddress addr = server.getListenerAddress();
+    InetSocketAddress addr = NetUtils.getConnectAddress(server);
     proxy = (TestProtocol)RPC.getProxy(
         TestProtocol.class, TestProtocol.versionID, addr, conf);
       



Mime
View raw message