mumrah commented on a change in pull request #9050: URL: https://github.com/apache/kafka/pull/9050#discussion_r461709093
########## File path: core/src/main/scala/kafka/controller/KafkaController.scala ########## @@ -1986,101 +1965,125 @@ private[controller] class ControllerStats extends KafkaMetricsGroup { sealed trait ControllerEvent { def state: ControllerState + def preempt(): Unit } case object ControllerChange extends ControllerEvent { - override def state = ControllerState.ControllerChange + override def state: ControllerState = ControllerState.ControllerChange + override def preempt(): Unit = {} Review comment: Can we define a default implementation on the trait rather than overriding all these with empty functions? ########## File path: core/src/main/scala/kafka/controller/KafkaController.scala ########## @@ -2090,6 +2093,12 @@ case class ReplicaLeaderElection( callback: ElectLeadersCallback = _ => {} ) extends ControllerEvent { override def state: ControllerState = ControllerState.ManualLeaderBalance + + override def preempt(): Unit = callback( + partitionsFromAdminClientOpt.fold(Map.empty[TopicPartition, Either[ApiError, Int]]) { partitions => Review comment: nit: I think you can use `foreach` instead of fold + default value ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org