Return-Path: Delivered-To: apmail-lucene-hadoop-commits-archive@locus.apache.org Received: (qmail 4408 invoked from network); 30 Aug 2007 22:08:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Aug 2007 22:08:33 -0000 Received: (qmail 41980 invoked by uid 500); 30 Aug 2007 22:08:29 -0000 Delivered-To: apmail-lucene-hadoop-commits-archive@lucene.apache.org Received: (qmail 41955 invoked by uid 500); 30 Aug 2007 22:08:29 -0000 Mailing-List: contact hadoop-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hadoop-dev@lucene.apache.org Delivered-To: mailing list hadoop-commits@lucene.apache.org Received: (qmail 41946 invoked by uid 99); 30 Aug 2007 22:08:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Aug 2007 15:08:29 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Aug 2007 22:08:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DC2D91A9832; Thu, 30 Aug 2007 15:08:12 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Thu, 30 Aug 2007 22:08:12 -0000 To: hadoop-commits@lucene.apache.org From: cutting@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070830220812.DC2D91A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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);