Interface TaskAssignor

All Superinterfaces:
Configurable
All Known Implementing Classes:
StickyTaskAssignor

public interface TaskAssignor extends Configurable
A TaskAssignor is responsible for creating a TaskAssignment from a given ApplicationState. The implementation may also override the onAssignmentComputed callback for insight into the result of the assignment result.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    NONE: no error detected ACTIVE_TASK_ASSIGNED_MULTIPLE_TIMES: multiple KafkaStreams clients assigned with the same active task INVALID_STANDBY_TASK: stateless task assigned as a standby task MISSING_PROCESS_ID: ProcessId present in the input ApplicationState was not present in the output TaskAssignment UNKNOWN_PROCESS_ID: unrecognized ProcessId not matching any of the participating consumers UNKNOWN_TASK_ID: unrecognized TaskId not matching any of the tasks to be assigned
    static class 
    Wrapper class for the final assignment of active and standbys tasks to individual KafkaStreams clients.
  • Method Summary

    Modifier and Type
    Method
    Description
    assign(ApplicationState applicationState)
     
    default void
    configure(Map<String,?> configs)
    Configure this class with the given key-value pairs
    default void
    This callback can be used to observe the final assignment returned to the brokers and check for any errors that were detected while processing the returned assignment.
  • Method Details

    • assign

      Parameters:
      applicationState - the metadata for this Kafka Streams application
      Returns:
      the assignment of active and standby tasks to KafkaStreams clients
      Throws:
      TaskAssignmentException - If an error occurs during assignment, and you wish for the rebalance to be retried, you can throw this exception to keep the assignment unchanged and automatically schedule an immediate followup rebalance.
    • onAssignmentComputed

      This callback can be used to observe the final assignment returned to the brokers and check for any errors that were detected while processing the returned assignment. If any errors were found, the corresponding will be returned and a StreamsException will be thrown after this callback returns. The StreamsException will be thrown up to kill the StreamThread and can be handled as any other uncaught exception would if the application has registered a StreamsUncaughtExceptionHandler.

      Note: some kinds of errors will make it impossible for the StreamsPartitionAssignor to parse the TaskAssignment that was returned from the TaskAssignor's assign(org.apache.kafka.streams.processor.assignment.ApplicationState). If this occurs, the ConsumerPartitionAssignor.GroupAssignment passed in to this callback will contain an empty map instead of the consumer assignments.

      Parameters:
      assignment - the final consumer assignments returned to the kafka broker, or an empty assignment map if an error prevented the assignor from converting the TaskAssignment into a GroupAssignment
      subscription - the original consumer subscriptions passed into the assignor
      error - the corresponding error type if one was detected while processing the returned assignment, or AssignmentError.NONE if the returned assignment was valid
    • configure

      default void configure(Map<String,?> configs)
      Description copied from interface: Configurable
      Configure this class with the given key-value pairs
      Specified by:
      configure in interface Configurable