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