HBASE-16302 age of last shipped op and age of last applied op should be histograms

Signed-off-by: Ashish Singhi <ashishsinghi@apache.org>
This commit is contained in:
Ashu Pachauri 2016-11-29 13:51:32 +05:30 committed by Ashish Singhi
parent 346e904a21
commit 7bcbac91a2
5 changed files with 20 additions and 13 deletions

View File

@ -20,11 +20,12 @@ package org.apache.hadoop.hbase.replication.regionserver;
import org.apache.hadoop.metrics2.lib.MutableFastCounter;
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
import org.apache.hadoop.metrics2.lib.MutableHistogram;
public class MetricsReplicationGlobalSourceSource implements MetricsReplicationSourceSource{
private final MetricsReplicationSourceImpl rms;
private final MutableGaugeLong ageOfLastShippedOpGauge;
private final MutableHistogram ageOfLastShippedOpHist;
private final MutableGaugeLong sizeOfLogQueueGauge;
private final MutableFastCounter logReadInEditsCounter;
private final MutableFastCounter logEditsFilteredCounter;
@ -47,7 +48,7 @@ public class MetricsReplicationGlobalSourceSource implements MetricsReplicationS
public MetricsReplicationGlobalSourceSource(MetricsReplicationSourceImpl rms) {
this.rms = rms;
ageOfLastShippedOpGauge = rms.getMetricsRegistry().getGauge(SOURCE_AGE_OF_LAST_SHIPPED_OP, 0L);
ageOfLastShippedOpHist = rms.getMetricsRegistry().getHistogram(SOURCE_AGE_OF_LAST_SHIPPED_OP);
sizeOfLogQueueGauge = rms.getMetricsRegistry().getGauge(SOURCE_SIZE_OF_LOG_QUEUE, 0L);
@ -80,7 +81,7 @@ public class MetricsReplicationGlobalSourceSource implements MetricsReplicationS
}
@Override public void setLastShippedAge(long age) {
ageOfLastShippedOpGauge.set(age);
ageOfLastShippedOpHist.add(age);
}
@Override public void incrSizeOfLogQueue(int size) {
@ -137,7 +138,7 @@ public class MetricsReplicationGlobalSourceSource implements MetricsReplicationS
@Override
public long getLastShippedAge() {
return ageOfLastShippedOpGauge.value();
return ageOfLastShippedOpHist.getMax();
}
@Override public void incrHFilesShipped(long hfiles) {

View File

@ -20,23 +20,24 @@ package org.apache.hadoop.hbase.replication.regionserver;
import org.apache.hadoop.metrics2.lib.MutableFastCounter;
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
import org.apache.hadoop.metrics2.lib.MutableHistogram;
public class MetricsReplicationSinkSourceImpl implements MetricsReplicationSinkSource {
private final MutableGaugeLong ageGauge;
private final MutableHistogram ageHist;
private final MutableFastCounter batchesCounter;
private final MutableFastCounter opsCounter;
private final MutableFastCounter hfilesCounter;
public MetricsReplicationSinkSourceImpl(MetricsReplicationSourceImpl rms) {
ageGauge = rms.getMetricsRegistry().getGauge(SINK_AGE_OF_LAST_APPLIED_OP, 0L);
ageHist = rms.getMetricsRegistry().getHistogram(SINK_AGE_OF_LAST_APPLIED_OP);
batchesCounter = rms.getMetricsRegistry().getCounter(SINK_APPLIED_BATCHES, 0L);
opsCounter = rms.getMetricsRegistry().getCounter(SINK_APPLIED_OPS, 0L);
hfilesCounter = rms.getMetricsRegistry().getCounter(SINK_APPLIED_HFILES, 0L);
}
@Override public void setLastAppliedOpAge(long age) {
ageGauge.set(age);
ageHist.add(age);
}
@Override public void incrAppliedBatches(long batches) {
@ -49,7 +50,7 @@ public class MetricsReplicationSinkSourceImpl implements MetricsReplicationSinkS
@Override
public long getLastAppliedOpAge() {
return ageGauge.value();
return ageHist.getMax();
}
@Override

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.replication.regionserver;
import org.apache.hadoop.metrics2.lib.MutableFastCounter;
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
import org.apache.hadoop.metrics2.lib.MutableHistogram;
public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSourceSource {
@ -39,7 +40,7 @@ public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSou
private final String shippedHFilesKey;
private final String sizeOfHFileRefsQueueKey;
private final MutableGaugeLong ageOfLastShippedOpGauge;
private final MutableHistogram ageOfLastShippedOpHist;
private final MutableGaugeLong sizeOfLogQueueGauge;
private final MutableFastCounter logReadInEditsCounter;
private final MutableFastCounter logEditsFilteredCounter;
@ -72,7 +73,7 @@ public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSou
this.keyPrefix = "source." + this.id + ".";
ageOfLastShippedOpKey = this.keyPrefix + "ageOfLastShippedOp";
ageOfLastShippedOpGauge = rms.getMetricsRegistry().getGauge(ageOfLastShippedOpKey, 0L);
ageOfLastShippedOpHist = rms.getMetricsRegistry().getHistogram(ageOfLastShippedOpKey);
sizeOfLogQueueKey = this.keyPrefix + "sizeOfLogQueue";
sizeOfLogQueueGauge = rms.getMetricsRegistry().getGauge(sizeOfLogQueueKey, 0L);
@ -127,7 +128,7 @@ public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSou
}
@Override public void setLastShippedAge(long age) {
ageOfLastShippedOpGauge.set(age);
ageOfLastShippedOpHist.add(age);
}
@Override public void incrSizeOfLogQueue(int size) {
@ -193,7 +194,7 @@ public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSou
@Override
public long getLastShippedAge() {
return ageOfLastShippedOpGauge.value();
return ageOfLastShippedOpHist.getMax();
}
@Override

View File

@ -75,6 +75,10 @@ public class MutableHistogram extends MutableMetric implements MetricHistogram {
histogram.add(val, 1);
}
public long getMax() {
return histogram.getMax();
}
@Override
public synchronized void snapshot(MetricsRecordBuilder metricsRecordBuilder, boolean all) {
// Get a reference to the old histogram.

View File

@ -82,7 +82,7 @@ public class MetricsSource implements BaseSource {
public void setAgeOfLastShippedOp(long timestamp, String walGroup) {
long age = EnvironmentEdgeManager.currentTime() - timestamp;
singleSourceSource.setLastShippedAge(age);
globalSourceSource.setLastShippedAge(Math.max(age, globalSourceSource.getLastShippedAge()));
globalSourceSource.setLastShippedAge(age);
this.lastTimeStamps.put(walGroup, timestamp);
}