diff --git hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java index 329727b..200e621 100644 --- hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java +++ hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java @@ -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) { diff --git hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java index efb8d4c..15f00a3 100644 --- hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java +++ hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java @@ -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. diff --git hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java index 7050417..89b6ddb 100644 --- hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java +++ hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/metrics/MasterMetricsSourceImpl.java @@ -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) { diff --git hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java index 7155c4e..1e619e9 100644 --- hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java +++ hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseMetricsSourceImpl.java @@ -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);