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



##########
File path: core/src/main/scala/kafka/tools/GetOffsetShell.scala
##########
@@ -222,11 +240,19 @@ object GetOffsetShell {
   }
 
   /**
-   * Return the partition infos. Filter them with topicPartitionFilter.
+   * Return the partition infos. Filter them with topicFilter and 
topicPartitionFilter.
    */
-  private def listPartitionInfos(consumer: KafkaConsumer[_, _], 
topicPartitionFilter: PartitionInfo => Boolean): Seq[PartitionInfo] = {
-    consumer.listTopics.asScala.values.flatMap { partitions =>
-      partitions.asScala.filter(topicPartitionFilter)
+  private def listPartitionInfos(client: Admin,
+                                 topicFilter: String => Boolean,
+                                 topicPartitionFilter: PartitionInfo => 
Boolean,
+                                 excludeInternalTopics: Boolean): 
Seq[PartitionInfo] = {
+    val topics = client.listTopics(new 
ListTopicsOptions().listInternal(!excludeInternalTopics)).names().get().asScala.filter(topicFilter)
+    
client.describeTopics(topics.asJavaCollection).allTopicNames().get().asScala.flatMap
 { case (topic, description) =>
+      description
+        .partitions()
+        .asScala
+        .map(tp => new PartitionInfo(topic, tp.partition(), tp.leader(), 
tp.replicas().asScala.toArray, tp.isr().asScala.toArray))

Review comment:
       I tried this according to your suggestion, however, the 
class`TopicPartitionInfo` holds no topic information and the class 
`TopicPartition` holds no leader information, these 2 fields are necessary for 
`listOffsets`, so I just left as it was.




-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to