This is the zookeeper listener that triggers all the state transitions for a replica
This API exercises the replica's state machine.
This API exercises the replica's state machine. It ensures that every state transition happens from a legal previous state to the target state.
The topic of the replica for which the state transition is invoked
The partition of the replica for which the state transition is invoked
The replica for which the state transition is invoked
The end state that the replica should be moved to
This API is invoked by the broker change controller callbacks and the startup API of the state machine
This API is invoked by the broker change controller callbacks and the startup API of the state machine
The list of replicas (brokers) that need to be transitioned to the target state
The state that the replicas should be moved to The controller's allLeaders cache should have been updated before this
Invoked on controller shutdown.
Invoked on successful controller election.
Invoked on successful controller election. First registers a broker change listener since that triggers all state transitions for replicas. Initializes the state of replicas for all partitions by reading from zookeeper. Then triggers the OnlineReplica state change for all replicas.
This class represents the state machine for replicas. It defines the states that a replica can be in, and transitions to move the replica to another legal state. The different states that a replica can be in are - 1. NewReplica : The controller can create new replicas during partition reassignment. In this state, a replica can only get become follower state change request. Valid previous state is NonExistentReplica 2. OnlineReplica : Once a replica is started and part of the assigned replicas for its partition, it is in this state. In this state, it can get either become leader or become follower state change requests. Valid previous state are NewReplica, OnlineReplica or OfflineReplica 3. OfflineReplica : If a replica dies, it moves to this state. This happens when the broker hosting the replica is down. Valid previous state are NewReplica, OnlineReplica 4. NonExistentReplica: If a replica is deleted, it is moved to this state. Valid previous state is OfflineReplica