You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/05/09 14:57:15 UTC

[GitHub] [kafka] chia7712 commented on pull request #8633: KAFKA-9965: Incrementing counter cause uneven distribution with RoundRobinPartitioner

chia7712 commented on pull request #8633:
URL: https://github.com/apache/kafka/pull/8633#issuecomment-626188379


   > I was unable to modify the existing test methods. This RoundRobinPartitioner#onNewBatch is not being used anywhere in the existing test methods, hence there was no scope to check.
   The onNewBatch overridden method only decrementing the counter in the map, so it needs to be tested from a method where it is being called.
   
   For example, you can verify the output of ```RoundRobinPartitioner#partition``` after calling ```RoundRobinPartitioner#onNewBatch``` to make sure the output is what you expect.
   ```java
   Partitioner partitioner = new RoundRobinPartitioner();
   Cluster cluster = new Cluster("clusterId", asList(NODES[0], NODES[1], NODES[2]), partitions,
       Collections.<String>emptySet(), Collections.<String>emptySet());
   int part = partitioner.partition("test", null, null, null, null, cluster);
   assertEqual(expected, part);
   partitioner.onNewBatch ("test", cluster, part);
   part = partitioner.partition("test", null, null, null, null, cluster);
   assertEqual(expected, part);
   ```
   (this code is sample)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org