@Test public void testRpcWithWriteThread() throws IOException, InterruptedException { LOG.info("Starting test"); Cluster cluster = new Cluster(1, 1); cluster.startServer(); conf.setBoolean(SPECIFIC_WRITE_THREAD, true); for(int i = 0; i <1000; i++) { AbstractRpcClient<?> rpcClient = createRpcClient(conf, true); SimpleClient client = new SimpleClient(cluster, rpcClient, "Client1"); client.start(); while(!client.isSending()) { Thread.sleep(1); } client.stopRunning(); rpcClient.close(); } }
rpcClient.close();
@Test public void testAsyncRemoteError() throws IOException { AbstractRpcClient<?> client = createRpcClient(CONF); RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface( SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1)); try { rpcServer.start(); Interface stub = newStub(client, rpcServer.getListenerAddress()); BlockingRpcCallback<EmptyResponseProto> callback = new BlockingRpcCallback<>(); HBaseRpcController pcrc = new HBaseRpcControllerImpl(); stub.error(pcrc, EmptyRequestProto.getDefaultInstance(), callback); assertNull(callback.get()); assertTrue(pcrc.failed()); LOG.info("Caught expected exception: " + pcrc.getFailed()); IOException ioe = ProtobufUtil.handleRemoteException(pcrc.getFailed()); assertTrue(ioe instanceof DoNotRetryIOException); assertTrue(ioe.getMessage().contains("server error!")); } finally { client.close(); rpcServer.stop(); } }
@Test public void testRpcWithWriteThread() throws IOException, InterruptedException { LOG.info("Starting test"); Cluster cluster = new Cluster(1, 1); cluster.startServer(); conf.setBoolean(SPECIFIC_WRITE_THREAD, true); for(int i = 0; i <1000; i++) { AbstractRpcClient<?> rpcClient = createRpcClient(conf, true); SimpleClient client = new SimpleClient(cluster, rpcClient, "Client1"); client.start(); while(!client.isSending()) { Thread.sleep(1); } client.stopRunning(); rpcClient.close(); } }
rpcClient.close();
@Test public void testAsyncRemoteError() throws IOException { AbstractRpcClient<?> client = createRpcClient(CONF); RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface( SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1)); try { rpcServer.start(); Interface stub = newStub(client, rpcServer.getListenerAddress()); BlockingRpcCallback<EmptyResponseProto> callback = new BlockingRpcCallback<>(); HBaseRpcController pcrc = new HBaseRpcControllerImpl(); stub.error(pcrc, EmptyRequestProto.getDefaultInstance(), callback); assertNull(callback.get()); assertTrue(pcrc.failed()); LOG.info("Caught expected exception: " + pcrc.getFailed()); IOException ioe = ProtobufUtil.handleRemoteException(pcrc.getFailed()); assertTrue(ioe instanceof DoNotRetryIOException); assertTrue(ioe.getMessage().contains("server error!")); } finally { client.close(); rpcServer.stop(); } }