Search in sources :

Example 1 with SlowLogResponseRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponseRequest 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 SlowLogResponseRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponseRequest in project hbase by apache.

the class RequestConverter method buildSlowLogResponseRequest.

/**
 * Build RPC request payload for getLogEntries
 *
 * @param filterParams map of filter params
 * @param limit limit for no of records that server returns
 * @param logType type of the log records
 * @return request payload {@link HBaseProtos.LogRequest}
 */
public static HBaseProtos.LogRequest buildSlowLogResponseRequest(final Map<String, Object> filterParams, final int limit, final String logType) {
    SlowLogResponseRequest.Builder builder = SlowLogResponseRequest.newBuilder();
    builder.setLimit(limit);
    if (logType.equals("SLOW_LOG")) {
        builder.setLogType(SlowLogResponseRequest.LogType.SLOW_LOG);
    } else if (logType.equals("LARGE_LOG")) {
        builder.setLogType(SlowLogResponseRequest.LogType.LARGE_LOG);
    }
    boolean filterByAnd = false;
    if (MapUtils.isNotEmpty(filterParams)) {
        if (filterParams.containsKey("clientAddress")) {
            final String clientAddress = (String) filterParams.get("clientAddress");
            if (StringUtils.isNotEmpty(clientAddress)) {
                builder.setClientAddress(clientAddress);
            }
        }
        if (filterParams.containsKey("regionName")) {
            final String regionName = (String) filterParams.get("regionName");
            if (StringUtils.isNotEmpty(regionName)) {
                builder.setRegionName(regionName);
            }
        }
        if (filterParams.containsKey("tableName")) {
            final String tableName = (String) filterParams.get("tableName");
            if (StringUtils.isNotEmpty(tableName)) {
                builder.setTableName(tableName);
            }
        }
        if (filterParams.containsKey("userName")) {
            final String userName = (String) filterParams.get("userName");
            if (StringUtils.isNotEmpty(userName)) {
                builder.setUserName(userName);
            }
        }
        if (filterParams.containsKey("filterByOperator")) {
            final String filterByOperator = (String) filterParams.get("filterByOperator");
            if (StringUtils.isNotEmpty(filterByOperator)) {
                if (filterByOperator.toUpperCase().equals("AND")) {
                    filterByAnd = true;
                }
            }
        }
    }
    if (filterByAnd) {
        builder.setFilterByOperator(SlowLogResponseRequest.FilterByOperator.AND);
    } else {
        builder.setFilterByOperator(SlowLogResponseRequest.FilterByOperator.OR);
    }
    SlowLogResponseRequest slowLogResponseRequest = builder.build();
    return HBaseProtos.LogRequest.newBuilder().setLogClassName(slowLogResponseRequest.getClass().getName()).setLogMessage(slowLogResponseRequest.toByteString()).build();
}
Also used : SlowLogResponseRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponseRequest) ClearSlowLogResponseRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponseRequest) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString)

Aggregations

ClearSlowLogResponseRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponseRequest)2 SlowLogResponseRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponseRequest)2 ByteString (org.apache.hbase.thirdparty.com.google.protobuf.ByteString)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 ClearSlowLogResponses (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearSlowLogResponses)1 SlowLogResponses (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.SlowLogResponses)1 SlowLogPayload (org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1