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;
019
020import java.util.Map;
021import org.apache.hadoop.hbase.client.CompactionState;
022import org.apache.hadoop.hbase.util.Bytes;
023import org.apache.yetus.audience.InterfaceAudience;
024
025/**
026 * Encapsulates per-region load metrics.
027 */
028@InterfaceAudience.Public
029public interface RegionMetrics {
030
031  /** Returns the region name */
032  byte[] getRegionName();
033
034  /** Returns the number of stores */
035  int getStoreCount();
036
037  /** Returns the number of storefiles */
038  int getStoreFileCount();
039
040  /** Returns the total size of the storefiles */
041  Size getStoreFileSize();
042
043  /** Returns the memstore size */
044  Size getMemStoreSize();
045
046  /** Returns the number of read requests made to region */
047  long getReadRequestCount();
048
049  /** Returns the number of write requests made to region */
050  long getWriteRequestCount();
051
052  /** Returns the number of write requests and read requests made to region */
053  default long getRequestCount() {
054    return getReadRequestCount() + getWriteRequestCount();
055  }
056
057  /** Returns the region name as a string */
058  default String getNameAsString() {
059    return Bytes.toStringBinary(getRegionName());
060  }
061
062  /** Returns the number of filtered read requests made to region */
063  long getFilteredReadRequestCount();
064
065  /**
066   * TODO: why we pass the same value to different counters? Currently, the value from
067   * getStoreFileIndexSize() is same with getStoreFileRootLevelIndexSize() see
068   * HRegionServer#createRegionLoad.
069   * @return The current total size of root-level indexes for the region
070   */
071  Size getStoreFileIndexSize();
072
073  /** Returns The current total size of root-level indexes for the region */
074  Size getStoreFileRootLevelIndexSize();
075
076  /** Returns The total size of all index blocks, not just the root level */
077  Size getStoreFileUncompressedDataIndexSize();
078
079  /** Returns The total size of all Bloom filter blocks, not just loaded into the block cache */
080  Size getBloomFilterSize();
081
082  /** Returns the total number of cells in current compaction */
083  long getCompactingCellCount();
084
085  /** Returns the number of already compacted kvs in current compaction */
086  long getCompactedCellCount();
087
088  /**
089   * This does not really belong inside RegionLoad but its being done in the name of expediency.
090   * @return the completed sequence Id for the region
091   */
092  long getCompletedSequenceId();
093
094  /** Returns completed sequence id per store. */
095  Map<byte[], Long> getStoreSequenceId();
096
097  /** Returns the uncompressed size of the storefiles */
098  Size getUncompressedStoreFileSize();
099
100  /** Returns the data locality of region in the regionserver. */
101  float getDataLocality();
102
103  /** Returns the timestamp of the oldest hfile for any store of this region. */
104  long getLastMajorCompactionTimestamp();
105
106  /** Returns the reference count for the stores of this region */
107  int getStoreRefCount();
108
109  /**
110   * Returns the max reference count for any store file among all compacted stores files of this
111   * region
112   */
113  int getMaxCompactedStoreFileRefCount();
114
115  /**
116   * Different from dataLocality,this metric's numerator only include the data stored on ssd
117   * @return the data locality for ssd of region in the regionserver
118   */
119  float getDataLocalityForSsd();
120
121  /** Returns the data at local weight of this region in the regionserver */
122  long getBlocksLocalWeight();
123
124  /**
125   * Different from blocksLocalWeight,this metric's numerator only include the data stored on ssd
126   * @return the data at local with ssd weight of this region in the regionserver
127   */
128  long getBlocksLocalWithSsdWeight();
129
130  /** Returns the block total weight of this region */
131  long getBlocksTotalWeight();
132
133  /** Returns the compaction state of this region */
134  CompactionState getCompactionState();
135
136  /** Returns the total size of the hfiles in the region */
137  Size getRegionSizeMB();
138
139  /** Returns current prefetch ratio of this region on this server */
140  float getCurrentRegionCachedRatio();
141}