Example usage for org.apache.hadoop.ipc RPC getServerAddress

List of usage examples for org.apache.hadoop.ipc RPC getServerAddress

Introduction

In this page you can find the example usage for org.apache.hadoop.ipc RPC getServerAddress.

Prototype

public static InetSocketAddress getServerAddress(Object proxy) 

Source Link

Document

Returns the server address for a given proxy.

Usage

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);
        }
    }
}