Package org.apache.hadoop.hbase.metrics
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static enum
-
Field Summary
Modifier and TypeFieldDescriptionprotected final HBaseMetrics2HadoopMetricsAdapter
The adapter from hbase-metrics module to metrics2.protected final String
protected final String
protected final String
protected final String
protected final DynamicMetricsRegistry
Deprecated.Use hbase-metrics/hbase-metrics-api module interfaces for new metrics.protected final MetricRegistry
Note that there are at least 4 MetricRegistry definitions in the source code.Fields inherited from interface org.apache.hadoop.hbase.metrics.BaseSource
HBASE_METRICS_SYSTEM_NAME
-
Constructor Summary
ConstructorDescriptionBaseSourceImpl
(String metricsName, String metricsDescription, String metricsContext, String metricsJmxContext) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Decrease the value of a named gauge.void
getMetrics
(org.apache.hadoop.metrics2.MetricsCollector metricsCollector, boolean all) Get the metrics context.Get the description of what this source exposes.Get the name of the context in JMX that this source will be exposed through.Get the name of the metrics that are being exported by this source.void
incCounters
(String key, long delta) Increment a named counter by some value.void
Add some amount to a gauge.void
init()
Clear out the metrics and re-prepare the source.void
removeMetric
(String key) Remove a named gauge.void
Set a single gauge to a value.void
updateHistogram
(String name, long value) Add some value to a histogram.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.metrics.BaseSource
getMetricRegistryInfo
-
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 existingBaseSource
implementations, please use the field named "registry" which is aMetricRegistry
instance together with theHBaseMetrics2HadoopMetricsAdapter
. -
metricsName
-
metricsDescription
-
metricsContext
-
metricsJmxContext
-
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. SeeMetricsRegionServerSourceImpl
.
-
-
Constructor Details
-
BaseSourceImpl
public BaseSourceImpl(String metricsName, String metricsDescription, String metricsContext, String metricsJmxContext)
-
-
Method Details
-
init
Description copied from interface:BaseSource
Clear out the metrics and re-prepare the source.- Specified by:
init
in interfaceBaseSource
-
setGauge
Set a single gauge to a value.- Specified by:
setGauge
in interfaceBaseSource
- Parameters:
gaugeName
- gauge namevalue
- the new value of the gauge.
-
incGauge
Add some amount to a gauge.- Specified by:
incGauge
in interfaceBaseSource
- Parameters:
gaugeName
- The name of the gauge to increment.delta
- The amount to increment the gauge by.
-
decGauge
Decrease the value of a named gauge.- Specified by:
decGauge
in interfaceBaseSource
- Parameters:
gaugeName
- The name of the gauge.delta
- the ammount to subtract from a gauge value.
-
incCounters
Increment a named counter by some value.- Specified by:
incCounters
in interfaceBaseSource
- Parameters:
key
- the name of the counterdelta
- the ammount to increment
-
updateHistogram
Description copied from interface:BaseSource
Add some value to a histogram.- Specified by:
updateHistogram
in interfaceBaseSource
- Parameters:
name
- the name of the histogramvalue
- the value to add to the histogram
-
removeMetric
Remove a named gauge.- Specified by:
removeMetric
in interfaceBaseSource
- Parameters:
key
- the key of the gauge to remove
-
getMetrics
- Specified by:
getMetrics
in interfaceorg.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 interfaceBaseSource
- 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 interfaceBaseSource
-
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 interfaceBaseSource
-
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 interfaceBaseSource
-