@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).
| 构造器和说明 |
|---|
FlinkFixedPartitioner() |
| 限定符和类型 | 方法和说明 |
|---|---|
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)
FlinkKafkaPartitioneropen 在类中 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)
FlinkKafkaPartitionerpartition 在类中 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–2023 The Apache Software Foundation. All rights reserved.