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