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 coprocessor service requests made to region */
053  public long getCpRequestCount();
054
055  /**
056   * Returns the number of write requests and read requests and coprocessor service requests made to
057   * region
058   */
059  default long getRequestCount() {
060    return getReadRequestCount() + getWriteRequestCount() + getCpRequestCount();
061  }
062
063  /** Returns the region name as a string */
064  default String getNameAsString() {
065    return Bytes.toStringBinary(getRegionName());
066  }
067
068  /** Returns the number of filtered read requests made to region */
069  long getFilteredReadRequestCount();
070
071  /**
072   * TODO: why we pass the same value to different counters? Currently, the value from
073   * getStoreFileIndexSize() is same with getStoreFileRootLevelIndexSize() see
074   * HRegionServer#createRegionLoad.
075   * @return The current total size of root-level indexes for the region
076   */
077  Size getStoreFileIndexSize();
078
079  /** Returns The current total size of root-level indexes for the region */
080  Size getStoreFileRootLevelIndexSize();
081
082  /** Returns The total size of all index blocks, not just the root level */
083  Size getStoreFileUncompressedDataIndexSize();
084
085  /** Returns The total size of all Bloom filter blocks, not just loaded into the block cache */
086  Size getBloomFilterSize();
087
088  /** Returns the total number of cells in current compaction */
089  long getCompactingCellCount();
090
091  /** Returns the number of already compacted kvs in current compaction */
092  long getCompactedCellCount();
093
094  /**
095   * This does not really belong inside RegionLoad but its being done in the name of expediency.
096   * @return the completed sequence Id for the region
097   */
098  long getCompletedSequenceId();
099
100  /** Returns completed sequence id per store. */
101  Map<byte[], Long> getStoreSequenceId();
102
103  /** Returns the uncompressed size of the storefiles */
104  Size getUncompressedStoreFileSize();
105
106  /** Returns the data locality of region in the regionserver. */
107  float getDataLocality();
108
109  /** Returns the timestamp of the oldest hfile for any store of this region. */
110  long getLastMajorCompactionTimestamp();
111
112  /** Returns the reference count for the stores of this region */
113  int getStoreRefCount();
114
115  /**
116   * Returns the max reference count for any store file among all compacted stores files of this
117   * region
118   */
119  int getMaxCompactedStoreFileRefCount();
120
121  /**
122   * Different from dataLocality,this metric's numerator only include the data stored on ssd
123   * @return the data locality for ssd of region in the regionserver
124   */
125  float getDataLocalityForSsd();
126
127  /** Returns the data at local weight of this region in the regionserver */
128  long getBlocksLocalWeight();
129
130  /**
131   * Different from blocksLocalWeight,this metric's numerator only include the data stored on ssd
132   * @return the data at local with ssd weight of this region in the regionserver
133   */
134  long getBlocksLocalWithSsdWeight();
135
136  /** Returns the block total weight of this region */
137  long getBlocksTotalWeight();
138
139  /** Returns the compaction state of this region */
140  CompactionState getCompactionState();
141}