use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoResponseProto in project hbase by apache.
the class TestProtoBufRpc method testProtoBufRpc.
@Test(expected = org.apache.hbase.thirdparty.com.google.protobuf.ServiceException.class)
public void testProtoBufRpc() throws Exception {
RpcClient rpcClient = RpcClientFactory.createClient(conf, HConstants.CLUSTER_ID_DEFAULT);
try {
BlockingInterface stub = newBlockingStub(rpcClient, this.isa);
// Test ping method
TestProtos.EmptyRequestProto emptyRequest = TestProtos.EmptyRequestProto.newBuilder().build();
stub.ping(null, emptyRequest);
// Test echo method
EchoRequestProto echoRequest = EchoRequestProto.newBuilder().setMessage("hello").build();
EchoResponseProto echoResponse = stub.echo(null, echoRequest);
assertEquals("hello", echoResponse.getMessage());
stub.error(null, emptyRequest);
fail("Expected exception is not thrown");
} finally {
rpcClient.close();
}
}
use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoResponseProto 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();
}
}
Aggregations