Class KafkaStreamsAssignment

java.lang.Object
org.apache.kafka.streams.processor.assignment.KafkaStreamsAssignment

public class KafkaStreamsAssignment extends Object
A simple container class for the assignor to return the desired placement of active and standby tasks on KafkaStreams clients.
  • Method Details

    • of

      public static KafkaStreamsAssignment of(ProcessId processId, Set<KafkaStreamsAssignment.AssignedTask> assignment)
      Construct an instance of KafkaStreamsAssignment with this processId and the given set of assigned tasks. If you want this KafkaStreams client to request a followup rebalance, you can set the followupRebalanceDeadline via the withFollowupRebalance(Instant) API.
      Parameters:
      processId - the processId for the KafkaStreams client that should receive this assignment
      assignment - the set of tasks to be assigned to this KafkaStreams client
      Returns:
      a new KafkaStreamsAssignment object with the given processId and assignment
    • withFollowupRebalance

      public KafkaStreamsAssignment withFollowupRebalance(Instant rebalanceDeadline)
      This API can be used to request that a followup rebalance be triggered by the KafkaStreams client receiving this assignment. The followup rebalance will be initiated after the provided deadline has passed, although it will always wait until it has finished the current rebalance before triggering a new one. This request will last until the new rebalance, and will be erased if a new rebalance begins before the scheduled followup rebalance deadline has elapsed. The next assignment must request the followup rebalance again if it still wants to schedule one for the given instant, otherwise no additional rebalance will be triggered after that.
      Parameters:
      rebalanceDeadline - the instant after which this KafkaStreams client will trigger a followup rebalance
      Returns:
      a new KafkaStreamsAssignment object with the same processId and assignment but with the given rebalanceDeadline
    • processId

      public ProcessId processId()
      Returns:
      the ProcessID associated with this KafkaStreamsAssignment
    • tasks

      Returns:
      a read-only set of assigned tasks that are part of this KafkaStreamsAssignment
    • assignTask

      public void assignTask(KafkaStreamsAssignment.AssignedTask newTask)
    • removeTask

      public void removeTask(KafkaStreamsAssignment.AssignedTask removedTask)
    • followupRebalanceDeadline

      public Optional<Instant> followupRebalanceDeadline()
      Returns:
      the followup rebalance deadline in epoch time, after which this KafkaStreams client will trigger a new rebalance.
    • toString

      public String toString()
      Overrides:
      toString in class Object