Class AbstractGangliaSink
java.lang.Object
org.apache.hadoop.metrics2.sink.ganglia.AbstractGangliaSink
- All Implemented Interfaces:
MetricsPlugin,MetricsSink
- Direct Known Subclasses:
GangliaSink30
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 ClassesModifier and TypeClassDescriptionstatic enumdefine enum for various type of confstatic enumganglia slope values which equal the ordinal -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final booleanstatic final intstatic final intstatic final AbstractGangliaSink.GangliaSlopestatic final intstatic final Stringstatic final Stringprotected final org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricVisitorUsed for visiting Metricsfinal org.slf4j.Loggerstatic final Stringstatic final Stringstatic final Stringstatic final booleanstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidSends Ganglia Metrics to the configured hostsvoidflush()Flush any buffered metricsprotected org.apache.hadoop.metrics2.sink.ganglia.GangliaConfgetGangliaConfForMetric(String metricName) Lookup GangliaConf from cache.protected StringList<? extends SocketAddress>voidinit(org.apache.commons.configuration2.SubsetConfiguration conf) Initialize the pluginprotected booleanprotected voidxdr_int(int i) Puts an integer into the buffer as 4 bytes, big-endian.protected voidxdr_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, waitMethods inherited from interface org.apache.hadoop.metrics2.MetricsSink
putMetrics
-
Field Details
-
LOG
public final org.slf4j.Logger LOG -
DEFAULT_UNITS
- See Also:
-
DEFAULT_TMAX
public static final int DEFAULT_TMAX- See Also:
-
DEFAULT_DMAX
public static final int DEFAULT_DMAX- See Also:
-
DEFAULT_SLOPE
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
DEFAULT_MULTICAST_ENABLED
public static final boolean DEFAULT_MULTICAST_ENABLED- See Also:
-
DEFAULT_MULTICAST_TTL
public static final int DEFAULT_MULTICAST_TTL- See Also:
-
SERVERS_PROPERTY
- See Also:
-
MULTICAST_ENABLED_PROPERTY
- See Also:
-
MULTICAST_TTL_PROPERTY
- See Also:
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
SUPPORT_SPARSE_METRICS_PROPERTY
- See Also:
-
SUPPORT_SPARSE_METRICS_DEFAULT
public static final boolean SUPPORT_SPARSE_METRICS_DEFAULT- See Also:
-
EQUAL
- See Also:
-
gangliaMetricVisitor
protected final org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricVisitor gangliaMetricVisitorUsed for visiting Metrics
-
-
Constructor Details
-
AbstractGangliaSink
public AbstractGangliaSink()
-
-
Method Details
-
getMetricsServers
-
init
public void init(org.apache.commons.configuration2.SubsetConfiguration conf) Description copied from interface:MetricsPluginInitialize the plugin- Specified by:
initin interfaceMetricsPlugin- Parameters:
conf- the configuration object for the plugin
-
flush
public void flush()Description copied from interface:MetricsSinkFlush any buffered metrics- Specified by:
flushin interfaceMetricsSink
-
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
- Returns:
- the hostName
-
xdr_string
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
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
-