org.apache.flume.instrumentation
Class GangliaServer

java.lang.Object
  extended by org.apache.flume.instrumentation.GangliaServer
All Implemented Interfaces:
Configurable, MonitorService

public class GangliaServer
extends Object
implements MonitorService

A Ganglia server that polls JMX based at a configured frequency (defaults to once every 60 seconds). This implementation can send data to ganglia 3 and ganglia 3.1.

Mandatory Parameters:

hosts: List of comma separated hostname:ports of ganglia servers to report metrics to.

Optional Parameters:

pollFrequency:Interval in seconds between consecutive reports to ganglia servers. Default = 60 seconds.

isGanglia3: Report to ganglia 3 ? Default = false - reports to ganglia 3.1.


Nested Class Summary
protected  class GangliaServer.GangliaCollector
          Worker which polls JMX for all mbeans with ObjectName within the flume namespace: org.apache.flume.
 
Field Summary
protected  byte[] buffer
           
static int BUFFER_SIZE
           
protected  GangliaServer.GangliaCollector collectorRunnable
           
 String CONF_HOSTS
           
 String CONF_ISGANGLIA3
           
 String CONF_POLL_FREQUENCY
           
static int DEFAULT_DMAX
           
 int DEFAULT_POLL_FREQUENCY
           
static int DEFAULT_SLOPE
           
static int DEFAULT_TMAX
           
static String DEFAULT_UNITS
           
static String GANGLIA_DOUBLE_TYPE
           
protected  int offset
           
 
Constructor Summary
GangliaServer()
           
 
Method Summary
 void configure(Context context)
           Request the implementing class to (re)configure itself.
protected  void createGangliaMessage(String name, String value)
           
protected  void createGangliaMessage31(String name, String value)
           
 int getPollFrequency()
           
 boolean isGanglia3()
           
 void sendToGangliaNodes()
           
 void setIsGanglia3(boolean isGanglia3)
           
 void setPollFrequency(int pollFrequency)
           
 void start()
          Start this server, causing it to poll JMX at the configured frequency.
 void stop()
          Stop this server.
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
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values

buffer

protected byte[] buffer

offset

protected int offset

collectorRunnable

protected final GangliaServer.GangliaCollector collectorRunnable

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 int DEFAULT_SLOPE
See Also:
Constant Field Values

GANGLIA_DOUBLE_TYPE

public static final String GANGLIA_DOUBLE_TYPE
See Also:
Constant Field Values

CONF_POLL_FREQUENCY

public final String CONF_POLL_FREQUENCY
See Also:
Constant Field Values

DEFAULT_POLL_FREQUENCY

public final int DEFAULT_POLL_FREQUENCY
See Also:
Constant Field Values

CONF_HOSTS

public final String CONF_HOSTS
See Also:
Constant Field Values

CONF_ISGANGLIA3

public final String CONF_ISGANGLIA3
See Also:
Constant Field Values
Constructor Detail

GangliaServer

public GangliaServer()
              throws FlumeException
Parameters:
hosts - List of hosts to send the metrics to. All of them have to be running the version of ganglia specified by the configuration.
Throws:
FlumeException
Method Detail

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.


sendToGangliaNodes

public void sendToGangliaNodes()

start

public void start()
Start this server, causing it to poll JMX at the configured frequency.

Specified by:
start in interface MonitorService

stop

public void stop()
Stop this server.

Specified by:
stop in interface MonitorService

setPollFrequency

public void setPollFrequency(int pollFrequency)
Parameters:
pollFrequency - Seconds between consecutive JMX polls.

getPollFrequency

public int getPollFrequency()
Returns:
Seconds between consecutive JMX polls

setIsGanglia3

public void setIsGanglia3(boolean isGanglia3)
Parameters:
isGanglia3 - When true, ganglia 3 messages will be sent, else Ganglia 3.1 formatted messages are sent.

isGanglia3

public boolean isGanglia3()
Returns:
True if the server is currently sending ganglia 3 formatted msgs. False if the server returns Ganglia 3.1

createGangliaMessage

protected void createGangliaMessage(String name,
                                    String value)

createGangliaMessage31

protected void createGangliaMessage31(String name,
                                      String value)

configure

public void configure(Context context)
Description copied from interface: Configurable

Request the implementing class to (re)configure itself.

When configuration parameters are changed, they must be reflected by the component asap.

There are no thread safety guarrantees on when configure might be called.

Specified by:
configure in interface Configurable


Copyright © 2009-2015 Apache Software Foundation. All Rights Reserved.