Hi All,
In DefaultPartitioner implementation, when key is null, we get the
partition number by modulo of available partitions. Below is the code
snippet.
if (availablePartitions.size() > 0)
{ int part = Utils.toPositive(nextValue) % availablePartitions.size();
return availablePartitions.get(part).partition();
}
Where as when key is not null, we get the partition number by modulo of
total no og partitions.
return Utils.toPositive(Utils.murmur2(keyBytes)) % numPartitions;
As if some partitions are not available,then the producer will not be able
to publish message to that partition.
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
Could any help to clarify on this issue.
Thanks,
Bharat