Class BaseSourceImpl

java.lang.Object
org.apache.hadoop.hbase.metrics.BaseSourceImpl
All Implemented Interfaces:
BaseSource, org.apache.hadoop.metrics2.MetricsSource
Direct Known Subclasses:
ExceptionTrackingSourceImpl, MetricsAssignmentManagerSourceImpl, MetricsBalancerSourceImpl, MetricsHeapMemoryManagerSourceImpl, MetricsIOSourceImpl, MetricsMasterFilesystemSourceImpl, MetricsMasterProcSourceImpl, MetricsMasterQuotaSourceImpl, MetricsMasterSourceImpl, MetricsRegionAggregateSourceImpl, MetricsRegionServerQuotaSourceImpl, MetricsRegionServerSourceImpl, MetricsReplicationSourceImpl, MetricsRESTSourceImpl, MetricsSnapshotSourceImpl, MetricsTableAggregateSourceImpl, MetricsUserAggregateSourceImpl, MetricsWALEventTrackerSourceImpl, MetricsWALSourceImpl, MetricsZooKeeperSourceImpl

@Private public class BaseSourceImpl extends Object implements BaseSource, org.apache.hadoop.metrics2.MetricsSource
Hadoop 2 implementation of BaseSource (using metrics2 framework). It handles registration to DefaultMetricsSystem and creation of the metrics registry. All MetricsSource's in hbase-hadoop2-compat should derive from this class.
  • Field Details

    • metricsRegistry

      Deprecated.
      Use hbase-metrics/hbase-metrics-api module interfaces for new metrics. Defining BaseSources for new metric groups (WAL, RPC, etc) is not needed anymore, however, for existing BaseSource implementations, please use the field named "registry" which is a MetricRegistry instance together with the HBaseMetrics2HadoopMetricsAdapter.
    • metricsName

      protected final String metricsName
    • metricsDescription

      protected final String metricsDescription
    • metricsContext

      protected final String metricsContext
    • metricsJmxContext

      protected final String metricsJmxContext
    • registry

      protected final MetricRegistry registry
      Note that there are at least 4 MetricRegistry definitions in the source code. The first one is Hadoop Metrics2 MetricRegistry, second one is DynamicMetricsRegistry which is HBase's fork of the Hadoop metrics2 class. The third one is the dropwizard metrics implementation of MetricRegistry, and finally a new API abstraction in HBase that is the o.a.h.h.metrics.MetricRegistry class. This last one is the new way to use metrics within the HBase code. However, the others are in play because of existing metrics2 based code still needs to coexists until we get rid of all of our BaseSource and convert them to the new framework. Until that happens, new metrics can use the new API, but will be collected through the HBaseMetrics2HadoopMetricsAdapter class. BaseSourceImpl has two MetricRegistries. metricRegistry is for hadoop Metrics2 based metrics, while the registry is for hbase-metrics based metrics.
    • metricsAdapter

      The adapter from hbase-metrics module to metrics2. This adepter is the connection between the Metrics in the MetricRegistry and the Hadoop Metrics2 system. Using this adapter, existing BaseSource implementations can define new metrics using the hbase-metrics/hbase-metrics-api module interfaces and still be able to make use of metrics2 sinks (including JMX). Existing BaseSources should call metricsAdapter.snapshotAllMetrics() in getMetrics() method. See MetricsRegionServerSourceImpl.
  • Constructor Details

  • Method Details

    • init

      public void init()
      Description copied from interface: BaseSource
      Clear out the metrics and re-prepare the source.
      Specified by:
      init in interface BaseSource
    • setGauge

      public void setGauge(String gaugeName, long value)
      Set a single gauge to a value.
      Specified by:
      setGauge in interface BaseSource
      Parameters:
      gaugeName - gauge name
      value - the new value of the gauge.
    • incGauge

      public void incGauge(String gaugeName, long delta)
      Add some amount to a gauge.
      Specified by:
      incGauge in interface BaseSource
      Parameters:
      gaugeName - The name of the gauge to increment.
      delta - The amount to increment the gauge by.
    • decGauge

      public void decGauge(String gaugeName, long delta)
      Decrease the value of a named gauge.
      Specified by:
      decGauge in interface BaseSource
      Parameters:
      gaugeName - The name of the gauge.
      delta - the ammount to subtract from a gauge value.
    • incCounters

      public void incCounters(String key, long delta)
      Increment a named counter by some value.
      Specified by:
      incCounters in interface BaseSource
      Parameters:
      key - the name of the counter
      delta - the ammount to increment
    • updateHistogram

      public void updateHistogram(String name, long value)
      Description copied from interface: BaseSource
      Add some value to a histogram.
      Specified by:
      updateHistogram in interface BaseSource
      Parameters:
      name - the name of the histogram
      value - the value to add to the histogram
    • removeMetric

      public void removeMetric(String key)
      Remove a named gauge.
      Specified by:
      removeMetric in interface BaseSource
      Parameters:
      key - the key of the gauge to remove
    • getMetrics

      public void getMetrics(org.apache.hadoop.metrics2.MetricsCollector metricsCollector, boolean all)
      Specified by:
      getMetrics in interface org.apache.hadoop.metrics2.MetricsSource
    • getMetricsRegistry

    • getMetricsContext

      Description copied from interface: BaseSource
      Get the metrics context. For hadoop metrics2 system this is usually an all lowercased string. eg. regionserver, master, thriftserver
      Specified by:
      getMetricsContext in interface BaseSource
      Returns:
      The string context used to register this source to hadoop's metrics2 system.
    • getMetricsDescription

      Description copied from interface: BaseSource
      Get the description of what this source exposes.
      Specified by:
      getMetricsDescription in interface BaseSource
    • getMetricsJmxContext

      Description copied from interface: BaseSource
      Get the name of the context in JMX that this source will be exposed through. This is in ObjectName format. With the default context being Hadoop -> HBase
      Specified by:
      getMetricsJmxContext in interface BaseSource
    • getMetricsName

      Description copied from interface: BaseSource
      Get the name of the metrics that are being exported by this source. Eg. IPC, GC, WAL
      Specified by:
      getMetricsName in interface BaseSource