HBASE-4050 Clean up BaseMetricsSourceImpl
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1381008 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ae8410f77
commit
b815812863
|
@ -53,10 +53,10 @@ public class MasterMetricsSourceImpl
|
||||||
super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
|
super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
|
||||||
|
|
||||||
this.masterWrapper = masterWrapper;
|
this.masterWrapper = masterWrapper;
|
||||||
clusterRequestsCounter = getLongCounter("cluster_requests", 0);
|
clusterRequestsCounter = metricsRegistry.newCounter("cluster_requests", "", 0l);
|
||||||
ritGauge = getLongGauge("ritCount", 0);
|
ritGauge = metricsRegistry.newGauge("ritCount", "", 0l);
|
||||||
ritCountOverThresholdGauge = getLongGauge("ritCountOverThreshold", 0);
|
ritCountOverThresholdGauge = metricsRegistry.newGauge("ritCountOverThreshold","", 0l);
|
||||||
ritOldestAgeGauge = getLongGauge("ritOldestAge", 0);
|
ritOldestAgeGauge = metricsRegistry.newGauge("ritOldestAge", "", 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incRequests(final int inc) {
|
public void incRequests(final int inc) {
|
||||||
|
|
|
@ -77,28 +77,6 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
||||||
DefaultMetricsSystem.INSTANCE.registerSource(metricsJmxContext, metricsDescription, this);
|
DefaultMetricsSystem.INSTANCE.registerSource(metricsJmxContext, metricsDescription, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a MetricMutableGaugeLong from the storage. If it is not there atomically put it.
|
|
||||||
*
|
|
||||||
* @param gaugeName name of the gauge to create or get.
|
|
||||||
* @param potentialStartingValue value of the new gauge if we have to create it.
|
|
||||||
* @return a metric object
|
|
||||||
*/
|
|
||||||
protected MetricMutableGaugeLong getLongGauge(String gaugeName, long potentialStartingValue) {
|
|
||||||
return metricsRegistry.getLongGauge(gaugeName, potentialStartingValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a MetricMutableCounterLong from the storage. If it is not there atomically put it.
|
|
||||||
*
|
|
||||||
* @param counterName Name of the counter to get
|
|
||||||
* @param potentialStartingValue starting value if we have to create a new counter
|
|
||||||
* @return a metric object
|
|
||||||
*/
|
|
||||||
protected MetricMutableCounterLong getLongCounter(String counterName,
|
|
||||||
long potentialStartingValue) {
|
|
||||||
return metricsRegistry.getLongCounter(counterName, potentialStartingValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a single gauge to a value.
|
* Set a single gauge to a value.
|
||||||
|
|
|
@ -51,10 +51,10 @@ public class MasterMetricsSourceImpl
|
||||||
super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
|
super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
|
||||||
this.masterWrapper = masterWrapper;
|
this.masterWrapper = masterWrapper;
|
||||||
|
|
||||||
clusterRequestsCounter = getLongCounter("cluster_requests", 0);
|
clusterRequestsCounter = metricsRegistry.newCounter("cluster_requests", "", 0l);
|
||||||
ritGauge = getLongGauge("ritCount", 0);
|
ritGauge = metricsRegistry.newGauge("ritCount", "", 0l);
|
||||||
ritCountOverThresholdGauge = getLongGauge("ritCountOverThreshold", 0);
|
ritCountOverThresholdGauge = metricsRegistry.newGauge("ritCountOverThreshold", "" , 0l);
|
||||||
ritOldestAgeGauge = getLongGauge("ritOldestAge", 0);
|
ritOldestAgeGauge = metricsRegistry.newGauge("ritOldestAge", "", 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incRequests(final int inc) {
|
public void incRequests(final int inc) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
||||||
* @param value the new value of the gauge.
|
* @param value the new value of the gauge.
|
||||||
*/
|
*/
|
||||||
public void setGauge(String gaugeName, long value) {
|
public void setGauge(String gaugeName, long value) {
|
||||||
MutableGaugeLong gaugeInt = getLongGauge(gaugeName, value);
|
MutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName, value);
|
||||||
gaugeInt.set(value);
|
gaugeInt.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
||||||
* @param delta The amount to increment the gauge by.
|
* @param delta The amount to increment the gauge by.
|
||||||
*/
|
*/
|
||||||
public void incGauge(String gaugeName, long delta) {
|
public void incGauge(String gaugeName, long delta) {
|
||||||
MutableGaugeLong gaugeInt = getLongGauge(gaugeName, 0l);
|
MutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName, 0l);
|
||||||
gaugeInt.incr(delta);
|
gaugeInt.incr(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
||||||
* @param delta the ammount to subtract from a gauge value.
|
* @param delta the ammount to subtract from a gauge value.
|
||||||
*/
|
*/
|
||||||
public void decGauge(String gaugeName, long delta) {
|
public void decGauge(String gaugeName, long delta) {
|
||||||
MutableGaugeLong gaugeInt = getLongGauge(gaugeName, 0l);
|
MutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName, 0l);
|
||||||
gaugeInt.decr(delta);
|
gaugeInt.decr(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
||||||
* @param delta the ammount to increment
|
* @param delta the ammount to increment
|
||||||
*/
|
*/
|
||||||
public void incCounters(String key, long delta) {
|
public void incCounters(String key, long delta) {
|
||||||
MutableCounterLong counter = getLongCounter(key, 0l);
|
MutableCounterLong counter = metricsRegistry.getLongCounter(key, 0l);
|
||||||
counter.incr(delta);
|
counter.incr(delta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,28 +129,6 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
||||||
metricsRegistry.removeMetric(key);
|
metricsRegistry.removeMetric(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a MetricMutableGaugeLong from the storage. If it is not there atomically put it.
|
|
||||||
*
|
|
||||||
* @param gaugeName name of the gauge to create or get.
|
|
||||||
* @param potentialStartingValue value of the new counter if we have to create it.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected MutableGaugeLong getLongGauge(String gaugeName, long potentialStartingValue) {
|
|
||||||
return metricsRegistry.getLongGauge(gaugeName, potentialStartingValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a MetricMutableCounterLong from the storage. If it is not there atomically put it.
|
|
||||||
*
|
|
||||||
* @param counterName Name of the counter to get
|
|
||||||
* @param potentialStartingValue starting value if we have to create a new counter
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected MutableCounterLong getLongCounter(String counterName, long potentialStartingValue) {
|
|
||||||
return metricsRegistry.getLongCounter(counterName, potentialStartingValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
|
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
|
||||||
metricsRegistry.snapshot(metricsCollector.addRecord(metricsRegistry.info()), all);
|
metricsRegistry.snapshot(metricsCollector.addRecord(metricsRegistry.info()), all);
|
||||||
|
|
Loading…
Reference in New Issue