Class DefaultKafkaSinkContext
- java.lang.Object
-
- org.apache.flink.connector.kafka.sink.DefaultKafkaSinkContext
-
- All Implemented Interfaces:
KafkaRecordSerializationSchema.KafkaSinkContext
public class DefaultKafkaSinkContext extends Object implements KafkaRecordSerializationSchema.KafkaSinkContext
Context providing information to assist constructing aProducerRecord.
-
-
Constructor Summary
Constructors Constructor Description DefaultKafkaSinkContext(int subtaskId, int numberOfParallelInstances, Properties kafkaProducerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetNumberOfParallelInstances()intgetParallelInstanceId()Get the ID of the subtask the KafkaSink is running on.int[]getPartitionsForTopic(String topic)For a given topic id retrieve the available partitions.
-
-
-
Constructor Detail
-
DefaultKafkaSinkContext
public DefaultKafkaSinkContext(int subtaskId, int numberOfParallelInstances, Properties kafkaProducerConfig)
-
-
Method Detail
-
getParallelInstanceId
public int getParallelInstanceId()
Description copied from interface:KafkaRecordSerializationSchema.KafkaSinkContextGet the ID of the subtask the KafkaSink is running on. The numbering starts from 0 and goes up to parallelism-1. (parallelism as returned byKafkaRecordSerializationSchema.KafkaSinkContext.getNumberOfParallelInstances()- Specified by:
getParallelInstanceIdin interfaceKafkaRecordSerializationSchema.KafkaSinkContext- Returns:
- ID of subtask
-
getNumberOfParallelInstances
public int getNumberOfParallelInstances()
- Specified by:
getNumberOfParallelInstancesin interfaceKafkaRecordSerializationSchema.KafkaSinkContext- Returns:
- number of parallel KafkaSink tasks.
-
getPartitionsForTopic
public int[] getPartitionsForTopic(String topic)
Description copied from interface:KafkaRecordSerializationSchema.KafkaSinkContextFor a given topic id retrieve the available partitions.After the first retrieval the returned partitions are cached. If the partitions are updated the job has to be restarted to make the change visible.
- Specified by:
getPartitionsForTopicin interfaceKafkaRecordSerializationSchema.KafkaSinkContext- Parameters:
topic- kafka topic with partitions- Returns:
- the ids of the currently available partitions
-
-