From c853a425a04efb1f4c953c9ae123d9cf1e600e10 Mon Sep 17 00:00:00 2001 From: Robert Joseph Evans Date: Wed, 9 May 2012 17:06:27 +0000 Subject: [PATCH] HADOOP-8373. Port RPC.getServerAddress to 0.23 (Daryn Sharp via bobby) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1336299 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 2 ++ .../java/org/apache/hadoop/ipc/TestRPC.java | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 283158e850..c34deefafd 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -550,6 +550,8 @@ Release 0.23.3 - UNRELEASED HADOOP-8341. Fix or filter findbugs issues in hadoop-tools (bobby) + HADOOP-8373. Port RPC.getServerAddress to 0.23 (Daryn Sharp via bobby) + Release 0.23.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java index 56b2b2487b..cc0c5c9f54 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java @@ -322,6 +322,29 @@ public void testConfRpc() throws Exception { server.stop(); } + @Test + public void testProxyAddress() throws Exception { + Server server = RPC.getServer(TestProtocol.class, + new TestImpl(), ADDRESS, 0, conf); + TestProtocol proxy = null; + + try { + server.start(); + InetSocketAddress addr = NetUtils.getConnectAddress(server); + + // create a client + proxy = (TestProtocol)RPC.getProxy( + TestProtocol.class, TestProtocol.versionID, addr, conf); + + assertEquals(addr, RPC.getServerAddress(proxy)); + } finally { + server.stop(); + if (proxy != null) { + RPC.stopProxy(proxy); + } + } + } + @Test public void testSlowRpc() throws Exception { System.out.println("Testing Slow RPC");