Class FlinkFixedPartitioner<T>
- java.lang.Object
-
- org.apache.flink.streaming.connectors.kafka.partitioner.FlinkKafkaPartitioner<T>
-
- org.apache.flink.streaming.connectors.kafka.partitioner.FlinkFixedPartitioner<T>
-
- All Implemented Interfaces:
Serializable,KafkaPartitioner<T>
@PublicEvolving @Deprecated public class FlinkFixedPartitioner<T> extends FlinkKafkaPartitioner<T>
Deprecated.Will be turned into internal class whenFlinkKafkaProduceris removed.A partitioner ensuring that each internal Flink partition ends up in one Kafka partition.Note, one Kafka partition can contain multiple Flink partitions.
There are a couple of cases to consider.
More Flink partitions than kafka partitions
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 5Not 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).
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FlinkFixedPartitioner()Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object o)Deprecated.inthashCode()Deprecated.voidopen(int parallelInstanceId, int parallelInstances)Deprecated.Initializer for the partitioner.intpartition(T record, byte[] key, byte[] value, String targetTopic, int[] partitions)Deprecated.Determine the id of the partition that the record should be written to.
-
-
-
Method Detail
-
open
public void open(int parallelInstanceId, int parallelInstances)Deprecated.Description copied from interface:KafkaPartitionerInitializer 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 int partition(T record, byte[] key, byte[] value, String targetTopic, int[] partitions)
Deprecated.Description copied from interface:KafkaPartitionerDetermine 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
-
-