public class FixedPartitioner extends KafkaPartitioner implements Serializable
Flink Sinks: Kafka Partitions
1 ----------------> 1
2 --------------/
3 -------------/
4 ------------/
Some (or all) kafka partitions contain the output of more than one flink partition
# Fewer Flink partitions than Kafka
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 |
|---|
FixedPartitioner() |
| Modifier and Type | Method and Description |
|---|---|
void |
open(int parallelInstanceId,
int parallelInstances,
int[] partitions)
Initializer for the Partitioner.
|
int |
partition(Object element,
int numPartitions) |
public void open(int parallelInstanceId,
int parallelInstances,
int[] partitions)
KafkaPartitioneropen in class KafkaPartitionerparallelInstanceId - 0-indexed id of the parallel instance in FlinkparallelInstances - the total number of parallel instancespartitions - an array describing the partition IDs of the available Kafka partitions.public int partition(Object element, int numPartitions)
partition in interface kafka.producer.PartitionerCopyright © 2014–2015 The Apache Software Foundation. All rights reserved.