HBASE-18374 RegionServer Metrics improvements

This commit is contained in:
Abhishek Singh Chouhan 2017-07-28 19:01:42 +05:30
parent df90ba58db
commit 95808b4672
8 changed files with 133 additions and 24 deletions

View File

@ -53,6 +53,12 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
*/
void updatePut(long t);
/**
* Update the PutBatch time histogram if a batch contains a Put op
* @param t
*/
void updatePutBatch(long t);
/**
* Update the Delete time histogram
*
@ -60,6 +66,24 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
*/
void updateDelete(long t);
/**
* Update the Delete time histogram if a batch contains a delete op
* @param t time it took
*/
void updateDeleteBatch(long t);
/**
* Update checkAndDelete histogram
* @param t time it took
*/
void updateCheckAndDelete(long t);
/**
* Update checkAndPut histogram
* @param t time it took
*/
void updateCheckAndPut(long t);
/**
* Update the Get time histogram .
*
@ -334,25 +358,29 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
String UPDATES_BLOCKED_DESC =
"Number of MS updates have been blocked so that the memstore can be flushed.";
String DELETE_KEY = "delete";
String CHECK_AND_DELETE_KEY = "checkAndDelete";
String CHECK_AND_PUT_KEY = "checkAndPut";
String DELETE_BATCH_KEY = "deleteBatch";
String GET_SIZE_KEY = "getSize";
String GET_KEY = "get";
String INCREMENT_KEY = "increment";
String MUTATE_KEY = "mutate";
String PUT_KEY = "put";
String PUT_BATCH_KEY = "putBatch";
String APPEND_KEY = "append";
String REPLAY_KEY = "replay";
String SCAN_KEY = "scan";
String SCAN_SIZE_KEY = "scanSize";
String SCAN_TIME_KEY = "scanTime";
String SLOW_MUTATE_KEY = "slowPutCount";
String SLOW_PUT_KEY = "slowPutCount";
String SLOW_GET_KEY = "slowGetCount";
String SLOW_DELETE_KEY = "slowDeleteCount";
String SLOW_INCREMENT_KEY = "slowIncrementCount";
String SLOW_APPEND_KEY = "slowAppendCount";
String SLOW_MUTATE_DESC =
"The number of Multis that took over 1000ms to complete";
String SLOW_PUT_DESC =
"The number of batches containing puts that took over 1000ms to complete";
String SLOW_DELETE_DESC =
"The number of Deletes that took over 1000ms to complete";
"The number of batches containing delete(s) that took over 1000ms to complete";
String SLOW_GET_DESC = "The number of Gets that took over 1000ms to complete";
String SLOW_INCREMENT_DESC =
"The number of Increments that took over 1000ms to complete";

View File

@ -37,7 +37,11 @@ public class MetricsRegionServerSourceImpl
final MetricsRegionServerWrapper rsWrap;
private final MetricHistogram putHisto;
private final MetricHistogram putBatchHisto;
private final MetricHistogram deleteHisto;
private final MetricHistogram deleteBatchHisto;
private final MetricHistogram checkAndDeleteHisto;
private final MetricHistogram checkAndPutHisto;
private final MetricHistogram getHisto;
private final MetricHistogram incrementHisto;
private final MetricHistogram appendHisto;
@ -97,12 +101,17 @@ public class MetricsRegionServerSourceImpl
super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
this.rsWrap = rsWrap;
putHisto = getMetricsRegistry().newTimeHistogram(MUTATE_KEY);
slowPut = getMetricsRegistry().newCounter(SLOW_MUTATE_KEY, SLOW_MUTATE_DESC, 0L);
putHisto = getMetricsRegistry().newTimeHistogram(PUT_KEY);
putBatchHisto = getMetricsRegistry().newTimeHistogram(PUT_BATCH_KEY);
slowPut = getMetricsRegistry().newCounter(SLOW_PUT_KEY, SLOW_PUT_DESC, 0L);
deleteHisto = getMetricsRegistry().newTimeHistogram(DELETE_KEY);
slowDelete = getMetricsRegistry().newCounter(SLOW_DELETE_KEY, SLOW_DELETE_DESC, 0L);
deleteBatchHisto = getMetricsRegistry().newTimeHistogram(DELETE_BATCH_KEY);
checkAndDeleteHisto = getMetricsRegistry().newTimeHistogram(CHECK_AND_DELETE_KEY);
checkAndPutHisto = getMetricsRegistry().newTimeHistogram(CHECK_AND_PUT_KEY);
getHisto = getMetricsRegistry().newTimeHistogram(GET_KEY);
slowGet = getMetricsRegistry().newCounter(SLOW_GET_KEY, SLOW_GET_DESC, 0L);
@ -537,4 +546,24 @@ public class MetricsRegionServerSourceImpl
public void updatePauseTimeWithoutGc(long t) {
pausesWithoutGc.add(t);
}
@Override
public void updateDeleteBatch(long t) {
deleteBatchHisto.add(t);
}
@Override
public void updateCheckAndDelete(long t) {
checkAndDeleteHisto.add(t);
}
@Override
public void updateCheckAndPut(long t) {
checkAndPutHisto.add(t);
}
@Override
public void updatePutBatch(long t) {
putBatchHisto.add(t);
}
}

View File

@ -83,7 +83,7 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
String suffix = "Count";
regionPutKey = regionNamePrefix + MetricsRegionServerSource.MUTATE_KEY + suffix;
regionPutKey = regionNamePrefix + MetricsRegionServerSource.PUT_KEY + suffix;
regionPut = registry.getCounter(regionPutKey, 0L);
regionDeleteKey = regionNamePrefix + MetricsRegionServerSource.DELETE_KEY + suffix;

View File

@ -71,18 +71,34 @@ public class MetricsRegionServer {
return regionServerWrapper;
}
public void updatePut(long t) {
public void updatePutBatch(long t) {
if (t > 1000) {
serverSource.incrSlowPut();
}
serverSource.updatePutBatch(t);
}
public void updatePut(long t) {
serverSource.updatePut(t);
}
public void updateDelete(long t) {
serverSource.updateDelete(t);
}
public void updateDeleteBatch(long t) {
if (t > 1000) {
serverSource.incrSlowDelete();
}
serverSource.updateDelete(t);
serverSource.updateDeleteBatch(t);
}
public void updateCheckAndDelete(long t) {
serverSource.updateCheckAndDelete(t);
}
public void updateCheckAndPut(long t) {
serverSource.updateCheckAndPut(t);
}
public void updateGet(long t) {

View File

@ -1029,10 +1029,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
if (regionServer.metricsRegionServer != null) {
long after = EnvironmentEdgeManager.currentTime();
if (batchContainsPuts) {
regionServer.metricsRegionServer.updatePut(after - before);
regionServer.metricsRegionServer.updatePutBatch(after - before);
}
if (batchContainsDelete) {
regionServer.metricsRegionServer.updateDelete(after - before);
regionServer.metricsRegionServer.updateDeleteBatch(after - before);
}
}
}
@ -1104,10 +1104,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
if (regionServer.metricsRegionServer != null) {
long after = EnvironmentEdgeManager.currentTime();
if (batchContainsPuts) {
regionServer.metricsRegionServer.updatePut(after - before);
regionServer.metricsRegionServer.updatePutBatch(after - before);
}
if (batchContainsDelete) {
regionServer.metricsRegionServer.updateDelete(after - before);
regionServer.metricsRegionServer.updateDeleteBatch(after - before);
}
}
}
@ -2681,6 +2681,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
OperationQuota quota = null;
RpcCallContext context = RpcServer.getCurrentCall();
ActivePolicyEnforcement spaceQuotaEnforcement = null;
MutationType type = null;
long before = EnvironmentEdgeManager.currentTime();
// Clear scanner so we are not holding on to reference across call.
if (controller != null) {
controller.setCellScanner(null);
@ -2698,7 +2700,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
long nonceGroup = request.hasNonceGroup() ? request.getNonceGroup() : HConstants.NO_NONCE;
Result r = null;
Boolean processed = null;
MutationType type = mutation.getMutateType();
type = mutation.getMutateType();
quota = getRpcQuotaManager().checkQuota(region, OperationQuota.OperationType.MUTATE);
spaceQuotaEnforcement = getSpaceQuotaManager().getActiveEnforcements();
@ -2795,6 +2797,29 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
if (quota != null) {
quota.close();
}
// Update metrics
if (regionServer.metricsRegionServer != null && type != null) {
long after = EnvironmentEdgeManager.currentTime();
switch (type) {
case DELETE:
if (request.hasCondition()) {
regionServer.metricsRegionServer.updateCheckAndDelete(after - before);
} else {
regionServer.metricsRegionServer.updateDelete(after - before);
}
break;
case PUT:
if (request.hasCondition()) {
regionServer.metricsRegionServer.updateCheckAndPut(after - before);
} else {
regionServer.metricsRegionServer.updatePut(after - before);
}
break;
default:
break;
}
}
}
}

View File

@ -111,8 +111,8 @@ public class TestMetricsRegionServer {
rsm.updateAppend(1002);
}
for (int i=0; i < 13; i ++) {
rsm.updateDelete(13);
rsm.updateDelete(1003);
rsm.updateDeleteBatch(13);
rsm.updateDeleteBatch(1003);
}
for (int i=0; i < 14; i ++) {
rsm.updateGet(14);
@ -123,15 +123,26 @@ public class TestMetricsRegionServer {
rsm.updateIncrement(1005);
}
for (int i=0; i < 16; i ++) {
rsm.updatePut(16);
rsm.updatePut(1006);
rsm.updatePutBatch(16);
rsm.updatePutBatch(1006);
}
for (int i=0; i < 17; i ++) {
rsm.updatePut(17);
rsm.updateDelete(17);
rsm.updateCheckAndDelete(17);
rsm.updateCheckAndPut(17);
}
HELPER.assertCounter("appendNumOps", 24, serverSource);
HELPER.assertCounter("deleteNumOps", 26, serverSource);
HELPER.assertCounter("deleteBatchNumOps", 26, serverSource);
HELPER.assertCounter("getNumOps", 28, serverSource);
HELPER.assertCounter("incrementNumOps", 30, serverSource);
HELPER.assertCounter("mutateNumOps", 32, serverSource);
HELPER.assertCounter("putBatchNumOps", 32, serverSource);
HELPER.assertCounter("putNumOps", 17, serverSource);
HELPER.assertCounter("deleteNumOps", 17, serverSource);
HELPER.assertCounter("checkAndDeleteNumOps", 17, serverSource);
HELPER.assertCounter("checkAndPutNumOps", 17, serverSource);
HELPER.assertCounter("slowAppendCount", 12, serverSource);

View File

@ -260,7 +260,7 @@ public class TestRegionServerMetrics {
assertCounter("writeRequestCount", writeRequests + 30);
assertRegionMetrics("getCount", 10);
assertRegionMetrics("mutateCount", 31);
assertRegionMetrics("putCount", 31);
doNGets(10, true); // true = batch

View File

@ -114,7 +114,7 @@ public class TestRemoveRegionMetrics {
"_region_" + regionInfo.getEncodedName()+
"_metric";
metricsHelper.assertCounter(prefix + "_mutateCount", 1, currentAgg);
metricsHelper.assertCounter(prefix + "_putCount", 1, currentAgg);
try {
@ -129,7 +129,7 @@ public class TestRemoveRegionMetrics {
.getMetrics()
.getSource()
.getAggregateSource();
metricsHelper.assertCounter(prefix + "_mutateCount", 0, destAgg);
metricsHelper.assertCounter(prefix + "_putCount", 0, destAgg);
}
}