Skip to content

ReplicaStateMachine

Review Me

ReplicaStateMachine is the <> of <> that can <>, be <> and <> in the end.

[[contract]] .ReplicaStateMachine Contract (Abstract Methods Only) [cols="30m,70",options="header",width="100%"] |=== | Method | Description

| handleStateChanges a| [[handleStateChanges]]

[source, scala]

handleStateChanges( replicas: Seq[PartitionAndReplica], targetState: ReplicaState): Unit


Handles state changes of replicas (replica state changes)

Used when:

  • KafkaController is requested to <>, <>, <>, <>, <>, <>, <>, and <>

  • ReplicaStateMachine is requested to <> (when KafkaController is requested to <> on a broker elected as the controller)

  • TopicDeletionManager is requested to <>, <>, <>, <>, and <>

|===

[[implementations]] NOTE: <> is the default and only known implementation of the <> in Apache Kafka.

[[creating-instance]][[controllerContext]] ReplicaStateMachine takes a single <> to be created.

NOTE: ReplicaStateMachine is a Scala abstract class and cannot be <> directly. It is created indirectly for the <>.

=== [[shutdown]] Shutting Down -- shutdown Method

[source, scala]

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 <>.

=== [[startup]] Starting Up (On Active Controller) -- startup Method

[source, scala]

startup(): Unit

startup prints out the following INFO message to the logs:

Initializing replica state

startup <>.

startup prints out the following INFO message to the logs:

Triggering online replica state changes

startup requests the <> for <>.

startup <> (with the online replicas and OnlineReplica target state).

startup prints out the following INFO message to the logs:

Triggering offline replica state changes

startup <> (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 <> (when a broker is successfully elected as the controller).

=== [[initializeReplicaState]] Initializing Partition Replica States using ControllerContext -- initializeReplicaState Internal Method

[source, scala]

initializeReplicaState(): Unit

initializeReplicaState requests the <> for <>.

For every partition, initializeReplicaState requests the <> for the <> (the broker IDs of partition replicas).

For every partition replica, initializeReplicaState requests the <> to <> to OnlineReplica or ReplicaDeletionIneligible per <>.

NOTE: initializeReplicaState is used exclusively when ReplicaStateMachine is requested to <>.