Package org.apache.hadoop.metrics2.sink
Class KafkaSink
java.lang.Object
org.apache.hadoop.metrics2.sink.KafkaSink
- All Implemented Interfaces:
Closeable,AutoCloseable,MetricsPlugin,MetricsSink
A metrics sink that writes to a Kafka broker. This requires you to configure
a broker_list and a topic in the metrics2 configuration file. The broker_list
must contain a comma-separated list of kafka broker host and ports. The topic
will contain only one topic.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()Flush any buffered metricsvoidinit(org.apache.commons.configuration2.SubsetConfiguration conf) Initialize the pluginvoidputMetrics(MetricsRecord record) Put a metrics record in the sinkvoidsetProducer(org.apache.kafka.clients.producer.Producer<Integer, byte[]> p)
-
Field Details
-
BROKER_LIST
- See Also:
-
TOPIC
- See Also:
-
-
Constructor Details
-
KafkaSink
public KafkaSink()
-
-
Method Details
-
setProducer
-
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
-
putMetrics
Description copied from interface:MetricsSinkPut a metrics record in the sink- Specified by:
putMetricsin interfaceMetricsSink- Parameters:
record- the record to put
-
flush
public void flush()Description copied from interface:MetricsSinkFlush any buffered metrics- Specified by:
flushin interfaceMetricsSink
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-