virajjasani commented on a change in pull request #754: HBASE-22978 : Online slow response log URL: https://github.com/apache/hbase/pull/754#discussion_r371618142
########## File path: hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java ########## @@ -2205,6 +2216,57 @@ private static String getStringForByteString(ByteString bs) { return Bytes.toStringBinary(bs.toByteArray()); } + /** + * Return SlowLogParams to maintain recent online slowlog responses + * + * @param message Message object {@link Message} + * @return SlowLogParams with regionName(for filter queries) and params + */ + public static SlowLogParams getSlowLogParams(Message message) { + if (message == null) { + return null; + } + if (message instanceof ScanRequest) { + ScanRequest scanRequest = (ScanRequest) message; + String regionName = getStringForByteString(scanRequest.getRegion().getValue()); + String params = TextFormat.shortDebugString(message); + return new SlowLogParams(regionName, params); + } else if (message instanceof MutationProto) { + MutationProto mutationProto = (MutationProto) message; + String params = "type= " + mutationProto.getMutateType().toString(); + return new SlowLogParams(StringUtils.EMPTY, params); + } else if (message instanceof GetRequest) { + GetRequest getRequest = (GetRequest) message; + String regionName = getStringForByteString(getRequest.getRegion().getValue()); + String params = "region= " + regionName + ", row= " + + getStringForByteString(getRequest.getGet().getRow()); + return new SlowLogParams(regionName, params); + } else if (message instanceof MultiRequest) { + MultiRequest multiRequest = (MultiRequest) message; + int actionsCount = multiRequest.getRegionActionList() + .stream() + .mapToInt(ClientProtos.RegionAction::getActionCount) + .sum(); + RegionAction actions = multiRequest.getRegionActionList().get(0); + String regionName = getStringForByteString(actions.getRegion().getValue()); + String params = "region= " + regionName + ", for " + actionsCount + " action(s)"; + return new SlowLogParams(regionName, params); + } else if (message instanceof MutateRequest) { + MutateRequest mutateRequest = (MutateRequest) message; + String regionName = getStringForByteString(mutateRequest.getRegion().getValue()); + String params = "region= " + regionName; + return new SlowLogParams(regionName, params); + } else if (message instanceof CoprocessorServiceRequest) { + CoprocessorServiceRequest coprocessorServiceRequest = (CoprocessorServiceRequest) message; + String params = "coprocessorService= " + + coprocessorServiceRequest.getCall().getServiceName() + + ":" + coprocessorServiceRequest.getCall().getMethodName(); + return new SlowLogParams(StringUtils.EMPTY, params); + } + String params = "TODO: " + message.getClass().toString(); Review comment: Okk let me display just the className in that case ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services