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.
  • Field Details

  • 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