kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: MINOR: Describe topics should describe, not delete
Date Tue, 02 May 2017 11:43:14 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 94a35fd93 -> 64ea193ce


MINOR: Describe topics should describe, not delete

Author: dan norwood <norwood@confluent.io>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #2952 from norwood/describe-not-delete


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/64ea193c
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/64ea193c
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/64ea193c

Branch: refs/heads/trunk
Commit: 64ea193ceee931ee42c3fce27341980ee7c50d15
Parents: 94a35fd
Author: dan norwood <norwood@confluent.io>
Authored: Mon May 1 23:43:04 2017 -0700
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Tue May 2 12:28:20 2017 +0100

----------------------------------------------------------------------
 .../clients/admin/DescribeTopicsResults.java    |  4 ++--
 .../kafka/clients/admin/KafkaAdminClient.java   |  3 ++-
 .../api/KafkaAdminClientIntegrationTest.scala   | 21 +++++++++-----------
 3 files changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/64ea193c/clients/src/main/java/org/apache/kafka/clients/admin/DescribeTopicsResults.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/clients/admin/DescribeTopicsResults.java
b/clients/src/main/java/org/apache/kafka/clients/admin/DescribeTopicsResults.java
index 630ba95..5c309bb 100644
--- a/clients/src/main/java/org/apache/kafka/clients/admin/DescribeTopicsResults.java
+++ b/clients/src/main/java/org/apache/kafka/clients/admin/DescribeTopicsResults.java
@@ -37,14 +37,14 @@ public class DescribeTopicsResults {
 
     /**
      * Return a map from topic names to futures which can be used to check the status of
-     * individual deletions.
+     * individual topics.
      */
     public Map<String, KafkaFuture<TopicDescription>> results() {
         return futures;
     }
 
     /**
-     * Return a future which succeeds only if all the topic deletions succeed.
+     * Return a future which succeeds only if all the topic descriptions succeed.
      */
     public KafkaFuture<Map<String, TopicDescription>> all() {
         return KafkaFuture.allOf(futures.values().toArray(new KafkaFuture[0])).

http://git-wip-us.apache.org/repos/asf/kafka/blob/64ea193c/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
----------------------------------------------------------------------
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 cf37aa7..ad921f8 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
@@ -63,6 +63,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.net.InetSocketAddress;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -965,7 +966,7 @@ public class KafkaAdminClient extends AdminClient {
 
             @Override
             AbstractRequest.Builder createRequest(int timeoutMs) {
-                return new DeleteTopicsRequest.Builder(new HashSet<>(topicNames), timeoutMs);
+                return new MetadataRequest.Builder(new ArrayList<>(topicNames));
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/kafka/blob/64ea193c/core/src/test/scala/integration/kafka/api/KafkaAdminClientIntegrationTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/integration/kafka/api/KafkaAdminClientIntegrationTest.scala
b/core/src/test/scala/integration/kafka/api/KafkaAdminClientIntegrationTest.scala
index 9c5468f..04ed9c9 100644
--- a/core/src/test/scala/integration/kafka/api/KafkaAdminClientIntegrationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/KafkaAdminClientIntegrationTest.scala
@@ -108,27 +108,24 @@ class KafkaAdminClientIntegrationTest extends KafkaServerTestHarness
with Loggin
   @Test
   def testCreateDeleteTopics(): Unit = {
     client = AdminClient.create(createConfig())
-    val newTopics : List[NewTopic] = List(
-        new NewTopic("mytopic", 1, 1),
-        new NewTopic("mytopic2", 1, 1))
-    client.createTopics(newTopics.asJava,
-      new CreateTopicsOptions().validateOnly(true)).all().get()
+    val topics = Seq("mytopic", "mytopic2")
+    val newTopics = topics.map(new NewTopic(_, 1, 1))
+    client.createTopics(newTopics.asJava, new CreateTopicsOptions().validateOnly(true)).all.get()
     waitForTopics(client, List(), List("mytopic", "mytopic2"))
 
-    client.createTopics(newTopics.asJava).all().get()
+    client.createTopics(newTopics.asJava).all.get()
     waitForTopics(client, List("mytopic", "mytopic2"), List())
 
     val results = client.createTopics(newTopics.asJava).results()
-    assert(results.containsKey("mytopic"))
+    assertTrue(results.containsKey("mytopic"))
     assertFutureExceptionTypeEquals(results.get("mytopic"), classOf[TopicExistsException])
-    assert(results.containsKey("mytopic2"))
+    assertTrue(results.containsKey("mytopic2"))
     assertFutureExceptionTypeEquals(results.get("mytopic2"), classOf[TopicExistsException])
+    val topicsFromDescribe = client.describeTopics(Seq("mytopic", "mytopic2").asJava).all.get().asScala.keys
+    assertEquals(topics.toSet, topicsFromDescribe)
 
-    val deleteTopics : Set[String] = Set("mytopic", "mytopic2")
-    client.deleteTopics(deleteTopics.asJava).all().get()
+    client.deleteTopics(topics.asJava).all.get()
     waitForTopics(client, List(), List("mytopic", "mytopic2"))
-
-    client.close()
   }
 
   @Test


Mime
View raw message