You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/01 10:35:50 UTC

[GitHub] [kafka] dengziming commented on a change in pull request #9769: KAFKA-10774; Support Describe topic using topic IDs

dengziming commented on a change in pull request #9769:
URL: https://github.com/apache/kafka/pull/9769#discussion_r567718317



##########
File path: core/src/main/scala/kafka/server/KafkaApis.scala
##########
@@ -1191,8 +1192,35 @@ class KafkaApis(val requestChannel: RequestChannel,
     val metadataRequest = request.body[MetadataRequest]
     val requestVersion = request.header.apiVersion
 
+    // Check if topicId is presented firstly.
+    val topicIds = metadataRequest.topicIds.asScala.toSet.filterNot(_ == Uuid.ZERO_UUID)
+    val useTopicId = topicIds.nonEmpty
+
+    val (supportedVersionTopicIds, unsupportedVersionTopicIds) = if (config.interBrokerProtocolVersion >= KAFKA_2_8_IV1)
+      (topicIds, Set.empty[Uuid])
+    else
+      (Set.empty[Uuid], topicIds)
+
+    val unsupportedVersionTopicMetadata = if (unsupportedVersionTopicIds.isEmpty)
+      Seq.empty[MetadataResponseTopic]
+    else
+      unsupportedVersionTopicIds.map(topicId =>
+        metadataResponseTopic(Errors.UNSUPPORTED_VERSION, null, topicId, false, util.Collections.emptyList())).toSeq
+
+    // Only get topicIds and topicNames when supporting topicId
+    val unknownTopicIds = supportedVersionTopicIds.filter(metadataCache.getTopicName(_).isEmpty)
+    val knownTopicNames = supportedVersionTopicIds.flatMap(metadataCache.getTopicName)
+
+    val unknownTopicIdsTopicMetadata = if (unknownTopicIds.isEmpty)
+      Seq.empty[MetadataResponseTopic]
+    else
+      unknownTopicIds.map(topicId =>
+        metadataResponseTopic(Errors.UNKNOWN_TOPIC_ID, null, topicId, false, util.Collections.emptyList())).toSeq
+
     val topics = if (metadataRequest.isAllTopics)
       metadataCache.getAllTopics()
+    else if (useTopicId)

Review comment:
       According to KIP-516, we just ignore topic name if a none zero topic id is provided. 




----------------------------------------------------------------
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:
users@infra.apache.org