mumrah commented on code in PR #12961:
URL: https://github.com/apache/kafka/pull/12961#discussion_r1046370590
##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -1317,14 +1316,23 @@ class KafkaApis(val requestChannel: RequestChannel,
trace("Sending topic metadata %s and brokers %s for correlation id %d to
client %s".format(completeTopicMetadata.mkString(","),
brokers.mkString(","), request.header.correlationId,
request.header.clientId))
+ val controllerId = {
+ metadataCache match {
+ case cache: KRaftMetadataCache => cache.getControllerId.map(_.id)
+ case cache => cache.getControllerId.flatMap {
Review Comment:
Can we add the class for this case as well?
##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -3332,13 +3340,21 @@ class KafkaApis(val requestChannel: RequestChannel,
}
val brokers =
metadataCache.getAliveBrokerNodes(request.context.listenerName)
- val controllerId =
metadataCache.getControllerId.getOrElse(MetadataResponse.NO_CONTROLLER_ID)
+ val controllerId = {
+ metadataCache match {
+ case cache: KRaftMetadataCache => cache.getControllerId.map(_.id)
+ case cache => cache.getControllerId.flatMap {
Review Comment:
And here
##########
core/src/main/scala/kafka/server/metadata/ZkMetadataCache.scala:
##########
@@ -315,7 +324,18 @@ class ZkMetadataCache(brokerId: Int, metadataVersion:
MetadataVersion, brokerFea
}.getOrElse(Map.empty[Int, Node])
}
- def getControllerId: Option[Int] = metadataSnapshot.controllerId
+ def getControllerId: Option[CachedControllerId] = {
+ val snapshot = metadataSnapshot
+ snapshot.kraftControllerId match {
+ case Some(id) => Some(KRaftCachedControllerId(id))
+ case None => snapshot.controllerId.map(ZkCachedControllerId)
+ }
+ }
+
+ def getRandomAliveBrokerId: Option[Int] = {
Review Comment:
errant whitespace
--
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]