001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.io.hfile; 019 020import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 021import org.apache.hadoop.hbase.metrics.impl.FastLongHistogram; 022import org.apache.yetus.audience.InterfaceAudience; 023 024/** 025 * Snapshot of block cache age in cache. 026 * This object is preferred because we can control how it is serialized out when JSON'ing. 027 */ 028@InterfaceAudience.Private 029@JsonIgnoreProperties({"ageHistogram", "snapshot"}) 030public class AgeSnapshot { 031 032 private final FastLongHistogram ageHistogram; 033 private final long[] quantiles; 034 035 AgeSnapshot(final FastLongHistogram ageHistogram) { 036 this.ageHistogram = ageHistogram; 037 this.quantiles = ageHistogram.getQuantiles(new double[]{0.75, 0.95, 0.98, 0.99, 0.999}); 038 } 039 040 public double get75thPercentile() { 041 return quantiles[0]; 042 } 043 044 public double get95thPercentile() { 045 return quantiles[1]; 046 } 047 048 public double get98thPercentile() { 049 return quantiles[2]; 050 } 051 052 public double get99thPercentile() { 053 return quantiles[3]; 054 } 055 056 public double get999thPercentile() { 057 return quantiles[4]; 058 } 059 060 061 public double getMean() { 062 return this.ageHistogram.getMean(); 063 } 064 065 public double getMax() { 066 return this.ageHistogram.getMax(); 067 } 068 069 public double getMin() { 070 return this.ageHistogram.getMin(); 071 } 072}