Package org.apache.hadoop.metrics2.impl
Class MetricsSystemImpl
java.lang.Object
org.apache.hadoop.metrics2.MetricsSystem
org.apache.hadoop.metrics2.impl.MetricsSystemImpl
- All Implemented Interfaces:
MetricsSource,MetricsSystemMXBean
@Private
@Metrics(context="metricssystem")
public class MetricsSystemImpl
extends MetricsSystem
implements MetricsSource
A base class for metrics system singletons
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.metrics2.MetricsSystem
MetricsSystem.AbstractCallback, MetricsSystem.Callback -
Constructor Summary
ConstructorsConstructorDescriptionConstruct the system but not initializing (read config etc.) it.MetricsSystemImpl(String prefix) Construct the metrics system -
Method Summary
Modifier and TypeMethodDescriptionvoidgetMetrics(MetricsCollector builder, boolean all) Get metrics from the metrics sourceorg.apache.hadoop.metrics2.impl.MetricsSinkAdaptergetSinkAdapter(String name) Initialized the metrics system with a prefix.voidRequests an immediate publish of all metrics from sources to sinks.<T> TRegister a metrics sourcevoidregister(MetricsSystem.Callback callback) Register a callback interface for JMX eventsorg.apache.hadoop.metrics2.impl.MetricsBufferSample all the sources for a snapshot of metrics/tagsbooleanshutdown()Shutdown the metrics system completely (usually during server shutdown.)voidstart()Start the metrics systemvoidStart metrics MBeansvoidstop()Stop the metrics systemvoidStop metrics MBeans.voidunregisterSource(String name) Unregister a metrics sourceMethods inherited from class org.apache.hadoop.metrics2.MetricsSystem
register
-
Constructor Details
-
MetricsSystemImpl
Construct the metrics system- Parameters:
prefix- for the system
-
MetricsSystemImpl
public MetricsSystemImpl()Construct the system but not initializing (read config etc.) it.
-
-
Method Details
-
init
Initialized the metrics system with a prefix.- Specified by:
initin classMetricsSystem- Parameters:
prefix- the system will look for configs with the prefix- Returns:
- the metrics system object itself
-
start
public void start()Description copied from interface:MetricsSystemMXBeanStart the metrics system- Specified by:
startin interfaceMetricsSystemMXBean
-
stop
public void stop()Description copied from interface:MetricsSystemMXBeanStop the metrics system- Specified by:
stopin interfaceMetricsSystemMXBean
-
register
Description copied from class:MetricsSystemRegister a metrics source- Specified by:
registerin classMetricsSystem- Type Parameters:
T- the actual type of the source object- Parameters:
name- of the source. Must be unique or null (then extracted from the annotations of the source object.)desc- the description of the source (or null. See above.)source- object to register- Returns:
- the source object
-
unregisterSource
Description copied from class:MetricsSystemUnregister a metrics source- Specified by:
unregisterSourcein classMetricsSystem- Parameters:
name- of the source. This is the name you use to call register()
-
register
Description copied from class:MetricsSystemRegister a metrics sink- Specified by:
registerin classMetricsSystem- Type Parameters:
T- the type of the sink- Parameters:
name- of the sink. Must be unique.description- the description of the sinksink- to register- Returns:
- the sink
-
register
Description copied from class:MetricsSystemRegister a callback interface for JMX events- Specified by:
registerin classMetricsSystem- Parameters:
callback- the callback object implementing the MBean interface.
-
startMetricsMBeans
public void startMetricsMBeans()Description copied from interface:MetricsSystemMXBeanStart metrics MBeans- Specified by:
startMetricsMBeansin interfaceMetricsSystemMXBean
-
stopMetricsMBeans
public void stopMetricsMBeans()Description copied from interface:MetricsSystemMXBeanStop metrics MBeans. Note, it doesn't stop the metrics system control MBean, i.e this interface.- Specified by:
stopMetricsMBeansin interfaceMetricsSystemMXBean
-
currentConfig
- Specified by:
currentConfigin interfaceMetricsSystemMXBean- Returns:
- the current config Avoided getConfig, as it'll turn into a "Config" attribute, which doesn't support multiple line values in jconsole.
-
publishMetricsNow
public void publishMetricsNow()Requests an immediate publish of all metrics from sources to sinks.- Specified by:
publishMetricsNowin classMetricsSystem
-
sampleMetrics
@VisibleForTesting public org.apache.hadoop.metrics2.impl.MetricsBuffer sampleMetrics()Sample all the sources for a snapshot of metrics/tags- Returns:
- the metrics buffer containing the snapshot
-
getMetrics
Description copied from interface:MetricsSourceGet metrics from the metrics source- Specified by:
getMetricsin interfaceMetricsSource- Parameters:
builder- to contain the resulting metrics snapshotall- if true, return all metrics even if unchanged.
-
shutdown
public boolean shutdown()Description copied from class:MetricsSystemShutdown the metrics system completely (usually during server shutdown.) The MetricsSystemMXBean will be unregistered.- Specified by:
shutdownin classMetricsSystem- Returns:
- true if shutdown completed
-
getSource
- Specified by:
getSourcein classMetricsSystem- Parameters:
name- of the metrics source- Returns:
- the metrics source (potentially wrapped) object
-
getSinkAdapter
@VisibleForTesting public org.apache.hadoop.metrics2.impl.MetricsSinkAdapter getSinkAdapter(String name)
-