Search in sources :

Example 11 with RequestHeader

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader in project hbase by apache.

the class TestSimpleRpcScheduler method testSoftAndHardQueueLimits.

@Test
public void testSoftAndHardQueueLimits() throws Exception {
    Configuration schedConf = HBaseConfiguration.create();
    schedConf.setInt(HConstants.REGION_SERVER_HANDLER_COUNT, 0);
    schedConf.setInt("hbase.ipc.server.max.callqueue.length", 5);
    schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, RpcExecutor.CALL_QUEUE_TYPE_DEADLINE_CONF_VALUE);
    PriorityFunction priority = mock(PriorityFunction.class);
    when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS);
    SimpleRpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 0, 0, 0, priority, HConstants.QOS_THRESHOLD);
    try {
        scheduler.start();
        CallRunner putCallTask = mock(CallRunner.class);
        ServerCall putCall = mock(ServerCall.class);
        putCall.param = RequestConverter.buildMutateRequest(Bytes.toBytes("abc"), new Put(Bytes.toBytes("row")));
        RequestHeader putHead = RequestHeader.newBuilder().setMethodName("mutate").build();
        when(putCallTask.getRpcCall()).thenReturn(putCall);
        when(putCall.getHeader()).thenReturn(putHead);
        assertTrue(scheduler.dispatch(putCallTask));
        schedConf.setInt("hbase.ipc.server.max.callqueue.length", 0);
        scheduler.onConfigurationChange(schedConf);
        assertFalse(scheduler.dispatch(putCallTask));
        waitUntilQueueEmpty(scheduler);
        schedConf.setInt("hbase.ipc.server.max.callqueue.length", 1);
        scheduler.onConfigurationChange(schedConf);
        assertTrue(scheduler.dispatch(putCallTask));
    } finally {
        scheduler.stop();
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) RequestHeader(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Example 12 with RequestHeader

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader in project hbase by apache.

the class TestPriorityRpc method testQosFunctionForMeta.

@Test
public void testQosFunctionForMeta() throws IOException {
    RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
    // create a rpc request that has references to hbase:meta region and also
    // uses one of the known argument classes (known argument classes are
    // listed in HRegionServer.QosFunctionImpl.knownArgumentClasses)
    headerBuilder.setMethodName("foo");
    GetRequest.Builder getRequestBuilder = GetRequest.newBuilder();
    RegionSpecifier.Builder regionSpecifierBuilder = RegionSpecifier.newBuilder();
    regionSpecifierBuilder.setType(RegionSpecifierType.REGION_NAME);
    ByteString name = UnsafeByteOperations.unsafeWrap(RegionInfoBuilder.FIRST_META_REGIONINFO.getRegionName());
    regionSpecifierBuilder.setValue(name);
    RegionSpecifier regionSpecifier = regionSpecifierBuilder.build();
    getRequestBuilder.setRegion(regionSpecifier);
    Get.Builder getBuilder = Get.newBuilder();
    getBuilder.setRow(UnsafeByteOperations.unsafeWrap(Bytes.toBytes("somerow")));
    getRequestBuilder.setGet(getBuilder.build());
    GetRequest getRequest = getRequestBuilder.build();
    RequestHeader header = headerBuilder.build();
    HRegion mockRegion = mock(HRegion.class);
    RSRpcServices mockRpc = mock(RSRpcServices.class);
    when(mockRpc.getConfiguration()).thenReturn(CONF);
    RegionInfo mockRegionInfo = mock(RegionInfo.class);
    when(mockRpc.getRegion(any())).thenReturn(mockRegion);
    when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
    when(mockRegionInfo.getTable()).thenReturn(RegionInfoBuilder.FIRST_META_REGIONINFO.getTable());
    RSAnnotationReadingPriorityFunction qosFunc = new RSAnnotationReadingPriorityFunction(mockRpc);
    assertEquals(HConstants.SYSTEMTABLE_QOS, qosFunc.getPriority(header, getRequest, createSomeUser()));
}
Also used : ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier) GetRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest) Get(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Get) RequestHeader(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader) Test(org.junit.Test)

Example 13 with RequestHeader

use of org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader in project hbase by apache.

the class TestPriorityRpc method testQosFunctionForScanMethod.

@Test
public void testQosFunctionForScanMethod() throws IOException {
    RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
    headerBuilder.setMethodName("Scan");
    RequestHeader header = headerBuilder.build();
    // build an empty scan request
    ScanRequest.Builder scanBuilder = ScanRequest.newBuilder();
    ScanRequest scanRequest = scanBuilder.build();
    HRegion mockRegion = mock(HRegion.class);
    RSRpcServices mockRpc = mock(RSRpcServices.class);
    when(mockRpc.getConfiguration()).thenReturn(CONF);
    RegionInfo mockRegionInfo = mock(RegionInfo.class);
    when(mockRpc.getRegion(any())).thenReturn(mockRegion);
    when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
    // make isSystemTable return false
    when(mockRegionInfo.getTable()).thenReturn(TableName.valueOf("testQosFunctionForScanMethod"));
    RSAnnotationReadingPriorityFunction qosFunc = new RSAnnotationReadingPriorityFunction(mockRpc);
    final int qos = qosFunc.getPriority(header, scanRequest, createSomeUser());
    assertEquals(Integer.toString(qos), qos, HConstants.NORMAL_QOS);
    // build a scan request with scannerID
    scanBuilder = ScanRequest.newBuilder();
    scanBuilder.setScannerId(12345);
    scanRequest = scanBuilder.build();
    // mock out a high priority type handling and see the QoS returned
    RegionScanner mockRegionScanner = mock(RegionScanner.class);
    when(mockRpc.getScanner(12345)).thenReturn(mockRegionScanner);
    when(mockRegionScanner.getRegionInfo()).thenReturn(mockRegionInfo);
    when(mockRpc.getRegion((RegionSpecifier) any())).thenReturn(mockRegion);
    when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
    when(mockRegionInfo.getTable()).thenReturn(RegionInfoBuilder.FIRST_META_REGIONINFO.getTable());
    assertEquals(HConstants.SYSTEMTABLE_QOS, qosFunc.getPriority(header, scanRequest, createSomeUser()));
    // the same as above but with non-meta region
    // make isSystemTable return false
    when(mockRegionInfo.getTable()).thenReturn(TableName.valueOf("testQosFunctionForScanMethod"));
    assertEquals(HConstants.NORMAL_QOS, qosFunc.getPriority(header, scanRequest, createSomeUser()));
}
Also used : ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest) RequestHeader(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Test(org.junit.Test)

Aggregations

RequestHeader (org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader)13 Test (org.junit.Test)8 Configuration (org.apache.hadoop.conf.Configuration)5 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 Put (org.apache.hadoop.hbase.client.Put)4 ArrayList (java.util.ArrayList)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)2 CellBlockMeta (org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.CellBlockMeta)2 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)2 CodedInputStream (org.apache.hbase.thirdparty.com.google.protobuf.CodedInputStream)2 Message (org.apache.hbase.thirdparty.com.google.protobuf.Message)2 ByteBuf (org.apache.hbase.thirdparty.io.netty.buffer.ByteBuf)2 Span (io.opentelemetry.api.trace.Span)1 Context (io.opentelemetry.context.Context)1 Scope (io.opentelemetry.context.Scope)1 TextMapGetter (io.opentelemetry.context.propagation.TextMapGetter)1 BufferedInputStream (java.io.BufferedInputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1