1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.apache.hadoop.hbase.io.hfile;
19
20 import org.apache.hadoop.hbase.metrics.impl.FastLongHistogram;
21
22 /**
23 * Snapshot of block cache age in cache.
24 * This object is preferred because we can control how it is serialized out when JSON'ing.
25 */
26 public class AgeSnapshot {
27
28 private transient final FastLongHistogram ageHistogram;
29 private transient final long[] quantiles;
30
31 AgeSnapshot(final FastLongHistogram ageHistogram) {
32 this.ageHistogram = ageHistogram;
33 this.quantiles = ageHistogram.getQuantiles(new double[]{0.75, 0.95, 0.98, 0.99, 0.999});
34 }
35
36 public double get75thPercentile() {
37 return quantiles[0];
38 }
39
40 public double get95thPercentile() {
41 return quantiles[1];
42 }
43
44 public double get98thPercentile() {
45 return quantiles[2];
46 }
47
48 public double get99thPercentile() {
49 return quantiles[3];
50 }
51
52 public double get999thPercentile() {
53 return quantiles[4];
54 }
55
56
57 public double getMean() {
58 return this.ageHistogram.getMean();
59 }
60
61 public double getMax() {
62 return this.ageHistogram.getMax();
63 }
64
65 public double getMin() {
66 return this.ageHistogram.getMin();
67 }
68 }