use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface in project hbase by apache.
the class AbstractTestIPC method testAsyncEcho.
@Test
public void testAsyncEcho() throws IOException {
Configuration conf = HBaseConfiguration.create();
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());
int num = 10;
List<HBaseRpcController> pcrcList = new ArrayList<>();
List<BlockingRpcCallback<EchoResponseProto>> callbackList = new ArrayList<>();
for (int i = 0; i < num; i++) {
HBaseRpcController pcrc = new HBaseRpcControllerImpl();
BlockingRpcCallback<EchoResponseProto> done = new BlockingRpcCallback<>();
stub.echo(pcrc, EchoRequestProto.newBuilder().setMessage("hello-" + i).build(), done);
pcrcList.add(pcrc);
callbackList.add(done);
}
for (int i = 0; i < num; i++) {
HBaseRpcController pcrc = pcrcList.get(i);
assertFalse(pcrc.failed());
assertNull(pcrc.cellScanner());
assertEquals("hello-" + i, callbackList.get(i).get().getMessage());
}
} finally {
rpcServer.stop();
}
}
use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface 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();
}
}
use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface 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();
}
}
Aggregations