org.apache.hadoop.metrics2.lib
Enum DefaultMetricsSystem

java.lang.Object
  extended by java.lang.Enum<DefaultMetricsSystem>
      extended by org.apache.hadoop.metrics2.lib.DefaultMetricsSystem
All Implemented Interfaces:
Serializable, Comparable<DefaultMetricsSystem>, MetricsSystem, MetricsSystemMXBean

public enum DefaultMetricsSystem
extends Enum<DefaultMetricsSystem>
implements MetricsSystem

The default metrics system singleton


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.metrics2.MetricsSystem
MetricsSystem.AbstractCallback, MetricsSystem.Callback
 
Enum Constant Summary
INSTANCE
          The singleton instance
 
Method Summary
 String currentConfig()
           
static MetricsSystem initialize(String prefix)
          Common static convenience method to initialize the metrics system
 void publishMetricsNow()
          Requests an immediate publish of all metrics from sources to sinks.
 void refreshMBeans()
          Force a refresh of MBeans
 void register(MetricsSystem.Callback callback)
          Register a callback interface for JMX events
<T extends MetricsSink>
T
register(String name, String desc, T sink)
          Register a metrics sink
<T extends MetricsSource>
T
register(String name, String desc, T source)
          Register a metrics source
static
<T extends MetricsSource>
T
registerSource(String name, String desc, T source)
          Common static method to register a source
 void shutdown()
          Shutdown the metrics system completely (usually during server shutdown.) The MetricsSystemMXBean will be unregistered.
 void start()
          Start the metrics system
 void stop()
          Stop the metrics system
static DefaultMetricsSystem valueOf(String name)
          Returns the enum constant of this type with the specified name.
static DefaultMetricsSystem[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

INSTANCE

public static final DefaultMetricsSystem INSTANCE
The singleton instance

Method Detail

values

public static DefaultMetricsSystem[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (DefaultMetricsSystem c : DefaultMetricsSystem.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static DefaultMetricsSystem valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

initialize

public static MetricsSystem initialize(String prefix)
Common static convenience method to initialize the metrics system

Parameters:
prefix - for configuration
Returns:
the metrics system instance

register

public <T extends MetricsSource> T register(String name,
                                            String desc,
                                            T source)
Description copied from interface: MetricsSystem
Register a metrics source

Specified by:
register in interface MetricsSystem
Type Parameters:
T - the type of the source
Parameters:
name - of the source. Must be unique.
desc - the description of the source.
source - to register
Returns:
the source

registerSource

public static <T extends MetricsSource> T registerSource(String name,
                                                         String desc,
                                                         T source)
Common static method to register a source

Type Parameters:
T - type of the source
Parameters:
name - of the source
desc - description
source - the source object to register
Returns:
the source object

register

public <T extends MetricsSink> T register(String name,
                                          String desc,
                                          T sink)
Description copied from interface: MetricsSystem
Register a metrics sink

Specified by:
register in interface MetricsSystem
Type Parameters:
T - the type of the sink
Parameters:
name - of the sink. Must be unique.
desc - the description of the sink
sink - to register
Returns:
the sink

register

public void register(MetricsSystem.Callback callback)
Description copied from interface: MetricsSystem
Register a callback interface for JMX events

Specified by:
register in interface MetricsSystem
Parameters:
callback - the callback object implementing the MBean interface.

publishMetricsNow

public void publishMetricsNow()
Description copied from interface: MetricsSystem
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.

Specified by:
publishMetricsNow in interface MetricsSystem

start

public void start()
Description copied from interface: MetricsSystemMXBean
Start the metrics system

Specified by:
start in interface MetricsSystemMXBean

stop

public void stop()
Description copied from interface: MetricsSystemMXBean
Stop the metrics system

Specified by:
stop in interface MetricsSystemMXBean

refreshMBeans

public void refreshMBeans()
Description copied from interface: MetricsSystemMXBean
Force a refresh of MBeans

Specified by:
refreshMBeans in interface MetricsSystemMXBean

currentConfig

public String currentConfig()
Specified by:
currentConfig in interface MetricsSystemMXBean
Returns:
the current config Note, avoid getConfig, as it'll turn it into an attribute, which doesn't support multiple lines in the values.

shutdown

public void shutdown()
Description copied from interface: MetricsSystem
Shutdown the metrics system completely (usually during server shutdown.) The MetricsSystemMXBean will be unregistered.

Specified by:
shutdown in interface MetricsSystem


Copyright © 2009 The Apache Software Foundation