Search in sources :

Example 1 with SlowLogPayload

use of org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload in project hbase by apache.

the class HBaseRpcServicesBase method getLogEntries.

@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public HBaseProtos.LogEntry getLogEntries(RpcController controller, HBaseProtos.LogRequest request) throws ServiceException {
    try {
        final String logClassName = request.getLogClassName();
        Class<?> logClass = Class.forName(logClassName).asSubclass(Message.class);
        Method method = logClass.getMethod("parseFrom", ByteString.class);
        if (logClassName.contains("SlowLogResponseRequest")) {
            SlowLogResponseRequest slowLogResponseRequest = (SlowLogResponseRequest) method.invoke(null, request.getLogMessage());
            final NamedQueueRecorder namedQueueRecorder = this.server.getNamedQueueRecorder();
            final List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(slowLogResponseRequest, namedQueueRecorder);
            SlowLogResponses slowLogResponses = SlowLogResponses.newBuilder().addAllSlowLogPayloads(slowLogPayloads).build();
            return HBaseProtos.LogEntry.newBuilder().setLogClassName(slowLogResponses.getClass().getName()).setLogMessage(slowLogResponses.toByteString()).build();
        }
    } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        LOG.error("Error while retrieving log entries.", e);
        throw new ServiceException(e);
    }
    throw new ServiceException("Invalid request params");
}
Also used : SlowLogPayload(org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) NamedQueueRecorder(org.apache.hadoop.hbase.namequeues.NamedQueueRecorder) SlowLogResponseRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponseRequest) ClearSlowLogResponseRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponseRequest) ClearSlowLogResponses(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponses) SlowLogResponses(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponses) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority)

Example 2 with SlowLogPayload

use of org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload in project hbase by apache.

the class TestNamedQueueRecorder method testOnlineSlowLogWithHighRecords.

@Test
public void testOnlineSlowLogWithHighRecords() throws Exception {
    Configuration conf = applySlowLogRecorderConf(14);
    Constructor<NamedQueueRecorder> constructor = NamedQueueRecorder.class.getDeclaredConstructor(Configuration.class);
    constructor.setAccessible(true);
    namedQueueRecorder = constructor.newInstance(conf);
    AdminProtos.SlowLogResponseRequest request = AdminProtos.SlowLogResponseRequest.newBuilder().setLimit(14 * 11).build();
    Assert.assertEquals(getSlowLogPayloads(request).size(), 0);
    LOG.debug("Initially ringbuffer of Slow Log records is empty");
    for (int i = 0; i < 14 * 11; i++) {
        RpcLogDetails rpcLogDetails = getRpcLogDetails("userName_" + (i + 1), "client_" + (i + 1), "class_" + (i + 1));
        namedQueueRecorder.addRecord(rpcLogDetails);
    }
    LOG.debug("Added 14 * 11 records, ringbuffer should only provide latest 14 records");
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> getSlowLogPayloads(request).size() == 14));
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> {
        List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(request);
        // confirm strict order of slow log payloads
        return slowLogPayloads.size() == 14 && confirmPayloadParams(0, 154, slowLogPayloads) && confirmPayloadParams(1, 153, slowLogPayloads) && confirmPayloadParams(2, 152, slowLogPayloads) && confirmPayloadParams(3, 151, slowLogPayloads) && confirmPayloadParams(4, 150, slowLogPayloads) && confirmPayloadParams(5, 149, slowLogPayloads) && confirmPayloadParams(6, 148, slowLogPayloads) && confirmPayloadParams(7, 147, slowLogPayloads) && confirmPayloadParams(8, 146, slowLogPayloads) && confirmPayloadParams(9, 145, slowLogPayloads) && confirmPayloadParams(10, 144, slowLogPayloads) && confirmPayloadParams(11, 143, slowLogPayloads) && confirmPayloadParams(12, 142, slowLogPayloads) && confirmPayloadParams(13, 141, slowLogPayloads);
    }));
    boolean isRingBufferCleaned = namedQueueRecorder.clearNamedQueue(NamedQueuePayload.NamedQueueEvent.SLOW_LOG);
    Assert.assertTrue(isRingBufferCleaned);
    LOG.debug("cleared the ringbuffer of Online Slow Log records");
    List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(request);
    // confirm ringbuffer is empty
    Assert.assertEquals(slowLogPayloads.size(), 0);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) AdminProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos) SlowLogPayload(org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload) List(java.util.List) Test(org.junit.Test)

