You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/05/10 13:37:44 UTC

[21/22] ambari git commit: AMBARI-20434. Enhance Kafka Service Check (WangJie via dlysnichenko)

AMBARI-20434. Enhance Kafka Service Check (WangJie via dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/80ef7729
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/80ef7729
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/80ef7729

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 80ef77299855f4f1c6a0aceed9cee9ee93c22da1
Parents: 9abfcf2
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Wed May 10 14:34:05 2017 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Wed May 10 14:34:05 2017 +0300

----------------------------------------------------------------------
 .../KAFKA/0.8.1/package/scripts/service_check.py     | 15 ++++++++++-----
 .../KAFKA/0.9.0/configuration/kafka-broker.xml       |  2 +-
 2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/80ef7729/ambari-server/src/main/resources/common-services/KAFKA/0.8.1/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KAFKA/0.8.1/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/KAFKA/0.8.1/package/scripts/service_check.py
index 0f3a417..cb66f98 100644
--- a/ambari-server/src/main/resources/common-services/KAFKA/0.8.1/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/common-services/KAFKA/0.8.1/package/scripts/service_check.py
@@ -40,12 +40,17 @@ class ServiceCheck(Script):
     topic_exists_cmd = format("{kafka_home}/bin/kafka-topics.sh --zookeeper {kafka_config[zookeeper.connect]} --topic {topic} --list")
     topic_exists_cmd_p = subprocess.Popen(topic_exists_cmd.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     topic_exists_cmd_out, topic_exists_cmd_err = topic_exists_cmd_p.communicate()
-    # run create topic command only if the topic doesn't exists
-    if topic not in topic_exists_cmd_out:
-      create_topic_cmd = format("{kafka_home}/bin/kafka-topics.sh --zookeeper {kafka_config[zookeeper.connect]} --create --topic {topic} --partitions 1 --replication-factor 1")
+    
+    delete_topic_cmd = format("{kafka_home}/bin/kafka-topics.sh --zookeeper {kafka_config[zookeeper.connect]} --delete --topic {topic}")
+    create_topic_cmd = format("{kafka_home}/bin/kafka-topics.sh --zookeeper {kafka_config[zookeeper.connect]} --create --topic {topic} --partitions 1 --replication-factor 1")
+    if topic in topic_exists_cmd_out:
+      # run delete topic and recreate the topic command only if the topic exists
+      command = source_cmd + " ; " + delete_topic_cmd + ";" + create_topic_cmd
+    else:
+      # run create topic command 
       command = source_cmd + " ; " + create_topic_cmd
-      Logger.info("Running kafka create topic command: %s" % command)
-      call_and_match_output(command, format("({create_topic_cmd_created_output})|({create_topic_cmd_exists_output})"), "Failed to check that topic exists", user=params.kafka_user)
+    Logger.info("Running kafka create topic command: %s" % command)
+    call_and_match_output(command, format("({create_topic_cmd_created_output})|({create_topic_cmd_exists_output})"), "Failed to check that topic exists", user=params.kafka_user)
 
   def read_kafka_config(self):
     import params

http://git-wip-us.apache.org/repos/asf/ambari/blob/80ef7729/ambari-server/src/main/resources/common-services/KAFKA/0.9.0/configuration/kafka-broker.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KAFKA/0.9.0/configuration/kafka-broker.xml b/ambari-server/src/main/resources/common-services/KAFKA/0.9.0/configuration/kafka-broker.xml
index 0275358..73a5eff 100644
--- a/ambari-server/src/main/resources/common-services/KAFKA/0.9.0/configuration/kafka-broker.xml
+++ b/ambari-server/src/main/resources/common-services/KAFKA/0.9.0/configuration/kafka-broker.xml
@@ -126,7 +126,7 @@
   </property>
   <property>
     <name>delete.topic.enable</name>
-    <value>false</value>
+    <value>true</value>
     <description>Enables delete topic. Delete topic through the admin tool will have no effect if this config is turned off</description>
     <on-ambari-upgrade add="true"/>
   </property>