kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [kafka] branch 1.1 updated: KAFKA-6640; Improve efficiency of KafkaAdminClient.describeTopics() (#4694)
Date Wed, 14 Mar 2018 22:06:14 GMT
This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch 1.1
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/1.1 by this push:
     new a3c7031  KAFKA-6640; Improve efficiency of KafkaAdminClient.describeTopics() (#4694)
a3c7031 is described below

commit a3c70315090b96769afef7e2af9aa505cb7d1837
Author: Dong Lin <lindong28@users.noreply.github.com>
AuthorDate: Wed Mar 14 14:58:24 2018 -0700

    KAFKA-6640; Improve efficiency of KafkaAdminClient.describeTopics() (#4694)
    
    Currently in KafkaAdminClient.describeTopics(), for each topic in the request, a complete
map of cluster and errors will be constructed for every topic and partition. This unnecessarily
increases the complexity of describeTopics() to O(n^2). This patch improves the complexity
to O(n).
    
    Reviewers: Ismael Juma <ismael@juma.me.uk>, Colin Patrick McCabe <colin@cmccabe.xyz>,
Jason Gustafson <jason@confluent.io>
---
 .../main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java b/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
index 36cbe6c..e455b9c 100644
--- a/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
+++ b/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
@@ -1276,15 +1276,16 @@ public class KafkaAdminClient extends AdminClient {
             void handleResponse(AbstractResponse abstractResponse) {
                 MetadataResponse response = (MetadataResponse) abstractResponse;
                 // Handle server responses for particular topics.
+                Cluster cluster = response.cluster();
+                Map<String, Errors> errors = response.errors();
                 for (Map.Entry<String, KafkaFutureImpl<TopicDescription>> entry
: topicFutures.entrySet()) {
                     String topicName = entry.getKey();
                     KafkaFutureImpl<TopicDescription> future = entry.getValue();
-                    Errors topicError = response.errors().get(topicName);
+                    Errors topicError = errors.get(topicName);
                     if (topicError != null) {
                         future.completeExceptionally(topicError.exception());
                         continue;
                     }
-                    Cluster cluster = response.cluster();
                     if (!cluster.topics().contains(topicName)) {
                         future.completeExceptionally(new InvalidTopicException("Topic " +
topicName + " not found."));
                         continue;

-- 
To stop receiving notification emails like this one, please contact
jgus@apache.org.

Mime
View raw message