diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java index 4722610abf77..1f5b30240f1a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java @@ -2130,7 +2130,8 @@ public static SlowLogParams getSlowLogParams(Message message, boolean slowLogSca } } else if (message instanceof MutationProto) { MutationProto mutationProto = (MutationProto) message; - String params = "type= " + mutationProto.getMutateType().toString(); + String params = "type= " + mutationProto.getMutateType().toString() + ", row= " + + getStringForByteString(mutationProto.getRow()); return new SlowLogParams(params); } else if (message instanceof GetRequest) { GetRequest getRequest = (GetRequest) message; @@ -2149,7 +2150,8 @@ public static SlowLogParams getSlowLogParams(Message message, boolean slowLogSca } else if (message instanceof MutateRequest) { MutateRequest mutateRequest = (MutateRequest) message; String regionName = getStringForByteString(mutateRequest.getRegion().getValue()); - String params = "region= " + regionName; + String params = "region= " + regionName + ", row= " + + getStringForByteString(mutateRequest.getMutation().getRow()); return new SlowLogParams(regionName, params); } else if (message instanceof CoprocessorServiceRequest) { CoprocessorServiceRequest coprocessorServiceRequest = (CoprocessorServiceRequest) message; diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java index fc442b8998d9..2b4380dfbb6d 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java @@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Increment; import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.SlowLogParams; import org.apache.hadoop.hbase.io.TimeRange; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.util.Bytes; @@ -64,6 +65,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.DeleteType; import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType; +import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair; import org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos; @@ -593,4 +595,32 @@ public void testIsEOF() throws Exception { } } } + + @Test + public void testSlowLogParamsMutationProto() { + MutationProto mutationProto = + ClientProtos.MutationProto.newBuilder().setRow(ByteString.copyFromUtf8("row123")).build(); + + SlowLogParams slowLogParams = ProtobufUtil.getSlowLogParams(mutationProto, false); + + assertTrue(slowLogParams.getParams() + .contains(Bytes.toStringBinary(mutationProto.getRow().toByteArray()))); + } + + @Test + public void testSlowLogParamsMutateRequest() { + MutationProto mutationProto = + ClientProtos.MutationProto.newBuilder().setRow(ByteString.copyFromUtf8("row123")).build(); + ClientProtos.MutateRequest mutateRequest = + ClientProtos.MutateRequest.newBuilder().setMutation(mutationProto) + .setRegion(HBaseProtos.RegionSpecifier.newBuilder() + .setType(HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME) + .setValue(ByteString.EMPTY).build()) + .build(); + + SlowLogParams slowLogParams = ProtobufUtil.getSlowLogParams(mutateRequest, false); + + assertTrue(slowLogParams.getParams() + .contains(Bytes.toStringBinary(mutationProto.getRow().toByteArray()))); + } }