...
Refactor the HeartbeatThread out of the existing implementation. Therefore, we won’t be starting the heartbeat thread, but having the send heartbeat mechanism piggy back onto the background thread.
Right now, the Coordinator state consist of: Unjoin, Prepare_Rebalancing, Complete_Rebalancing, and Stable. Because of the complexity of the rebalance callback and background thread added to the new implementation, we will:
Add new states for partition assignment and revocation:
Add “REVOKE_PARTITION” state, to handle onPartitionRevoke
Add “ASSIGN_PARTITION” state to handle onPartitionAssigned
joinGroupIfNeeded will need to be refactored
(See above) Finer stages of rebalance process, each should be represented by a state, in order for finer control of the rebalance process
For example: onJoinPrepare becomes onJoinPrepare, PartitionRevocation, onJoinPrepareCompleted
Because of the async nature of the new implementation, polling loops like rejoinNeededOrPending will be removed. Background thread will automatically re-discover coordinator if disconnect, using the state machine
We are already doing networkclinet.poll() in the background thread loop
These “loop until done or timeout” mechanisms will piggy back on the background thread loop, and
usetake the advantage of the state machine to advance the progress:
Rebalance States
The existing coordinator impl already has a state machine in place. We will add 4 states, to facilitate the callback execution, and modify the existing states.
...