Repository: kafka Updated Branches: refs/heads/trunk 06a57cf19 -> 4b28d38ca
MINOR: Add comment for round robin partitioner with different subscriptions Author: Liquan Pei <[email protected]> Reviewers: Ewen Cheslack-Postava <[email protected]> Closes #1475 from Ishiihara/roundrobin-comment Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/4b28d38c Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/4b28d38c Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/4b28d38c Branch: refs/heads/trunk Commit: 4b28d38ca463ff3788885a904591a5699127158a Parents: 06a57cf Author: Liquan Pei <[email protected]> Authored: Tue Jun 7 19:38:39 2016 -0700 Committer: Ewen Cheslack-Postava <[email protected]> Committed: Tue Jun 7 19:38:39 2016 -0700 ---------------------------------------------------------------------- .../kafka/clients/consumer/RoundRobinAssignor.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/4b28d38c/clients/src/main/java/org/apache/kafka/clients/consumer/RoundRobinAssignor.java ---------------------------------------------------------------------- diff --git a/clients/src/main/java/org/apache/kafka/clients/consumer/RoundRobinAssignor.java b/clients/src/main/java/org/apache/kafka/clients/consumer/RoundRobinAssignor.java index a5de595..a598258 100644 --- a/clients/src/main/java/org/apache/kafka/clients/consumer/RoundRobinAssignor.java +++ b/clients/src/main/java/org/apache/kafka/clients/consumer/RoundRobinAssignor.java @@ -25,8 +25,8 @@ import java.util.SortedSet; import java.util.TreeSet; /** - * The roundrobin assignor lays out all the available partitions and all the available consumers. It - * then proceeds to do a roundrobin assignment from partition to consumer. If the subscriptions of all consumer + * The round robin assignor lays out all the available partitions and all the available consumers. It + * then proceeds to do a round robin assignment from partition to consumer. If the subscriptions of all consumer * instances are identical, then the partitions will be uniformly distributed. (i.e., the partition ownership counts * will be within a delta of exactly one across all consumers.) * @@ -36,6 +36,18 @@ import java.util.TreeSet; * The assignment will be: * C0: [t0p0, t0p2, t1p1] * C1: [t0p1, t1p0, t1p2] + * + * When subscriptions differ across consumer instances, the assignment process still considers each + * consumer instance in round robin fashion but skips over an instance if it is not subscribed to + * the topic. Unlike the case when subscriptions are identical, this can result in imbalanced + * assignments. For example, we have three consumers C0, C1, C2, and three topics t0, t1, t2, + * with 1, 2, and 3 partitions, respectively. Therefore, the partitions are t0p0, t1p0, t1p1, t2p0, + * t2p1, t2p2. C0 is subscribed to t0; C1 is subscribed to t0, t1; and C2 is subscribed to t0, t1, t2. + * + * Tha assignment will be: + * C0: [t0p0] + * C1: [t1p0] + * C2: [t1p1, t2p0, t2p1, t2p2] */ public class RoundRobinAssignor extends AbstractPartitionAssignor {
