handleStateChanges(
replicas: Seq[PartitionAndReplica],
targetState: ReplicaState): Unit
ReplicaStateMachine
ReplicaStateMachine
is the base of Replica State Machines that can handleStateChanges, be started up and shut down in the end.
Method | Description |
---|---|
|
Handles state changes of replicas (replica state changes) Used when:
|
Note
|
ZkReplicaStateMachine is the default and only known implementation of the ReplicaStateMachine Contract in Apache Kafka. |
ReplicaStateMachine
takes a single ControllerContext to be created.
Note
|
ReplicaStateMachine is a Scala abstract class and cannot be created directly. It is created indirectly for the concrete ReplicaStateMachines.
|
Shutting Down — shutdown
Method
shutdown(): Unit
shutdown
simply prints out the following INFO message to the logs:
Stopped replica state machine
Note
|
shutdown is used exclusively when KafkaController is requested to resign as the active controller.
|
Starting Up (On Active Controller) — startup
Method
startup(): Unit
startup
prints out the following INFO message to the logs:
Initializing replica state
startup
initializeReplicaState.
startup
prints out the following INFO message to the logs:
Triggering online replica state changes
startup
requests the ControllerContext for online and offline replicas.
startup
handleStateChanges (with the online replicas and OnlineReplica
target state).
startup
prints out the following INFO message to the logs:
Triggering offline replica state changes
startup
handleStateChanges (with the offline replicas and OfflineReplica
target state).
In the end, startup
prints out the following DEBUG message to the logs:
Started replica state machine with initial state -> [replicaState]
Note
|
startup is used exclusively when KafkaController is requested to onControllerFailover (when a broker is successfully elected as the controller).
|
Initializing Partition Replica States using ControllerContext — initializeReplicaState
Internal Method
initializeReplicaState(): Unit
initializeReplicaState
requests the ControllerContext for all partitions.
For every partition, initializeReplicaState
requests the ControllerContext for the partition replica assignment (the broker IDs of partition replicas).
For every partition replica, initializeReplicaState
requests the ControllerContext to putReplicaState to OnlineReplica
or ReplicaDeletionIneligible
per isReplicaOnline.
Note
|
initializeReplicaState is used exclusively when ReplicaStateMachine is requested to start up.
|