Interface ManualPartitioner

All Superinterfaces:
Serializable
All Known Implementing Classes:
RoundRobinManualPartitioner
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ManualPartitioner extends Serializable
A function used to assign partitions to this spout.

WARNING if this is not done correctly you can really mess things up, like not reading data in some partitions. The complete TopologyContext is passed in, but it is suggested that you use the index of the spout and the total number of spouts to avoid missing partitions or double assigning partitions.

  • Method Summary

    Modifier and Type
    Method
    Description
    Set<org.apache.kafka.common.TopicPartition>
    getPartitionsForThisTask(List<org.apache.kafka.common.TopicPartition> allPartitionsSorted, TopologyContext context)
    Filter the list of all partitions handled by this set of spouts to get only the partitions assigned to this task.
  • Method Details

    • getPartitionsForThisTask

      Set<org.apache.kafka.common.TopicPartition> getPartitionsForThisTask(List<org.apache.kafka.common.TopicPartition> allPartitionsSorted, TopologyContext context)
      Filter the list of all partitions handled by this set of spouts to get only the partitions assigned to this task.
      Parameters:
      allPartitionsSorted - all of the partitions that the set of spouts want to subscribe to in a strict ordering that is consistent across tasks
      context - the context of the topology
      Returns:
      the subset of the partitions that this spout task should handle.