@PublicEvolving public class FlinkFixedPartitioner<T> extends FlinkKafkaPartitioner<T>
Note, one Kafka partition can contain multiple Flink partitions.
There are a couple of cases to consider.
Flink Sinks: Kafka Partitions 1 ----------------> 1 2 --------------/ 3 -------------/ 4 ------------/
Some (or all) kafka partitions contain the output of more than one flink partition
Flink Sinks: Kafka Partitions 1 ----------------> 1 2 ----------------> 2 3 4 5
Not all Kafka partitions contain data To avoid such an unbalanced partitioning, use a round-robin kafka partitioner (note that this will cause a lot of network connections between all the Flink instances and all the Kafka brokers).
Constructor and Description |
---|
FlinkFixedPartitioner() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
hashCode() |
void |
open(int parallelInstanceId,
int parallelInstances)
Initializer for the partitioner.
|
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.
|
public void open(int parallelInstanceId, int parallelInstances)
FlinkKafkaPartitioner
open
in class FlinkKafkaPartitioner<T>
parallelInstanceId
- 0-indexed id of the parallel sink instance in FlinkparallelInstances
- the total number of parallel instancespublic int partition(T record, byte[] key, byte[] value, String targetTopic, int[] partitions)
FlinkKafkaPartitioner
partition
in class FlinkKafkaPartitioner<T>
record
- the record valuekey
- serialized key of the recordvalue
- serialized value of the recordtargetTopic
- target topic for the recordpartitions
- found partitions for the target topicCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.