You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by jg...@apache.org on 2018/03/14 21:58:27 UTC
[kafka] branch trunk updated: KAFKA-6640;
Improve efficiency of KafkaAdminClient.describeTopics() (#4694)
This is an automated email from the ASF dual-hosted git repository.
jgus pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new d935699 KAFKA-6640; Improve efficiency of KafkaAdminClient.describeTopics() (#4694)
d935699 is described below
commit d93569948657a1fd58dad9fd2541b75b2b330a4a
Author: Dong Lin <li...@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 <is...@juma.me.uk>, Colin Patrick McCabe <co...@cmccabe.xyz>, Jason Gustafson <ja...@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.