HBASE-25189 [Metrics] Add checkAndPut and checkAndDelete latency metrics at table level (#2548)
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
parent
9eb3a7918f
commit
b30d1d1180
@ -50,6 +50,8 @@ public interface MetricsTableLatencies {
|
||||
String DELETE_BATCH_TIME = "deleteBatchTime";
|
||||
String INCREMENT_TIME = "incrementTime";
|
||||
String APPEND_TIME = "appendTime";
|
||||
String CHECK_AND_DELETE_TIME = "checkAndDeleteTime";
|
||||
String CHECK_AND_PUT_TIME = "checkAndPutTime";
|
||||
|
||||
/**
|
||||
* Update the Put time histogram
|
||||
@ -122,4 +124,19 @@ public interface MetricsTableLatencies {
|
||||
* @param t time it took
|
||||
*/
|
||||
void updateScanTime(String tableName, long t);
|
||||
|
||||
/**
|
||||
* Update the CheckAndDelete time histogram.
|
||||
* @param nameAsString The table the metric is for
|
||||
* @param time time it took
|
||||
*/
|
||||
void updateCheckAndDelete(String nameAsString, long time);
|
||||
|
||||
/**
|
||||
* Update the CheckAndPut time histogram.
|
||||
* @param nameAsString The table the metric is for
|
||||
* @param time time it took
|
||||
*/
|
||||
void updateCheckAndPut(String nameAsString, long time);
|
||||
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ public class MetricsTableLatenciesImpl extends BaseSourceImpl implements Metrics
|
||||
final MetricHistogram deleteBatchTimeHisto;
|
||||
final MetricHistogram scanTimeHisto;
|
||||
final MetricHistogram scanSizeHisto;
|
||||
final MetricHistogram checkAndDeleteTimeHisto;
|
||||
final MetricHistogram checkAndPutTimeHisto;
|
||||
|
||||
TableHistograms(DynamicMetricsRegistry registry, TableName tn) {
|
||||
getTimeHisto = registry.newTimeHistogram(qualifyMetricsName(tn, GET_TIME));
|
||||
@ -61,6 +63,10 @@ public class MetricsTableLatenciesImpl extends BaseSourceImpl implements Metrics
|
||||
qualifyMetricsName(tn, DELETE_BATCH_TIME));
|
||||
scanTimeHisto = registry.newTimeHistogram(qualifyMetricsName(tn, SCAN_TIME));
|
||||
scanSizeHisto = registry.newSizeHistogram(qualifyMetricsName(tn, SCAN_SIZE));
|
||||
checkAndDeleteTimeHisto =
|
||||
registry.newTimeHistogram(qualifyMetricsName(tn, CHECK_AND_DELETE_TIME));
|
||||
checkAndPutTimeHisto =
|
||||
registry.newTimeHistogram(qualifyMetricsName(tn, CHECK_AND_PUT_TIME));
|
||||
}
|
||||
|
||||
public void updatePut(long time) {
|
||||
@ -98,6 +104,15 @@ public class MetricsTableLatenciesImpl extends BaseSourceImpl implements Metrics
|
||||
public void updateScanTime(long t) {
|
||||
scanTimeHisto.add(t);
|
||||
}
|
||||
|
||||
public void updateCheckAndDeleteTime(long t) {
|
||||
checkAndDeleteTimeHisto.add(t);
|
||||
}
|
||||
|
||||
public void updateCheckAndPutTime(long t) {
|
||||
checkAndPutTimeHisto.add(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@ -175,6 +190,16 @@ public class MetricsTableLatenciesImpl extends BaseSourceImpl implements Metrics
|
||||
getOrCreateTableHistogram(tableName).updateScanTime(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCheckAndDelete(String tableName, long time) {
|
||||
getOrCreateTableHistogram(tableName).updateCheckAndDeleteTime(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCheckAndPut(String tableName, long time) {
|
||||
getOrCreateTableHistogram(tableName).updateCheckAndPutTime(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
|
||||
MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName);
|
||||
|
@ -139,11 +139,17 @@ public class MetricsRegionServer {
|
||||
serverSource.updateDeleteBatch(t);
|
||||
}
|
||||
|
||||
public void updateCheckAndDelete(long t) {
|
||||
public void updateCheckAndDelete(TableName tn, long t) {
|
||||
if (tableMetrics != null && tn != null) {
|
||||
tableMetrics.updateCheckAndDelete(tn, t);
|
||||
}
|
||||
serverSource.updateCheckAndDelete(t);
|
||||
}
|
||||
|
||||
public void updateCheckAndPut(long t) {
|
||||
public void updateCheckAndPut(TableName tn, long t) {
|
||||
if (tableMetrics != null && tn != null) {
|
||||
tableMetrics.updateCheckAndPut(tn, t);
|
||||
}
|
||||
serverSource.updateCheckAndPut(t);
|
||||
}
|
||||
|
||||
|
@ -2710,7 +2710,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||
switch (type) {
|
||||
case DELETE:
|
||||
if (request.hasCondition()) {
|
||||
regionServer.metricsRegionServer.updateCheckAndDelete(after - before);
|
||||
regionServer.metricsRegionServer.updateCheckAndDelete(
|
||||
region == null ? null : region.getRegionInfo().getTable(), after - before);
|
||||
} else {
|
||||
regionServer.metricsRegionServer.updateDelete(
|
||||
region == null ? null : region.getRegionInfo().getTable(), after - before);
|
||||
@ -2718,15 +2719,15 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||
break;
|
||||
case PUT:
|
||||
if (request.hasCondition()) {
|
||||
regionServer.metricsRegionServer.updateCheckAndPut(after - before);
|
||||
regionServer.metricsRegionServer.updateCheckAndPut(
|
||||
region == null ? null : region.getRegionInfo().getTable(), after - before);
|
||||
} else {
|
||||
regionServer.metricsRegionServer.updatePut(
|
||||
region == null ? null : region.getRegionInfo().getTable(),after - before);
|
||||
region == null ? null : region.getRegionInfo().getTable(), after - before);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,14 @@ public class RegionServerTableMetrics {
|
||||
latencies.updateDeleteBatch(table.getNameAsString(), time);
|
||||
}
|
||||
|
||||
public void updateCheckAndDelete(TableName table, long time) {
|
||||
latencies.updateCheckAndDelete(table.getNameAsString(), time);
|
||||
}
|
||||
|
||||
public void updateCheckAndPut(TableName table, long time) {
|
||||
latencies.updateCheckAndPut(table.getNameAsString(), time);
|
||||
}
|
||||
|
||||
public void updateScanTime(TableName table, long time) {
|
||||
latencies.updateScanTime(table.getNameAsString(), time);
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ public class TestMetricsRegionServer {
|
||||
for (int i=0; i < 17; i ++) {
|
||||
rsm.updatePut(null, 17);
|
||||
rsm.updateDelete(null, 17);
|
||||
rsm.updateCheckAndDelete(17);
|
||||
rsm.updateCheckAndPut(17);
|
||||
rsm.updateCheckAndDelete(null, 17);
|
||||
rsm.updateCheckAndPut(null, 17);
|
||||
}
|
||||
|
||||
HELPER.assertCounter("appendNumOps", 24, serverSource);
|
||||
@ -162,17 +162,6 @@ public class TestMetricsRegionServer {
|
||||
HELPER.assertCounter("slowPutCount", 16, serverSource);
|
||||
}
|
||||
|
||||
String FLUSH_TIME = "flushTime";
|
||||
String FLUSH_TIME_DESC = "Histogram for the time in millis for memstore flush";
|
||||
String FLUSH_MEMSTORE_SIZE = "flushMemstoreSize";
|
||||
String FLUSH_MEMSTORE_SIZE_DESC = "Histogram for number of bytes in the memstore for a flush";
|
||||
String FLUSH_FILE_SIZE = "flushFileSize";
|
||||
String FLUSH_FILE_SIZE_DESC = "Histogram for number of bytes in the resulting file for a flush";
|
||||
String FLUSHED_OUTPUT_BYTES = "flushedOutputBytes";
|
||||
String FLUSHED_OUTPUT_BYTES_DESC = "Total number of bytes written from flush";
|
||||
String FLUSHED_MEMSTORE_BYTES = "flushedMemstoreBytes";
|
||||
String FLUSHED_MEMSTORE_BYTES_DESC = "Total number of bytes of cells in memstore from flush";
|
||||
|
||||
@Test
|
||||
public void testFlush() {
|
||||
rsm.updateFlush(1, 2, 3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user