KafkaSink (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.metrics2.sink, class: KafkaSink

Package org.apache.hadoop.metrics2.sink

# Class KafkaSink

java.lang.Object
org.apache.hadoop.metrics2.sink.KafkaSink

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `MetricsPlugin`, `MetricsSink`

@Public @Evolving public class KafkaSink extends Object implements MetricsSink, Closeable
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
  Modifier and Type
  Field
  Description
  `static final String`
  `BROKER_LIST`
  `static final String`
  `TOPIC`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `KafkaSink()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `void`
  `flush()`
  Flush any buffered metrics
  `void`
  `init(org.apache.commons.configuration2.SubsetConfiguration conf)`
  Initialize the plugin
  `void`
  `putMetrics(MetricsRecord record)`
  Put a metrics record in the sink
  `void`
  `setProducer(org.apache.kafka.clients.producer.Producer<Integer,byte[]> p)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### BROKER_LIST

    public static final String BROKER_LIST
    See Also:
      - Constant Field Values

  - ### TOPIC

    public static final String TOPIC
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### KafkaSink

    public KafkaSink()

- ## Method Details

  - ### setProducer

    public void setProducer(org.apache.kafka.clients.producer.Producer<Integer,byte[]> p)

  - ### init

    public void init(org.apache.commons.configuration2.SubsetConfiguration conf)
    Description copied from interface: `MetricsPlugin`
    Initialize the plugin
    Specified by:
      `init` in interface `MetricsPlugin`
    Parameters:
      `conf` - the configuration object for the plugin

  - ### putMetrics

    public void putMetrics(MetricsRecord record)
    Description copied from interface: `MetricsSink`
    Put a metrics record in the sink
    Specified by:
      `putMetrics` in interface `MetricsSink`
    Parameters:
      `record` - the record to put

  - ### flush

    public void flush()
    Description copied from interface: `MetricsSink`
    Flush any buffered metrics
    Specified by:
      `flush` in interface `MetricsSink`

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Throws:
      `IOException`