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);
|
||||
|
||||
this.masterWrapper = masterWrapper;
|
||||
clusterRequestsCounter = getLongCounter("cluster_requests", 0);
|
||||
ritGauge = getLongGauge("ritCount", 0);
|
||||
ritCountOverThresholdGauge = getLongGauge("ritCountOverThreshold", 0);
|
||||
ritOldestAgeGauge = getLongGauge("ritOldestAge", 0);
|
||||
clusterRequestsCounter = metricsRegistry.newCounter("cluster_requests", "", 0l);
|
||||
ritGauge = metricsRegistry.newGauge("ritCount", "", 0l);
|
||||
ritCountOverThresholdGauge = metricsRegistry.newGauge("ritCountOverThreshold","", 0l);
|
||||
ritOldestAgeGauge = metricsRegistry.newGauge("ritOldestAge", "", 0l);
|
||||
}
|
||||
|
||||
public void incRequests(final int inc) {
|
||||
|
|
|
@ -77,28 +77,6 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
|||
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.
|
||||
|
|
|
@ -51,10 +51,10 @@ public class MasterMetricsSourceImpl
|
|||
super(metricsName, metricsDescription, metricsContext, metricsJmxContext);
|
||||
this.masterWrapper = masterWrapper;
|
||||
|
||||
clusterRequestsCounter = getLongCounter("cluster_requests", 0);
|
||||
ritGauge = getLongGauge("ritCount", 0);
|
||||
ritCountOverThresholdGauge = getLongGauge("ritCountOverThreshold", 0);
|
||||
ritOldestAgeGauge = getLongGauge("ritOldestAge", 0);
|
||||
clusterRequestsCounter = metricsRegistry.newCounter("cluster_requests", "", 0l);
|
||||
ritGauge = metricsRegistry.newGauge("ritCount", "", 0l);
|
||||
ritCountOverThresholdGauge = metricsRegistry.newGauge("ritCountOverThreshold", "" , 0l);
|
||||
ritOldestAgeGauge = metricsRegistry.newGauge("ritOldestAge", "", 0l);
|
||||
}
|
||||
|
||||
public void incRequests(final int inc) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
|||
* @param value the new value of the gauge.
|
||||
*/
|
||||
public void setGauge(String gaugeName, long value) {
|
||||
MutableGaugeLong gaugeInt = getLongGauge(gaugeName, value);
|
||||
MutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName, value);
|
||||
gaugeInt.set(value);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
|||
* @param delta The amount to increment the gauge by.
|
||||
*/
|
||||
public void incGauge(String gaugeName, long delta) {
|
||||
MutableGaugeLong gaugeInt = getLongGauge(gaugeName, 0l);
|
||||
MutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName, 0l);
|
||||
gaugeInt.incr(delta);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
|||
* @param delta the ammount to subtract from a gauge value.
|
||||
*/
|
||||
public void decGauge(String gaugeName, long delta) {
|
||||
MutableGaugeLong gaugeInt = getLongGauge(gaugeName, 0l);
|
||||
MutableGaugeLong gaugeInt = metricsRegistry.getLongGauge(gaugeName, 0l);
|
||||
gaugeInt.decr(delta);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
|||
* @param delta the ammount to increment
|
||||
*/
|
||||
public void incCounters(String key, long delta) {
|
||||
MutableCounterLong counter = getLongCounter(key, 0l);
|
||||
MutableCounterLong counter = metricsRegistry.getLongCounter(key, 0l);
|
||||
counter.incr(delta);
|
||||
|
||||
}
|
||||
|
@ -129,28 +129,6 @@ public class BaseMetricsSourceImpl implements BaseMetricsSource, MetricsSource {
|
|||
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
|
||||
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
|
||||
metricsRegistry.snapshot(metricsCollector.addRecord(metricsRegistry.info()), all);
|
||||
|
|
Loading…
Reference in New Issue