proxy.sleep(100); } catch (RemoteException e) { IOException unwrapExeption = e.unwrapRemoteException();
@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(); 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(); } }
@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(); 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(); } }
/** * Test RPC timeout. */ @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); } }
/** * Test RPC timeout. */ @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); } }
@Override public Void call() throws IOException, InterruptedException { proxy.sleep(100000); return null; } }));
@Override public Void call() throws IOException, InterruptedException { proxy.sleep(100000); return null; } }));
@Override public Void call() throws IOException, InterruptedException { proxy.sleep(100000); return null; } }));