Class FlinkKafkaPartitioner<T>
- java.lang.Object
-
- org.apache.flink.streaming.connectors.kafka.partitioner.FlinkKafkaPartitioner<T>
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FlinkFixedPartitioner
@PublicEvolving public abstract class FlinkKafkaPartitioner<T> extends Object implements Serializable
AFlinkKafkaPartitionerwraps logic on how to partition records across partitions of multiple Kafka topics.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FlinkKafkaPartitioner()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidopen(int parallelInstanceId, int parallelInstances)Initializer for the partitioner.abstract intpartition(T record, byte[] key, byte[] value, String targetTopic, int[] partitions)Determine the id of the partition that the record should be written to.
-
-
-
Method Detail
-
open
public void open(int parallelInstanceId, int parallelInstances)Initializer for the partitioner. This is called once on each parallel sink instance of the Flink Kafka producer. This method should be overridden if necessary.- Parameters:
parallelInstanceId- 0-indexed id of the parallel sink instance in FlinkparallelInstances- the total number of parallel instances
-
partition
public abstract int partition(T record, byte[] key, byte[] value, String targetTopic, int[] partitions)
Determine the id of the partition that the record should be written to.- Parameters:
record- the record valuekey- serialized key of the recordvalue- serialized value of the recordtargetTopic- target topic for the recordpartitions- found partitions for the target topic- Returns:
- the id of the target partition
-
-