HBASE-17957 Custom metrics of replicate endpoints don't prepend "source." to global metrics
Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
1848353fd6
commit
ef94de3eb7
|
@ -23,6 +23,8 @@ import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
|
|||
import org.apache.hadoop.metrics2.lib.MutableHistogram;
|
||||
|
||||
public class MetricsReplicationGlobalSourceSource implements MetricsReplicationSourceSource{
|
||||
private static final String KEY_PREFIX = "source.";
|
||||
|
||||
private final MetricsReplicationSourceImpl rms;
|
||||
|
||||
private final MutableHistogram ageOfLastShippedOpHist;
|
||||
|
@ -196,32 +198,32 @@ public class MetricsReplicationGlobalSourceSource implements MetricsReplicationS
|
|||
|
||||
@Override
|
||||
public void setGauge(String gaugeName, long value) {
|
||||
rms.setGauge(gaugeName, value);
|
||||
rms.setGauge(KEY_PREFIX + gaugeName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incGauge(String gaugeName, long delta) {
|
||||
rms.incGauge(gaugeName, delta);
|
||||
rms.incGauge(KEY_PREFIX + gaugeName, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decGauge(String gaugeName, long delta) {
|
||||
rms.decGauge(gaugeName, delta);
|
||||
rms.decGauge(KEY_PREFIX + gaugeName, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetric(String key) {
|
||||
rms.removeMetric(key);
|
||||
rms.removeMetric(KEY_PREFIX + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incCounters(String counterName, long delta) {
|
||||
rms.incCounters(counterName, delta);
|
||||
rms.incCounters(KEY_PREFIX + counterName, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateHistogram(String name, long value) {
|
||||
rms.updateHistogram(name, value);
|
||||
rms.updateHistogram(KEY_PREFIX + name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -310,9 +310,11 @@ public class TestReplicationEndpoint extends TestReplicationBase {
|
|||
MetricsSource source = new MetricsSource(id, singleSourceSource, globalSourceSource);
|
||||
String gaugeName = "gauge";
|
||||
String singleGaugeName = "source.id." + gaugeName;
|
||||
String globalGaugeName = "source." + gaugeName;
|
||||
long delta = 1;
|
||||
String counterName = "counter";
|
||||
String singleCounterName = "source.id." + counterName;
|
||||
String globalCounterName = "source." + counterName;
|
||||
long count = 2;
|
||||
source.decGauge(gaugeName, delta);
|
||||
source.getMetricsContext();
|
||||
|
@ -327,21 +329,21 @@ public class TestReplicationEndpoint extends TestReplicationBase {
|
|||
source.updateHistogram(counterName, count);
|
||||
|
||||
verify(singleRms).decGauge(singleGaugeName, delta);
|
||||
verify(globalRms).decGauge(gaugeName, delta);
|
||||
verify(globalRms).decGauge(globalGaugeName, delta);
|
||||
verify(globalRms).getMetricsContext();
|
||||
verify(globalRms).getMetricsJmxContext();
|
||||
verify(globalRms).getMetricsName();
|
||||
verify(singleRms).incCounters(singleCounterName, count);
|
||||
verify(globalRms).incCounters(counterName, count);
|
||||
verify(globalRms).incCounters(globalCounterName, count);
|
||||
verify(singleRms).incGauge(singleGaugeName, delta);
|
||||
verify(globalRms).incGauge(gaugeName, delta);
|
||||
verify(globalRms).incGauge(globalGaugeName, delta);
|
||||
verify(globalRms).init();
|
||||
verify(singleRms).removeMetric(singleGaugeName);
|
||||
verify(globalRms).removeMetric(gaugeName);
|
||||
verify(globalRms).removeMetric(globalGaugeName);
|
||||
verify(singleRms).setGauge(singleGaugeName, delta);
|
||||
verify(globalRms).setGauge(gaugeName, delta);
|
||||
verify(globalRms).setGauge(globalGaugeName, delta);
|
||||
verify(singleRms).updateHistogram(singleCounterName, count);
|
||||
verify(globalRms).updateHistogram(counterName, count);
|
||||
verify(globalRms).updateHistogram(globalCounterName, count);
|
||||
}
|
||||
|
||||
private void doPut(byte[] row) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue