kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject kafka git commit: KAFKA-4480: Report an error in 'kafka-configs' command if the config to be removed does not exist
Date Sat, 31 Dec 2016 18:49:32 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 29d456cd2 -> 6f09bcb59


KAFKA-4480: Report an error in 'kafka-configs' command if the config to be removed does not
exist

Author: Vahid Hashemian <vahidhashemian@us.ibm.com>

Reviewers: Guozhang Wang <wangguoz@gmail.com>

Closes #2218 from vahidhashemian/KAFKA-4480


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

Branch: refs/heads/trunk
Commit: 6f09bcb59cd42521152cd8439df94606036ad85f
Parents: 29d456c
Author: Vahid Hashemian <vahidhashemian@us.ibm.com>
Authored: Sat Dec 31 10:49:27 2016 -0800
Committer: Guozhang Wang <wangguoz@gmail.com>
Committed: Sat Dec 31 10:49:27 2016 -0800

----------------------------------------------------------------------
 core/src/main/scala/kafka/admin/ConfigCommand.scala | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/6f09bcb5/core/src/main/scala/kafka/admin/ConfigCommand.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/admin/ConfigCommand.scala b/core/src/main/scala/kafka/admin/ConfigCommand.scala
index aa3780e..9c4c5ed 100644
--- a/core/src/main/scala/kafka/admin/ConfigCommand.scala
+++ b/core/src/main/scala/kafka/admin/ConfigCommand.scala
@@ -21,13 +21,12 @@ import java.util.Properties
 import joptsimple._
 import kafka.common.Config
 import kafka.log.LogConfig
-import kafka.server.{ConfigEntityName, QuotaId}
-import kafka.server.{DynamicConfig, ConfigType}
+import kafka.server.{ConfigEntityName, ConfigType, DynamicConfig, QuotaId}
 import kafka.utils.{CommandLineUtils, ZkUtils}
 import org.apache.kafka.common.security.JaasUtils
 import org.apache.kafka.common.utils.Utils
-import scala.collection.JavaConverters._
 import scala.collection._
+import scala.collection.JavaConverters._
 
 
 /**
@@ -83,8 +82,15 @@ object ConfigCommand extends Config {
 
     // compile the final set of configs
     val configs = utils.fetchEntityConfig(zkUtils, entityType, entityName)
+
     configs.putAll(configsToBeAdded)
-    configsToBeDeleted.foreach(config => configs.remove(config))
+    configsToBeDeleted.foreach { config =>
+      // log an error if the config to be deleted does not exist
+      if (!configs.containsKey(config))
+        System.err.println(s"Deleting config '$config' from entity '$entityName' of type
'$entityType' failed, because the specified config does not exist.")
+      else
+        configs.remove(config)
+    }
 
     entityType match {
       case ConfigType.Topic => utils.changeTopicConfig(zkUtils, entityName, configs)
@@ -93,7 +99,7 @@ object ConfigCommand extends Config {
       case ConfigType.Broker => utils.changeBrokerConfig(zkUtils, Seq(parseBroker(entityName)),
configs)
       case _ => throw new IllegalArgumentException(s"$entityType is not a known entityType.
Should be one of ${ConfigType.Topic}, ${ConfigType.Client}, ${ConfigType.Broker}")
     }
-    println(s"Updated config for entity: $entity.")
+    println(s"Completed Updating config for entity: $entity.")
   }
 
   private def parseBroker(broker: String): Int = {


Mime
View raw message