001/**
002 * Copyright The Apache Software Foundation
003 *
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *     http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020
021package org.apache.hadoop.hbase;
022
023import java.util.Map;
024import org.apache.hadoop.hbase.client.CompactionState;
025import org.apache.hadoop.hbase.util.Bytes;
026import org.apache.yetus.audience.InterfaceAudience;
027
028/**
029  * Encapsulates per-region load metrics.
030  */
031@InterfaceAudience.Public
032public interface RegionMetrics {
033
034  /**
035   * @return the region name
036   */
037  byte[] getRegionName();
038
039  /**
040   * @return the number of stores
041   */
042  int getStoreCount();
043
044  /**
045   * @return the number of storefiles
046   */
047  int getStoreFileCount();
048
049  /**
050   * @return the total size of the storefiles
051   */
052  Size getStoreFileSize();
053
054  /**
055   * @return the memstore size
056   */
057  Size getMemStoreSize();
058
059  /**
060   * @return the number of read requests made to region
061   */
062  long getReadRequestCount();
063
064  /**
065   * @return the number of write requests made to region
066   */
067  long getWriteRequestCount();
068
069  /**
070   * @return the number of coprocessor service requests made to region
071   */
072  public long getCpRequestCount();
073
074  /**
075   * @return the number of write requests and read requests and coprocessor
076   *         service requests made to region
077   */
078  default long getRequestCount() {
079    return getReadRequestCount() + getWriteRequestCount() + getCpRequestCount();
080  }
081
082  /**
083   * @return the region name as a string
084   */
085  default String getNameAsString() {
086    return Bytes.toStringBinary(getRegionName());
087  }
088
089  /**
090   * @return the number of filtered read requests made to region
091   */
092  long getFilteredReadRequestCount();
093
094  /**
095   * TODO: why we pass the same value to different counters? Currently, the value from
096   * getStoreFileIndexSize() is same with getStoreFileRootLevelIndexSize()
097   * see HRegionServer#createRegionLoad.
098   * @return The current total size of root-level indexes for the region
099   */
100  Size getStoreFileIndexSize();
101
102  /**
103   * @return The current total size of root-level indexes for the region
104   */
105  Size getStoreFileRootLevelIndexSize();
106
107  /**
108   * @return The total size of all index blocks, not just the root level
109   */
110  Size getStoreFileUncompressedDataIndexSize();
111
112  /**
113   * @return The total size of all Bloom filter blocks, not just loaded into the block cache
114   */
115  Size getBloomFilterSize();
116
117  /**
118   * @return the total number of cells in current compaction
119   */
120  long getCompactingCellCount();
121
122  /**
123   * @return the number of already compacted kvs in current compaction
124   */
125  long getCompactedCellCount();
126
127  /**
128   * This does not really belong inside RegionLoad but its being done in the name of expediency.
129   * @return the completed sequence Id for the region
130   */
131  long getCompletedSequenceId();
132
133  /**
134   * @return completed sequence id per store.
135   */
136  Map<byte[], Long> getStoreSequenceId();
137
138
139  /**
140   * @return the uncompressed size of the storefiles
141   */
142  Size getUncompressedStoreFileSize();
143
144  /**
145   * @return the data locality of region in the regionserver.
146   */
147  float getDataLocality();
148
149  /**
150   * @return the timestamp of the oldest hfile for any store of this region.
151   */
152  long getLastMajorCompactionTimestamp();
153
154  /**
155   * @return the reference count for the stores of this region
156   */
157  int getStoreRefCount();
158
159  /**
160   * @return the max reference count for any store file among all compacted stores files
161   *   of this region
162   */
163  int getMaxCompactedStoreFileRefCount();
164
165  /**
166   * Different from dataLocality,this metric's numerator only include the data stored on ssd
167   * @return the data locality for ssd of region in the regionserver
168   */
169  float getDataLocalityForSsd();
170
171  /**
172   * @return the data at local weight of this region in the regionserver
173   */
174  long getBlocksLocalWeight();
175
176  /**
177   * Different from blocksLocalWeight,this metric's numerator only include the data stored on ssd
178   * @return the data at local with ssd weight of this region in the regionserver
179   */
180  long getBlocksLocalWithSsdWeight();
181
182  /**
183   * @return the block total weight of this region
184   */
185  long getBlocksTotalWeight();
186
187  /**
188   * @return the compaction state of this region
189   */
190  CompactionState getCompactionState();
191}