Skip to content

Commit

Permalink
HBASE-27553 Add row param to mutation slow logs (apache#5328)
Browse files Browse the repository at this point in the history
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Bryan Beaudreault <bbeaudreault@apache.org>
  • Loading branch information
rmdmattingly authored and bbeaudreault committed Jul 24, 2023
1 parent 229d770 commit cfa3f13
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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())));
}
}

0 comments on commit cfa3f13

Please sign in to comment.