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.regionserver; 019 020import org.apache.hadoop.hbase.metrics.BaseSourceImpl; 021import org.apache.hadoop.hbase.metrics.Interns; 022import org.apache.hadoop.metrics2.MetricHistogram; 023import org.apache.hadoop.metrics2.MetricsCollector; 024import org.apache.hadoop.metrics2.MetricsRecordBuilder; 025import org.apache.hadoop.metrics2.lib.MutableFastCounter; 026import org.apache.yetus.audience.InterfaceAudience; 027 028/** 029 * Hadoop2 implementation of MetricsRegionServerSource. Implements BaseSource through 030 * BaseSourceImpl, following the pattern 031 */ 032@InterfaceAudience.Private 033public class MetricsRegionServerSourceImpl extends BaseSourceImpl 034 implements MetricsRegionServerSource { 035 036 final MetricsRegionServerWrapper rsWrap; 037 private final MetricHistogram putHisto; 038 private final MetricHistogram putBatchHisto; 039 private final MetricHistogram deleteHisto; 040 private final MetricHistogram deleteBatchHisto; 041 private final MetricHistogram checkAndDeleteHisto; 042 private final MetricHistogram checkAndPutHisto; 043 private final MetricHistogram checkAndMutateHisto; 044 private final MetricHistogram getHisto; 045 private final MetricHistogram incrementHisto; 046 private final MetricHistogram appendHisto; 047 private final MetricHistogram replayHisto; 048 private final MetricHistogram scanSizeHisto; 049 private final MetricHistogram scanTimeHisto; 050 051 private final MutableFastCounter blockBytesScannedCount; 052 private final MetricHistogram checkAndMutateBlockBytesScanned; 053 private final MetricHistogram getBlockBytesScanned; 054 private final MetricHistogram incrementBlockBytesScanned; 055 private final MetricHistogram appendBlockBytesScanned; 056 private final MetricHistogram scanBlockBytesScanned; 057 058 private final MutableFastCounter slowPut; 059 private final MutableFastCounter slowDelete; 060 private final MutableFastCounter slowGet; 061 private final MutableFastCounter slowIncrement; 062 private final MutableFastCounter slowAppend; 063 064 // split related metrics 065 private final MutableFastCounter splitRequest; 066 private final MutableFastCounter splitSuccess; 067 private final MetricHistogram splitTimeHisto; 068 069 // flush related metrics 070 private final MetricHistogram flushTimeHisto; 071 private final MetricHistogram flushMemstoreSizeHisto; 072 private final MetricHistogram flushOutputSizeHisto; 073 private final MutableFastCounter flushedMemstoreBytes; 074 private final MutableFastCounter flushedOutputBytes; 075 076 // compaction related metrics 077 private final MetricHistogram compactionTimeHisto; 078 private final MetricHistogram compactionInputFileCountHisto; 079 private final MetricHistogram compactionInputSizeHisto; 080 private final MetricHistogram compactionOutputFileCountHisto; 081 private final MetricHistogram compactionOutputSizeHisto; 082 private final MutableFastCounter compactedInputBytes; 083 private final MutableFastCounter compactedOutputBytes; 084 085 private final MetricHistogram majorCompactionTimeHisto; 086 private final MetricHistogram majorCompactionInputFileCountHisto; 087 private final MetricHistogram majorCompactionInputSizeHisto; 088 private final MetricHistogram majorCompactionOutputFileCountHisto; 089 private final MetricHistogram majorCompactionOutputSizeHisto; 090 private final MutableFastCounter majorCompactedInputBytes; 091 private final MutableFastCounter majorCompactedOutputBytes; 092 093 // pause monitor metrics 094 private final MutableFastCounter infoPauseThresholdExceeded; 095 private final MutableFastCounter warnPauseThresholdExceeded; 096 private final MetricHistogram pausesWithGc; 097 private final MetricHistogram pausesWithoutGc; 098 099 private final MutableFastCounter scannerLeaseExpiredCount; 100 101 public MetricsRegionServerSourceImpl(MetricsRegionServerWrapper rsWrap) { 102 this(METRICS_NAME, METRICS_DESCRIPTION, METRICS_CONTEXT, METRICS_JMX_CONTEXT, rsWrap); 103 } 104 105 public MetricsRegionServerSourceImpl(String metricsName, String metricsDescription, 106 String metricsContext, String metricsJmxContext, MetricsRegionServerWrapper rsWrap) { 107 super(metricsName, metricsDescription, metricsContext, metricsJmxContext); 108 this.rsWrap = rsWrap; 109 110 putHisto = getMetricsRegistry().newTimeHistogram(PUT_KEY); 111 putBatchHisto = getMetricsRegistry().newTimeHistogram(PUT_BATCH_KEY); 112 slowPut = getMetricsRegistry().newCounter(SLOW_PUT_KEY, SLOW_PUT_DESC, 0L); 113 114 deleteHisto = getMetricsRegistry().newTimeHistogram(DELETE_KEY); 115 slowDelete = getMetricsRegistry().newCounter(SLOW_DELETE_KEY, SLOW_DELETE_DESC, 0L); 116 117 deleteBatchHisto = getMetricsRegistry().newTimeHistogram(DELETE_BATCH_KEY); 118 checkAndDeleteHisto = getMetricsRegistry().newTimeHistogram(CHECK_AND_DELETE_KEY); 119 checkAndPutHisto = getMetricsRegistry().newTimeHistogram(CHECK_AND_PUT_KEY); 120 checkAndMutateHisto = getMetricsRegistry().newTimeHistogram(CHECK_AND_MUTATE_KEY); 121 122 getHisto = getMetricsRegistry().newTimeHistogram(GET_KEY); 123 slowGet = getMetricsRegistry().newCounter(SLOW_GET_KEY, SLOW_GET_DESC, 0L); 124 125 incrementHisto = getMetricsRegistry().newTimeHistogram(INCREMENT_KEY); 126 slowIncrement = getMetricsRegistry().newCounter(SLOW_INCREMENT_KEY, SLOW_INCREMENT_DESC, 0L); 127 128 appendHisto = getMetricsRegistry().newTimeHistogram(APPEND_KEY); 129 slowAppend = getMetricsRegistry().newCounter(SLOW_APPEND_KEY, SLOW_APPEND_DESC, 0L); 130 131 replayHisto = getMetricsRegistry().newTimeHistogram(REPLAY_KEY); 132 scanSizeHisto = getMetricsRegistry().newSizeHistogram(SCAN_SIZE_KEY); 133 scanTimeHisto = getMetricsRegistry().newTimeHistogram(SCAN_TIME_KEY); 134 135 blockBytesScannedCount = 136 getMetricsRegistry().newCounter(BLOCK_BYTES_SCANNED_KEY, BLOCK_BYTES_SCANNED_DESC, 0L); 137 checkAndMutateBlockBytesScanned = 138 getMetricsRegistry().newSizeHistogram(CHECK_AND_MUTATE_BLOCK_BYTES_SCANNED_KEY); 139 getBlockBytesScanned = getMetricsRegistry().newSizeHistogram(GET_BLOCK_BYTES_SCANNED_KEY); 140 incrementBlockBytesScanned = 141 getMetricsRegistry().newSizeHistogram(INCREMENT_BLOCK_BYTES_SCANNED_KEY); 142 appendBlockBytesScanned = getMetricsRegistry().newSizeHistogram(APPEND_BLOCK_BYTES_SCANNED_KEY); 143 scanBlockBytesScanned = getMetricsRegistry().newSizeHistogram(SCAN_BLOCK_BYTES_SCANNED_KEY); 144 145 flushTimeHisto = getMetricsRegistry().newTimeHistogram(FLUSH_TIME, FLUSH_TIME_DESC); 146 flushMemstoreSizeHisto = 147 getMetricsRegistry().newSizeHistogram(FLUSH_MEMSTORE_SIZE, FLUSH_MEMSTORE_SIZE_DESC); 148 flushOutputSizeHisto = 149 getMetricsRegistry().newSizeHistogram(FLUSH_OUTPUT_SIZE, FLUSH_OUTPUT_SIZE_DESC); 150 flushedOutputBytes = 151 getMetricsRegistry().newCounter(FLUSHED_OUTPUT_BYTES, FLUSHED_OUTPUT_BYTES_DESC, 0L); 152 flushedMemstoreBytes = 153 getMetricsRegistry().newCounter(FLUSHED_MEMSTORE_BYTES, FLUSHED_MEMSTORE_BYTES_DESC, 0L); 154 155 compactionTimeHisto = 156 getMetricsRegistry().newTimeHistogram(COMPACTION_TIME, COMPACTION_TIME_DESC); 157 compactionInputFileCountHisto = getMetricsRegistry().newHistogram(COMPACTION_INPUT_FILE_COUNT, 158 COMPACTION_INPUT_FILE_COUNT_DESC); 159 compactionInputSizeHisto = 160 getMetricsRegistry().newSizeHistogram(COMPACTION_INPUT_SIZE, COMPACTION_INPUT_SIZE_DESC); 161 compactionOutputFileCountHisto = getMetricsRegistry().newHistogram(COMPACTION_OUTPUT_FILE_COUNT, 162 COMPACTION_OUTPUT_FILE_COUNT_DESC); 163 compactionOutputSizeHisto = 164 getMetricsRegistry().newSizeHistogram(COMPACTION_OUTPUT_SIZE, COMPACTION_OUTPUT_SIZE_DESC); 165 compactedInputBytes = 166 getMetricsRegistry().newCounter(COMPACTED_INPUT_BYTES, COMPACTED_INPUT_BYTES_DESC, 0L); 167 compactedOutputBytes = 168 getMetricsRegistry().newCounter(COMPACTED_OUTPUT_BYTES, COMPACTED_OUTPUT_BYTES_DESC, 0L); 169 170 majorCompactionTimeHisto = 171 getMetricsRegistry().newTimeHistogram(MAJOR_COMPACTION_TIME, MAJOR_COMPACTION_TIME_DESC); 172 majorCompactionInputFileCountHisto = getMetricsRegistry() 173 .newHistogram(MAJOR_COMPACTION_INPUT_FILE_COUNT, MAJOR_COMPACTION_INPUT_FILE_COUNT_DESC); 174 majorCompactionInputSizeHisto = getMetricsRegistry() 175 .newSizeHistogram(MAJOR_COMPACTION_INPUT_SIZE, MAJOR_COMPACTION_INPUT_SIZE_DESC); 176 majorCompactionOutputFileCountHisto = getMetricsRegistry() 177 .newHistogram(MAJOR_COMPACTION_OUTPUT_FILE_COUNT, MAJOR_COMPACTION_OUTPUT_FILE_COUNT_DESC); 178 majorCompactionOutputSizeHisto = getMetricsRegistry() 179 .newSizeHistogram(MAJOR_COMPACTION_OUTPUT_SIZE, MAJOR_COMPACTION_OUTPUT_SIZE_DESC); 180 majorCompactedInputBytes = getMetricsRegistry().newCounter(MAJOR_COMPACTED_INPUT_BYTES, 181 MAJOR_COMPACTED_INPUT_BYTES_DESC, 0L); 182 majorCompactedOutputBytes = getMetricsRegistry().newCounter(MAJOR_COMPACTED_OUTPUT_BYTES, 183 MAJOR_COMPACTED_OUTPUT_BYTES_DESC, 0L); 184 185 splitTimeHisto = getMetricsRegistry().newTimeHistogram(SPLIT_KEY); 186 splitRequest = getMetricsRegistry().newCounter(SPLIT_REQUEST_KEY, SPLIT_REQUEST_DESC, 0L); 187 splitSuccess = getMetricsRegistry().newCounter(SPLIT_SUCCESS_KEY, SPLIT_SUCCESS_DESC, 0L); 188 189 // pause monitor metrics 190 infoPauseThresholdExceeded = 191 getMetricsRegistry().newCounter(INFO_THRESHOLD_COUNT_KEY, INFO_THRESHOLD_COUNT_DESC, 0L); 192 warnPauseThresholdExceeded = 193 getMetricsRegistry().newCounter(WARN_THRESHOLD_COUNT_KEY, WARN_THRESHOLD_COUNT_DESC, 0L); 194 pausesWithGc = getMetricsRegistry().newTimeHistogram(PAUSE_TIME_WITH_GC_KEY); 195 pausesWithoutGc = getMetricsRegistry().newTimeHistogram(PAUSE_TIME_WITHOUT_GC_KEY); 196 197 scannerLeaseExpiredCount = getMetricsRegistry().newCounter(SCANNER_LEASE_EXPIRED_COUNT, 198 SCANNER_LEASE_EXPIRED_COUNT_DESC, 0L); 199 } 200 201 @Override 202 public void updatePut(long t) { 203 putHisto.add(t); 204 } 205 206 @Override 207 public void updateDelete(long t) { 208 deleteHisto.add(t); 209 } 210 211 @Override 212 public void updateGet(long t, long blockBytesScanned) { 213 getHisto.add(t); 214 if (blockBytesScanned > 0) { 215 blockBytesScannedCount.incr(blockBytesScanned); 216 getBlockBytesScanned.add(blockBytesScanned); 217 } 218 } 219 220 @Override 221 public void updateIncrement(long t, long blockBytesScanned) { 222 incrementHisto.add(t); 223 if (blockBytesScanned > 0) { 224 blockBytesScannedCount.incr(blockBytesScanned); 225 incrementBlockBytesScanned.add(blockBytesScanned); 226 } 227 } 228 229 @Override 230 public void updateAppend(long t, long blockBytesScanned) { 231 appendHisto.add(t); 232 if (blockBytesScanned > 0) { 233 blockBytesScannedCount.incr(blockBytesScanned); 234 appendBlockBytesScanned.add(blockBytesScanned); 235 } 236 } 237 238 @Override 239 public void updateReplay(long t) { 240 replayHisto.add(t); 241 } 242 243 @Override 244 public void updateScan(long time, long responseSize, long blockBytesScanned) { 245 scanTimeHisto.add(time); 246 scanSizeHisto.add(responseSize); 247 if (blockBytesScanned > 0) { 248 blockBytesScannedCount.incr(blockBytesScanned); 249 scanBlockBytesScanned.add(blockBytesScanned); 250 } 251 } 252 253 @Override 254 public void incrSlowPut() { 255 slowPut.incr(); 256 } 257 258 @Override 259 public void incrSlowDelete() { 260 slowDelete.incr(); 261 } 262 263 @Override 264 public void incrSlowGet() { 265 slowGet.incr(); 266 } 267 268 @Override 269 public void incrSlowIncrement() { 270 slowIncrement.incr(); 271 } 272 273 @Override 274 public void incrSlowAppend() { 275 slowAppend.incr(); 276 } 277 278 @Override 279 public void incrSplitRequest() { 280 splitRequest.incr(); 281 } 282 283 @Override 284 public void incrSplitSuccess() { 285 splitSuccess.incr(); 286 } 287 288 @Override 289 public void updateSplitTime(long t) { 290 splitTimeHisto.add(t); 291 } 292 293 @Override 294 public void updateFlushTime(long t) { 295 flushTimeHisto.add(t); 296 } 297 298 @Override 299 public void updateFlushMemStoreSize(long bytes) { 300 flushMemstoreSizeHisto.add(bytes); 301 flushedMemstoreBytes.incr(bytes); 302 } 303 304 @Override 305 public void updateFlushOutputSize(long bytes) { 306 flushOutputSizeHisto.add(bytes); 307 flushedOutputBytes.incr(bytes); 308 } 309 310 @Override 311 public void updateCompactionTime(boolean isMajor, long t) { 312 compactionTimeHisto.add(t); 313 if (isMajor) { 314 majorCompactionTimeHisto.add(t); 315 } 316 } 317 318 @Override 319 public void updateCompactionInputFileCount(boolean isMajor, long c) { 320 compactionInputFileCountHisto.add(c); 321 if (isMajor) { 322 majorCompactionInputFileCountHisto.add(c); 323 } 324 } 325 326 @Override 327 public void updateCompactionInputSize(boolean isMajor, long bytes) { 328 compactionInputSizeHisto.add(bytes); 329 compactedInputBytes.incr(bytes); 330 if (isMajor) { 331 majorCompactionInputSizeHisto.add(bytes); 332 majorCompactedInputBytes.incr(bytes); 333 } 334 } 335 336 @Override 337 public void updateCompactionOutputFileCount(boolean isMajor, long c) { 338 compactionOutputFileCountHisto.add(c); 339 if (isMajor) { 340 majorCompactionOutputFileCountHisto.add(c); 341 } 342 } 343 344 @Override 345 public void updateCompactionOutputSize(boolean isMajor, long bytes) { 346 compactionOutputSizeHisto.add(bytes); 347 compactedOutputBytes.incr(bytes); 348 if (isMajor) { 349 majorCompactionOutputSizeHisto.add(bytes); 350 majorCompactedOutputBytes.incr(bytes); 351 } 352 } 353 354 @Override 355 public void incrScannerLeaseExpired() { 356 scannerLeaseExpiredCount.incr(); 357 } 358 359 /** 360 * Yes this is a get function that doesn't return anything. Thanks Hadoop for breaking all 361 * expectations of java programmers. Instead of returning anything Hadoop metrics expects 362 * getMetrics to push the metrics into the collector. 363 * @param metricsCollector Collector to accept metrics 364 * @param all push all or only changed? 365 */ 366 @Override 367 public void getMetrics(MetricsCollector metricsCollector, boolean all) { 368 MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName); 369 370 // rsWrap can be null because this function is called inside of init. 371 if (rsWrap != null) { 372 addGaugesToMetricsRecordBuilder(mrb) 373 .addCounter(Interns.info(TOTAL_REQUEST_COUNT, TOTAL_REQUEST_COUNT_DESC), 374 rsWrap.getTotalRequestCount()) 375 .addCounter( 376 Interns.info(TOTAL_ROW_ACTION_REQUEST_COUNT, TOTAL_ROW_ACTION_REQUEST_COUNT_DESC), 377 rsWrap.getTotalRowActionRequestCount()) 378 .addCounter(Interns.info(READ_REQUEST_COUNT, READ_REQUEST_COUNT_DESC), 379 rsWrap.getReadRequestsCount()) 380 .addCounter(Interns.info(FILTERED_READ_REQUEST_COUNT, FILTERED_READ_REQUEST_COUNT_DESC), 381 rsWrap.getFilteredReadRequestsCount()) 382 .addCounter(Interns.info(WRITE_REQUEST_COUNT, WRITE_REQUEST_COUNT_DESC), 383 rsWrap.getWriteRequestsCount()) 384 .addCounter(Interns.info(RPC_GET_REQUEST_COUNT, RPC_GET_REQUEST_COUNT_DESC), 385 rsWrap.getRpcGetRequestsCount()) 386 .addCounter(Interns.info(RPC_FULL_SCAN_REQUEST_COUNT, RPC_FULL_SCAN_REQUEST_COUNT_DESC), 387 rsWrap.getRpcFullScanRequestsCount()) 388 .addCounter(Interns.info(RPC_SCAN_REQUEST_COUNT, RPC_SCAN_REQUEST_COUNT_DESC), 389 rsWrap.getRpcScanRequestsCount()) 390 .addCounter(Interns.info(RPC_MULTI_REQUEST_COUNT, RPC_MULTI_REQUEST_COUNT_DESC), 391 rsWrap.getRpcMultiRequestsCount()) 392 .addCounter(Interns.info(RPC_MUTATE_REQUEST_COUNT, RPC_MUTATE_REQUEST_COUNT_DESC), 393 rsWrap.getRpcMutateRequestsCount()) 394 .addCounter(Interns.info(CHECK_MUTATE_FAILED_COUNT, CHECK_MUTATE_FAILED_COUNT_DESC), 395 rsWrap.getCheckAndMutateChecksFailed()) 396 .addCounter(Interns.info(CHECK_MUTATE_PASSED_COUNT, CHECK_MUTATE_PASSED_COUNT_DESC), 397 rsWrap.getCheckAndMutateChecksPassed()) 398 .addCounter(Interns.info(BLOCK_CACHE_HIT_COUNT, BLOCK_CACHE_HIT_COUNT_DESC), 399 rsWrap.getBlockCacheHitCount()) 400 .addCounter(Interns.info(BLOCK_CACHE_PRIMARY_HIT_COUNT, BLOCK_CACHE_PRIMARY_HIT_COUNT_DESC), 401 rsWrap.getBlockCachePrimaryHitCount()) 402 .addCounter(Interns.info(BLOCK_CACHE_HIT_CACHING_COUNT, BLOCK_CACHE_HIT_CACHING_COUNT_DESC), 403 rsWrap.getBlockCacheHitCachingCount()) 404 .addCounter(Interns.info(BLOCK_CACHE_MISS_COUNT, BLOCK_COUNT_MISS_COUNT_DESC), 405 rsWrap.getBlockCacheMissCount()) 406 .addCounter( 407 Interns.info(BLOCK_CACHE_PRIMARY_MISS_COUNT, BLOCK_COUNT_PRIMARY_MISS_COUNT_DESC), 408 rsWrap.getBlockCachePrimaryMissCount()) 409 .addCounter( 410 Interns.info(BLOCK_CACHE_MISS_CACHING_COUNT, BLOCK_COUNT_MISS_CACHING_COUNT_DESC), 411 rsWrap.getBlockCacheMissCachingCount()) 412 .addCounter(Interns.info(BLOCK_CACHE_EVICTION_COUNT, BLOCK_CACHE_EVICTION_COUNT_DESC), 413 rsWrap.getBlockCacheEvictedCount()) 414 .addCounter( 415 Interns.info(BLOCK_CACHE_PRIMARY_EVICTION_COUNT, BLOCK_CACHE_PRIMARY_EVICTION_COUNT_DESC), 416 rsWrap.getBlockCachePrimaryEvictedCount()) 417 .addCounter( 418 Interns.info(BLOCK_CACHE_FAILED_INSERTION_COUNT, BLOCK_CACHE_FAILED_INSERTION_COUNT_DESC), 419 rsWrap.getBlockCacheFailedInsertions()) 420 .addCounter(Interns.info(BLOCK_CACHE_DATA_MISS_COUNT, ""), rsWrap.getDataMissCount()) 421 .addCounter(Interns.info(BLOCK_CACHE_LEAF_INDEX_MISS_COUNT, ""), 422 rsWrap.getLeafIndexMissCount()) 423 .addCounter(Interns.info(BLOCK_CACHE_BLOOM_CHUNK_MISS_COUNT, ""), 424 rsWrap.getBloomChunkMissCount()) 425 .addCounter(Interns.info(BLOCK_CACHE_META_MISS_COUNT, ""), rsWrap.getMetaMissCount()) 426 .addCounter(Interns.info(BLOCK_CACHE_ROOT_INDEX_MISS_COUNT, ""), 427 rsWrap.getRootIndexMissCount()) 428 .addCounter(Interns.info(BLOCK_CACHE_INTERMEDIATE_INDEX_MISS_COUNT, ""), 429 rsWrap.getIntermediateIndexMissCount()) 430 .addCounter(Interns.info(BLOCK_CACHE_FILE_INFO_MISS_COUNT, ""), 431 rsWrap.getFileInfoMissCount()) 432 .addCounter(Interns.info(BLOCK_CACHE_GENERAL_BLOOM_META_MISS_COUNT, ""), 433 rsWrap.getGeneralBloomMetaMissCount()) 434 .addCounter(Interns.info(BLOCK_CACHE_DELETE_FAMILY_BLOOM_MISS_COUNT, ""), 435 rsWrap.getDeleteFamilyBloomMissCount()) 436 .addCounter(Interns.info(BLOCK_CACHE_TRAILER_MISS_COUNT, ""), rsWrap.getTrailerMissCount()) 437 .addCounter(Interns.info(BLOCK_CACHE_DATA_HIT_COUNT, ""), rsWrap.getDataHitCount()) 438 .addCounter(Interns.info(BLOCK_CACHE_LEAF_INDEX_HIT_COUNT, ""), 439 rsWrap.getLeafIndexHitCount()) 440 .addCounter(Interns.info(BLOCK_CACHE_BLOOM_CHUNK_HIT_COUNT, ""), 441 rsWrap.getBloomChunkHitCount()) 442 .addCounter(Interns.info(BLOCK_CACHE_META_HIT_COUNT, ""), rsWrap.getMetaHitCount()) 443 .addCounter(Interns.info(BLOCK_CACHE_ROOT_INDEX_HIT_COUNT, ""), 444 rsWrap.getRootIndexHitCount()) 445 .addCounter(Interns.info(BLOCK_CACHE_INTERMEDIATE_INDEX_HIT_COUNT, ""), 446 rsWrap.getIntermediateIndexHitCount()) 447 .addCounter(Interns.info(BLOCK_CACHE_FILE_INFO_HIT_COUNT, ""), rsWrap.getFileInfoHitCount()) 448 .addCounter(Interns.info(BLOCK_CACHE_GENERAL_BLOOM_META_HIT_COUNT, ""), 449 rsWrap.getGeneralBloomMetaHitCount()) 450 .addCounter(Interns.info(BLOCK_CACHE_DELETE_FAMILY_BLOOM_HIT_COUNT, ""), 451 rsWrap.getDeleteFamilyBloomHitCount()) 452 .addCounter(Interns.info(BLOCK_CACHE_TRAILER_HIT_COUNT, ""), rsWrap.getTrailerHitCount()) 453 .addCounter(Interns.info(UPDATES_BLOCKED_TIME, UPDATES_BLOCKED_DESC), 454 rsWrap.getUpdatesBlockedTime()) 455 .addCounter(Interns.info(FLUSHED_CELLS, FLUSHED_CELLS_DESC), rsWrap.getFlushedCellsCount()) 456 .addCounter(Interns.info(COMPACTED_CELLS, COMPACTED_CELLS_DESC), 457 rsWrap.getCompactedCellsCount()) 458 .addCounter(Interns.info(MAJOR_COMPACTED_CELLS, MAJOR_COMPACTED_CELLS_DESC), 459 rsWrap.getMajorCompactedCellsCount()) 460 .addCounter(Interns.info(FLUSHED_CELLS_SIZE, FLUSHED_CELLS_SIZE_DESC), 461 rsWrap.getFlushedCellsSize()) 462 .addCounter(Interns.info(COMPACTED_CELLS_SIZE, COMPACTED_CELLS_SIZE_DESC), 463 rsWrap.getCompactedCellsSize()) 464 .addCounter(Interns.info(MAJOR_COMPACTED_CELLS_SIZE, MAJOR_COMPACTED_CELLS_SIZE_DESC), 465 rsWrap.getMajorCompactedCellsSize()) 466 .addCounter( 467 Interns.info(CELLS_COUNT_COMPACTED_FROM_MOB, CELLS_COUNT_COMPACTED_FROM_MOB_DESC), 468 rsWrap.getCellsCountCompactedFromMob()) 469 .addCounter(Interns.info(CELLS_COUNT_COMPACTED_TO_MOB, CELLS_COUNT_COMPACTED_TO_MOB_DESC), 470 rsWrap.getCellsCountCompactedToMob()) 471 .addCounter(Interns.info(CELLS_SIZE_COMPACTED_FROM_MOB, CELLS_SIZE_COMPACTED_FROM_MOB_DESC), 472 rsWrap.getCellsSizeCompactedFromMob()) 473 .addCounter(Interns.info(CELLS_SIZE_COMPACTED_TO_MOB, CELLS_SIZE_COMPACTED_TO_MOB_DESC), 474 rsWrap.getCellsSizeCompactedToMob()) 475 .addCounter(Interns.info(MOB_FLUSH_COUNT, MOB_FLUSH_COUNT_DESC), rsWrap.getMobFlushCount()) 476 .addCounter(Interns.info(MOB_FLUSHED_CELLS_COUNT, MOB_FLUSHED_CELLS_COUNT_DESC), 477 rsWrap.getMobFlushedCellsCount()) 478 .addCounter(Interns.info(MOB_FLUSHED_CELLS_SIZE, MOB_FLUSHED_CELLS_SIZE_DESC), 479 rsWrap.getMobFlushedCellsSize()) 480 .addCounter(Interns.info(MOB_SCAN_CELLS_COUNT, MOB_SCAN_CELLS_COUNT_DESC), 481 rsWrap.getMobScanCellsCount()) 482 .addCounter(Interns.info(MOB_SCAN_CELLS_SIZE, MOB_SCAN_CELLS_SIZE_DESC), 483 rsWrap.getMobScanCellsSize()) 484 .addCounter(Interns.info(MOB_FILE_CACHE_ACCESS_COUNT, MOB_FILE_CACHE_ACCESS_COUNT_DESC), 485 rsWrap.getMobFileCacheAccessCount()) 486 .addCounter(Interns.info(MOB_FILE_CACHE_MISS_COUNT, MOB_FILE_CACHE_MISS_COUNT_DESC), 487 rsWrap.getMobFileCacheMissCount()) 488 .addCounter(Interns.info(MOB_FILE_CACHE_EVICTED_COUNT, MOB_FILE_CACHE_EVICTED_COUNT_DESC), 489 rsWrap.getMobFileCacheEvictedCount()) 490 .addCounter(Interns.info(HEDGED_READS, HEDGED_READS_DESC), rsWrap.getHedgedReadOps()) 491 .addCounter(Interns.info(HEDGED_READ_WINS, HEDGED_READ_WINS_DESC), 492 rsWrap.getHedgedReadWins()) 493 .addCounter(Interns.info(HEDGED_READ_IN_CUR_THREAD, HEDGED_READ_IN_CUR_THREAD_DESC), 494 rsWrap.getHedgedReadOpsInCurThread()) 495 .addCounter(Interns.info(BLOCKED_REQUESTS_COUNT, BLOCKED_REQUESTS_COUNT_DESC), 496 rsWrap.getBlockedRequestsCount()) 497 .tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC), 498 rsWrap.getZookeeperQuorum()) 499 .tag(Interns.info(SERVER_NAME_NAME, SERVER_NAME_DESC), rsWrap.getServerName()) 500 .tag(Interns.info(CLUSTER_ID_NAME, CLUSTER_ID_DESC), rsWrap.getClusterId()); 501 } 502 503 metricsRegistry.snapshot(mrb, all); 504 505 // source is registered in supers constructor, sometimes called before the whole initialization. 506 if (metricsAdapter != null) { 507 // snapshot MetricRegistry as well 508 metricsAdapter.snapshotAllMetrics(registry, mrb); 509 } 510 } 511 512 private MetricsRecordBuilder addGaugesToMetricsRecordBuilder(MetricsRecordBuilder mrb) { 513 return mrb.addGauge(Interns.info(REGION_COUNT, REGION_COUNT_DESC), rsWrap.getNumOnlineRegions()) 514 .addGauge(Interns.info(STORE_COUNT, STORE_COUNT_DESC), rsWrap.getNumStores()) 515 .addGauge(Interns.info(WALFILE_COUNT, WALFILE_COUNT_DESC), rsWrap.getNumWALFiles()) 516 .addGauge(Interns.info(WALFILE_SIZE, WALFILE_SIZE_DESC), rsWrap.getWALFileSize()) 517 .addGauge(Interns.info(STOREFILE_COUNT, STOREFILE_COUNT_DESC), rsWrap.getNumStoreFiles()) 518 .addGauge(Interns.info(MAX_STOREFILE_COUNT, MAX_STOREFILE_COUNT_DESC), 519 rsWrap.getMaxStoreFiles()) 520 .addGauge(Interns.info(MEMSTORE_SIZE, MEMSTORE_SIZE_DESC), rsWrap.getMemStoreSize()) 521 .addGauge(Interns.info(MEMSTORE_HEAP_SIZE, MEMSTORE_HEAP_SIZE_DESC), 522 rsWrap.getOnHeapMemStoreSize()) 523 .addGauge(Interns.info(MEMSTORE_OFFHEAP_SIZE, MEMSTORE_OFFHEAP_SIZE_DESC), 524 rsWrap.getOffHeapMemStoreSize()) 525 .addGauge(Interns.info(STOREFILE_SIZE, STOREFILE_SIZE_DESC), rsWrap.getStoreFileSize()) 526 .addGauge(Interns.info(MAX_STORE_FILE_AGE, MAX_STORE_FILE_AGE_DESC), 527 rsWrap.getMaxStoreFileAge()) 528 .addGauge(Interns.info(MIN_STORE_FILE_AGE, MIN_STORE_FILE_AGE_DESC), 529 rsWrap.getMinStoreFileAge()) 530 .addGauge(Interns.info(AVG_STORE_FILE_AGE, AVG_STORE_FILE_AGE_DESC), 531 rsWrap.getAvgStoreFileAge()) 532 .addGauge(Interns.info(NUM_REFERENCE_FILES, NUM_REFERENCE_FILES_DESC), 533 rsWrap.getNumReferenceFiles()) 534 .addGauge(Interns.info(RS_START_TIME_NAME, RS_START_TIME_DESC), rsWrap.getStartCode()) 535 .addGauge(Interns.info(AVERAGE_REGION_SIZE, AVERAGE_REGION_SIZE_DESC), 536 rsWrap.getAverageRegionSize()) 537 .addGauge(Interns.info(STOREFILE_INDEX_SIZE, STOREFILE_INDEX_SIZE_DESC), 538 rsWrap.getStoreFileIndexSize()) 539 .addGauge(Interns.info(STATIC_INDEX_SIZE, STATIC_INDEX_SIZE_DESC), 540 rsWrap.getTotalStaticIndexSize()) 541 .addGauge(Interns.info(STATIC_BLOOM_SIZE, STATIC_BLOOM_SIZE_DESC), 542 rsWrap.getTotalStaticBloomSize()) 543 .addCounter(Interns.info(BLOOM_FILTER_REQUESTS_COUNT, BLOOM_FILTER_REQUESTS_COUNT_DESC), 544 rsWrap.getBloomFilterRequestsCount()) 545 .addCounter( 546 Interns.info(BLOOM_FILTER_NEGATIVE_RESULTS_COUNT, BLOOM_FILTER_NEGATIVE_RESULTS_COUNT_DESC), 547 rsWrap.getBloomFilterNegativeResultsCount()) 548 .addCounter(Interns.info(BLOOM_FILTER_ELIGIBLE_REQUESTS_COUNT, 549 BLOOM_FILTER_ELIGIBLE_REQUESTS_COUNT_DESC), rsWrap.getBloomFilterEligibleRequestsCount()) 550 .addGauge(Interns.info(NUMBER_OF_MUTATIONS_WITHOUT_WAL, NUMBER_OF_MUTATIONS_WITHOUT_WAL_DESC), 551 rsWrap.getNumMutationsWithoutWAL()) 552 .addGauge(Interns.info(DATA_SIZE_WITHOUT_WAL, DATA_SIZE_WITHOUT_WAL_DESC), 553 rsWrap.getDataInMemoryWithoutWAL()) 554 .addGauge(Interns.info(PERCENT_FILES_LOCAL, PERCENT_FILES_LOCAL_DESC), 555 rsWrap.getPercentFileLocal()) 556 .addGauge(Interns.info(PERCENT_FILES_LOCAL_SECONDARY_REGIONS, 557 PERCENT_FILES_LOCAL_SECONDARY_REGIONS_DESC), rsWrap.getPercentFileLocalSecondaryRegions()) 558 .addGauge(Interns.info(TOTAL_BYTES_READ, TOTAL_BYTES_READ_DESC), rsWrap.getTotalBytesRead()) 559 .addGauge(Interns.info(LOCAL_BYTES_READ, LOCAL_BYTES_READ_DESC), rsWrap.getLocalBytesRead()) 560 .addGauge(Interns.info(SHORTCIRCUIT_BYTES_READ, SHORTCIRCUIT_BYTES_READ_DESC), 561 rsWrap.getShortCircuitBytesRead()) 562 .addGauge(Interns.info(ZEROCOPY_BYTES_READ, ZEROCOPY_BYTES_READ_DESC), 563 rsWrap.getZeroCopyBytesRead()) 564 .addGauge(Interns.info(SPLIT_QUEUE_LENGTH, SPLIT_QUEUE_LENGTH_DESC), 565 rsWrap.getSplitQueueSize()) 566 .addGauge(Interns.info(COMPACTION_QUEUE_LENGTH, COMPACTION_QUEUE_LENGTH_DESC), 567 rsWrap.getCompactionQueueSize()) 568 .addGauge(Interns.info(SMALL_COMPACTION_QUEUE_LENGTH, SMALL_COMPACTION_QUEUE_LENGTH_DESC), 569 rsWrap.getSmallCompactionQueueSize()) 570 .addGauge(Interns.info(LARGE_COMPACTION_QUEUE_LENGTH, LARGE_COMPACTION_QUEUE_LENGTH_DESC), 571 rsWrap.getLargeCompactionQueueSize()) 572 .addGauge(Interns.info(FLUSH_QUEUE_LENGTH, FLUSH_QUEUE_LENGTH_DESC), 573 rsWrap.getFlushQueueSize()) 574 .addGauge(Interns.info(BLOCK_CACHE_FREE_SIZE, BLOCK_CACHE_FREE_DESC), 575 rsWrap.getBlockCacheFreeSize()) 576 .addGauge(Interns.info(BLOCK_CACHE_COUNT, BLOCK_CACHE_COUNT_DESC), 577 rsWrap.getBlockCacheCount()) 578 .addGauge(Interns.info(BLOCK_CACHE_DATA_BLOCK_COUNT, BLOCK_CACHE_DATA_BLOCK_COUNT_DESC), 579 rsWrap.getBlockCacheDataBlockCount()) 580 .addGauge(Interns.info(BLOCK_CACHE_SIZE, BLOCK_CACHE_SIZE_DESC), rsWrap.getBlockCacheSize()) 581 .addGauge(Interns.info(BLOCK_CACHE_HIT_PERCENT, BLOCK_CACHE_HIT_PERCENT_DESC), 582 rsWrap.getBlockCacheHitPercent()) 583 .addGauge(Interns.info(BLOCK_CACHE_EXPRESS_HIT_PERCENT, BLOCK_CACHE_EXPRESS_HIT_PERCENT_DESC), 584 rsWrap.getBlockCacheHitCachingPercent()) 585 .addGauge(Interns.info(L1_CACHE_SIZE, L1_CACHE_SIZE_DESC), rsWrap.getL1CacheSize()) 586 .addGauge(Interns.info(L1_CACHE_FREE_SIZE, L1_CACHE_FREE_SIZE_DESC), 587 rsWrap.getL1CacheFreeSize()) 588 .addGauge(Interns.info(L1_CACHE_COUNT, L1_CACHE_COUNT_DESC), rsWrap.getL1CacheCount()) 589 .addCounter(Interns.info(L1_CACHE_EVICTION_COUNT, L1_CACHE_EVICTION_COUNT_DESC), 590 rsWrap.getL1CacheEvictedCount()) 591 .addGauge(Interns.info(L1_CACHE_HIT_COUNT, L1_CACHE_HIT_COUNT_DESC), 592 rsWrap.getL1CacheHitCount()) 593 .addGauge(Interns.info(L1_CACHE_MISS_COUNT, L1_CACHE_MISS_COUNT_DESC), 594 rsWrap.getL1CacheMissCount()) 595 .addGauge(Interns.info(L1_CACHE_HIT_RATIO, L1_CACHE_HIT_RATIO_DESC), 596 rsWrap.getL1CacheHitRatio()) 597 .addGauge(Interns.info(L1_CACHE_MISS_RATIO, L1_CACHE_MISS_RATIO_DESC), 598 rsWrap.getL1CacheMissRatio()) 599 .addGauge(Interns.info(L2_CACHE_SIZE, L2_CACHE_SIZE_DESC), rsWrap.getL2CacheSize()) 600 .addGauge(Interns.info(L2_CACHE_FREE_SIZE, L2_CACHE_FREE_SIZE_DESC), 601 rsWrap.getL2CacheFreeSize()) 602 .addGauge(Interns.info(L2_CACHE_COUNT, L2_CACHE_COUNT_DESC), rsWrap.getL2CacheCount()) 603 .addCounter(Interns.info(L2_CACHE_EVICTION_COUNT, L2_CACHE_EVICTION_COUNT_DESC), 604 rsWrap.getL2CacheEvictedCount()) 605 .addGauge(Interns.info(L2_CACHE_HIT_COUNT, L2_CACHE_HIT_COUNT_DESC), 606 rsWrap.getL2CacheHitCount()) 607 .addGauge(Interns.info(L2_CACHE_MISS_COUNT, L2_CACHE_MISS_COUNT_DESC), 608 rsWrap.getL2CacheMissCount()) 609 .addGauge(Interns.info(L2_CACHE_HIT_RATIO, L2_CACHE_HIT_RATIO_DESC), 610 rsWrap.getL2CacheHitRatio()) 611 .addGauge(Interns.info(L2_CACHE_MISS_RATIO, L2_CACHE_MISS_RATIO_DESC), 612 rsWrap.getL2CacheMissRatio()) 613 .addGauge(Interns.info(MOB_FILE_CACHE_COUNT, MOB_FILE_CACHE_COUNT_DESC), 614 rsWrap.getMobFileCacheCount()) 615 .addGauge(Interns.info(MOB_FILE_CACHE_HIT_PERCENT, MOB_FILE_CACHE_HIT_PERCENT_DESC), 616 rsWrap.getMobFileCacheHitPercent()) 617 .addGauge(Interns.info(READ_REQUEST_RATE_PER_SECOND, READ_REQUEST_RATE_DESC), 618 rsWrap.getReadRequestsRatePerSecond()) 619 .addGauge(Interns.info(WRITE_REQUEST_RATE_PER_SECOND, WRITE_REQUEST_RATE_DESC), 620 rsWrap.getWriteRequestsRatePerSecond()) 621 .addGauge( 622 Interns.info(BYTE_BUFF_ALLOCATOR_HEAP_ALLOCATION_BYTES, 623 BYTE_BUFF_ALLOCATOR_HEAP_ALLOCATION_BYTES_DESC), 624 rsWrap.getByteBuffAllocatorHeapAllocationBytes()) 625 .addGauge( 626 Interns.info(BYTE_BUFF_ALLOCATOR_POOL_ALLOCATION_BYTES, 627 BYTE_BUFF_ALLOCATOR_POOL_ALLOCATION_BYTES_DESC), 628 rsWrap.getByteBuffAllocatorPoolAllocationBytes()) 629 .addGauge( 630 Interns.info(BYTE_BUFF_ALLOCATOR_HEAP_ALLOCATION_RATIO, 631 BYTE_BUFF_ALLOCATOR_HEAP_ALLOCATION_RATIO_DESC), 632 rsWrap.getByteBuffAllocatorHeapAllocRatio()) 633 .addGauge( 634 Interns.info(BYTE_BUFF_ALLOCATOR_TOTAL_BUFFER_COUNT, 635 BYTE_BUFF_ALLOCATOR_TOTAL_BUFFER_COUNT_DESC), 636 rsWrap.getByteBuffAllocatorTotalBufferCount()) 637 .addGauge(Interns.info(BYTE_BUFF_ALLOCATOR_USED_BUFFER_COUNT, 638 BYTE_BUFF_ALLOCATOR_USED_BUFFER_COUNT_DESC), rsWrap.getByteBuffAllocatorUsedBufferCount()) 639 .addGauge(Interns.info(ACTIVE_SCANNERS, ACTIVE_SCANNERS_DESC), rsWrap.getActiveScanners()); 640 } 641 642 @Override 643 public void incInfoThresholdExceeded(int count) { 644 infoPauseThresholdExceeded.incr(count); 645 } 646 647 @Override 648 public void incWarnThresholdExceeded(int count) { 649 warnPauseThresholdExceeded.incr(count); 650 } 651 652 @Override 653 public void updatePauseTimeWithGc(long t) { 654 pausesWithGc.add(t); 655 } 656 657 @Override 658 public void updatePauseTimeWithoutGc(long t) { 659 pausesWithoutGc.add(t); 660 } 661 662 @Override 663 public void updateDeleteBatch(long t) { 664 deleteBatchHisto.add(t); 665 } 666 667 @Override 668 public void updateCheckAndDelete(long t) { 669 checkAndDeleteHisto.add(t); 670 } 671 672 @Override 673 public void updateCheckAndPut(long t) { 674 checkAndPutHisto.add(t); 675 } 676 677 @Override 678 public void updateCheckAndMutate(long time, long blockBytesScanned) { 679 checkAndMutateHisto.add(time); 680 if (blockBytesScanned > 0) { 681 blockBytesScannedCount.incr(blockBytesScanned); 682 checkAndMutateBlockBytesScanned.add(blockBytesScanned); 683 } 684 } 685 686 @Override 687 public void updatePutBatch(long t) { 688 putBatchHisto.add(t); 689 } 690}