THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
stateChangeListener(r) { // listens to state change requests issued by the leader and acts on those read next state change request if(becomeFollowerRequest) becomeFollower(r) if(replicaUnassignedRequest) closeReplica(r) if(deleteReplicaRequest) deleteReplica(r) if(replicaAssignedRequest) replicaStateChange(r) } |
State change events
On leader change
This state change listener is registered on every broker hosting partition p. Each time it is triggered, the following procedure is executed -
Code Block |
---|
onLeaderChange()
{
if(r is registered under /brokers/topics/[topic]/[partition_id]/replicas)
leaderElection()
else
// some other replica is already the leader, and will send the become follower state change request to this replica
}
|
On replica change
Every time a replica change event is triggered, the leader calls onReplicaChange()
Code Block |
---|
onReplicaChange()
{
for new replica assigned to follower R
send start replica state change request to R
for replica r un-assigned from follower R
send close replica state change request to R
}
|
On reassignment of partitions
Each time a partition reassigned event is triggered, the leader calls onPartitionReassigned()
Code Block |
---|
onPartitionsReassigned()
{
p.RAR = the new replicas from /brokers/partitions_reassigned/[topic]/[partition_id]
if(a new replica is to be reassigned to follower R)
send start-replica state change request to R
}
|
State change operations
Replica state change
...