This is an automated email from the ASF dual-hosted git repository.

bbeaudreault pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.4 by this push:
     new 49c1749a000 HBASE-27553 Add row param to mutation slow logs (#5328)
49c1749a000 is described below

commit 49c1749a000861583b26edd0d407ff9a2f214b3e
Author: Ray Mattingly <rmdmattin...@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 <zhang...@apache.org>
    Signed-off-by: Bryan Beaudreault <bbeaudrea...@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 5280391fe4b..6e4396b5c60 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
@@ -2114,7 +2114,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;
@@ -2133,7 +2134,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())));
+  }
 }

Reply via email to