You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2007/08/31 00:08:12 UTC
svn commit: r571331 - in /lucene/hadoop/trunk: CHANGES.txt
src/test/org/apache/hadoop/ipc/TestIPC.java
src/test/org/apache/hadoop/ipc/TestRPC.java
Author: cutting
Date: Thu Aug 30 15:08:11 2007
New Revision: 571331
URL: http://svn.apache.org/viewvc?rev=571331&view=rev
Log:
HADOOP-1812. Let OS choose ports for IPC and RPC unit tests.
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java
lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=571331&r1=571330&r2=571331&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Thu Aug 30 15:08:11 2007
@@ -142,6 +142,8 @@
port. Also switch default address for umbilical connections to
loopback. (cutting)
+ HADOOP-1812. Let OS choose ports for IPC and RPC unit tests. (cutting)
+
Release 0.14.1 - 2007-09-04
Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java?rev=571331&r1=571330&r2=571331&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java (original)
+++ lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestIPC.java Thu Aug 30 15:08:11 2007
@@ -42,15 +42,14 @@
private static final Random RANDOM = new Random();
- private static final int PORT = 1234;
private static final String ADDRESS = "0.0.0.0";
private static class TestServer extends Server {
private boolean sleep;
- public TestServer(String bindAddress, int port, int handlerCount, boolean sleep)
+ public TestServer(int handlerCount, boolean sleep)
throws IOException {
- super(bindAddress, port, LongWritable.class, handlerCount, conf);
+ super(ADDRESS, 0, LongWritable.class, handlerCount, conf);
this.setTimeout(1000);
this.sleep = sleep;
}
@@ -67,11 +66,13 @@
private static class SerialCaller extends Thread {
private Client client;
+ private InetSocketAddress server;
private int count;
private boolean failed;
- public SerialCaller(Client client, int count) {
+ public SerialCaller(Client client, InetSocketAddress server, int count) {
this.client = client;
+ this.server = server;
this.count = count;
client.setTimeout(1000);
}
@@ -81,7 +82,7 @@
try {
LongWritable param = new LongWritable(RANDOM.nextLong());
LongWritable value =
- (LongWritable)client.call(param, new InetSocketAddress(PORT));
+ (LongWritable)client.call(param, server);
if (!param.equals(value)) {
LOG.fatal("Call failed!");
failed = true;
@@ -138,7 +139,8 @@
public void testSerial(int handlerCount, boolean handlerSleep,
int clientCount, int callerCount, int callCount)
throws Exception {
- Server server = new TestServer(ADDRESS, PORT, handlerCount, handlerSleep);
+ Server server = new TestServer(handlerCount, handlerSleep);
+ InetSocketAddress addr = server.getListenerAddress();
server.start();
Client[] clients = new Client[clientCount];
@@ -148,7 +150,7 @@
SerialCaller[] callers = new SerialCaller[callerCount];
for (int i = 0; i < callerCount; i++) {
- callers[i] = new SerialCaller(clients[i%clientCount], callCount);
+ callers[i] = new SerialCaller(clients[i%clientCount], addr, callCount);
callers[i].start();
}
for (int i = 0; i < callerCount; i++) {
@@ -171,13 +173,13 @@
throws Exception {
Server[] servers = new Server[serverCount];
for (int i = 0; i < serverCount; i++) {
- servers[i] = new TestServer(ADDRESS, PORT+i+1, handlerCount, handlerSleep);
+ servers[i] = new TestServer(handlerCount, handlerSleep);
servers[i].start();
}
InetSocketAddress[] addresses = new InetSocketAddress[addressCount];
for (int i = 0; i < addressCount; i++) {
- addresses[i] = new InetSocketAddress(PORT+1+(i%serverCount));
+ addresses[i] = servers[i%serverCount].getListenerAddress();
}
Client[] clients = new Client[clientCount];
Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java?rev=571331&r1=571330&r2=571331&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java (original)
+++ lucene/hadoop/trunk/src/test/org/apache/hadoop/ipc/TestRPC.java Thu Aug 30 15:08:11 2007
@@ -36,7 +36,6 @@
/** Unit tests for RPC. */
public class TestRPC extends TestCase {
- private static final int PORT = 1234;
private static final String ADDRESS = "0.0.0.0";
public static final Log LOG =
@@ -99,10 +98,10 @@
}
public void testCalls() throws Exception {
- Server server = RPC.getServer(new TestImpl(), ADDRESS, PORT, conf);
+ Server server = RPC.getServer(new TestImpl(), ADDRESS, 0, conf);
server.start();
- InetSocketAddress addr = new InetSocketAddress(PORT);
+ InetSocketAddress addr = server.getListenerAddress();
TestProtocol proxy =
(TestProtocol)RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf);