diff --git a/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/FastLongHistogram.java b/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/FastLongHistogram.java index b1b47e3904e..85046dfe55c 100644 --- a/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/FastLongHistogram.java +++ b/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/FastLongHistogram.java @@ -312,8 +312,16 @@ public class FastLongHistogram { * Resets the histogram for new counting. */ public Snapshot snapshotAndReset() { - final Bins oldBins = this.bins; + Snapshot snapshot = snapshot(); this.bins = new Bins(this.bins, this.bins.counts.length - 3, 0.01, 0.99); + return snapshot; + } + + /** + * do snapshot without reset + */ + public Snapshot snapshot() { + final Bins oldBins = this.bins; final long[] percentiles = oldBins.getQuantiles(DEFAULT_QUANTILES); final long count = oldBins.count.sum(); diff --git a/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/HistogramImpl.java b/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/HistogramImpl.java index c29b267e347..cb82a2a5033 100644 --- a/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/HistogramImpl.java +++ b/hbase-metrics/src/main/java/org/apache/hadoop/hbase/metrics/impl/HistogramImpl.java @@ -78,7 +78,7 @@ public class HistogramImpl implements Histogram { @Override public Snapshot snapshot() { - return histogram.snapshotAndReset(); + return histogram.snapshot(); } public long[] getQuantiles(double[] quantiles) {