kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [kafka] branch trunk updated: KAFKA-6672; ConfigCommand should create config change parent path if needed (#4727)
Date Sat, 17 Mar 2018 05:29:31 GMT
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 9782465  KAFKA-6672; ConfigCommand should create config change parent path if needed
(#4727)
9782465 is described below

commit 9782465d6f28dda7fd7f156743f4278e6b62364b
Author: Jason Gustafson <jason@confluent.io>
AuthorDate: Fri Mar 16 22:29:22 2018 -0700

    KAFKA-6672; ConfigCommand should create config change parent path if needed (#4727)
    
    Change `KafkaZkClient.createConfigChangeNotification` to ensure creation of the change
directory. This fixes failing system tests which depend on setting SCRAM credentials prior
to broker startup. Existing test case has been modified for new expected usage.
    
    Reviewers: Ismael Juma <ismael@juma.me.uk>
---
 core/src/main/scala/kafka/admin/ConfigCommand.scala       |  4 ++--
 core/src/main/scala/kafka/zk/KafkaZkClient.scala          |  3 ++-
 core/src/test/scala/unit/kafka/zk/KafkaZkClientTest.scala | 13 ++++++++-----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/core/src/main/scala/kafka/admin/ConfigCommand.scala b/core/src/main/scala/kafka/admin/ConfigCommand.scala
index 044be6a..3563448 100644
--- a/core/src/main/scala/kafka/admin/ConfigCommand.scala
+++ b/core/src/main/scala/kafka/admin/ConfigCommand.scala
@@ -80,12 +80,12 @@ object ConfigCommand extends Config {
       }
     } catch {
       case e @ (_: IllegalArgumentException | _: InvalidConfigException | _: OptionException)
=>
-        logger.debug(s"Failed config command with args $args", e)
+        logger.debug(s"Failed config command with args '${args.mkString(" ")}'", e)
         System.err.println(e.getMessage)
         Exit.exit(1)
 
       case t: Throwable =>
-        System.err.println(s"Error while executing config command with args $args")
+        System.err.println(s"Error while executing config command with args '${args.mkString("
")}'")
         t.printStackTrace(System.err)
         Exit.exit(1)
     }
diff --git a/core/src/main/scala/kafka/zk/KafkaZkClient.scala b/core/src/main/scala/kafka/zk/KafkaZkClient.scala
index d61b281..0a2d96a 100644
--- a/core/src/main/scala/kafka/zk/KafkaZkClient.scala
+++ b/core/src/main/scala/kafka/zk/KafkaZkClient.scala
@@ -286,10 +286,11 @@ class KafkaZkClient private (zooKeeperClient: ZooKeeperClient, isSecure:
Boolean
    * @throws KeeperException if there is an error while setting or creating the znode
    */
   def createConfigChangeNotification(sanitizedEntityPath: String): Unit = {
+    makeSurePersistentPathExists(ConfigEntityChangeNotificationZNode.path)
     val path = ConfigEntityChangeNotificationSequenceZNode.createPath
     val createRequest = CreateRequest(path, ConfigEntityChangeNotificationSequenceZNode.encode(sanitizedEntityPath),
acls(path), CreateMode.PERSISTENT_SEQUENTIAL)
     val createResponse = retryRequestUntilConnected(createRequest)
-    createResponse.maybeThrow
+    createResponse.maybeThrow()
   }
 
   /**
diff --git a/core/src/test/scala/unit/kafka/zk/KafkaZkClientTest.scala b/core/src/test/scala/unit/kafka/zk/KafkaZkClientTest.scala
index e44c2c9..a6c0956 100644
--- a/core/src/test/scala/unit/kafka/zk/KafkaZkClientTest.scala
+++ b/core/src/test/scala/unit/kafka/zk/KafkaZkClientTest.scala
@@ -562,16 +562,19 @@ class KafkaZkClientTest extends ZooKeeperTestHarness {
 
   @Test
   def testCreateConfigChangeNotification(): Unit = {
-    intercept[NoNodeException] {
-      zkClient.createConfigChangeNotification(ConfigEntityZNode.path(ConfigType.Topic, topic1))
-    }
+    assertFalse(zkClient.pathExists(ConfigEntityChangeNotificationZNode.path))
 
-    zkClient.createTopLevelPaths()
+    // The parent path is created if needed
     zkClient.createConfigChangeNotification(ConfigEntityZNode.path(ConfigType.Topic, topic1))
-
     assertPathExistenceAndData(
       "/config/changes/config_change_0000000000",
       """{"version":2,"entity_path":"/config/topics/topic1"}""")
+
+    // Creation does not fail if the parent path exists
+    zkClient.createConfigChangeNotification(ConfigEntityZNode.path(ConfigType.Topic, topic2))
+    assertPathExistenceAndData(
+      "/config/changes/config_change_0000000001",
+      """{"version":2,"entity_path":"/config/topics/topic2"}""")
   }
 
   private def createLogProps(bytesProp: Int): Properties = {

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

Mime
View raw message