HBASE-15222 Addendum - Use less contended classes for metrics
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/77133fd2 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/77133fd2 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/77133fd2 Branch: refs/heads/hbase-12439 Commit: 77133fd225df9f65be87ce97b38676d2bab48a71 Parents: 43f99de Author: Elliott Clark <ecl...@apache.org> Authored: Thu Feb 25 09:08:11 2016 -0800 Committer: Elliott Clark <ecl...@apache.org> Committed: Thu Feb 25 09:08:11 2016 -0800 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/util/FastLongHistogram.java | 10 +++------- .../org/apache/hadoop/metrics2/lib/MutableHistogram.java | 4 +++- .../apache/hadoop/metrics2/lib/MutableRangeHistogram.java | 6 ++++-- 3 files changed, 10 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/77133fd2/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FastLongHistogram.java ---------------------------------------------------------------------- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FastLongHistogram.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FastLongHistogram.java index 78b2bf0..9b403d9 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FastLongHistogram.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/FastLongHistogram.java @@ -310,12 +310,8 @@ public class FastLongHistogram { * Resets the histogram for new counting. */ public FastLongHistogram reset() { - if (this.bins.hasData.get()) { - Bins oldBins = this.bins; - this.bins = new Bins(this.bins, this.bins.counts.length - 3, 0.01, 0.99); - return new FastLongHistogram(oldBins); - } - - return null; + Bins oldBins = this.bins; + this.bins = new Bins(this.bins, this.bins.counts.length - 3, 0.01, 0.99); + return new FastLongHistogram(oldBins); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/77133fd2/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableHistogram.java ---------------------------------------------------------------------- diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableHistogram.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableHistogram.java index 717e0ee..5b4a294 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableHistogram.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableHistogram.java @@ -63,7 +63,9 @@ public class MutableHistogram extends MutableMetric implements MetricHistogram { public synchronized void snapshot(MetricsRecordBuilder metricsRecordBuilder, boolean all) { // Get a reference to the old histogram. FastLongHistogram histo = histogram.reset(); - updateSnapshotMetrics(metricsRecordBuilder, histo); + if (histo != null) { + updateSnapshotMetrics(metricsRecordBuilder, histo); + } } protected void updateSnapshotMetrics(MetricsRecordBuilder metricsRecordBuilder, http://git-wip-us.apache.org/repos/asf/hbase/blob/77133fd2/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java ---------------------------------------------------------------------- diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java index ac8aee0..13187af 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/metrics2/lib/MutableRangeHistogram.java @@ -56,8 +56,10 @@ public abstract class MutableRangeHistogram extends MutableHistogram implements public synchronized void snapshot(MetricsRecordBuilder metricsRecordBuilder, boolean all) { // Get a reference to the old histogram. FastLongHistogram histo = histogram.reset(); - updateSnapshotMetrics(metricsRecordBuilder, histo); - updateSnapshotRangeMetrics(metricsRecordBuilder, histo); + if (histo != null) { + updateSnapshotMetrics(metricsRecordBuilder, histo); + updateSnapshotRangeMetrics(metricsRecordBuilder, histo); + } } public void updateSnapshotRangeMetrics(MetricsRecordBuilder metricsRecordBuilder,