Search in sources :

Example 1 with EmptyResponseProto

use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EmptyResponseProto in project hbase by apache.

the class AbstractTestIPC method testAsyncRemoteError.

@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();
    }
}
Also used : BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) InetSocketAddress(java.net.InetSocketAddress) EmptyResponseProto(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EmptyResponseProto) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Interface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) Test(org.junit.Test)

Example 2 with EmptyResponseProto

use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EmptyResponseProto in project hbase by apache.

the class AbstractTestIPC method testAsyncTimeout.

@Test
public void testAsyncTimeout() throws IOException {
    RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1));
    try (AbstractRpcClient<?> client = createRpcClient(CONF)) {
        rpcServer.start();
        Interface stub = newStub(client, rpcServer.getListenerAddress());
        List<HBaseRpcController> pcrcList = new ArrayList<>();
        List<BlockingRpcCallback<EmptyResponseProto>> callbackList = new ArrayList<>();
        int ms = 1000;
        int timeout = 100;
        long startTime = System.nanoTime();
        for (int i = 0; i < 10; i++) {
            HBaseRpcController pcrc = new HBaseRpcControllerImpl();
            pcrc.setCallTimeout(timeout);
            BlockingRpcCallback<EmptyResponseProto> callback = new BlockingRpcCallback<>();
            stub.pause(pcrc, PauseRequestProto.newBuilder().setMs(ms).build(), callback);
            pcrcList.add(pcrc);
            callbackList.add(callback);
        }
        for (BlockingRpcCallback<?> callback : callbackList) {
            assertNull(callback.get());
        }
        long waitTime = (System.nanoTime() - startTime) / 1000000;
        for (HBaseRpcController pcrc : pcrcList) {
            assertTrue(pcrc.failed());
            LOG.info("Caught expected exception: " + pcrc.getFailed());
            IOException ioe = ProtobufUtil.handleRemoteException(pcrc.getFailed());
            assertTrue(ioe.getCause() instanceof CallTimeoutException);
        }
        // confirm that we got exception before the actual pause.
        assertTrue(waitTime < ms);
    } finally {
        rpcServer.stop();
    }
}
Also used : BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) EmptyResponseProto(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EmptyResponseProto) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Interface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 BlockingServiceAndInterface (org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface)2 EmptyResponseProto (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EmptyResponseProto)2 BlockingInterface (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface)2 Interface (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1