Example 3 with SlowLogPayload

use of org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload in project hbase by apache.

the class HBaseRpcServicesBase method getSlowLogPayloads.

private List<SlowLogPayload> getSlowLogPayloads(SlowLogResponseRequest request, NamedQueueRecorder namedQueueRecorder) {
    if (namedQueueRecorder == null) {
        return Collections.emptyList();
    }
    List<SlowLogPayload> slowLogPayloads;
    NamedQueueGetRequest namedQueueGetRequest = new NamedQueueGetRequest();
    namedQueueGetRequest.setNamedQueueEvent(RpcLogDetails.SLOW_LOG_EVENT);
    namedQueueGetRequest.setSlowLogResponseRequest(request);
    NamedQueueGetResponse namedQueueGetResponse = namedQueueRecorder.getNamedQueueRecords(namedQueueGetRequest);
    slowLogPayloads = namedQueueGetResponse != null ? namedQueueGetResponse.getSlowLogPayloads() : Collections.emptyList();
    return slowLogPayloads;
}
Also used : SlowLogPayload(org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload) NamedQueueGetResponse(org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse) NamedQueueGetRequest(org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest)

Example 4 with SlowLogPayload

use of org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload in project hbase by apache.

the class TestNamedQueueRecorder method testOnlieSlowLogConsumption.

