AbstractGangliaSink (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.metrics2.sink.ganglia, class: AbstractGangliaSink

Package org.apache.hadoop.metrics2.sink.ganglia

# Class AbstractGangliaSink

java.lang.Object
org.apache.hadoop.metrics2.sink.ganglia.AbstractGangliaSink

All Implemented Interfaces:
  `MetricsPlugin`, `MetricsSink`

Direct Known Subclasses:
  `GangliaSink30`

public abstract class AbstractGangliaSink extends Object implements MetricsSink
This the base class for Ganglia sink classes using metrics2. Lot of the code has been derived from org.apache.hadoop.metrics.ganglia.GangliaContext. As per the documentation, sink implementations doesn't have to worry about thread safety. Hence the code wasn't written for thread safety and should be modified in case the above assumption changes in the future.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `AbstractGangliaSink.GangliaConfType`
  define enum for various type of conf
  `static enum`
  `AbstractGangliaSink.GangliaSlope`
  ganglia slope values which equal the ordinal

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `BUFFER_SIZE`
  `static final int`
  `DEFAULT_DMAX`
  `static final boolean`
  `DEFAULT_MULTICAST_ENABLED`
  `static final int`
  `DEFAULT_MULTICAST_TTL`
  `static final int`
  `DEFAULT_PORT`
  `static final AbstractGangliaSink.GangliaSlope`
  `DEFAULT_SLOPE`
  `static final int`
  `DEFAULT_TMAX`
  `static final String`
  `DEFAULT_UNITS`
  `static final String`
  `EQUAL`
  `protected final org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricVisitor`
  `gangliaMetricVisitor`
  Used for visiting Metrics
  `final org.slf4j.Logger`
  `LOG`
  `static final String`
  `MULTICAST_ENABLED_PROPERTY`
  `static final String`
  `MULTICAST_TTL_PROPERTY`
  `static final String`
  `SERVERS_PROPERTY`
  `static final boolean`
  `SUPPORT_SPARSE_METRICS_DEFAULT`
  `static final String`
  `SUPPORT_SPARSE_METRICS_PROPERTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractGangliaSink()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `emitToGangliaHosts()`
  Sends Ganglia Metrics to the configured hosts
  `void`
  `flush()`
  Flush any buffered metrics
  `protected org.apache.hadoop.metrics2.sink.ganglia.GangliaConf`
  `getGangliaConfForMetric(String metricName)`
  Lookup GangliaConf from cache.
  `protected String`
  `getHostName()`
  `List<? extends SocketAddress>`
  `getMetricsServers()`
  `void`
  `init(org.apache.commons.configuration2.SubsetConfiguration conf)`
  Initialize the plugin
  `protected boolean`
  `isSupportSparseMetrics()`
  `protected void`
  `xdr_int(int i)`
  Puts an integer into the buffer as 4 bytes, big-endian.
  `protected void`
  `xdr_string(String s)`
  Puts a string into the buffer by first writing the size of the string as an int, followed by the bytes of the string, padded if necessary to a multiple of 4.

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

  `putMetrics`

- ## Field Details

  - ### LOG

    public final org.slf4j.Logger LOG

  - ### DEFAULT_UNITS

    public static final String DEFAULT_UNITS
    See Also:
      - Constant Field Values

  - ### DEFAULT_TMAX

    public static final int DEFAULT_TMAX
    See Also:
      - Constant Field Values

  - ### DEFAULT_DMAX

    public static final int DEFAULT_DMAX
    See Also:
      - Constant Field Values

  - ### DEFAULT_SLOPE

    public static final AbstractGangliaSink.GangliaSlope DEFAULT_SLOPE

  - ### DEFAULT_PORT

    public static final int DEFAULT_PORT
    See Also:
      - Constant Field Values

  - ### DEFAULT_MULTICAST_ENABLED

    public static final boolean DEFAULT_MULTICAST_ENABLED
    See Also:
      - Constant Field Values

  - ### DEFAULT_MULTICAST_TTL

    public static final int DEFAULT_MULTICAST_TTL
    See Also:
      - Constant Field Values

  - ### SERVERS_PROPERTY

    public static final String SERVERS_PROPERTY
    See Also:
      - Constant Field Values

  - ### MULTICAST_ENABLED_PROPERTY

    public static final String MULTICAST_ENABLED_PROPERTY
    See Also:
      - Constant Field Values

  - ### MULTICAST_TTL_PROPERTY

    public static final String MULTICAST_TTL_PROPERTY
    See Also:
      - Constant Field Values

  - ### BUFFER_SIZE

    public static final int BUFFER_SIZE
    See Also:
      - Constant Field Values

  - ### SUPPORT_SPARSE_METRICS_PROPERTY

    public static final String SUPPORT_SPARSE_METRICS_PROPERTY
    See Also:
      - Constant Field Values

  - ### SUPPORT_SPARSE_METRICS_DEFAULT

    public static final boolean SUPPORT_SPARSE_METRICS_DEFAULT
    See Also:
      - Constant Field Values

  - ### EQUAL

    public static final String EQUAL
    See Also:
      - Constant Field Values

  - ### gangliaMetricVisitor

    protected final org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricVisitor gangliaMetricVisitor
    Used for visiting Metrics

- ## Constructor Details

  - ### AbstractGangliaSink

    public AbstractGangliaSink()

- ## Method Details

  - ### getMetricsServers

    public List<? extends SocketAddress> getMetricsServers()

  - ### init

    public void init(org.apache.commons.configuration2.SubsetConfiguration conf)
    Description copied from interface: `MetricsPlugin`
    Initialize the plugin
    Specified by:
      `init` in interface `MetricsPlugin`
    Parameters:
      `conf` - the configuration object for the plugin

  - ### flush

    public void flush()
    Description copied from interface: `MetricsSink`
    Flush any buffered metrics
    Specified by:
      `flush` in interface `MetricsSink`

  - ### getGangliaConfForMetric

    protected org.apache.hadoop.metrics2.sink.ganglia.GangliaConf getGangliaConfForMetric(String metricName)
    Lookup GangliaConf from cache. If not found, return default values
    Parameters:
      `metricName` - metricName.
    Returns:
      looked up GangliaConf

  - ### getHostName

    protected String getHostName()
    Returns:
      the hostName

  - ### xdr_string

    protected void xdr_string(String s)
    Puts a string into the buffer by first writing the size of the string as an int, followed by the bytes of the string, padded if necessary to a multiple of 4.
    Parameters:
      `s` - the string to be written to buffer at offset location

  - ### xdr_int

    protected void xdr_int(int i)
    Puts an integer into the buffer as 4 bytes, big-endian.
    Parameters:
      `i` - i.

  - ### emitToGangliaHosts

    protected void emitToGangliaHosts() throws IOException
    Sends Ganglia Metrics to the configured hosts
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### isSupportSparseMetrics

    protected boolean isSupportSparseMetrics()
    Returns:
      whether sparse metrics are supported