org.apache.hadoop.metrics.ganglia
Class GangliaContext

java.lang.Object
  extended by org.apache.hadoop.metrics.spi.AbstractMetricsContext
      extended by org.apache.hadoop.metrics.ganglia.GangliaContext
All Implemented Interfaces:
MetricsContext
Direct Known Subclasses:
GangliaContext31

public class GangliaContext
extends AbstractMetricsContext

Context for sending metrics to Ganglia.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.metrics.spi.AbstractMetricsContext
AbstractMetricsContext.MetricMap, AbstractMetricsContext.TagMap
 
Field Summary
protected  byte[] buffer
           
protected  DatagramSocket datagramSocket
           
protected  List<? extends SocketAddress> metricsServers
           
protected  int offset
           
 
Fields inherited from interface org.apache.hadoop.metrics.MetricsContext
DEFAULT_PERIOD
 
Constructor Summary
GangliaContext()
          Creates a new instance of GangliaContext
 
Method Summary
protected  void emitMetric(String name, String type, String value)
           
 void emitRecord(String contextName, String recordName, OutputRecord outRec)
          Sends a record to the metrics system.
protected  int getDmax(String metricName)
           
protected  int getSlope(String metricName)
           
protected  int getTmax(String metricName)
           
protected  String getUnits(String metricName)
           
 void init(String contextName, ContextFactory factory)
          Initializes the context.
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 org.apache.hadoop.metrics.spi.AbstractMetricsContext
close, createRecord, flush, getAllRecords, getAttribute, getAttributeTable, getContextFactory, getContextName, getPeriod, isMonitoring, newRecord, parseAndSetPeriod, registerUpdater, remove, setPeriod, startMonitoring, stopMonitoring, unregisterUpdater, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected byte[] buffer

offset

protected int offset

metricsServers

protected List<? extends SocketAddress> metricsServers

datagramSocket

protected DatagramSocket datagramSocket
Constructor Detail

GangliaContext

public GangliaContext()
Creates a new instance of GangliaContext

Method Detail

init

public void init(String contextName,
                 ContextFactory factory)
Description copied from class: AbstractMetricsContext
Initializes the context.

Specified by:
init in interface MetricsContext
Overrides:
init in class AbstractMetricsContext
Parameters:
contextName - The given name for this context
factory - The creator of this context

emitRecord

public void emitRecord(String contextName,
                       String recordName,
                       OutputRecord outRec)
                throws IOException
Description copied from class: AbstractMetricsContext
Sends a record to the metrics system.

Specified by:
emitRecord in class AbstractMetricsContext
Throws:
IOException

emitMetric

protected void emitMetric(String name,
                          String type,
                          String value)
                   throws IOException
Throws:
IOException

getUnits

protected String getUnits(String metricName)

getSlope

protected int getSlope(String metricName)

getTmax

protected int getTmax(String metricName)

getDmax

protected int getDmax(String metricName)

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.


xdr_int

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



Copyright © 2009 The Apache Software Foundation