[
https://issues.apache.org/jira/browse/KAFKA-4087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15980200#comment-15980200
]
Bharat Viswanadham commented on KAFKA-4087:
-------------------------------------------
This is according to design, when key is not null, to get that record with a
key assigned to always one partition, we do this. If we do by considering
available no of partitions, the same key might be assigned to different
partition.
> DefaultParitioner Implementation Issue
> --------------------------------------
>
> Key: KAFKA-4087
> URL: https://issues.apache.org/jira/browse/KAFKA-4087
> Project: Kafka
> Issue Type: Bug
> Components: producer
> Affects Versions: 0.9.0.1, 0.10.0.1
> Reporter: Bharat Viswanadham
> Assignee: Bharat Viswanadham
> Labels: partitioners, producer
>
> In DefaultPartitioner implementation, when key is null
> if (availablePartitions.size() > 0) {
> int part = Utils.toPositive(nextValue) %
> availablePartitions.size();
> return availablePartitions.get(part).partition();
> }
> Where as when key is not null
> return Utils.toPositive(Utils.murmur2(keyBytes)) % numPartitions;
> We are returning partition by using total number of partitions.
> Should n't we do the same as by considering only available partitions?
> https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/DefaultPartitioner.java#L67
>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)