List of usage examples for org.apache.hadoop.ipc RPC getServerAddress
public static InetSocketAddress getServerAddress(Object proxy)
From source file:rpc.TestRPC.java
License:Apache License
@Test public void testProxyAddress() throws IOException { Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class).setInstance(new TestImpl()) .setBindAddress(ADDRESS).setPort(0).build(); TestProtocol proxy = null;/*from w ww . j a v a2 s . c om*/ try { server.start(); InetSocketAddress addr = NetUtils.getConnectAddress(server); // create a client proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID, addr, conf); assertEquals(addr, RPC.getServerAddress(proxy)); } finally { server.stop(); if (proxy != null) { RPC.stopProxy(proxy); } } }