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

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

Introduction

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

Prototype

String IPC_CLIENT_RPC_TIMEOUT_KEY

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

Click Source Link

Document

Timeout value for RPC client on waiting for response.

Usage

From source file:rpc.TestRPC.java

License:Apache License

/**
 * Test RPC timeout.//from   ww  w. jav  a  2 s .  c om
 */
@Test(timeout = 30000)
public void testClientRpcTimeout() throws Exception {
    final Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class).setInstance(new TestImpl())
            .setBindAddress(ADDRESS).setPort(0).setQueueSizePerHandler(1).setNumHandlers(1).setVerbose(true)
            .build();
    server.start();

    final Configuration conf = new Configuration();
    conf.setInt(CommonConfigurationKeys.IPC_CLIENT_RPC_TIMEOUT_KEY, 1000);
    final TestProtocol proxy = RPC.getProxy(TestProtocol.class, TestProtocol.versionID,
            NetUtils.getConnectAddress(server), conf);

    try {
        proxy.sleep(3000);
        fail("RPC should time out.");
    } catch (SocketTimeoutException e) {
        LOG.info("got expected timeout.", e);
    } finally {
        server.stop();
        RPC.stopProxy(proxy);
    }
}