MetricsSystem (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.metrics2, class: MetricsSystem

Package org.apache.hadoop.metrics2

# Class MetricsSystem

java.lang.Object
org.apache.hadoop.metrics2.MetricsSystem

All Implemented Interfaces:
  `MetricsSystemMXBean`

@Public @Evolving public abstract class MetricsSystem extends Object implements MetricsSystemMXBean
The metrics system interface. The following components are used for metrics.

- `MetricsSource` generate and update metrics information.
- `MetricsSink` consume the metrics information

`MetricsSource` and `MetricsSink` register with the metrics system. Implementations of `MetricsSystem` polls the `MetricsSource`s periodically and pass the `MetricsRecord`s to `MetricsSink`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `org.apache.hadoop.metrics2.MetricsSystem.AbstractCallback`
  Convenient abstract class for implementing callback interface
  `static interface`
  `org.apache.hadoop.metrics2.MetricsSystem.Callback`
  The metrics system callback interface (needed for proxies.)

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MetricsSystem()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract MetricsSource`
  `getSource(String name)`
  `abstract MetricsSystem`
  `init(String prefix)`
  `abstract void`
  `publishMetricsNow()`
  Requests an immediate publish of all metrics from sources to sinks.
  `abstract <T> T`
  `register(String name, String desc, T source)`
  Register a metrics source
  `abstract void`
  `register(org.apache.hadoop.metrics2.MetricsSystem.Callback callback)`
  Register a callback interface for JMX events
  `<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.)
  `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 Details

  - ### MetricsSystem

    public MetricsSystem()

- ## Method Details

  - ### init

    @Private public abstract MetricsSystem init(String prefix)

  - ### 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` - Metrics Exception.

  - ### 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` - Metrics Exception.

  - ### getSource

    @Private public abstract MetricsSource getSource(String name)
    Parameters:
      `name` - of the metrics source
    Returns:
      the metrics source (potentially wrapped) object

  - ### 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` - 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