public class GangliaListener extends Object implements Callable<Void>, IGangliaDefaults
IGangliaMessageHandler
.
The decoded messages are reported without any additional translation. The
receiver may need to reconcile host names, IGangliaMetadataMessage
s
with those already on hand, and/or reconcile IGangliaMetricMessage
with the IGangliaMetadataMessage
s already on hand. The
GangliaListener
does NOT perform such operations by design so it
maybe used to obtain a faithful transcription of the chatter on the ganglia
network.
BUFFER_SIZE, DEFAULT_DMAX, DEFAULT_GROUP, DEFAULT_PORT, DEFAULT_SLOPE, DEFAULT_TMAX, DEFAULT_UNITS, HEARTBEAT_INTERVAL, INITIAL_DELAY, MONITORING_INTERVAL, QUIET_PERIOD
Constructor and Description |
---|
GangliaListener(IGangliaMessageHandler handler)
Listen at the default multicast group address and port.
|
GangliaListener(InetAddress group,
int port,
IGangliaMessageDecoder decoder,
IGangliaMessageHandler handler)
Listen at the specified multicast group address and port.
|
Modifier and Type | Method and Description |
---|---|
Void |
call()
Listens for ganglia messages.
|
protected IGangliaMessage |
decodeRecord(byte[] data,
int off,
int len)
Decode a Ganglia message from the datagram packet.
|
boolean |
isListening()
Return
true iff the listener is running when this method is
invoked. |
static void |
main(String[] args)
Listens to ganglia services on the default multicast address and port and
writes out the messages that it observes on stdout.
|
public GangliaListener(IGangliaMessageHandler handler) throws UnknownHostException
handler
- The interface to receive the ganglia messages.UnknownHostException
IGangliaDefaults.DEFAULT_GROUP
,
IGangliaDefaults.DEFAULT_PORT
public GangliaListener(InetAddress group, int port, IGangliaMessageDecoder decoder, IGangliaMessageHandler handler)
group
- The multicast address used by ganglia for hosts to join.port
- The port on which the ganglia services are talking.decoder
- Object responsible for decoding packets.handler
- The interface to receive the ganglia messages.public boolean isListening()
true
iff the listener is running when this method is
invoked.public Void call() throws Exception
Note: This method BLOCKS and does NOT notice an interrupt. This is because JDK 6 does not support multicast NIO. TODO Java 6 does not support non-blocking multicast receive. Write a JDK 7 specific version of class class which uses multicast with non-blocking IO and hence can be interrupted.
call
in interface Callable<Void>
Exception
protected IGangliaMessage decodeRecord(byte[] data, int off, int len)
data
- The packet data.off
- The offset of the first byte in the packet.len
- The #of bytes in the packet.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.