Package org.apache.hadoop.metrics2
Class MetricsSystem
java.lang.Object
org.apache.hadoop.metrics2.MetricsSystem
- All Implemented Interfaces:
MetricsSystemMXBean
The metrics system interface.
The following components are used for metrics.
MetricsSourcegenerate and update metrics information.MetricsSinkconsume the metrics information
MetricsSource and MetricsSink register with the metrics
system. Implementations of MetricsSystem polls the
MetricsSources periodically and pass the MetricsRecords to
MetricsSink.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classorg.apache.hadoop.metrics2.MetricsSystem.AbstractCallbackConvenient abstract class for implementing callback interfacestatic interfaceorg.apache.hadoop.metrics2.MetricsSystem.CallbackThe metrics system callback interface (needed for proxies.) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract MetricsSourcegetSource(String name) abstract MetricsSysteminit(String prefix) abstract voidRequests an immediate publish of all metrics from sources to sinks.abstract <T> TRegister a metrics sourceabstract voidregister(org.apache.hadoop.metrics2.MetricsSystem.Callback callback) Register a callback interface for JMX events<T> Tregister(T source) Register a metrics source (deriving name and description from the object)abstract booleanshutdown()Shutdown the metrics system completely (usually during server shutdown.)abstract voidunregisterSource(String name) Unregister a metrics sourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.metrics2.MetricsSystemMXBean
currentConfig, start, startMetricsMBeans, stop, stopMetricsMBeans
-
Constructor Details
-
MetricsSystem
public MetricsSystem()
-
-
Method Details
-
init
-
register
Register a metrics source- Type Parameters:
T- the actual type of the source object- Parameters:
source- object to registername- 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.)- Returns:
- the source object
- Throws:
MetricsException- Metrics Exception.
-
unregisterSource
Unregister a metrics source- Parameters:
name- of the source. This is the name you use to call register()
-
register
public <T> T register(T source) Register a metrics source (deriving name and description from the object)- Type Parameters:
T- the actual type of the source object- Parameters:
source- object to register- Returns:
- the source object
- Throws:
MetricsException- Metrics Exception.
-
getSource
- Parameters:
name- of the metrics source- Returns:
- the metrics source (potentially wrapped) object
-
register
Register a metrics sink- Type Parameters:
T- the type of the sink- Parameters:
sink- to registername- of the sink. Must be unique.desc- the description of the sink- Returns:
- the sink
- Throws:
MetricsException- Metrics Exception.
-
register
public abstract void register(org.apache.hadoop.metrics2.MetricsSystem.Callback callback) Register a callback interface for JMX events- Parameters:
callback- the callback object implementing the MBean interface.
-
publishMetricsNow
public abstract void publishMetricsNow()Requests an immediate publish of all metrics from sources to sinks. This is a "soft" request: the expectation is that a best effort will be done to synchronously snapshot the metrics from all the sources and put them in all the sinks (including flushing the sinks) before returning to the caller. If this can't be accomplished in reasonable time it's OK to return to the caller before everything is done. -
shutdown
public abstract boolean shutdown()Shutdown the metrics system completely (usually during server shutdown.) The MetricsSystemMXBean will be unregistered.- Returns:
- true if shutdown completed
-