Class RangeAssignor

  • All Implemented Interfaces:
    org.apache.kafka.clients.consumer.internals.PartitionAssignor

    public class RangeAssignor
    extends org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignor

    This class is not supported.

    The range assignor works on a per-topic basis. For each topic, we lay out the available partitions in numeric order and the consumers in lexicographic order. We then divide the number of partitions by the total number of consumers to determine the number of partitions to assign to each consumer. If it does not evenly divide, then the first few consumers will have one extra partition.

    For example, suppose there are two consumers C0 and C1, two topics t0 and t1, and each topic has 3 partitions, resulting in partitions t0p0, t0p1, t0p2, t1p0, t1p1, and t1p2.

    The assignment will be:

    • C0: [t0p0, t0p1, t1p0, t1p1]
    • C1: [t0p2, t1p2]
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.kafka.clients.consumer.internals.PartitionAssignor

        org.apache.kafka.clients.consumer.internals.PartitionAssignor.Assignment, org.apache.kafka.clients.consumer.internals.PartitionAssignor.Subscription
    • Constructor Summary

      Constructors 
      Constructor Description
      RangeAssignor()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.util.List<TopicPartition>> assign​(java.util.Map<java.lang.String,​java.lang.Integer> partitionsPerTopic, java.util.Map<java.lang.String,​org.apache.kafka.clients.consumer.internals.PartitionAssignor.Subscription> subscriptions)  
      java.lang.String name()  
      • Methods inherited from class org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignor

        assign, onAssignment, partitions, put, subscription
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RangeAssignor

        public RangeAssignor()
    • Method Detail

      • name

        public java.lang.String name()
      • assign

        public java.util.Map<java.lang.String,​java.util.List<TopicPartition>> assign​(java.util.Map<java.lang.String,​java.lang.Integer> partitionsPerTopic,
                                                                                           java.util.Map<java.lang.String,​org.apache.kafka.clients.consumer.internals.PartitionAssignor.Subscription> subscriptions)
        Specified by:
        assign in class org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignor