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 a
ProducerRecord.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultKafkaSinkContext(int subtaskId, int numberOfParallelInstances, Properties kafkaProducerConfig) -
Method Summary
Modifier and TypeMethodDescriptionintintGet the ID of the subtask the KafkaSink is running on.int[]getPartitionsForTopic(String topic) For a given topic id retrieve the available partitions.
-
Constructor Details
-
DefaultKafkaSinkContext
public DefaultKafkaSinkContext(int subtaskId, int numberOfParallelInstances, Properties kafkaProducerConfig)
-
-
Method Details
-
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
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
-