org.apache.hadoop.metrics2
Class MetricsSystem

java.lang.Object
  extended by org.apache.hadoop.metrics2.MetricsSystem
All Implemented Interfaces:
MetricsSystemMXBean

@InterfaceAudience.Public
@InterfaceStability.Evolving
public abstract class MetricsSystem
extends Object
implements MetricsSystemMXBean

The metrics system interface


Constructor Summary
MetricsSystem()
           
 
Method Summary
abstract  void publishMetricsNow()
          Requests an immediate publish of all metrics from sources to sinks.
abstract  void register(org.apache.hadoop.metrics2.MetricsSystem.Callback callback)
          Register a callback interface for JMX events
abstract
<T> T
register(String name, String desc, T source)
          Register a metrics source
abstract
<T extends MetricsSink>
T
register(String name, String desc, T sink)
          Register a metrics sink
<T> T
register(T source)
          Register a metrics source (deriving name and description from the object)
abstract  boolean shutdown()
          Shutdown the metrics system completely (usually during server shutdown.) The MetricsSystemMXBean will be unregistered.
abstract  void unregisterSource(String name)
          Unregister a metrics source
 
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.metrics2.MetricsSystemMXBean
currentConfig, start, startMetricsMBeans, stop, stopMetricsMBeans
 

Constructor Detail

MetricsSystem

public MetricsSystem()
Method Detail

register

public abstract <T> T register(String name,
                               String desc,
                               T source)
Register a metrics source

Type Parameters:
T - the actual type of the source object
Parameters:
source - object to register
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.)
Returns:
the source object
Throws:
MetricsException

unregisterSource

public abstract void unregisterSource(String name)
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

register

public abstract <T extends MetricsSink> T register(String name,
                                                   String desc,
                                                   T sink)
Register a metrics sink

Type Parameters:
T - the type of the sink
Parameters:
sink - to register
name - of the sink. Must be unique.
desc - the description of the sink
Returns:
the sink
Throws:
MetricsException

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


Copyright © 2014 Apache Software Foundation. All Rights Reserved.