mumrah commented on code in PR #15695:
URL: https://github.com/apache/kafka/pull/15695#discussion_r1560161829
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -657,15 +657,19 @@ class KafkaServer(
}
private def createCurrentControllerIdMetric(): Unit = {
-
KafkaYammerMetrics.defaultRegistry().newGauge(MetadataLoaderMetrics.CURRENT_CONTROLLER_ID,
() => {
- Option(metadataCache) match {
- case None => -1
- case Some(cache) => cache.getControllerId match {
- case None => -1
- case Some(id) => id.id
- }
- }
- })
+
KafkaYammerMetrics.defaultRegistry().newGauge(MetadataLoaderMetrics.CURRENT_CONTROLLER_ID,
+ () => getCurrentControllerIdFromOldController())
+ }
+
+ /**
+ * Get the current controller ID from the old controller code.
+ * This is the most up-to-date controller ID we can get when in ZK mode.
+ */
+ def getCurrentControllerIdFromOldController(): Int = {
+ Option(_kafkaController) match {
+ case None => -1
Review Comment:
Is this just to cover the startup case? (When `_kafkaController` is None)
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -657,15 +657,19 @@ class KafkaServer(
}
private def createCurrentControllerIdMetric(): Unit = {
-
KafkaYammerMetrics.defaultRegistry().newGauge(MetadataLoaderMetrics.CURRENT_CONTROLLER_ID,
() => {
- Option(metadataCache) match {
- case None => -1
- case Some(cache) => cache.getControllerId match {
Review Comment:
Will this work in hybrid mode? Don't we still need to read from the metadata
cache to get the KRaft controller ID once we've entered hybrid mode?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]