@Test
public void testOnlieSlowLogConsumption() throws Exception {
    Configuration conf = applySlowLogRecorderConf(8);
    Constructor<NamedQueueRecorder> constructor = NamedQueueRecorder.class.getDeclaredConstructor(Configuration.class);
    constructor.setAccessible(true);
    namedQueueRecorder = constructor.newInstance(conf);
    AdminProtos.SlowLogResponseRequest request = AdminProtos.SlowLogResponseRequest.newBuilder().setLimit(15).build();
    namedQueueRecorder.clearNamedQueue(NamedQueuePayload.NamedQueueEvent.SLOW_LOG);
    Assert.assertEquals(getSlowLogPayloads(request).size(), 0);
    LOG.debug("Initially ringbuffer of Slow Log records is empty");
    int i = 0;
    // add 5 records initially
    for (; i < 5; i++) {
        RpcLogDetails rpcLogDetails = getRpcLogDetails("userName_" + (i + 1), "client_" + (i + 1), "class_" + (i + 1));
        namedQueueRecorder.addRecord(rpcLogDetails);
    }
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> getSlowLogPayloads(request).size() == 5));
    List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(request);
    Assert.assertTrue(confirmPayloadParams(0, 5, slowLogPayloads));
    Assert.assertTrue(confirmPayloadParams(1, 4, slowLogPayloads));
    Assert.assertTrue(confirmPayloadParams(2, 3, slowLogPayloads));
    Assert.assertTrue(confirmPayloadParams(3, 2, slowLogPayloads));
    Assert.assertTrue(confirmPayloadParams(4, 1, slowLogPayloads));
    // add 2 more records
    for (; i < 7; i++) {
        RpcLogDetails rpcLogDetails = getRpcLogDetails("userName_" + (i + 1), "client_" + (i + 1), "class_" + (i + 1));
        namedQueueRecorder.addRecord(rpcLogDetails);
    }
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> getSlowLogPayloads(request).size() == 7));
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> {
        List<SlowLogPayload> slowLogPayloadsList = getSlowLogPayloads(request);
        return slowLogPayloadsList.size() == 7 && confirmPayloadParams(0, 7, slowLogPayloadsList) && confirmPayloadParams(5, 2, slowLogPayloadsList) && confirmPayloadParams(6, 1, slowLogPayloadsList);
    }));
    // add 3 more records
    for (; i < 10; i++) {
        RpcLogDetails rpcLogDetails = getRpcLogDetails("userName_" + (i + 1), "client_" + (i + 1), "class_" + (i + 1));
        namedQueueRecorder.addRecord(rpcLogDetails);
    }
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> getSlowLogPayloads(request).size() == 8));
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> {
        List<SlowLogPayload> slowLogPayloadsList = getSlowLogPayloads(request);
        // confirm ringbuffer is full
        return slowLogPayloadsList.size() == 8 && confirmPayloadParams(7, 3, slowLogPayloadsList) && confirmPayloadParams(0, 10, slowLogPayloadsList) && confirmPayloadParams(1, 9, slowLogPayloadsList);
    }));
    // add 4 more records
    for (; i < 14; i++) {
        RpcLogDetails rpcLogDetails = getRpcLogDetails("userName_" + (i + 1), "client_" + (i + 1), "class_" + (i + 1));
        namedQueueRecorder.addRecord(rpcLogDetails);
    }
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> getSlowLogPayloads(request).size() == 8));
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> {
        List<SlowLogPayload> slowLogPayloadsList = getSlowLogPayloads(request);
        // and ordered events
        return slowLogPayloadsList.size() == 8 && confirmPayloadParams(0, 14, slowLogPayloadsList) && confirmPayloadParams(1, 13, slowLogPayloadsList) && confirmPayloadParams(2, 12, slowLogPayloadsList) && confirmPayloadParams(3, 11, slowLogPayloadsList);
    }));
    AdminProtos.SlowLogResponseRequest largeLogRequest = AdminProtos.SlowLogResponseRequest.newBuilder().setLimit(15).setLogType(AdminProtos.SlowLogResponseRequest.LogType.LARGE_LOG).build();
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> {
        List<SlowLogPayload> slowLogPayloadsList = getSlowLogPayloads(largeLogRequest);
        // and ordered events
        return slowLogPayloadsList.size() == 8 && confirmPayloadParams(0, 14, slowLogPayloadsList) && confirmPayloadParams(1, 13, slowLogPayloadsList) && confirmPayloadParams(2, 12, slowLogPayloadsList) && confirmPayloadParams(3, 11, slowLogPayloadsList);
    }));
    Assert.assertNotEquals(-1, HBASE_TESTING_UTILITY.waitFor(3000, () -> {
        boolean isRingBufferCleaned = namedQueueRecorder.clearNamedQueue(NamedQueuePayload.NamedQueueEvent.SLOW_LOG);
        LOG.debug("cleared the ringbuffer of Online Slow Log records");
        List<SlowLogPayload> slowLogPayloadsList = getSlowLogPayloads(request);
        // confirm ringbuffer is empty
        return slowLogPayloadsList.size() == 0 && isRingBufferCleaned;
    }));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) AdminProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos) SlowLogPayload(org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload) List(java.util.List) Test(org.junit.Test)

Aggregations

SlowLogPayload (org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload)4 List (java.util.List)2 Configuration (org.apache.hadoop.conf.Configuration)2 AdminProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos)2 Test (org.junit.Test)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 QosPriority (org.apache.hadoop.hbase.ipc.QosPriority)1 NamedQueueRecorder (org.apache.hadoop.hbase.namequeues.NamedQueueRecorder)1 NamedQueueGetRequest (org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest)1 NamedQueueGetResponse (org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse)1 ClearSlowLogResponseRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponseRequest)1 ClearSlowLogResponses (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponses)1 SlowLogResponseRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponseRequest)1 SlowLogResponses (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponses)1 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1