public interface TaskAssignor
extends org.apache.kafka.common.Configurable
ApplicationState
.
The implementation may also override the onAssignmentComputed
callback for insight into
the result of the assignment result.Modifier and Type | Interface and Description |
---|---|
static class |
TaskAssignor.AssignmentError
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 |
TaskAssignor.TaskAssignment
Wrapper class for the final assignment of active and standbys tasks to individual
KafkaStreams clients.
|
Modifier and Type | Method and Description |
---|---|
TaskAssignor.TaskAssignment |
assign(ApplicationState applicationState) |
default void |
configure(Map<String,?> configs) |
default void |
onAssignmentComputed(org.apache.kafka.clients.consumer.ConsumerPartitionAssignor.GroupAssignment assignment,
org.apache.kafka.clients.consumer.ConsumerPartitionAssignor.GroupSubscription subscription,
TaskAssignor.AssignmentError error)
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.
|
TaskAssignor.TaskAssignment assign(ApplicationState applicationState)
applicationState
- the metadata for this Kafka Streams applicationTaskAssignmentException
- 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.default void onAssignmentComputed(org.apache.kafka.clients.consumer.ConsumerPartitionAssignor.GroupAssignment assignment, org.apache.kafka.clients.consumer.ConsumerPartitionAssignor.GroupSubscription subscription, TaskAssignor.AssignmentError error)
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.
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 GroupAssignmentsubscription
- the original consumer subscriptions passed into the assignorerror
- the corresponding error type if one was detected while processing the returned assignment,
or AssignmentError.NONE if the returned assignment was valid