Example usage for org.apache.hadoop.fs CommonConfigurationKeys IPC_CLIENT_PING_KEY

List of usage examples for org.apache.hadoop.fs CommonConfigurationKeys IPC_CLIENT_PING_KEY

Introduction

In this page you can find the example usage for org.apache.hadoop.fs CommonConfigurationKeys IPC_CLIENT_PING_KEY.

Prototype

String IPC_CLIENT_PING_KEY

To view the source code for org.apache.hadoop.fs CommonConfigurationKeys IPC_CLIENT_PING_KEY.

Click Source Link

Document

Enables pings from RPC client to the server

Usage

From source file:rpc.TestRPC.java

License:Apache License

@Test
public void testConnectionPing() throws Exception {
    Configuration conf = new Configuration();
    int pingInterval = 50;
    conf.setBoolean(CommonConfigurationKeys.IPC_CLIENT_PING_KEY, true);
    conf.setInt(CommonConfigurationKeys.IPC_PING_INTERVAL_KEY, pingInterval);
    final Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class).setInstance(new TestImpl())
            .setBindAddress(ADDRESS).setPort(0).setNumHandlers(5).setVerbose(true).build();
    server.start();/*  w  w w.j  a  v a  2s . com*/

    final TestProtocol proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID,
            server.getListenerAddress(), conf);
    try {
        // this call will throw exception if server couldn't decode the ping
        proxy.sleep(pingInterval * 4);
    } finally {
        if (proxy != null)
            RPC.stopProxy(proxy);
        server.stop();
    }
}