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
Nested ClassesModifier and TypeClassDescriptionprivate static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HBaseMetrics2HadoopMetricsAdapterThe adapter from hbase-metrics module to metrics2.protected final Stringprotected final Stringprotected final Stringprotected final Stringprotected final DynamicMetricsRegistryDeprecated.Use hbase-metrics/hbase-metrics-api module interfaces for new metrics.protected final MetricRegistryNote 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
ConstructorsConstructorDescriptionBaseSourceImpl(String metricsName, String metricsDescription, String metricsContext, String metricsJmxContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidDecrease the value of a named gauge.voidgetMetrics(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.voidincCounters(String key, long delta) Increment a named counter by some value.voidAdd some amount to a gauge.voidinit()Clear out the metrics and re-prepare the source.voidremoveMetric(String key) Remove a named gauge.voidSet a single gauge to a value.voidupdateHistogram(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, waitMethods 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 existingBaseSourceimplementations, please use the field named "registry" which is aMetricRegistryinstance 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:BaseSourceClear out the metrics and re-prepare the source.- Specified by:
initin interfaceBaseSource
-
setGauge
Set a single gauge to a value.- Specified by:
setGaugein interfaceBaseSource- Parameters:
gaugeName- gauge namevalue- the new value of the gauge.
-
incGauge
Add some amount to a gauge.- Specified by:
incGaugein 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:
decGaugein 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:
incCountersin interfaceBaseSource- Parameters:
key- the name of the counterdelta- the ammount to increment
-
updateHistogram
Description copied from interface:BaseSourceAdd some value to a histogram.- Specified by:
updateHistogramin interfaceBaseSource- Parameters:
name- the name of the histogramvalue- the value to add to the histogram
-
removeMetric
Remove a named gauge.- Specified by:
removeMetricin interfaceBaseSource- Parameters:
key- the key of the gauge to remove
-
getMetrics
- Specified by:
getMetricsin interfaceorg.apache.hadoop.metrics2.MetricsSource
-
getMetricsRegistry
-
getMetricsContext
Description copied from interface:BaseSourceGet the metrics context. For hadoop metrics2 system this is usually an all lowercased string. eg. regionserver, master, thriftserver- Specified by:
getMetricsContextin interfaceBaseSource- Returns:
- The string context used to register this source to hadoop's metrics2 system.
-
getMetricsDescription
Description copied from interface:BaseSourceGet the description of what this source exposes.- Specified by:
getMetricsDescriptionin interfaceBaseSource
-
getMetricsJmxContext
Description copied from interface:BaseSourceGet 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:
getMetricsJmxContextin interfaceBaseSource
-
getMetricsName
Description copied from interface:BaseSourceGet the name of the metrics that are being exported by this source. Eg. IPC, GC, WAL- Specified by:
getMetricsNamein interfaceBaseSource
-