MetricsSystemImpl (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.metrics2.impl, class: MetricsSystemImpl

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

  Constructors
  Constructor
  Description
  `MetricsSystemImpl()`
  Construct the system but not initializing (read config etc.) it.
  `MetricsSystemImpl(String prefix)`
  Construct the metrics system

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `currentConfig()`
  `void`
  `getMetrics(MetricsCollector builder, boolean all)`
  Get metrics from the metrics source
  `org.apache.hadoop.metrics2.impl.MetricsSinkAdapter`
  `getSinkAdapter(String name)`
  `MetricsSource`
  `getSource(String name)`
  `MetricsSystem`
  `init(String prefix)`
  Initialized the metrics system with a prefix.
  `void`
  `publishMetricsNow()`
  Requests an immediate publish of all metrics from sources to sinks.
  `<T> T`
  `register(String name, String desc, T source)`
  Register a metrics source
  `void`
  `register(MetricsSystem.Callback callback)`
  Register a callback interface for JMX events
  `org.apache.hadoop.metrics2.impl.MetricsBuffer`
  `sampleMetrics()`
  Sample all the sources for a snapshot of metrics/tags
  `boolean`
  `shutdown()`
  Shutdown the metrics system completely (usually during server shutdown.)
  `void`
  `start()`
  Start the metrics system
  `void`
  `startMetricsMBeans()`
  Start metrics MBeans
  `void`
  `stop()`
  Stop the metrics system
  `void`
  `stopMetricsMBeans()`
  Stop metrics MBeans.
  `void`
  `unregisterSource(String name)`
  Unregister a metrics source

  ### Methods inherited from class org.apache.hadoop.metrics2.MetricsSystem

  `register`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MetricsSystemImpl

    public MetricsSystemImpl(String prefix)
    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

    public MetricsSystem init(String prefix)
    Initialized the metrics system with a prefix.
    Specified by:
      `init` in class `MetricsSystem`
    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: `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`

  - ### register

    public <T> T register(String name, String desc, T source)
    Description copied from class: `MetricsSystem`
    Register a metrics source
    Specified by:
      `register` in class `MetricsSystem`
    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

    public void unregisterSource(String name)
    Description copied from class: `MetricsSystem`
    Unregister a metrics source
    Specified by:
      `unregisterSource` in class `MetricsSystem`
    Parameters:
      `name` - of the source. This is the name you use to call register()

  - ### register

    public <T extends MetricsSink> T register(String name, String description, T sink)
    Description copied from class: `MetricsSystem`
    Register a metrics sink
    Specified by:
      `register` in class `MetricsSystem`
    Type Parameters:
      `T` - the type of the sink
    Parameters:
      `name` - of the sink. Must be unique.
      `description` - the description of the sink
      `sink` - to register
    Returns:
      the sink

  - ### register

    public void register(MetricsSystem.Callback callback)
    Description copied from class: `MetricsSystem`
    Register a callback interface for JMX events
    Specified by:
      `register` in class `MetricsSystem`
    Parameters:
      `callback` - the callback object implementing the MBean interface.

  - ### startMetricsMBeans

    public void startMetricsMBeans()
    Description copied from interface: `MetricsSystemMXBean`
    Start metrics MBeans
    Specified by:
      `startMetricsMBeans` in interface `MetricsSystemMXBean`

  - ### stopMetricsMBeans

    public void stopMetricsMBeans()
    Description copied from interface: `MetricsSystemMXBean`
    Stop metrics MBeans. Note, it doesn't stop the metrics system control MBean, i.e this interface.
    Specified by:
      `stopMetricsMBeans` in interface `MetricsSystemMXBean`

  - ### currentConfig

    public String currentConfig()
    Specified by:
      `currentConfig` in interface `MetricsSystemMXBean`
    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:
      `publishMetricsNow` in class `MetricsSystem`

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

    public void getMetrics(MetricsCollector builder, boolean all)
    Description copied from interface: `MetricsSource`
    Get metrics from the metrics source
    Specified by:
      `getMetrics` in interface `MetricsSource`
    Parameters:
      `builder` - to contain the resulting metrics snapshot
      `all` - if true, return all metrics even if unchanged.

  - ### shutdown

    public boolean shutdown()
    Description copied from class: `MetricsSystem`
    Shutdown the metrics system completely (usually during server shutdown.) The MetricsSystemMXBean will be unregistered.
    Specified by:
      `shutdown` in class `MetricsSystem`
    Returns:
      true if shutdown completed

  - ### getSource

    public MetricsSource getSource(String name)
    Specified by:
      `getSource` in class `MetricsSystem`
    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)