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.BaseSource;
021import org.apache.yetus.audience.InterfaceAudience;
022
023/**
024 * This interface will be implemented by a MetricsSource that will export metrics from
025 * HeapMemoryManager in RegionServer into the hadoop metrics system.
026 */
027@InterfaceAudience.Private
028public interface MetricsHeapMemoryManagerSource extends BaseSource {
029  /**
030   * The name of the metrics
031   */
032  String METRICS_NAME = "Memory";
033
034  /**
035   * The name of the metrics context that metrics will be under.
036   */
037  String METRICS_CONTEXT = "regionserver";
038
039  /**
040   * Description
041   */
042  String METRICS_DESCRIPTION = "Metrics about HBase RegionServer's memory";
043
044  /**
045   * The name of the metrics context that metrics will be under in jmx
046   */
047  String METRICS_JMX_CONTEXT = "RegionServer,sub=" + METRICS_NAME;
048
049  /**
050   * Update/Set the blocked flush count histogram/gauge
051   * @param blockedFlushCount the number of blocked flush since last tuning.
052   */
053  void updateBlockedFlushCount(long blockedFlushCount);
054
055  /**
056   * Update/Set the unblocked flush count histogram/gauge
057   * @param unblockedFlushCount the number of unblocked flush since last tuning.
058   */
059  void updateUnblockedFlushCount(long unblockedFlushCount);
060
061  /**
062   * Set the current blockcache size used gauge
063   * @param blockCacheSize the current memory usage in blockcache, in bytes.
064   */
065  void setCurBlockCacheSizeGauge(long blockCacheSize);
066
067  /**
068   * Set the current global memstore size used gauge
069   * @param memStoreSize the current memory usage in memstore, in bytes.
070   */
071  void setCurMemStoreSizeGauge(long memStoreSize);
072
073  /**
074   * Update the increase/decrease memstore size histogram
075   * @param memStoreDeltaSize the tuning result of memstore.
076   */
077  void updateMemStoreDeltaSizeHistogram(int memStoreDeltaSize);
078
079  /**
080   * Update the increase/decrease blockcache size histogram
081   * @param blockCacheDeltaSize the tuning result of blockcache.
082   */
083  void updateBlockCacheDeltaSizeHistogram(int blockCacheDeltaSize);
084
085  /**
086   * Increase the counter for tuner neither expanding memstore global size limit nor expanding
087   * blockcache max size.
088   */
089  void increaseTunerDoNothingCounter();
090
091  /**
092   * Increase the counter for heap occupancy percent above low watermark
093   */
094  void increaseAboveHeapOccupancyLowWatermarkCounter();
095
096  // Histograms
097  String BLOCKED_FLUSH_NAME = "blockedFlushes";
098  String BLOCKED_FLUSH_DESC = "Histogram for the number of blocked flushes in the memstore";
099  String UNBLOCKED_FLUSH_NAME = "unblockedFlushes";
100  String UNBLOCKED_FLUSH_DESC = "Histogram for the number of unblocked flushes in the memstore";
101  String INC_MEMSTORE_TUNING_NAME = "increaseMemStoreSize";
102  String INC_MEMSTORE_TUNING_DESC =
103    "Histogram for the heap memory tuner expanding memstore global size limit in bytes";
104  String DEC_MEMSTORE_TUNING_NAME = "decreaseMemStoreSize";
105  String DEC_MEMSTORE_TUNING_DESC =
106    "Histogram for the heap memory tuner shrinking memstore global size limit in bytes";
107  String INC_BLOCKCACHE_TUNING_NAME = "increaseBlockCacheSize";
108  String INC_BLOCKCACHE_TUNING_DESC =
109    "Histogram for the heap memory tuner expanding blockcache max heap size in bytes";
110  String DEC_BLOCKCACHE_TUNING_NAME = "decreaseBlockCacheSize";
111  String DEC_BLOCKCACHE_TUNING_DESC =
112    "Histogram for the heap memory tuner shrinking blockcache max heap size in bytes";
113
114  // Gauges
115  String BLOCKED_FLUSH_GAUGE_NAME = "blockedFlushGauge";
116  String BLOCKED_FLUSH_GAUGE_DESC = "Gauge for the blocked flush count before tuning";
117  String UNBLOCKED_FLUSH_GAUGE_NAME = "unblockedFlushGauge";
118  String UNBLOCKED_FLUSH_GAUGE_DESC = "Gauge for the unblocked flush count before tuning";
119  String MEMSTORE_SIZE_GAUGE_NAME = "memStoreSize";
120  String MEMSTORE_SIZE_GAUGE_DESC = "Global MemStore used in bytes by the RegionServer";
121  String BLOCKCACHE_SIZE_GAUGE_NAME = "blockCacheSize";
122  String BLOCKCACHE_SIZE_GAUGE_DESC = "BlockCache used in bytes by the RegionServer";
123
124  // Counters
125  String DO_NOTHING_COUNTER_NAME = "tunerDoNothingCounter";
126  String DO_NOTHING_COUNTER_DESC =
127    "The number of times that tuner neither expands memstore global size limit nor expands blockcache max size";
128  String ABOVE_HEAP_LOW_WATERMARK_COUNTER_NAME = "aboveHeapOccupancyLowWaterMarkCounter";
129  String ABOVE_HEAP_LOW_WATERMARK_COUNTER_DESC =
130    "The number of times that heap occupancy percent is above low watermark";
131}