Search in sources :

Example 11 with BlockingInterface

use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface in project hbase by apache.

the class AbstractTestIPC method testRpcScheduler.

/**
   * Tests that the rpc scheduler is called when requests arrive.
   */
@Test
public void testRpcScheduler() throws IOException, ServiceException, InterruptedException {
    RpcScheduler scheduler = spy(new FifoRpcScheduler(CONF, 1));
    RpcServer rpcServer = RpcServerFactory.createRpcServer(null, "testRpcServer", Lists.newArrayList(new BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, scheduler);
    verify(scheduler).init((RpcScheduler.Context) anyObject());
    try (AbstractRpcClient<?> client = createRpcClient(CONF)) {
        rpcServer.start();
        verify(scheduler).start();
        BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
        EchoRequestProto param = EchoRequestProto.newBuilder().setMessage("hello").build();
        for (int i = 0; i < 10; i++) {
            stub.echo(null, param);
        }
        verify(scheduler, times(10)).dispatch((CallRunner) anyObject());
    } finally {
        rpcServer.stop();
        verify(scheduler).stop();
    }
}
Also used : BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) EchoRequestProto(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoRequestProto) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 12 with BlockingInterface

use of org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface in project hbase by apache.

the class AbstractTestIPC method testCompressCellBlock.

/**
   * It is hard to verify the compression is actually happening under the wraps. Hope that if
   * unsupported, we'll get an exception out of some time (meantime, have to trace it manually to
   * confirm that compression is happening down in the client and server).
   */
@Test
public void testCompressCellBlock() throws IOException, ServiceException {
    Configuration conf = new Configuration(HBaseConfiguration.create());
    conf.set("hbase.client.rpc.compressor", GzipCodec.class.getCanonicalName());
    List<Cell> cells = new ArrayList<>();
    int count = 3;
    for (int i = 0; i < count; i++) {
        cells.add(CELL);
    }
    RpcServer rpcServer = RpcServerFactory.createRpcServer(null, "testRpcServer", Lists.newArrayList(new BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1));
    try (AbstractRpcClient<?> client = createRpcClient(conf)) {
        rpcServer.start();
        BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
        HBaseRpcController pcrc = new HBaseRpcControllerImpl(CellUtil.createCellScanner(cells));
        String message = "hello";
        assertEquals(message, stub.echo(pcrc, EchoRequestProto.newBuilder().setMessage(message).build()).getMessage());
        int index = 0;
        CellScanner cellScanner = pcrc.cellScanner();
        assertNotNull(cellScanner);
        while (cellScanner.advance()) {
            assertEquals(CELL, cellScanner.current());
            index++;
        }
        assertEquals(count, index);
    } finally {
        rpcServer.stop();
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) InetSocketAddress(java.net.InetSocketAddress) GzipCodec(org.apache.hadoop.io.compress.GzipCodec) ArrayList(java.util.ArrayList) CellScanner(org.apache.hadoop.hbase.CellScanner) BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Aggregations

BlockingInterface (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface)12 Test (org.junit.Test)11 InetSocketAddress (java.net.InetSocketAddress)10 BlockingServiceAndInterface (org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface)9 Configuration (org.apache.hadoop.conf.Configuration)5 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)5 IOException (java.io.IOException)4 EchoRequestProto (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoRequestProto)4 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 ArrayList (java.util.ArrayList)1 SaslException (javax.security.sasl.SaslException)1 Abortable (org.apache.hadoop.hbase.Abortable)1 Cell (org.apache.hadoop.hbase.Cell)1 CellScanner (org.apache.hadoop.hbase.CellScanner)1 BlockingRpcClient (org.apache.hadoop.hbase.ipc.BlockingRpcClient)1 FifoRpcScheduler (org.apache.hadoop.hbase.ipc.FifoRpcScheduler)1 NettyRpcClient (org.apache.hadoop.hbase.ipc.NettyRpcClient)1 RpcClient (org.apache.hadoop.hbase.ipc.RpcClient)1 RpcServerInterface (org.apache.hadoop.hbase.ipc.RpcServerInterface)1