You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2023/07/24 12:21:23 UTC
[hbase] branch branch-2.5 updated: HBASE-27553 Add row param to mutation slow logs (#5328)
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new ac02aa0d066 HBASE-27553 Add row param to mutation slow logs (#5328)
ac02aa0d066 is described below
commit ac02aa0d066809cfb12077ae2c6cce908fdc69b2
Author: Ray Mattingly <rm...@gmail.com>
AuthorDate: Mon Jul 24 07:58:13 2023 -0400
HBASE-27553 Add row param to mutation slow logs (#5328)
Signed-off-by: Duo Zhang <zh...@apache.org>
Signed-off-by: Bryan Beaudreault <bb...@apache.org>
---
.../hadoop/hbase/shaded/protobuf/ProtobufUtil.java | 6 +++--
.../hbase/shaded/protobuf/TestProtobufUtil.java | 30 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
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 68377bde13b..df839a65b47 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
@@ -2107,7 +2107,8 @@ public final class ProtobufUtil {
return new SlowLogParams(regionName, params);
} 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;
@@ -2126,7 +2127,8 @@ public final class ProtobufUtil {
} 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 fc442b8998d..298485cea55 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.Delete;
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.MutationPr
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 class TestProtobufUtil {
}
}
}
+
+ @Test
+ public void testSlowLogParamsMutationProto() {
+ MutationProto mutationProto =
+ ClientProtos.MutationProto.newBuilder().setRow(ByteString.copyFromUtf8("row123")).build();
+
+ SlowLogParams slowLogParams = ProtobufUtil.getSlowLogParams(mutationProto);
+
+ 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);
+
+ assertTrue(slowLogParams.getParams()
+ .contains(Bytes.toStringBinary(mutationProto.getRow().toByteArray())));
+ }
}