I was looking at removing unused partitions from
org.apache.kafka.clients.producer.internals.RecordAccumulator#batches to
avoid the map growing indefinitely, especially in the REST service. The PR
under https://issues.apache.org/jira/browse/KAFKA-2948 has the details.
With CopyOnWriteMap, removing entries requires synchronization, and there
are places in the code like dequeFor() which relies on partitions never
being removed from the map. I wasn't sure why CopyOnWriteMap was chosen for
this map, instead of perhaps ConcurrentHashMap. This would avoid large
copies of maps under a lock when there are large number of partitions, and
also make it easier to remove entries from the map. But I imagine there
must have been a reason why CopyOnWriteMap was preferred choice.

Thoughts?


Regards,

Rajini

Reply via email to