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 write requests and read requests made to region 071 */ 072 default long getRequestCount() { 073 return getReadRequestCount() + getWriteRequestCount(); 074 } 075 076 /** 077 * @return the region name as a string 078 */ 079 default String getNameAsString() { 080 return Bytes.toStringBinary(getRegionName()); 081 } 082 083 /** 084 * @return the number of filtered read requests made to region 085 */ 086 long getFilteredReadRequestCount(); 087 088 /** 089 * TODO: why we pass the same value to different counters? Currently, the value from 090 * getStoreFileIndexSize() is same with getStoreFileRootLevelIndexSize() 091 * see HRegionServer#createRegionLoad. 092 * @return The current total size of root-level indexes for the region 093 */ 094 Size getStoreFileIndexSize(); 095 096 /** 097 * @return The current total size of root-level indexes for the region 098 */ 099 Size getStoreFileRootLevelIndexSize(); 100 101 /** 102 * @return The total size of all index blocks, not just the root level 103 */ 104 Size getStoreFileUncompressedDataIndexSize(); 105 106 /** 107 * @return The total size of all Bloom filter blocks, not just loaded into the block cache 108 */ 109 Size getBloomFilterSize(); 110 111 /** 112 * @return the total number of cells in current compaction 113 */ 114 long getCompactingCellCount(); 115 116 /** 117 * @return the number of already compacted kvs in current compaction 118 */ 119 long getCompactedCellCount(); 120 121 /** 122 * This does not really belong inside RegionLoad but its being done in the name of expediency. 123 * @return the completed sequence Id for the region 124 */ 125 long getCompletedSequenceId(); 126 127 /** 128 * @return completed sequence id per store. 129 */ 130 Map<byte[], Long> getStoreSequenceId(); 131 132 133 /** 134 * @return the uncompressed size of the storefiles 135 */ 136 Size getUncompressedStoreFileSize(); 137 138 /** 139 * @return the data locality of region in the regionserver. 140 */ 141 float getDataLocality(); 142 143 /** 144 * @return the timestamp of the oldest hfile for any store of this region. 145 */ 146 long getLastMajorCompactionTimestamp(); 147 148 /** 149 * @return the reference count for the stores of this region 150 */ 151 int getStoreRefCount(); 152 153 /** 154 * @return the max reference count for any store file among all compacted stores files 155 * of this region 156 */ 157 int getMaxCompactedStoreFileRefCount(); 158 159 /** 160 * Different from dataLocality,this metric's numerator only include the data stored on ssd 161 * @return the data locality for ssd of region in the regionserver 162 */ 163 float getDataLocalityForSsd(); 164 165 /** 166 * @return the data at local weight of this region in the regionserver 167 */ 168 long getBlocksLocalWeight(); 169 170 /** 171 * Different from blocksLocalWeight,this metric's numerator only include the data stored on ssd 172 * @return the data at local with ssd weight of this region in the regionserver 173 */ 174 long getBlocksLocalWithSsdWeight(); 175 176 /** 177 * @return the block total weight of this region 178 */ 179 long getBlocksTotalWeight(); 180 181 /** 182 * @return the compaction state of this region 183 */ 184 CompactionState getCompactionState(); 185}