Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

PlantUML Render Macro
formatPNG

@startuml

[*]

--> NOT_IN_GROUP
NOT_IN_GROUP --->

Stable
Stable : this is a string
Stable : this is another string
Stable

UNJOINED

UNJOINED ---> UNJOINED : Heartbeat on retries
UNJOINED ---> STABLE : Heartbeat, epoch = 0
UNJOINED --->

Revoking

FATAL

Stable

STABLE --->

Assigning
state Revoking {
R1: entry point into revoking partitions
R2: if we have a callback,\nwe need to invoke it
R3: after we've made local changes,\nawait heartbeat
[*] --> R1
R1 -> R2
R2 -> R3
R1 -> R3
R3 ---> Stable
R3 ---> Assigning
}
state Assigning {
A1: entry point into assigning partitions
A2: if we have a callback,\nwe need to invoke it
A3: after we've made local changes,\nawait heartbeat
[*] --> A1
A1 -> A2
A1 -> A3
A2 -> A3
A3 -> Stable
}
Stable --> Closing
Revoking --> Closing
Assigning --> Closing
Closing -->

RECONCILING : new assignment received\ntrigger callbacks
STABLE ---> RELEASING_ASSIGNMENT : on HB fencing error, reset epoch,\ntrigger callbacks
STABLE ---> FATAL
STABLE ---> STABLE : Heartbeat

RECONCILING ---> RECONCILING : Heartbeat
RECONCILING ---> RECONCILIATION_COMPLETE : callback completed
RECONCILIATION_COMPLETE ---> STABLE : Send heartbeat w/ full assignment,\nreset interval timer to\nheartbeat.interval.ms
RECONCILING ---> FATAL

RELEASING_ASSIGNMENT ---> RELEASING_ASSIGNMENT_COMPLETE : 'onLost' callback completed
RELEASING_ASSIGNMENT_COMPLETE ---> UNJOINED : Send out-of-interval HB
RELEASING_ASSIGNMENT ---> FATAL

FATAL ---> [*]

@enduml




StepThreadStarting StateEnding StateNotes
1BackgroundStableStableNo new assignments are included in the heartbeat response.
2BackgroundStableUpdatingWhen the heartbeat response contains a new assignment, this is passed to the MemberAssignmentReconciler along with the current set of assigned partitions.
3BackgroundUpdatingUpdatingThe MemberAssignmentReconciler will compare the new assignment against the current assignment to determine any newly revoked partitions.
4Background

Updating

Revoking via Callback

If there are partitions that need to be revoked and there is a ConsumerRebalanceListener configured for the Consumer, the MemberAssignmentReconciler will enqueue a RevokePartitionsEvent containing the set of newly revoked partitions onto the background event queue.

5Background

Updating

Assigning

If there are no partitions to revoke or there is no ConsumerRebalanceListener, skip to step ??????

6ApplicationRevoking via CallbackRevoking via CallbackWhen the user next invokes Consumer.poll(), the events from the background event queue will be examined and acted upon. When the RevokePartitionsEvent is processed, the ConsumerRebalanceListener.onPartitionsRevoked() method will be invoked, passing along the partitions contained within the event.
7ApplicationRevokingRevokingAfter onPartitionsRevoked() has been successfully(?) invoked, the Consumer will enqueue a PartitionsRevokedEvent containing the set of partitions that were revoked onto the queue that flows from the application thread back to the background thread.
8BackgroundRevokingAwaiting Revocation ConfirmationRead the events of the application event queue and invoke the appropriate ApplicationEventProcessor handler for the PartitionsRevokedEvent. This will invoke the MemberAssignmentReconciler.onRevocation() method to update its state.
9BackgroundAwaiting Revocation ConfirmationAwaiting Revocation ConfirmationThe 
9BackgroundAwaiting Revocation ConfirmationUpdatingWhen the heartbeat response confirms (how?) that the revocation has been acknowledged by the coordinator, we can move to step 2.
10BackgroundUpdatingUpdatingThe MemberAssignmentReconciler will compare the new assignment against the current assignment to determine any newly assigned partition sets.
11BackgroundUpdatingAssigning via CallbackIf there are partitions that need to be assigned and there is a ConsumerRebalanceListener, the MemberAssignmentReconciler will enqueue an AssignPartitionsEvent containing the set of partitions to assign onto the queue that flows from the background thread to the application thread.
12


If there are no partitions to assign or there is no ConsumerRebalanceListener, skip to step 1
13ApplicationAssigning via Callback
When the user next invokes Consumer.poll(), the events from the background event queue will be examined and acted upon. When the AssignPartitionsEvent is processed, the ConsumerRebalanceListener's onPartitionsAssigned() method will be invoked, passing along the partitions contained within the event.
14



15



13



14



19