Search in sources :

Example 1 with BlockingServiceAndInterface

use of org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface in project hbase by apache.

the class MasterRpcServices method getServices.

/**
   * @return list of blocking services and their security info classes that this server supports
   */
@Override
protected List<BlockingServiceAndInterface> getServices() {
    List<BlockingServiceAndInterface> bssi = new ArrayList<>(5);
    bssi.add(new BlockingServiceAndInterface(MasterService.newReflectiveBlockingService(this), MasterService.BlockingInterface.class));
    bssi.add(new BlockingServiceAndInterface(RegionServerStatusService.newReflectiveBlockingService(this), RegionServerStatusService.BlockingInterface.class));
    bssi.add(new BlockingServiceAndInterface(LockService.newReflectiveBlockingService(this), LockService.BlockingInterface.class));
    bssi.addAll(super.getServices());
    return bssi;
}
Also used : BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) ArrayList(java.util.ArrayList)

Example 2 with BlockingServiceAndInterface

use of org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface in project hbase by apache.

the class AbstractTestIPC method testRTEDuringConnectionSetup.

@Test
public void testRTEDuringConnectionSetup() throws Exception {
    Configuration conf = HBaseConfiguration.create();
    RpcServer rpcServer = RpcServerFactory.createRpcServer(null, "testRpcServer", Lists.newArrayList(new BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, new FifoRpcScheduler(CONF, 1));
    try (AbstractRpcClient<?> client = createRpcClientRTEDuringConnectionSetup(conf)) {
        rpcServer.start();
        BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
        stub.ping(null, EmptyRequestProto.getDefaultInstance());
        fail("Expected an exception to have been thrown!");
    } catch (Exception e) {
        LOG.info("Caught expected exception: " + e.toString());
        assertTrue(e.toString(), StringUtils.stringifyException(e).contains("Injected fault"));
    } finally {
        rpcServer.stop();
    }
}
Also used : BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) InetSocketAddress(java.net.InetSocketAddress) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) Test(org.junit.Test)

Example 3 with BlockingServiceAndInterface

use of org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface in project hbase by apache.

the class AbstractTestIPC method testRpcMaxRequestSize.

/** Tests that the rpc scheduler is called when requests arrive. */
@Test
public void testRpcMaxRequestSize() throws IOException, ServiceException {
    Configuration conf = new Configuration(CONF);
    conf.setInt(RpcServer.MAX_REQUEST_SIZE, 1000);
    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());
        StringBuilder message = new StringBuilder(1200);
        for (int i = 0; i < 200; i++) {
            message.append("hello.");
        }
        // set total RPC size bigger than 100 bytes
        EchoRequestProto param = EchoRequestProto.newBuilder().setMessage(message.toString()).build();
        stub.echo(new HBaseRpcControllerImpl(CellUtil.createCellScanner(ImmutableList.<Cell>of(CELL))), param);
        fail("RPC should have failed because it exceeds max request size");
    } catch (ServiceException e) {
        LOG.info("Caught expected exception: " + e);
        assertTrue(e.toString(), StringUtils.stringifyException(e).contains("RequestTooBigException"));
    } finally {
        rpcServer.stop();
    }
}
Also used : BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) EchoRequestProto(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoRequestProto) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 4 with BlockingServiceAndInterface

use of org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface in project hbase by apache.

the class TestRpcHandlerException method testRpcScheduler.

/*
   * This is a unit test to make sure to abort region server when the number of Rpc handler thread
   * caught errors exceeds the threshold. Client will hang when RS aborts.
   */
@Ignore
@Test
public void testRpcScheduler() throws IOException, InterruptedException {
    PriorityFunction qosFunction = mock(PriorityFunction.class);
    Abortable abortable = new AbortServer();
    RpcScheduler scheduler = new SimpleRpcScheduler(CONF, 2, 0, 0, qosFunction, abortable, 0);
    RpcServer rpcServer = RpcServerFactory.createRpcServer(null, "testRpcServer", Lists.newArrayList(new BlockingServiceAndInterface((BlockingService) SERVICE, null)), new InetSocketAddress("localhost", 0), CONF, scheduler);
    try (BlockingRpcClient client = new BlockingRpcClient(CONF)) {
        rpcServer.start();
        BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
        stub.echo(null, EchoRequestProto.newBuilder().setMessage("hello").build());
    } catch (Throwable e) {
        assert (abortable.isAborted() == true);
    } finally {
        rpcServer.stop();
    }
}
Also used : BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) Abortable(org.apache.hadoop.hbase.Abortable) InetSocketAddress(java.net.InetSocketAddress) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with BlockingServiceAndInterface

use of org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface in project hbase by apache.

the class AbstractTestIPC method testAsyncEcho.

@Test
public void testAsyncEcho() throws IOException {
    Configuration conf = HBaseConfiguration.create();
    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();
        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();
    }
}
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) ArrayList(java.util.ArrayList) EchoResponseProto(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoResponseProto) Interface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) BlockingInterface(org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface) Test(org.junit.Test)

Aggregations

BlockingServiceAndInterface (org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface)15 InetSocketAddress (java.net.InetSocketAddress)12 BlockingInterface (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface)12 Test (org.junit.Test)12 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Configuration (org.apache.hadoop.conf.Configuration)5 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)5 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)4 Interface (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProtos.TestProtobufRpcProto.Interface)3 EchoRequestProto (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoRequestProto)2 EmptyResponseProto (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EmptyResponseProto)2 Abortable (org.apache.hadoop.hbase.Abortable)1 Cell (org.apache.hadoop.hbase.Cell)1 CellScanner (org.apache.hadoop.hbase.CellScanner)1 ServiceDescriptor (org.apache.hadoop.hbase.shaded.com.google.protobuf.Descriptors.ServiceDescriptor)1 EchoResponseProto (org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestProtos.EchoResponseProto)1 GzipCodec (org.apache.hadoop.io.compress.GzipCodec)1 Ignore (org.junit.Ignore)1