View Javadoc

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.codehaus.jackson.annotate.JsonIgnoreProperties;
21  
22  import com.yammer.metrics.core.Histogram;
23  import com.yammer.metrics.stats.Snapshot;
24  
25  /**
26   * Snapshot of block cache age in cache.
27   * This object is preferred because we can control how it is serialized out when JSON'ing.
28   */
29  @JsonIgnoreProperties({"ageHistogram", "snapshot"})
30  public class AgeSnapshot {
31    private final Histogram ageHistogram;
32    private final Snapshot snapshot;
33  
34    AgeSnapshot(final Histogram ageHistogram) {
35      this.ageHistogram = ageHistogram;
36      this.snapshot = ageHistogram.getSnapshot();
37    }
38  
39    public double get75thPercentile() {
40      return snapshot.get75thPercentile();
41    }
42  
43    public double get95thPercentile() {
44      return snapshot.get95thPercentile();
45    }
46  
47    public double get98thPercentile() {
48      return snapshot.get98thPercentile();
49    }
50  
51    public double get999thPercentile() {
52      return snapshot.get999thPercentile();
53    }
54  
55    public double get99thPercentile() {
56      return snapshot.get99thPercentile();
57    }
58  
59    public double getMean() {
60      return this.ageHistogram.mean();
61    }
62  
63    public double getMax() {
64      return ageHistogram.max();
65    }
66  
67    public double getMin() {
68      return ageHistogram.min();
69    }
70  
71    public double getStdDev() {
72      return ageHistogram.stdDev();
73    }
74  }