Returns true if this broker is the current controller.
This callback is invoked by the replica state machine's broker change listener with the list of failed brokers as input.
This callback is invoked by the replica state machine's broker change listener with the list of failed brokers as input. It does the following - 1. Mark partitions with dead leaders as offline 2. Triggers the OnlinePartition state change for all new/offline partitions 3. Invokes the OfflineReplica state change on the input list of newly started brokers
Note that we don't need to refresh the leader/isr cache for all topic/partitions at this point. This is because the partition state machine will refresh our cache for us when performing leader election for all new/offline partitions coming online.
This callback is invoked by the replica state machine's broker change listener, with the list of newly started brokers as input.
This callback is invoked by the replica state machine's broker change listener, with the list of newly started brokers as input. It does the following - 1. Triggers the OnlinePartition state change for all new/offline partitions 2. It checks whether there are reassigned replicas assigned to any newly started brokers. If so, it performs the reassignment logic for each topic/partition.
Note that we don't need to refresh the leader/isr cache for all topic/partitions at this point for two reasons: 1. The partition state machine, when triggering online state change, will refresh leader and ISR for only those partitions currently new or offline (rather than every partition this controller is aware of) 2. Even if we do refresh the cache, there is no guarantee that by the time the leader and ISR request reaches every broker that it is still valid. Brokers check the leader epoch to determine validity of the request.
This callback is invoked by the zookeeper leader elector on electing the current broker as the new controller.
This callback is invoked by the zookeeper leader elector on electing the current broker as the new controller. It does the following things on the become-controller state change - 1. Register controller epoch changed listener 2. Increments the controller epoch 3. Initializes the controller's context object that holds cache objects for current topics, live brokers and leaders for all existing partitions. 4. Starts the controller's channel manager 5. Starts the replica state machine 6. Starts the partition state machine If it encounters any unexpected exception/error while becoming controller, it resigns as the current controller. This ensures another controller election will be triggered and there will always be an actively serving controller
This callback is invoked by the topic change callback with the list of failed brokers as input.
This callback is invoked by the topic change callback with the list of failed brokers as input. It does the following - 1. Move the newly created partitions to the NewPartition state 2. Move the newly created partitions from NewPartition->OnlinePartition state
This callback is invoked by the partition state machine's topic change listener with the list of failed brokers as input.
This callback is invoked by the partition state machine's topic change listener with the list of failed brokers as input. It does the following - 1. Registers partition change listener. This is not required until KAFKA-347 2. Invokes the new partition callback
This callback is invoked by the reassigned partitions listener.
This callback is invoked by the reassigned partitions listener. When an admin command initiates a partition reassignment, it creates the /admin/reassign_partitions path that triggers the zookeeper listener. Reassigning replicas for a partition goes through a few stages - RAR = Reassigned replicas AR = Original list of replicas for partition 1. Register listener for ISR changes to detect when the RAR is a subset of the ISR 2. Start new replicas RAR - AR. 3. Wait until new replicas are in sync with the leader 4. If the leader is not in RAR, elect a new leader from RAR 5. Stop old replicas AR - RAR 6. Write new AR 7. Remove partition from the /admin/reassign_partitions path
Removes a given partition replica from the ISR; if it is not the current leader and there are sufficient remaining replicas in ISR.
Removes a given partition replica from the ISR; if it is not the current leader and there are sufficient remaining replicas in ISR.
topic
partition
replica Id
the new leaderAndIsr (with the replica removed if it was present), or None if leaderAndIsr is empty.
Invoked when the controller module of a Kafka server is shutting down.
Invoked when the controller module of a Kafka server is shutting down. If the broker was the current controller, it shuts down the partition and replica state machines. If not, those are a no-op. In addition to that, it also shuts down the controller channel manager, if one exists (i.e. if it was the current controller)
On clean shutdown, the controller first determines the partitions that the shutting down broker leads, and moves leadership of those partitions to another broker that is in that partition's ISR.
On clean shutdown, the controller first determines the partitions that the shutting down broker leads, and moves leadership of those partitions to another broker that is in that partition's ISR.
Id of the broker to shutdown.
The number of partitions that the broker still leads.
Invoked when the controller module of a Kafka server is started up.
Invoked when the controller module of a Kafka server is started up. This does not assume that the current broker is the controller. It merely registers the session expiration listener and starts the controller leader elector