Skip to content

Commit cfa3f13

Browse files
rmdmattinglybbeaudreault
authored andcommitted
HBASE-27553 Add row param to mutation slow logs (#5328)
Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Bryan Beaudreault <[email protected]>
1 parent 229d770 commit cfa3f13

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,8 @@ public static SlowLogParams getSlowLogParams(Message message, boolean slowLogSca
21302130
}
21312131
} else if (message instanceof MutationProto) {
21322132
MutationProto mutationProto = (MutationProto) message;
2133-
String params = "type= " + mutationProto.getMutateType().toString();
2133+
String params = "type= " + mutationProto.getMutateType().toString() + ", row= "
2134+
+ getStringForByteString(mutationProto.getRow());
21342135
return new SlowLogParams(params);
21352136
} else if (message instanceof GetRequest) {
21362137
GetRequest getRequest = (GetRequest) message;
@@ -2149,7 +2150,8 @@ public static SlowLogParams getSlowLogParams(Message message, boolean slowLogSca
21492150
} else if (message instanceof MutateRequest) {
21502151
MutateRequest mutateRequest = (MutateRequest) message;
21512152
String regionName = getStringForByteString(mutateRequest.getRegion().getValue());
2152-
String params = "region= " + regionName;
2153+
String params = "region= " + regionName + ", row= "
2154+
+ getStringForByteString(mutateRequest.getMutation().getRow());
21532155
return new SlowLogParams(regionName, params);
21542156
} else if (message instanceof CoprocessorServiceRequest) {
21552157
CoprocessorServiceRequest coprocessorServiceRequest = (CoprocessorServiceRequest) message;

hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.hadoop.hbase.client.Get;
4444
import org.apache.hadoop.hbase.client.Increment;
4545
import org.apache.hadoop.hbase.client.Put;
46+
import org.apache.hadoop.hbase.client.SlowLogParams;
4647
import org.apache.hadoop.hbase.io.TimeRange;
4748
import org.apache.hadoop.hbase.testclassification.SmallTests;
4849
import org.apache.hadoop.hbase.util.Bytes;
@@ -64,6 +65,7 @@
6465
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue;
6566
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.DeleteType;
6667
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType;
68+
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
6769
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair;
6870
import org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos;
6971
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos;
@@ -593,4 +595,32 @@ public void testIsEOF() throws Exception {
593595
}
594596
}
595597
}
598+
599+
@Test
600+
public void testSlowLogParamsMutationProto() {
601+
MutationProto mutationProto =
602+
ClientProtos.MutationProto.newBuilder().setRow(ByteString.copyFromUtf8("row123")).build();
603+
604+
SlowLogParams slowLogParams = ProtobufUtil.getSlowLogParams(mutationProto, false);
605+
606+
assertTrue(slowLogParams.getParams()
607+
.contains(Bytes.toStringBinary(mutationProto.getRow().toByteArray())));
608+
}
609+
610+
@Test
611+
public void testSlowLogParamsMutateRequest() {
612+
MutationProto mutationProto =
613+
ClientProtos.MutationProto.newBuilder().setRow(ByteString.copyFromUtf8("row123")).build();
614+
ClientProtos.MutateRequest mutateRequest =
615+
ClientProtos.MutateRequest.newBuilder().setMutation(mutationProto)
616+
.setRegion(HBaseProtos.RegionSpecifier.newBuilder()
617+
.setType(HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME)
618+
.setValue(ByteString.EMPTY).build())
619+
.build();
620+
621+
SlowLogParams slowLogParams = ProtobufUtil.getSlowLogParams(mutateRequest, false);
622+
623+
assertTrue(slowLogParams.getParams()
624+
.contains(Bytes.toStringBinary(mutationProto.getRow().toByteArray())));
625+
}
596626
}

0 commit comments

Comments
 (0)