The process of promoting a broker to be the active controller is called Kafka Controller Election.
In a Kafka cluster, one of the brokers serves as the controller, which is responsible for managing the states of partitions and replicas and for performing administrative tasks like reassigning partitions.
Kafka Controller registers handlers to be notified about changes in Zookeeper and propagate them across brokers in a Kafka cluster.
While in initializeControllerContext,
KafkaController updateLeaderAndIsrCache (and reads partition state from
/brokers/topics/[topic]/partitions/[partition]/state paths in Zookeeper that is then stored as partitionLeadershipInfo of the ControllerContext).