You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by gu...@apache.org on 2022/07/08 08:11:55 UTC

[bigtop] branch master updated: BIGTOP-3721: Add Kafka support for Bigtop 3.1.0 Mpack (#930)

This is an automated email from the ASF dual-hosted git repository.

guyuqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bigtop.git


The following commit(s) were added to refs/heads/master by this push:
     new 8b9628a5 BIGTOP-3721: Add Kafka support for Bigtop 3.1.0 Mpack (#930)
8b9628a5 is described below

commit 8b9628a568e8962995d8f1f39e132d202a301d3f
Author: 吴治国 <wz...@163.com>
AuthorDate: Fri Jul 8 16:11:50 2022 +0800

    BIGTOP-3721: Add Kafka support for Bigtop 3.1.0 Mpack (#930)
    
    * BIGTOP-3689: Add Kafka support for Bigtop 3.1.0 Mpack
---
 .../stacks/BGTP/1.0/properties/stack_features.json |   5 +
 .../stacks/BGTP/1.0/services/KAFKA/alert.json      |  32 +
 .../services/KAFKA/configuration/kafka-broker.xml  | 650 +++++++++++++++++++++
 .../1.0/services/KAFKA/configuration/kafka-env.xml | 130 +++++
 .../services/KAFKA/configuration/kafka-log4j.xml   | 168 ++++++
 .../KAFKA/configuration/kafka_client_jaas_conf.xml |  43 ++
 .../KAFKA/configuration/kafka_jaas_conf.xml        | 116 ++++
 .../stacks/BGTP/1.0/services/KAFKA/kerberos.json   |  64 ++
 .../stacks/BGTP/1.0/services/KAFKA/metainfo.xml    | 114 ++++
 .../stacks/BGTP/1.0/services/KAFKA/metrics.json    | 238 ++++++++
 .../1.0/services/KAFKA/package/scripts/kafka.py    | 289 +++++++++
 .../services/KAFKA/package/scripts/kafka_broker.py | 164 ++++++
 .../1.0/services/KAFKA/package/scripts/params.py   | 234 ++++++++
 .../KAFKA/package/scripts/service_check.py         |  81 +++
 .../KAFKA/package/scripts/status_params.py         |  26 +
 .../1.0/services/KAFKA/package/scripts/upgrade.py  |  74 +++
 .../1.0/services/KAFKA/package/scripts/utils.py    |  38 ++
 .../package/templates/input.config-kafka.json.j2   |  92 +++
 .../services/KAFKA/package/templates/kafka.conf.j2 |  20 +
 .../package/templates/kafka_client_jaas.conf.j2    |  32 +
 .../KAFKA/package/templates/kafka_jaas.conf.j2     |  99 ++++
 .../package/templates/tools-log4j.properties.j2    |  21 +
 .../1.0/services/KAFKA/role_command_order.json     |   7 +
 .../BGTP/1.0/services/KAFKA/service_advisor.py     | 451 ++++++++++++++
 .../1.0/services/KAFKA/themes/directories.json     |  98 ++++
 .../stacks/BGTP/1.0/services/KAFKA/widgets.json    | 181 ++++++
 26 files changed, 3467 insertions(+)

diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/properties/stack_features.json b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/properties/stack_features.json
index 3212400e..660bb3bf 100644
--- a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/properties/stack_features.json
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/properties/stack_features.json
@@ -47,6 +47,11 @@
       "name": "hive_metastore_site_support",
       "description": "Hive Metastore site support",
       "min_version": "2.5.0.0"
+    },
+    {
+      "name": "kafka_kerberos",
+      "description": "Kafka Kerberos support (AMBARI-10984)",
+      "min_version": "1.0.0.0"
     }
   ]
 }
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/alert.json b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/alert.json
new file mode 100644
index 00000000..19400d81
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/alert.json
@@ -0,0 +1,32 @@
+{
+  "KAFKA": {
+    "service": [],
+    "KAFKA_BROKER": [
+      {
+        "name": "kafka_broker_process",
+        "label": "Kafka Broker Process",
+        "description": "This host-level alert is triggered if the Kafka Broker cannot be determined to be up.",
+        "interval": 1,
+        "scope": "HOST",
+        "source": {
+          "type": "PORT",
+          "uri": "{{kafka-broker/listeners}}",
+          "default_port": 6667,
+          "reporting": {
+            "ok": {
+              "text": "TCP OK - {0:.3f}s response on port {1}"
+            },
+            "warning": {
+              "text": "TCP OK - {0:.3f}s response on port {1}",
+              "value": 1.5
+            },
+            "critical": {
+              "text": "Connection failed: {0} to {1}:{2}",
+              "value": 5.0
+            }
+          }
+        }
+      }
+    ]
+  }
+}
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-broker.xml b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-broker.xml
new file mode 100644
index 00000000..96a51d24
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-broker.xml
@@ -0,0 +1,650 @@
+<?xml version="1.0"?>
+<!--
+ censed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<configuration supports_final="true">
+  <property>
+    <name>log.dirs</name>
+    <display-name>Log directories</display-name>
+    <value>/kafka-logs</value>
+    <description>
+      A comma-separated list of one or more directories in which Kafka data is stored.
+      Each new partition that is created will be placed in the directory which currently has the fewest partitions.
+    </description>
+    <value-attributes>
+      <type>directories</type>
+    </value-attributes>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>port</name>
+    <value>6667</value>
+    <description>
+      The port on which the server accepts client connections.
+    </description>
+    <value-attributes>
+      <type>int</type>
+    </value-attributes>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>zookeeper.connect</name>
+    <value>localhost:2181</value>
+    <description>
+      Zookeeper also allows you to add a "chroot" path which will make all kafka data for this cluster appear under a particular path.
+      This is a way to setup multiple Kafka clusters or other applications on the same zookeeper cluster. To do this give a connection
+     string in the form hostname1:port1,hostname2:port2,hostname3:port3/chroot/path which would put all this cluster's data under the
+      path /chroot/path. Note that consumers must use the same connection string.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>message.max.bytes</name>
+    <value>1000000</value>
+    <description>
+      The maximum size of a message that the server can receive.
+      It is important that this property be in sync with the maximum fetch size your consumers use or
+      else an unruly producer will be able to publish messages too large for consumers to consume.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>num.network.threads</name>
+    <value>3</value>
+    <description>
+      The number of network threads that the server uses for handling network requests.
+      You probably don't need to change this.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>num.io.threads</name>
+    <value>8</value>
+    <description>
+      The number of I/O threads that the server uses for executing requests. You should have at least as many threads as you have disks.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>queued.max.requests</name>
+    <value>500</value>
+    <description>The number of requests that can be queued up for processing by the I/O threads before the network threads stop reading in new requests.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>socket.send.buffer.bytes</name>
+    <value>102400</value>
+    <description>
+      The SO_SNDBUFF buffer the server prefers for socket connections.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>socket.receive.buffer.bytes</name>
+    <value>102400</value>
+    <description>
+      The SO_RCVBUFF buffer the server prefers for socket connections.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>socket.request.max.bytes</name>
+    <value>104857600</value>
+    <description>
+      The maximum request size the server will allow. This prevents the server from running out of memory and should be smaller than the Java heap size.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>num.partitions</name>
+    <value>1</value>
+    <description>
+        The default number of partitions per topic.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.segment.bytes</name>
+    <value>1073741824</value>
+    <description>
+      The maximum request size the server will allow.
+      This prevents the server from running out of memory and should be smaller than the Java heap size.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.roll.hours</name>
+    <value>168</value>
+    <description>
+      This setting will force Kafka to roll a new log segment even if the log.segment.bytes size has not been reached.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.retention.bytes</name>
+    <value>-1</value>
+    <description>
+      The amount of data to retain in the log for each topic-partitions. Note that this is the limit per-partition so multiply by the number of partitions to get the total data retained for the topic. Also note that if both log.retention.hours and log.retention.bytes are both set we delete a segment when either limit is exceeded.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.retention.hours</name>
+    <value>168</value>
+    <description>
+      The number of hours to keep a log segment before it is deleted, i.e. the default data retention window for all topics. Note that if both log.retention.hours and log.retention.bytes are both set we delete a segment when either limit is exceeded.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.cleanup.interval.mins</name>
+    <value>10</value>
+    <description>The frequency in minutes that the log cleaner checks whether any log segment is eligible for deletion to meet the retention policies.
+    </description>
+    <deleted>true</deleted>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.retention.check.interval.ms</name>
+    <value>600000</value>
+    <description>
+      The frequency in milliseconds that the log cleaner checks whether any log segment is eligible for deletion to meet the retention policies.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.index.size.max.bytes</name>
+    <value>10485760</value>
+    <description>
+      The maximum size in bytes we allow for the offset index for each log segment. Note that we will always pre-allocate a
+      sparse file with this much space and shrink it down when the log rolls. If the index fills up we will roll a new log segment
+      even if we haven't reached the log.segment.bytes limit.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>log.index.interval.bytes</name>
+    <value>4096</value>
+    <description>
+      The byte interval at which we add an entry to the offset index. When executing a fetch request the server must do a linear scan for up to this many bytes to find the correct position in the log to begin and end the fetch. So setting this value to be larger will mean larger index files (and a bit more memory usage) but less scanning. However the server will never add more than one index entry per log append (even if more than log.index.interval worth of messages are appended). In ge [...]
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>auto.create.topics.enable</name>
+    <value>true</value>
+    <description>
+      Enable auto creation of topic on the server. If this is set to true then attempts to produce, consume, or fetch metadata for a non-existent topic will automatically create it with the default replication factor and number of partitions.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>controller.socket.timeout.ms</name>
+    <value>30000</value>
+    <description>The socket timeout for commands from the partition management controller to the replicas.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>controller.message.queue.size</name>
+    <value>10</value>
+    <description>The buffer size for controller-to-broker-channels</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>default.replication.factor</name>
+    <value>1</value>
+    <description>The default replication factor for automatically created topics.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.lag.time.max.ms</name>
+    <value>10000</value>
+    <description>If a follower hasn't sent any fetch requests for this window of time, the leader will remove the follower from ISR (in-sync replicas) and treat it as dead.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.lag.max.messages</name>
+    <value>4000</value>
+    <description>
+      If a replica falls more than this many messages behind the leader, the leader will remove the follower from ISR and treat it as dead.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.socket.timeout.ms</name>
+    <value>30000</value>
+    <description>The socket timeout for network requests to the leader for replicating data.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.socket.receive.buffer.bytes</name>
+    <value>65536</value>
+    <description>The socket receive buffer for network requests to the leader for replicating data.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.fetch.max.bytes</name>
+    <value>1048576</value>
+    <description>The number of byes of messages to attempt to fetch for each partition in the fetch requests the replicas send to the leader.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.fetch.wait.max.ms</name>
+    <value>500</value>
+    <description>The maximum amount of time to wait time for data to arrive on the leader in the fetch requests sent by the replicas to the leader.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.fetch.min.bytes</name>
+    <value>1</value>
+    <description>Minimum bytes expected for each fetch response for the fetch requests from the replica to the leader. If not enough bytes, wait up to replica.fetch.wait.max.ms for this many bytes to arrive.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>num.replica.fetchers</name>
+    <value>1</value>
+    <description>
+      Number of threads used to replicate messages from leaders. Increasing this value can increase the degree of I/O parallelism in the follower broker.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>replica.high.watermark.checkpoint.interval.ms</name>
+    <value>5000</value>
+    <description>The frequency with which each replica saves its high watermark to disk to handle recovery.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>fetch.purgatory.purge.interval.requests</name>
+    <value>10000</value>
+    <description>The purge interval (in number of requests) of the fetch request purgatory.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>producer.purgatory.purge.interval.requests</name>
+    <value>10000</value>
+    <description>The purge interval (in number of requests) of the producer request purgatory.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>zookeeper.session.timeout.ms</name>
+    <value>30000</value>
+    <description>Zookeeper session timeout. If the server fails to heartbeat to zookeeper within this period of time it is considered dead. If you set this too low the server may be falsely considered dead; if you set it too high it may take too long to recognize a truly dead server.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>zookeeper.connection.timeout.ms</name>
+    <value>25000</value>
+    <description>The maximum amount of time that the client waits to establish a connection to zookeeper.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>zookeeper.sync.time.ms</name>
+    <value>2000</value>
+    <description>How far a ZK follower can be behind a ZK leader.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>controlled.shutdown.max.retries</name>
+    <value>3</value>
+    <description>Number of retries to complete the controlled shutdown successfully before executing an unclean shutdown.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>controlled.shutdown.retry.backoff.ms</name>
+    <value>5000</value>
+    <description>
+      Backoff time between shutdown retries.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.metrics.reporters</name>
+    <value />
+    <description>
+      kafka ganglia metrics reporter and kafka timeline metrics reporter
+    </description>
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+    </value-attributes>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.ganglia.metrics.reporter.enabled</name>
+    <value>true</value>
+    <description>
+      kafka ganglia metrics reporter enable
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.ganglia.metrics.host</name>
+    <value>localhost</value>
+    <description> Ganglia host </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.ganglia.metrics.port</name>
+    <value>8671</value>
+    <description> Ganglia port </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.ganglia.metrics.group</name>
+    <value>kafka</value>
+    <description>Ganglia group name </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.reporter.enabled</name>
+    <value>true</value>
+    <description>Kafka timeline metrics reporter enable</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.hosts</name>
+    <value>{{ams_collector_hosts}}</value>
+    <description>Timeline host</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.port</name>
+    <value>{{metric_collector_port}}</value>
+    <description>Timeline port</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.protocol</name>
+    <value>{{metric_collector_protocol}}</value>
+    <description>Timeline protocol(http or https)</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.truststore.path</name>
+    <value>{{metric_truststore_path}}</value>
+    <description>Location of the trust store file.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.truststore.type</name>
+    <value>{{metric_truststore_type}}</value>
+    <description>Optional. Default value is "jks".</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.truststore.password</name>
+    <value>{{metric_truststore_password}}</value>
+    <description>Password to open the trust store file.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.reporter.sendInterval</name>
+    <value>5900</value>
+    <description>Timeline metrics reporter send interval</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.maxRowCacheSize</name>
+    <value>10000</value>
+    <description>Timeline metrics reporter send interval</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.host_in_memory_aggregation</name>
+    <value>{{host_in_memory_aggregation}}</value>
+    <description>if set to "true" host metrics will be aggregated in memory on each host</description>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.host_in_memory_aggregation_port</name>
+    <value>{{host_in_memory_aggregation_port}}</value>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>kafka.timeline.metrics.host_in_memory_aggregation_protocol</name>
+    <value>{{host_in_memory_aggregation_protocol}}</value>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>listeners</name>
+    <value>PLAINTEXT://localhost:9092</value>
+    <description>host and port where kafka broker will be accepting connections. localhost will be substituted with hostname. This property managed with Ambari and every user-defined listeners need to be placed to raw.listeners property.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>raw.listeners</name>
+    <value />
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+    </value-attributes>
+    <description>User-defined listeners that will be unchanged by Ambari. Value of this property will be merged with Ambari-managed listeners.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>controlled.shutdown.enable</name>
+    <value>true</value>
+    <description>Enable controlled shutdown of the broker. If enabled, the broker will move all leaders on it to some other brokers before shutting itself down. This reduces the unavailability window during shutdown.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>auto.leader.rebalance.enable</name>
+    <value>true</value>
+    <description>Enables auto leader balancing. A background thread checks and triggers leader balance if required at regular intervals</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>num.recovery.threads.per.data.dir</name>
+    <value>1</value>
+    <description>The number of threads per data directory to be used for log recovery at startup and flushing at shutdown</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>min.insync.replicas</name>
+    <value>1</value>
+    <description>define the minimum number of replicas in ISR needed to satisfy a produce request with required.acks=-1 (or all)</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>leader.imbalance.per.broker.percentage</name>
+    <value>10</value>
+    <description>The ratio of leader imbalance allowed per broker. The controller would trigger a leader balance if it goes above this value per broker. The value is specified in percentage.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>leader.imbalance.check.interval.seconds</name>
+    <value>300</value>
+    <description>The frequency with which the partition rebalance check is triggered by the controller</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offset.metadata.max.bytes</name>
+    <value>4096</value>
+    <description>The maximum size for a metadata entry associated with an offset commit</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.load.buffer.size</name>
+    <value>5242880</value>
+    <description>Batch size for reading from the offsets segments when loading offsets into the cache.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.topic.replication.factor</name>
+    <value>3</value>
+    <description>The replication factor for the offsets topic (set higher to ensure availability).
+    To ensure that the effective replication factor of the offsets topic is the configured value,
+    the number of alive brokers has to be at least the replication factor at the time of the
+    first request for the offsets topic. If not, either the offsets topic creation will fail or it will get a replication factor of min(alive brokers, configured replication factor).</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.topic.num.partitions</name>
+    <value>50</value>
+    <description>The number of partitions for the offset commit topic (should not change after deployment)</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.topic.segment.bytes</name>
+    <value>104857600</value>
+    <description>The offsets topic segment bytes should be kept relatively small in order to facilitate faster log compaction and cache loads</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.topic.compression.codec</name>
+    <value>0</value>
+    <description>Compression codec for the offsets topic - compression may be used to achieve \"atomic\" commits. Default is NoCompression. For Gzip add value 1 , SnappyCompression add value 2, LZ4CompressionCodec 3.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.retention.minutes</name>
+    <value>86400000</value>
+    <description>Log retention window in minutes for offsets topic</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.retention.check.interval.ms</name>
+    <value>600000</value>
+    <description>Frequency at which to check for stale offsets</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.commit.timeout.ms</name>
+    <value>5000</value>
+    <description>Offset commit will be delayed until all replicas for the offsets topic receive the commit or this timeout is reached. This is similar to the producer request timeout.</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>offsets.commit.required.acks</name>
+    <value>-1</value>
+    <description>The required acks before the commit can be accepted. In general, the default (-1) should not be overridden</description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>delete.topic.enable</name>
+    <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="false" />
+  </property>
+  <property>
+    <name>compression.type</name>
+    <description>Specify the final compression type for a given topic. This configuration accepts the standard compression codecs ('gzip', 'snappy', lz4). It additionally accepts 'uncompressed' which is equivalent to no compression; and 'producer' which means retain the original compression codec set by the producer.</description>
+    <value>producer</value>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>external.kafka.metrics.exclude.prefix</name>
+    <value>kafka.network.RequestMetrics,kafka.server.DelayedOperationPurgatory,kafka.server.BrokerTopicMetrics.BytesRejectedPerSec</value>
+    <description>
+      Exclude metrics starting with these prefixes from being collected.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>external.kafka.metrics.include.prefix</name>
+    <value>kafka.network.RequestMetrics.ResponseQueueTimeMs.request.OffsetCommit.98percentile,kafka.network.RequestMetrics.ResponseQueueTimeMs.request.Offsets.95percentile,kafka.network.RequestMetrics.ResponseSendTimeMs.request.Fetch.95percentile,kafka.network.RequestMetrics.RequestsPerSec.request</value>
+    <description>
+      These metrics would be included even if the exclude prefix omits them.
+    </description>
+    <on-ambari-upgrade add="false" />
+  </property>
+  <property>
+    <name>sasl.enabled.mechanisms</name>
+    <value>GSSAPI</value>
+    <description>The list of SASL mechanisms enabled in the Kafka server. The list may contain any mechanism for which a security provider is available. Only GSSAPI is enabled by default.</description>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>security.inter.broker.protocol</name>
+    <value>PLAINTEXT</value>
+    <description>Security protocol used to communicate between brokers. Valid values are: PLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL. It is an error to set this and inter.broker.listener.name properties at the same time.</description>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>sasl.mechanism.inter.broker.protocol</name>
+    <value>GSSAPI</value>
+    <description>SASL mechanism used for inter-broker communication. Default is GSSAPI.</description>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>ssl.client.auth</name>
+    <value>none</value>
+    <description>Configures kafka broker to request client authentication.</description>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>ssl.key.password</name>
+    <value />
+    <description>The password of private key in the key store file.</description>
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+      <type>password</type>
+    </value-attributes>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>ssl.keystore.location</name>
+    <value />
+    <description>The location of key store file.</description>
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+    </value-attributes>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>ssl.keystore.password</name>
+    <value />
+    <description>The store password for key store file.</description>
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+      <type>password</type>
+    </value-attributes>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>ssl.truststore.location</name>
+    <value />
+    <description>The location of trust store file.</description>
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+    </value-attributes>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>ssl.truststore.password</name>
+    <value />
+    <description>The password for trust store file. If a password is not set access to the truststore is still available, but integrity checking is disabled</description>
+    <value-attributes>
+      <empty-value-valid>true</empty-value-valid>
+      <type>password</type>
+    </value-attributes>
+    <on-ambari-upgrade add="true" />
+  </property>
+  <property>
+    <name>producer.metrics.enable</name>
+    <value>false</value>
+    <on-ambari-upgrade add="false" />
+    <depends-on>
+      <property>
+        <type>streams-messaging-manager-common</type>
+        <name>kafka.bootstrap.servers</name>
+      </property>
+    </depends-on>
+  </property>
+</configuration>
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-env.xml b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-env.xml
new file mode 100644
index 00000000..000e8814
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-env.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<configuration supports_adding_forbidden="true">
+    <property>
+        <name>kafka_user</name>
+        <display-name>Kafka User</display-name>
+        <value>kafka</value>
+        <property-type>USER</property-type>
+        <description />
+        <value-attributes>
+            <type>user</type>
+            <overridable>false</overridable>
+            <user-groups>
+                <property>
+                    <type>cluster-env</type>
+                    <name>user_group</name>
+                </property>
+            </user-groups>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>kafka_keytab</name>
+        <description>Kafka keytab path</description>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>kafka_principal_name</name>
+        <description>Kafka principal name</description>
+        <property-type>KERBEROS_PRINCIPAL</property-type>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>kafka_log_dir</name>
+        <display-name>Kafka Log directory</display-name>
+        <value>/var/log/kafka</value>
+        <description />
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>kafka_pid_dir</name>
+        <value>/var/run/kafka</value>
+        <display-name>Kafka PID dir</display-name>
+        <description />
+        <value-attributes>
+            <type>directory</type>
+            <editable-only-at-install>true</editable-only-at-install>
+            <overridable>false</overridable>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>kafka_user_nofile_limit</name>
+        <value>128000</value>
+        <description>Max open files limit setting for KAFKA user.</description>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>kerberos_merge_advertised_listeners</name>
+        <value>true</value>
+        <value-attributes>
+            <type>boolean</type>
+        </value-attributes>
+        <description>Merge default Ambari-managed "advertised.listeners" value with user defined value.</description>
+        <on-ambari-upgrade add="true" />
+    </property>
+    <property>
+        <name>kafka_user_nproc_limit</name>
+        <value>65536</value>
+        <description>Max number of processes limit setting for KAFKA user.</description>
+        <on-ambari-upgrade add="false" />
+    </property>
+
+    <property>
+        <name>content</name>
+        <display-name>kafka-env template</display-name>
+        <description>This is the jinja template for kafka-env.sh file</description>
+        <value>
+  #!/bin/bash
+  
+  # Set KAFKA specific environment variables here.
+  
+  # The java implementation to use.
+  export JAVA_HOME={{java64_home}}
+  export PATH=$PATH:$JAVA_HOME/bin
+  export PID_DIR={{kafka_pid_dir}}
+  export LOG_DIR={{kafka_log_dir}}
+  {% if kerberos_security_enabled or kafka_other_sasl_enabled %}
+  export KAFKA_OPTS="-Djavax.security.auth.useSubjectCredsOnly=false {{kafka_kerberos_params}}"
+  {% else %}
+  export KAFKA_OPTS={{kafka_kerberos_params}}
+  {% endif %}
+  # Add kafka sink to classpath and related depenencies
+  if [ -e "/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar" ]; then
+    export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/ambari-metrics-kafka-sink.jar
+    export CLASSPATH=$CLASSPATH:/usr/lib/ambari-metrics-kafka-sink/lib/*
+  fi
+  {% if stack_supports_kafka_env_include_ranger_script %}
+  if [ -f /etc/kafka/conf/kafka-ranger-env.sh ]; then
+  . /etc/kafka/conf/kafka-ranger-env.sh
+  fi
+  {% else %}
+        export CLASSPATH=$CLASSPATH:{{conf_dir}}
+  {% endif %}
+      </value>
+        <value-attributes>
+            <type>content</type>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+</configuration>
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-log4j.xml b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-log4j.xml
new file mode 100644
index 00000000..6ed2e6e6
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka-log4j.xml
@@ -0,0 +1,168 @@
+<?xml version="1.0"?>
+<!--
+ censed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<configuration supports_adding_forbidden="false" supports_final="false">
+    <property>
+        <name>kafka_log_maxfilesize</name>
+        <value>256</value>
+        <description>The maximum size of backup file before the log is rotated</description>
+        <display-name>Kafka Log: backup file size</display-name>
+        <value-attributes>
+            <unit>MB</unit>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>kafka_log_maxbackupindex</name>
+        <value>20</value>
+        <description>The number of backup files</description>
+        <display-name>Kafka Log: # of backup files</display-name>
+        <value-attributes>
+            <type>int</type>
+            <minimum>0</minimum>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>controller_log_maxfilesize</name>
+        <value>256</value>
+        <description>The maximum size of backup file before the log is rotated</description>
+        <display-name>Kafka Controller Log: backup file size</display-name>
+        <value-attributes>
+            <unit>MB</unit>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>controller_log_maxbackupindex</name>
+        <value>20</value>
+        <description>The number of backup files</description>
+        <display-name>Kafka Controller Log: # of backup files</display-name>
+        <value-attributes>
+            <type>int</type>
+            <minimum>0</minimum>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+    <property>
+        <name>content</name>
+        <display-name>kafka-log4j template</display-name>
+        <description>Custom log4j.properties</description>
+        <value>
+ #
+ #
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements.  See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership.  The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License.  You may obtain a copy of the License at
+ #
+ #   http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied.  See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+ #
+ #
+ #
+ kafka.logs.dir=logs
+ 
+ log4j.rootLogger=INFO, stdout
+ 
+ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+ log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}] %p %m (%c)%n
+ 
+ log4j.appender.kafkaAppender=org.apache.log4j.DailyRollingFileAppender
+ log4j.appender.kafkaAppender.DatePattern='.'yyyy-MM-dd-HH
+ log4j.appender.kafkaAppender.File=${kafka.logs.dir}/server.log
+ log4j.appender.kafkaAppender.layout=org.apache.log4j.PatternLayout
+ log4j.appender.kafkaAppender.layout.ConversionPattern=[%d{ISO8601}] %p %m (%c)%n
+ log4j.appender.kafkaAppender.MaxFileSize = {{kafka_log_maxfilesize}}MB
+ log4j.appender.kafkaAppender.MaxBackupIndex = {{kafka_log_maxbackupindex}}
+ 
+ log4j.appender.stateChangeAppender=org.apache.log4j.DailyRollingFileAppender
+ log4j.appender.stateChangeAppender.DatePattern='.'yyyy-MM-dd-HH
+ log4j.appender.stateChangeAppender.File=${kafka.logs.dir}/state-change.log
+ log4j.appender.stateChangeAppender.layout=org.apache.log4j.PatternLayout
+ log4j.appender.stateChangeAppender.layout.ConversionPattern=[%d{ISO8601}] %p %m (%c)%n
+ 
+ log4j.appender.requestAppender=org.apache.log4j.DailyRollingFileAppender
+ log4j.appender.requestAppender.DatePattern='.'yyyy-MM-dd-HH
+ log4j.appender.requestAppender.File=${kafka.logs.dir}/kafka-request.log
+ log4j.appender.requestAppender.layout=org.apache.log4j.PatternLayout
+ log4j.appender.requestAppender.layout.ConversionPattern=[%d{ISO8601}] %p %m (%c)%n
+ 
+ log4j.appender.cleanerAppender=org.apache.log4j.DailyRollingFileAppender
+ log4j.appender.cleanerAppender.DatePattern='.'yyyy-MM-dd-HH
+ log4j.appender.cleanerAppender.File=${kafka.logs.dir}/log-cleaner.log
+ log4j.appender.cleanerAppender.layout=org.apache.log4j.PatternLayout
+ log4j.appender.cleanerAppender.layout.ConversionPattern=[%d{ISO8601}] %p %m (%c)%n
+ 
+ log4j.appender.controllerAppender=org.apache.log4j.DailyRollingFileAppender
+ log4j.appender.controllerAppender.DatePattern='.'yyyy-MM-dd-HH
+ log4j.appender.controllerAppender.File=${kafka.logs.dir}/controller.log
+ log4j.appender.controllerAppender.layout=org.apache.log4j.PatternLayout
+ log4j.appender.controllerAppender.layout.ConversionPattern=[%d{ISO8601}] %p %m (%c)%n
+ log4j.appender.controllerAppender.MaxFileSize = {{controller_log_maxfilesize}}MB
+ log4j.appender.controllerAppender.MaxBackupIndex = {{controller_log_maxbackupindex}}
+ # Turn on all our debugging info
+ #log4j.logger.kafka.producer.async.DefaultEventHandler=DEBUG, kafkaAppender
+ #log4j.logger.kafka.client.ClientUtils=DEBUG, kafkaAppender
+ #log4j.logger.kafka.perf=DEBUG, kafkaAppender
+ #log4j.logger.kafka.perf.ProducerPerformance$ProducerThread=DEBUG, kafkaAppender
+ #log4j.logger.org.I0Itec.zkclient.ZkClient=DEBUG
+ log4j.logger.kafka=INFO, kafkaAppender
+ log4j.logger.kafka.network.RequestChannel$=WARN, requestAppender
+ log4j.additivity.kafka.network.RequestChannel$=false
+ 
+ #log4j.logger.kafka.network.Processor=TRACE, requestAppender
+ #log4j.logger.kafka.server.KafkaApis=TRACE, requestAppender
+ #log4j.additivity.kafka.server.KafkaApis=false
+ log4j.logger.kafka.request.logger=WARN, requestAppender
+ log4j.additivity.kafka.request.logger=false
+ 
+ log4j.logger.kafka.controller=TRACE, controllerAppender
+ log4j.additivity.kafka.controller=false
+ 
+ log4j.logger.kafka.log.LogCleaner=INFO, cleanerAppender
+ log4j.additivity.kafka.log.LogCleaner=false
+ 
+ log4j.logger.state.change.logger=TRACE, stateChangeAppender
+ log4j.additivity.state.change.logger=false
+ 
+    </value>
+        <value-attributes>
+            <type>content</type>
+            <show-property-name>false</show-property-name>
+        </value-attributes>
+        <depends-on>
+            <property>
+                <type>ranger-kafka-plugin-properties</type>
+                <name>ranger-kafka-plugin-enabled</name>
+            </property>
+        </depends-on>
+        <on-ambari-upgrade add="false" />
+    </property>
+</configuration>
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka_client_jaas_conf.xml b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka_client_jaas_conf.xml
new file mode 100644
index 00000000..e04c0968
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka_client_jaas_conf.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<configuration supports_adding_forbidden="true" supports_final="false">
+    <property>
+        <name>content</name>
+        <display-name>kafka_client_jaas template</display-name>
+        <description>Kafka client jaas config</description>
+        <value>
+  {% if kerberos_security_enabled %}
+  KafkaClient {
+  com.sun.security.auth.module.Krb5LoginModule required
+  useTicketCache=true
+  renewTicket=true
+  serviceName="{{kafka_bare_jaas_principal}}";
+  };
+  {% endif %}
+     </value>
+        <value-attributes>
+            <type>content</type>
+            <show-property-name>false</show-property-name>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+</configuration>
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka_jaas_conf.xml b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka_jaas_conf.xml
new file mode 100644
index 00000000..8185b3c9
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/configuration/kafka_jaas_conf.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<configuration supports_adding_forbidden="true" supports_final="false">
+    <property>
+        <name>content</name>
+        <display-name>kafka_jaas template</display-name>
+        <description>Kafka jaas config</description>
+        <value>
+          /**
+          * Example of SASL/PLAIN Configuration
+          *
+          * KafkaServer {
+          *   org.apache.kafka.common.security.plain.PlainLoginModule required
+          *   username="admin"
+          *   password="admin-secret"
+          *   user_admin="admin-secret"
+          *   user_alice="alice-secret";
+          *   };
+          *
+          * Example of SASL/SCRAM
+          *
+          * KafkaServer {
+          *   org.apache.kafka.common.security.scram.ScramLoginModule required
+          *   username="admin"
+          *   password="admin-secret"
+          *   };
+          *
+          * Example of Enabling multiple SASL mechanisms in a broker:
+          *
+          *   KafkaServer {
+          *
+          *    com.sun.security.auth.module.Krb5LoginModule required
+          *    useKeyTab=true
+          *    storeKey=true
+          *    keyTab="/etc/security/keytabs/kafka_server.keytab"
+          *    principal="kafka/kafka1.hostname.com@EXAMPLE.COM";
+          *
+          *    org.apache.kafka.common.security.plain.PlainLoginModule required
+          *    username="admin"
+          *    password="admin-secret"
+          *    user_admin="admin-secret"
+          *    user_alice="alice-secret";
+          *
+          *    org.apache.kafka.common.security.scram.ScramLoginModule required
+          *    username="scram-admin"
+          *    password="scram-admin-secret";
+          *    };
+          *
+          **/
+  
+          {% if kerberos_security_enabled %}
+  
+          KafkaServer {
+          com.sun.security.auth.module.Krb5LoginModule required
+          useKeyTab=true
+          keyTab="{{kafka_keytab_path}}"
+          storeKey=true
+          useTicketCache=false
+          serviceName="{{kafka_bare_jaas_principal}}"
+          principal="{{kafka_jaas_principal}}";
+          };
+          KafkaClient {
+          com.sun.security.auth.module.Krb5LoginModule required
+          useTicketCache=true
+          renewTicket=true
+          serviceName="{{kafka_bare_jaas_principal}}";
+          };
+          Client {
+          com.sun.security.auth.module.Krb5LoginModule required
+          useKeyTab=true
+          keyTab="{{kafka_keytab_path}}"
+          storeKey=true
+          useTicketCache=false
+          serviceName="zookeeper"
+          principal="{{kafka_jaas_principal}}";
+          };
+          com.sun.security.jgss.krb5.initiate {
+          com.sun.security.auth.module.Krb5LoginModule required
+          renewTGT=false
+          doNotPrompt=true
+          useKeyTab=true
+          keyTab="{{kafka_keytab_path}}"
+          storeKey=true
+          useTicketCache=false
+          serviceName="{{kafka_bare_jaas_principal}}"
+          principal="{{kafka_jaas_principal}}";
+          };
+  
+          {% endif %}
+     </value>
+        <value-attributes>
+            <type>content</type>
+            <show-property-name>false</show-property-name>
+        </value-attributes>
+        <on-ambari-upgrade add="false" />
+    </property>
+</configuration>
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/kerberos.json b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/kerberos.json
new file mode 100644
index 00000000..32333a3b
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/kerberos.json
@@ -0,0 +1,64 @@
+{
+  "services": [
+    {
+      "name": "KAFKA",
+      "identities": [
+        {
+          "name": "kafka_smokeuser",
+          "reference": "/smokeuser"
+        }
+      ],
+      "configurations": [
+        {
+          "kafka-broker": {
+            "authorizer.class.name": "kafka.security.auth.SimpleAclAuthorizer",
+            "principal.to.local.class": "kafka.security.auth.KerberosPrincipalToLocal",
+            "super.users": "user:${kafka-env/kafka_user}",
+            "security.inter.broker.protocol": "SASL_PLAINTEXT",
+            "zookeeper.set.acl": "true"
+          }
+        }
+      ],
+      "auth_to_local_properties": [
+        "kafka-broker/sasl.kerberos.principal.to.local.rules|comma"
+      ],
+      "components": [
+        {
+          "name": "KAFKA_BROKER",
+          "identities": [
+            {
+              "name": "kafka_broker",
+              "principal": {
+                "value": "${kafka-env/kafka_user}/_HOST@${realm}",
+                "type": "service",
+                "configuration": "kafka-env/kafka_principal_name"
+              },
+              "keytab": {
+                "file": "${keytab_dir}/kafka.service.keytab",
+                "owner": {
+                  "name": "${kafka-env/kafka_user}",
+                  "access": "r"
+                },
+                "group": {
+                  "name": "${cluster-env/user_group}",
+                  "access": ""
+                },
+                "configuration": "kafka-env/kafka_keytab"
+              }
+            },
+            {
+              "name": "kafka_kafka_broker_hdfs",
+              "reference": "/HDFS/NAMENODE/hdfs",
+              "when": {
+                "contains": [
+                  "services",
+                  "HDFS"
+                ]
+              }
+            }
+          ]
+        }
+      ]
+    }
+  ]
+}
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/metainfo.xml b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/metainfo.xml
new file mode 100644
index 00000000..e8c48af6
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/metainfo.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<metainfo>
+  <schemaVersion>2.0</schemaVersion>
+  <services>
+    <service>
+      <name>KAFKA</name>
+      <displayName>Kafka</displayName>
+      <comment>A high-throughput distributed messaging system</comment>
+      <version>Bigtop+3.1</version>
+
+      <components>
+        <component>
+          <name>KAFKA_BROKER</name>
+          <displayName>Kafka Broker</displayName>
+          <category>MASTER</category>
+          <cardinality>1+</cardinality>
+          <versionAdvertised>true</versionAdvertised>
+          <rollingRestartSupported>true</rollingRestartSupported>
+          <timelineAppid>kafka_broker</timelineAppid>
+          <dependencies>
+            <dependency>
+              <name>ZOOKEEPER/ZOOKEEPER_SERVER</name>
+              <scope>cluster</scope>
+              <auto-deploy>
+                <enabled>true</enabled>
+              </auto-deploy>
+            </dependency>
+          </dependencies>
+          <commandScript>
+            <script>scripts/kafka_broker.py</script>
+            <scriptType>PYTHON</scriptType>
+            <timeout>1200</timeout>
+          </commandScript>
+          <logs>
+            <log>
+              <logId>kafka_server</logId>
+              <primary>true</primary>
+            </log>
+            <log>
+              <logId>kafka_controller</logId>
+            </log>
+            <log>
+              <logId>kafka_request</logId>
+            </log>
+            <log>
+              <logId>kafka_logcleaner</logId>
+            </log>
+            <log>
+              <logId>kafka_statechange</logId>
+            </log>
+          </logs>
+        </component>
+      </components>
+
+      <commandScript>
+        <script>scripts/service_check.py</script>
+        <scriptType>PYTHON</scriptType>
+        <timeout>300</timeout>
+      </commandScript>
+
+      <requiredServices>
+        <service>ZOOKEEPER</service>
+      </requiredServices>
+
+      <configuration-dependencies>
+        <config-type>kafka-broker</config-type>
+        <config-type>kafka-env</config-type>
+        <config-type>kafka-log4j</config-type>
+        <config-type>zookeeper-env</config-type>
+        <config-type>zoo.cfg</config-type>
+        <config-type>kafka_jaas_conf</config-type>
+        <config-type>kafka_client_jaas_conf</config-type>
+      </configuration-dependencies>
+
+      <osSpecifics>
+        <osSpecific>
+          <osFamily>any</osFamily>
+          <packages>
+            <package>
+              <name>kafka</name>
+            </package>
+          </packages>
+        </osSpecific>
+      </osSpecifics>
+
+      <restartRequiredAfterChange>true</restartRequiredAfterChange>
+      <restartRequiredAfterRackChange>true</restartRequiredAfterRackChange>
+
+      <themes>
+        <theme>
+          <fileName>directories.json</fileName>
+          <default>true</default>
+        </theme>
+      </themes>
+
+    </service>
+  </services>
+</metainfo>
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/metrics.json b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/metrics.json
new file mode 100644
index 00000000..1ad625dc
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/metrics.json
@@ -0,0 +1,238 @@
+{
+  "KAFKA_BROKER": {
+    "Component": [
+      {
+        "type": "ganglia",
+        "metrics": {
+          "default": {
+            "metrics/jvm/uptime": {
+              "metric": "jvm.runtime.uptime",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/heap_usage": {
+              "metric": "jvm.memory.heap_usage",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/non_heap_usage": {
+              "metric": "jvm.memory.non_heap_usage",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/thread-states/runnable": {
+              "metric": "jvm.threads.thread-states.runnable",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/thread-states/blocked": {
+              "metric": "jvm.threads.thread-states.blocked",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/thread-states/timed_waiting": {
+              "metric": "jvm.threads.thread-states.timed_waiting",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/thread-states/terminated": {
+              "metric": "jvm.threads.thread-states.terminated",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/thread_count": {
+              "metric": "jvm.threads.thread_count",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/jvm/daemon_thread_count": {
+              "metric": "jvm.threads.daemon_thread_count",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsMessagesInPerSec/1MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.MessagesInPerSec.1MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsMessagesInPerSec/5MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.MessagesInPerSec.5MinuteRate",
+              "pointInTime": false,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsMessagesInPerSec/15MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.MessagesInPerSec.15MinuteRate",
+              "pointInTime": false,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsMessagesInPerSec/meanRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.MessagesInPerSec.meanRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsMessagesInPerSec/count": {
+              "metric": "kafka.server.BrokerTopicMetrics.MessagesInPerSec.count",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesInPerSec/1MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesInPerSec.1MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesInPerSec/5MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesInPerSec.5MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesInPerSec/15MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesInPerSec.15MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesInPerSec/meanRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesInPerSec.meanRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesInPerSec/count": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesInPerSec.count",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesOutPerSec/1MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesOutPerSec.1MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesOutPerSec/5MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesOutPerSec.5MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesOutPerSec/15MinuteRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesOutPerSec.15MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesOutPerSec/meanRate": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesOutPerSec.meanRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesOutPerSec/count": {
+              "metric": "kafka.server.BrokerTopicMetrics.BytesOutPerSec.count",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/KafkaController/ActiveControllerCount": {
+              "metric": "kafka.controller.KafkaController.ActiveControllerCount",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/LeaderElectionRateAndTimeMs/meanRate": {
+              "metric": "kafka.controller.ControllerStats.LeaderElectionRateAndTimeMs.meanRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/LeaderElectionRateAndTimeMs/1MinuteRate": {
+              "metric": "kafka.controller.ControllerStats.LeaderElectionRateAndTimeMs.1MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/LeaderElectionRateAndTimeMs/5MinuteRate": {
+              "metric": "kafka.controller.ControllerStats.LeaderElectionRateAndTimeMs.5MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/LeaderElectionRateAndTimeMs/15MinuteRate": {
+              "metric": "kafka.controller.ControllerStats.LeaderElectionRateAndTimeMs.15MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/LeaderElectionRateAndTimeMs/count": {
+              "metric": "kafka.controller.ControllerStats.LeaderElectionRateAndTimeMs.count",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/UncleanLeaderElectionsPerSec/1MinuteRate": {
+              "metric": "kafka.controller.ControllerStats.UncleanLeaderElectionsPerSec.1MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/UncleanLeaderElectionsPerSec/5MinuteRate": {
+              "metric": "kafka.controller.ControllerStats.UncleanLeaderElectionsPerSec.5MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/UncleanLeaderElectionsPerSec/15MinuteRate": {
+              "metric": "kafka.controller.ControllerStats.UncleanLeaderElectionsPerSec.15MinuteRate",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/controller/ControllerStats/OfflinePartitionsCount": {
+              "metric": "kafka.controller.ControllerStats.OfflinePartitionsCount",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/ReplicaManager/PartitionCount": {
+              "metric": "kafka.server.ReplicaManager.PartitionCount",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/ReplicaManager/LeaderCount": {
+              "metric": "kafka.server.ReplicaManager.LeaderCount",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/ReplicaManager/UnderReplicatedPartitions": {
+              "metric": "kafka.server.ReplicaManager.UnderReplicatedPartitions",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/ReplicaManager/ISRShrinksPerSec": {
+              "metric": "kafka.server.ReplicaManager.ISRShrinksPerSec",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/ReplicaManager/ISRExpandsPerSec": {
+              "metric": "kafka.server.ReplicaManager.ISRExpandsPerSec",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/ReplicaFetcherManager/Replica-MaxLag": {
+              "metric": "kafka.server.ReplicaFetcherManager.MaxLag.clientId.Replica",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/ProducerRequestPurgatory/PurgatorySize": {
+              "metric": "kafka.server.ProducerRequestPurgatory.PurgatorySize",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/server/FetchRequestPurgatory/PurgatorySize": {
+              "metric": "kafka.server.FetchRequestPurgatory.PurgatorySize",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/cluster/Partition/$1-UnderReplicated": {
+              "metric": "kafka.cluster.Partition.(\\w+)-UnderReplicated",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/consumer/ConsumerFetcherManager/$1-MaxLag": {
+              "metric": "kafka.consumer.ConsumerFetcherManager.(\\w+)-MaxLag",
+              "pointInTime": true,
+              "temporal": true
+            },
+            "metrics/kafka/consumer/ConsumerFetcherManager/$1-MinFetch": {
+              "metric": "kafka.consumer.ConsumerFetcherManager.(\\w+)-MinFetch",
+              "pointInTime": true,
+              "temporal": true
+            }
+          }
+        }
+      }
+    ]
+  }
+}
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/kafka.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/kafka.py
new file mode 100644
index 00000000..ea392a32
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/kafka.py
@@ -0,0 +1,289 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+import os
+
+from resource_management.libraries.functions.version import format_stack_version
+from resource_management.libraries.resources.properties_file import PropertiesFile
+from resource_management.libraries.resources.template_config import TemplateConfig
+from resource_management.core.resources.system import Directory, Execute, File, Link
+from resource_management.core.source import StaticFile, Template, InlineTemplate
+from resource_management.libraries.functions.default import default
+from resource_management.libraries.functions import format
+from resource_management.libraries.functions.generate_logfeeder_input_config import generate_logfeeder_input_config
+from resource_management.libraries.functions.stack_features import check_stack_feature
+from resource_management.libraries.functions import StackFeature
+import re
+
+from resource_management.core.logger import Logger
+
+
+def kafka(upgrade_type=None):
+    import params
+    ensure_base_directories()
+
+    kafka_server_config = mutable_config_dict(params.config['configurations']['kafka-broker'])
+    # This still has an issue of hostnames being alphabetically out-of-order for broker.id in HDP-2.2.
+    # Starting in HDP 2.3, Kafka handles the generation of broker.id so Ambari doesn't have to.
+
+    effective_version = params.stack_version_formatted if upgrade_type is None else format_stack_version(params.version)
+    Logger.info(format("Effective stack version: {effective_version}"))
+
+    # listeners and advertised.listeners are only added in 2.3.0.0 onwards.
+    if effective_version is not None and effective_version != "" and \
+       check_stack_feature(StackFeature.KAFKA_LISTENERS, effective_version):
+
+       listeners = kafka_server_config['listeners'].replace("localhost", params.hostname)
+       kafka_server_config['listeners'] = listeners
+
+       if params.kerberos_security_enabled and params.kafka_kerberos_enabled:
+         Logger.info("Kafka kerberos security is enabled.")
+
+         inter_broker_protocol = kafka_server_config['security.inter.broker.protocol']
+         inter_broker_protocol = replace_sasl_related_config(inter_broker_protocol, True)
+         kafka_server_config['security.inter.broker.protocol'] = inter_broker_protocol
+
+         listeners = kafka_server_config['listeners']
+         listeners = replace_sasl_related_config(listeners)
+         kafka_server_config['listeners'] = listeners
+
+         if 'advertised.listeners' not in kafka_server_config:
+           kafka_server_config['advertised.listeners'] = listeners
+         else:
+           if params.kafka_kerberos_merge_advertised_listeners:
+             Logger.warning("User defined advertised.listeners will be merged with Ambari-managed advertised.listeners value. To leave value as is change kafka-env/kerberos_merge_advertised_listeners to false.")
+             kafka_server_config['advertised.listeners'] = ",".join((listeners, kafka_server_config['advertised.listeners']))
+       elif 'advertised.listeners' in kafka_server_config:
+         advertised_listeners = kafka_server_config['advertised.listeners'].replace("localhost", params.hostname)
+         kafka_server_config['advertised.listeners'] = advertised_listeners
+
+       raw_listeners = kafka_server_config['raw.listeners'] if 'raw.listeners' in kafka_server_config else ""
+       if 'raw.listeners' in kafka_server_config:
+         del kafka_server_config['raw.listeners']
+       if raw_listeners.strip():
+         kafka_server_config['listeners'] = ",".join((kafka_server_config['listeners'], raw_listeners))
+       effective_kafka_listeners = kafka_server_config['listeners']
+       Logger.info("Kafka listeners: "+effective_kafka_listeners)
+       if 'advertised.listeners' in kafka_server_config:
+         effective_advertised_listeners = kafka_server_config['advertised.listeners']
+         Logger.info("Kafka advertised listeners: "+effective_advertised_listeners)
+    else:
+      kafka_server_config['host.name'] = params.hostname
+
+    if params.has_metric_collector:
+      kafka_server_config['kafka.timeline.metrics.hosts'] = params.ams_collector_hosts
+      kafka_server_config['kafka.timeline.metrics.port'] = params.metric_collector_port
+      kafka_server_config['kafka.timeline.metrics.protocol'] = params.metric_collector_protocol
+      kafka_server_config['kafka.timeline.metrics.truststore.path'] = params.metric_truststore_path
+      kafka_server_config['kafka.timeline.metrics.truststore.type'] = params.metric_truststore_type
+      kafka_server_config['kafka.timeline.metrics.truststore.password'] = params.metric_truststore_password
+
+    kafka_data_dir = kafka_server_config['log.dirs']
+    kafka_data_dirs = filter(None, kafka_data_dir.split(","))
+
+    rack="/default-rack"
+    i=0
+    if len(params.all_racks) > 0:
+     for host in params.all_hosts:
+      if host == params.hostname:
+        rack=params.all_racks[i]
+        break
+      i=i+1
+
+    Directory(kafka_data_dirs,
+              mode=0755,
+              cd_access='a',
+              owner=params.kafka_user,
+              group=params.user_group,
+              create_parents = True,
+              recursive_ownership = True,
+    )
+
+    PropertiesFile("server.properties",
+                      mode=0640,
+                      dir=params.conf_dir,
+                      properties=kafka_server_config,
+                      owner=params.kafka_user,
+                      group=params.user_group,
+    )
+
+    File(format("{conf_dir}/kafka-env.sh"),
+          owner=params.kafka_user,
+          content=InlineTemplate(params.kafka_env_sh_template)
+     )
+
+    if (params.log4j_props != None):
+        File(format("{conf_dir}/log4j.properties"),
+             mode=0644,
+             group=params.user_group,
+             owner=params.kafka_user,
+             content=InlineTemplate(params.log4j_props)
+         )
+
+    if (params.kerberos_security_enabled and params.kafka_kerberos_enabled) or params.kafka_other_sasl_enabled:
+      if params.kafka_jaas_conf_template:
+        File(format("{conf_dir}/kafka_jaas.conf"),
+             owner=params.kafka_user,
+             content=InlineTemplate(params.kafka_jaas_conf_template)
+        )
+      else:
+        TemplateConfig(format("{conf_dir}/kafka_jaas.conf"),
+                         owner=params.kafka_user)
+
+      if params.kafka_client_jaas_conf_template:
+        File(format("{conf_dir}/kafka_client_jaas.conf"),
+             owner=params.kafka_user,
+             content=InlineTemplate(params.kafka_client_jaas_conf_template)
+        )
+      else:
+        TemplateConfig(format("{conf_dir}/kafka_client_jaas.conf"),
+                       owner=params.kafka_user)
+
+    # On some OS this folder could be not exists, so we will create it before pushing there files
+    Directory(params.limits_conf_dir,
+              create_parents = True,
+              owner='root',
+              group='root'
+    )
+
+    File(os.path.join(params.limits_conf_dir, 'kafka.conf'),
+         owner='root',
+         group='root',
+         mode=0644,
+         content=Template("kafka.conf.j2")
+    )
+
+    File(os.path.join(params.conf_dir, 'tools-log4j.properties'),
+         owner='root',
+         group='root',
+         mode=0644,
+         content=Template("tools-log4j.properties.j2")
+         )
+
+    generate_logfeeder_input_config('kafka', Template("input.config-kafka.json.j2", extra_imports=[default]))
+
+    setup_symlink(params.kafka_managed_pid_dir, params.kafka_pid_dir)
+    setup_symlink(params.kafka_managed_log_dir, params.kafka_log_dir)
+
+
+def replace_sasl_related_config(property, only_protocol=False):
+  property = re.sub(r"(^|\b)PLAINTEXTSASL", "SASL_PLAINTEXT", property) if only_protocol else re.sub(r"(^|\b)PLAINTEXTSASL://", "SASL_PLAINTEXT://", property)
+  property = re.sub(r"(^|\b)PLAINTEXT", "SASL_PLAINTEXT", property) if only_protocol else re.sub(r"(^|\b)PLAINTEXT://", "SASL_PLAINTEXT://", property)
+  property = re.sub(r"(^|\b)SSL", "SASL_SSL", property) if only_protocol else re.sub(r"(^|\b)SSL://", "SASL_SSL://", property)
+  return property
+
+
+def mutable_config_dict(kafka_broker_config):
+    kafka_server_config = {}
+    for key, value in kafka_broker_config.iteritems():
+        kafka_server_config[key] = value
+    return kafka_server_config
+
+
+# Used to workaround the hardcoded pid/log dir used on the kafka bash process launcher
+def setup_symlink(kafka_managed_dir, kafka_ambari_managed_dir):
+  import params
+  backup_folder_path = None
+  backup_folder_suffix = "_tmp"
+  if kafka_ambari_managed_dir != kafka_managed_dir:
+    if os.path.exists(kafka_managed_dir) and not os.path.islink(kafka_managed_dir):
+
+      # Backup existing data before delete if config is changed repeatedly to/from default location at any point in time time, as there may be relevant contents (historic logs)
+      backup_folder_path = backup_dir_contents(kafka_managed_dir, backup_folder_suffix)
+
+      Directory(kafka_managed_dir,
+                action="delete",
+                create_parents = True)
+
+    elif os.path.islink(kafka_managed_dir) and os.path.realpath(kafka_managed_dir) != kafka_ambari_managed_dir:
+      Link(kafka_managed_dir,
+           action="delete")
+
+    if not os.path.islink(kafka_managed_dir):
+      Link(kafka_managed_dir,
+           to=kafka_ambari_managed_dir)
+
+  elif os.path.islink(kafka_managed_dir): # If config is changed and coincides with the kafka managed dir, remove the symlink and physically create the folder
+    Link(kafka_managed_dir,
+         action="delete")
+
+    Directory(kafka_managed_dir,
+              mode=0755,
+              cd_access='a',
+              owner=params.kafka_user,
+              group=params.user_group,
+              create_parents = True,
+              recursive_ownership = True,
+    )
+
+  if backup_folder_path:
+    # Restore backed up files to current relevant dirs if needed - will be triggered only when changing to/from default path;
+    for file in os.listdir(backup_folder_path):
+      if os.path.isdir(os.path.join(backup_folder_path, file)):
+        Execute(('cp', '-r', os.path.join(backup_folder_path, file), kafka_managed_dir),
+                sudo=True)
+        Execute(("chown", "-R", format("{kafka_user}:{user_group}"), os.path.join(kafka_managed_dir, file)),
+                sudo=True)
+      else:
+        File(os.path.join(kafka_managed_dir,file),
+             owner=params.kafka_user,
+             content = StaticFile(os.path.join(backup_folder_path,file)))
+
+    # Clean up backed up folder
+    Directory(backup_folder_path,
+              action="delete",
+              create_parents = True)
+
+
+# Uses agent temp dir to store backup files
+def backup_dir_contents(dir_path, backup_folder_suffix):
+  import params
+  backup_destination_path = params.tmp_dir + os.path.normpath(dir_path)+backup_folder_suffix
+  Directory(backup_destination_path,
+            mode=0755,
+            cd_access='a',
+            owner=params.kafka_user,
+            group=params.user_group,
+            create_parents = True,
+            recursive_ownership = True,
+  )
+  # Safely copy top-level contents to backup folder
+  for file in os.listdir(dir_path):
+    if os.path.isdir(os.path.join(dir_path, file)):
+      Execute(('cp', '-r', os.path.join(dir_path, file), backup_destination_path),
+              sudo=True)
+      Execute(("chown", "-R", format("{kafka_user}:{user_group}"), os.path.join(backup_destination_path, file)),
+              sudo=True)
+    else:
+      File(os.path.join(backup_destination_path, file),
+         owner=params.kafka_user,
+         content = StaticFile(os.path.join(dir_path,file)))
+
+  return backup_destination_path
+
+def ensure_base_directories():
+  import params
+  Directory([params.kafka_log_dir, params.kafka_pid_dir, params.conf_dir],
+            mode=0755,
+            cd_access='a',
+            owner=params.kafka_user,
+            group=params.user_group,
+            create_parents = True,
+            recursive_ownership = True,
+            )
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/kafka_broker.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/kafka_broker.py
new file mode 100644
index 00000000..b59b38c9
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/kafka_broker.py
@@ -0,0 +1,164 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+from resource_management import Script
+from resource_management.core import sudo
+from resource_management.core.logger import Logger
+from resource_management.core.resources.system import Execute, File
+from resource_management.core.exceptions import ComponentIsNotRunning, Fail
+from resource_management.libraries.functions import stack_select
+from resource_management.libraries.functions import Direction
+from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions.check_process_status import check_process_status
+from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.functions import upgrade_summary
+from resource_management.libraries.functions.stack_features import check_stack_feature
+from resource_management.libraries.functions.show_logs import show_logs
+from kafka import ensure_base_directories
+
+import upgrade
+from kafka import kafka
+
+class KafkaBroker(Script):
+
+  def install(self, env):
+    self.install_packages(env)
+
+  def configure(self, env, upgrade_type=None):
+    import params
+    env.set_params(params)
+    kafka(upgrade_type=upgrade_type)
+
+  def pre_upgrade_restart(self, env, upgrade_type=None):
+    import params
+    env.set_params(params)
+
+    if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.version):
+      stack_select.select_packages(params.version)
+
+    # This is extremely important since it should only be called if crossing the HDP 2.3.4.0 boundary.
+    if params.version and params.upgrade_direction:
+      src_version = dst_version = None
+      if params.upgrade_direction == Direction.UPGRADE:
+        src_version = upgrade_summary.get_source_version("KAFKA", default_version =  params.version)
+        dst_version = upgrade_summary.get_target_version("KAFKA", default_version =  params.version)
+      else:
+        # These represent the original values during the UPGRADE direction
+        src_version = upgrade_summary.get_target_version("KAFKA", default_version =  params.version)
+        dst_version = upgrade_summary.get_source_version("KAFKA", default_version =  params.version)
+
+      if not check_stack_feature(StackFeature.KAFKA_ACL_MIGRATION_SUPPORT, src_version) and check_stack_feature(StackFeature.KAFKA_ACL_MIGRATION_SUPPORT, dst_version):
+        # Calling the acl migration script requires the configs to be present.
+        self.configure(env, upgrade_type=upgrade_type)
+        upgrade.run_migration(env, upgrade_type)
+
+  def start(self, env, upgrade_type=None):
+    import params
+    env.set_params(params)
+    self.configure(env, upgrade_type=upgrade_type)
+
+    if params.kerberos_security_enabled:
+      if params.version and check_stack_feature(StackFeature.KAFKA_KERBEROS, params.version):
+        kafka_kinit_cmd = format("{kinit_path_local} -kt {kafka_keytab_path} {kafka_jaas_principal};")
+        Execute(kafka_kinit_cmd, user=params.kafka_user)
+
+    daemon_cmd = format('source {params.conf_dir}/kafka-env.sh ; {params.kafka_start_cmd}>>/dev/null 2>>{params.kafka_err_file} & echo $!>{params.kafka_pid_file}')
+    no_op_test = format('ls {params.kafka_pid_file}>/dev/null 2>&1 && ps -p `cat {params.kafka_pid_file}`>/dev/null 2>&1')
+    try:
+      Execute(daemon_cmd,
+              user=params.kafka_user,
+              not_if=no_op_test
+      )
+    except:
+      show_logs(params.kafka_log_dir, params.kafka_user)
+      raise
+
+  def stop(self, env, upgrade_type=None):
+    import os, time, params, signal
+
+    env.set_params(params)
+    # Kafka package scripts change permissions on folders, so we have to
+    # restore permissions after installing repo version bits
+    # before attempting to stop Kafka Broker
+    ensure_base_directories()
+
+    if not params.kafka_pid_file or not os.path.isfile(params.kafka_pid_file):
+      Logger.info("Kafka is not running. No pid file found.")
+      return
+    
+    try:
+      pid = int(sudo.read_file(params.kafka_pid_file))
+    except:
+      Logger.info("Pid file {0} does not exist or does not contain a process id number".format(params.kafka_pid_file))
+      return
+
+    max_wait = 120
+    for i in range(max_wait):
+      Logger.info("Waiting for Kafka Broker stop, current pid: {0}, seconds: {1}s".format(pid, i + 1))
+      try:
+        sudo.kill(pid, signal.SIGTERM)
+      except OSError, e:
+        Logger.info("Kafka Broker is not running, delete pid file: {0}".format(params.kafka_pid_file))
+        File(params.kafka_pid_file, action = "delete")
+        return
+        
+      time.sleep(1)
+
+      try:
+        check_process_status(params.kafka_pid_file)
+      except ComponentIsNotRunning, e:
+        File(params.kafka_pid_file, action = "delete")
+        return
+    
+    raise Fail("Cannot stop Kafka Broker after {0} seconds".format(max_wait))
+
+
+  def disable_security(self, env):
+    import params
+    if not params.zookeeper_connect:
+      Logger.info("No zookeeper connection string. Skipping reverting ACL")
+      return
+    if not params.secure_acls:
+      Logger.info("The zookeeper.set.acl is false. Skipping reverting ACL")
+      return
+    Execute(
+      "{0} --zookeeper.connect {1} --zookeeper.acl=unsecure".format(params.kafka_security_migrator, params.zookeeper_connect), \
+      user=params.kafka_user, \
+      environment={ 'JAVA_HOME': params.java64_home }, \
+      logoutput=True, \
+      tries=3)
+
+  def status(self, env):
+    import status_params
+    env.set_params(status_params)
+    check_process_status(status_params.kafka_pid_file)
+    
+  def get_log_folder(self):
+    import params
+    return params.kafka_log_dir
+  
+  def get_user(self):
+    import params
+    return params.kafka_user
+
+  def get_pid_files(self):
+    import status_params
+    return [status_params.kafka_pid_file]
+
+if __name__ == "__main__":
+  KafkaBroker().execute()
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/params.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/params.py
new file mode 100644
index 00000000..d407c602
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/params.py
@@ -0,0 +1,234 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+import os
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions.version import format_stack_version
+from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.functions.stack_features import check_stack_feature
+from resource_management.libraries.functions.stack_features import get_stack_feature_version
+from resource_management.libraries.functions.default import default
+from utils import get_bare_principal
+import status_params
+from resource_management.libraries.resources.hdfs_resource import HdfsResource
+from resource_management.libraries.functions import stack_select
+from resource_management.libraries.functions import conf_select
+from resource_management.libraries.functions import upgrade_summary
+from resource_management.libraries.functions import get_kinit_path
+from resource_management.libraries.functions.get_not_managed_resources import get_not_managed_resources
+
+# server configurations
+config = Script.get_config()
+tmp_dir = Script.get_tmp_dir()
+stack_root = Script.get_stack_root()
+stack_name = default("/clusterLevelParams/stack_name", None)
+retryAble = default("/commandParams/command_retry_enabled", False)
+
+# Version being upgraded/downgraded to
+version = default("/commandParams/version", None)
+
+stack_version_unformatted = config['clusterLevelParams']['stack_version']
+stack_version_formatted = format_stack_version(stack_version_unformatted)
+upgrade_direction = default("/commandParams/upgrade_direction", None)
+
+# get the correct version to use for checking stack features
+version_for_stack_feature_checks = get_stack_feature_version(config)
+
+# When downgrading the 'version' is pointing to the downgrade-target version
+# downgrade_from_version provides the source-version the downgrade is happening from
+downgrade_from_version = upgrade_summary.get_downgrade_from_version("KAFKA")
+
+hostname = config['agentLevelParams']['hostname']
+
+# default kafka parameters
+kafka_home = '/usr/lib/kafka'
+kafka_start_cmd = kafka_home + "/bin/kafka-server-start.sh " + kafka_home + "/config/server.properties"
+kafka_stop_cmd = kafka_home + "/bin/kafka-server-stop.sh " + kafka_home + "/config/server.properties"
+kafka_bin = kafka_home + '/bin/kafka'
+conf_dir = "/etc/kafka/conf"
+limits_conf_dir = "/etc/security/limits.d"
+
+# Used while upgrading the stack in a kerberized cluster and running kafka-acls.sh
+zookeeper_connect = default("/configurations/kafka-broker/zookeeper.connect", None)
+
+kafka_user_nofile_limit = default('/configurations/kafka-env/kafka_user_nofile_limit', 128000)
+kafka_user_nproc_limit = default('/configurations/kafka-env/kafka_user_nproc_limit', 65536)
+
+kafka_delete_topic_enable = default('/configurations/kafka-broker/delete.topic.enable', True)
+
+# parameters for 2.2+
+if stack_version_formatted and check_stack_feature(StackFeature.ROLLING_UPGRADE, stack_version_formatted):
+  kafka_home = os.path.join(stack_root,  "current", "kafka-broker")
+  kafka_bin = os.path.join(kafka_home, "bin", "kafka")
+  conf_dir = os.path.join(kafka_home, "config")
+
+kafka_user = config['configurations']['kafka-env']['kafka_user']
+kafka_log_dir = config['configurations']['kafka-env']['kafka_log_dir']
+kafka_pid_dir = status_params.kafka_pid_dir
+kafka_pid_file = kafka_pid_dir + "/kafka.pid"
+kafka_err_file = kafka_log_dir + "/kafka.err"
+# This is hardcoded on the kafka bash process lifecycle on which we have no control over
+kafka_managed_pid_dir = "/var/run/kafka"
+kafka_managed_log_dir = "/var/log/kafka"
+user_group = config['configurations']['cluster-env']['user_group']
+java64_home = config['ambariLevelParams']['java_home']
+kafka_env_sh_template = config['configurations']['kafka-env']['content']
+kafka_jaas_conf_template = default("/configurations/kafka_jaas_conf/content", None)
+kafka_client_jaas_conf_template = default("/configurations/kafka_client_jaas_conf/content", None)
+kafka_hosts = config['clusterHostInfo']['kafka_broker_hosts']
+kafka_hosts.sort()
+
+zookeeper_hosts = config['clusterHostInfo']['zookeeper_server_hosts']
+zookeeper_hosts.sort()
+secure_acls = default("/configurations/kafka-broker/zookeeper.set.acl", False)
+kafka_security_migrator = os.path.join(kafka_home, "bin", "zookeeper-security-migration.sh")
+
+all_hosts = default("/clusterHostInfo/all_hosts", [])
+all_racks = default("/clusterHostInfo/all_racks", [])
+
+#Kafka log4j
+kafka_log_maxfilesize = default('/configurations/kafka-log4j/kafka_log_maxfilesize',256)
+kafka_log_maxbackupindex = default('/configurations/kafka-log4j/kafka_log_maxbackupindex',20)
+controller_log_maxfilesize = default('/configurations/kafka-log4j/controller_log_maxfilesize',256)
+controller_log_maxbackupindex = default('/configurations/kafka-log4j/controller_log_maxbackupindex',20)
+
+if (('kafka-log4j' in config['configurations']) and ('content' in config['configurations']['kafka-log4j'])):
+    log4j_props = config['configurations']['kafka-log4j']['content']
+else:
+    log4j_props = None
+
+if 'ganglia_server_hosts' in config['clusterHostInfo'] and \
+    len(config['clusterHostInfo']['ganglia_server_hosts'])>0:
+  ganglia_installed = True
+  ganglia_server = config['clusterHostInfo']['ganglia_server_hosts'][0]
+  ganglia_report_interval = 60
+else:
+  ganglia_installed = False
+
+metric_collector_port = ""
+metric_collector_protocol = ""
+metric_truststore_path= default("/configurations/ams-ssl-client/ssl.client.truststore.location", "")
+metric_truststore_type= default("/configurations/ams-ssl-client/ssl.client.truststore.type", "")
+metric_truststore_password= default("/configurations/ams-ssl-client/ssl.client.truststore.password", "")
+
+set_instanceId = "false"
+cluster_name = config["clusterName"]
+
+if 'cluster-env' in config['configurations'] and \
+        'metrics_collector_external_hosts' in config['configurations']['cluster-env']:
+  ams_collector_hosts = config['configurations']['cluster-env']['metrics_collector_external_hosts']
+  set_instanceId = "true"
+else:
+  ams_collector_hosts = ",".join(default("/clusterHostInfo/metrics_collector_hosts", []))
+
+has_metric_collector = not len(ams_collector_hosts) == 0
+
+if has_metric_collector:
+  if 'cluster-env' in config['configurations'] and \
+      'metrics_collector_external_port' in config['configurations']['cluster-env']:
+    metric_collector_port = config['configurations']['cluster-env']['metrics_collector_external_port']
+  else:
+    metric_collector_web_address = default("/configurations/ams-site/timeline.metrics.service.webapp.address", "0.0.0.0:6188")
+    if metric_collector_web_address.find(':') != -1:
+      metric_collector_port = metric_collector_web_address.split(':')[1]
+    else:
+      metric_collector_port = '6188'
+  if default("/configurations/ams-site/timeline.metrics.service.http.policy", "HTTP_ONLY") == "HTTPS_ONLY":
+    metric_collector_protocol = 'https'
+  else:
+    metric_collector_protocol = 'http'
+
+  host_in_memory_aggregation = str(default("/configurations/ams-site/timeline.metrics.host.inmemory.aggregation", True)).lower()
+  host_in_memory_aggregation_port = default("/configurations/ams-site/timeline.metrics.host.inmemory.aggregation.port", 61888)
+  is_aggregation_https_enabled = False
+  if default("/configurations/ams-site/timeline.metrics.host.inmemory.aggregation.http.policy", "HTTP_ONLY") == "HTTPS_ONLY":
+    host_in_memory_aggregation_protocol = 'https'
+    is_aggregation_https_enabled = True
+  else:
+    host_in_memory_aggregation_protocol = 'http'
+  pass
+
+# Security-related params
+kerberos_security_enabled = config['configurations']['cluster-env']['security_enabled']
+kafka_kerberos_merge_advertised_listeners = default('/configurations/kafka-env/kerberos_merge_advertised_listeners', True)
+
+kafka_kerberos_enabled = (('security.inter.broker.protocol' in config['configurations']['kafka-broker']) and
+                          (config['configurations']['kafka-broker']['security.inter.broker.protocol'] in ("PLAINTEXTSASL", "SASL_PLAINTEXT", "SASL_SSL")))
+
+kafka_other_sasl_enabled = not kerberos_security_enabled and check_stack_feature(StackFeature.KAFKA_LISTENERS, stack_version_formatted) and \
+                           check_stack_feature(StackFeature.KAFKA_EXTENDED_SASL_SUPPORT, format_stack_version(version_for_stack_feature_checks)) and \
+                           (("SASL_PLAINTEXT" in config['configurations']['kafka-broker']['listeners']) or
+                            ("PLAINTEXTSASL" in config['configurations']['kafka-broker']['listeners']) or #to support backward compability (we'll replace this anyway before we write it to server.properties)
+                            ("SASL_SSL" in config['configurations']['kafka-broker']['listeners']))
+
+if kerberos_security_enabled and stack_version_formatted != "" and 'kafka_principal_name' in config['configurations']['kafka-env'] \
+  and check_stack_feature(StackFeature.KAFKA_KERBEROS, stack_version_formatted):
+    _hostname_lowercase = config['agentLevelParams']['hostname'].lower()
+    _kafka_principal_name = config['configurations']['kafka-env']['kafka_principal_name']
+    kafka_jaas_principal = _kafka_principal_name.replace('_HOST',_hostname_lowercase)
+    kafka_keytab_path = config['configurations']['kafka-env']['kafka_keytab']
+    kafka_bare_jaas_principal = get_bare_principal(_kafka_principal_name)
+    kafka_kerberos_params = "-Djava.security.auth.login.config="+ conf_dir +"/kafka_jaas.conf"
+elif kafka_other_sasl_enabled:
+  kafka_kerberos_params = "-Djava.security.auth.login.config="+ conf_dir +"/kafka_jaas.conf"
+else:
+    kafka_kerberos_params = ''
+    kafka_jaas_principal = None
+    kafka_keytab_path = None
+
+namenode_hosts = default("/clusterHostInfo/namenode_hosts", [])
+has_namenode = not len(namenode_hosts) == 0
+
+hdfs_user = config['configurations']['hadoop-env']['hdfs_user'] if has_namenode else None
+hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab'] if has_namenode else None
+hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name'] if has_namenode else None
+hdfs_site = config['configurations']['hdfs-site'] if has_namenode else None
+default_fs = config['configurations']['core-site']['fs.defaultFS'] if has_namenode else None
+hadoop_bin_dir = stack_select.get_hadoop_dir("bin") if has_namenode else None
+hadoop_conf_dir = conf_select.get_hadoop_conf_dir() if has_namenode else None
+kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None))
+dfs_type = default("/clusterLevelParams/dfs_type", "")
+mount_table_xml_inclusion_file_full_path = None
+mount_table_content = None
+if 'viewfs-mount-table' in config['configurations']:
+  xml_inclusion_file_name = 'viewfs-mount-table.xml'
+  mount_table = config['configurations']['viewfs-mount-table']
+
+  if 'content' in mount_table and mount_table['content'].strip():
+    mount_table_xml_inclusion_file_full_path = os.path.join(conf_dir, xml_inclusion_file_name)
+    mount_table_content = mount_table['content']
+
+import functools
+#create partial functions with common arguments for every HdfsResource call
+#to create/delete hdfs directory/file/copyfromlocal we need to call params.HdfsResource in code
+HdfsResource = functools.partial(
+  HdfsResource,
+  user = hdfs_user,
+  hdfs_resource_ignore_file = "/var/lib/ambari-agent/data/.hdfs_resource_ignore",
+  security_enabled = kerberos_security_enabled,
+  keytab = hdfs_user_keytab,
+  kinit_path_local = kinit_path_local,
+  hadoop_bin_dir = hadoop_bin_dir,
+  hadoop_conf_dir = hadoop_conf_dir,
+  principal_name = hdfs_principal_name,
+  hdfs_site = hdfs_site,
+  default_fs = default_fs,
+  immutable_paths = get_not_managed_resources(),
+  dfs_type = dfs_type,
+)
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/service_check.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/service_check.py
new file mode 100644
index 00000000..087bf681
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/service_check.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions.validate import call_and_match_output
+from resource_management.core import shell
+from resource_management.libraries.functions.format import format
+from resource_management.core.logger import Logger
+from resource_management.core.exceptions import Fail
+from resource_management.core import sudo
+
+class ServiceCheck(Script):
+  def service_check(self, env):
+    import params
+    env.set_params(params)
+
+    # TODO, Kafka Service check should be more robust , It should get all the broker_hosts
+    # Produce some messages and check if consumer reads same no.of messages.
+
+    kafka_config = self.read_kafka_config()
+    topic = "ambari_kafka_service_check"
+    create_topic_cmd_created_output = "Created topic ambari_kafka_service_check."
+    create_topic_cmd_exists_output = "Topic \'ambari_kafka_service_check\' already exists."
+    source_cmd = format("source {conf_dir}/kafka-env.sh")
+    topic_exists_cmd = format(source_cmd + " ; " + "{kafka_home}/bin/kafka-topics.sh --zookeeper {kafka_config[zookeeper.connect]} --topic {topic} --list")
+    topic_exists_cmd_code, topic_exists_cmd_out = shell.call(topic_exists_cmd, logoutput=True, quiet=False, user=params.kafka_user)
+
+    if topic_exists_cmd_code > 0:
+      raise Fail("Error encountered when attempting to list topics: {0}".format(topic_exists_cmd_out))
+
+    if not params.kafka_delete_topic_enable:
+      Logger.info('Kafka delete.topic.enable is not enabled. Skipping topic creation: %s' % topic)
+      return
+
+      # 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")
+      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)
+
+    under_rep_cmd = format("{kafka_home}/bin/kafka-topics.sh --describe --zookeeper {kafka_config[zookeeper.connect]} --under-replicated-partitions")
+    under_rep_cmd_code, under_rep_cmd_out = shell.call(under_rep_cmd, logoutput=True, quiet=False, user=params.kafka_user)
+
+    if under_rep_cmd_code > 0:
+      raise Fail("Error encountered when attempting find under replicated partitions: {0}".format(under_rep_cmd_out))
+    elif len(under_rep_cmd_out) > 0 and "Topic" in under_rep_cmd_out:
+      Logger.warning("Under replicated partitions found: {0}".format(under_rep_cmd_out))
+
+  def read_kafka_config(self):
+    import params
+
+    kafka_config = {}
+    content = sudo.read_file(params.conf_dir + "/server.properties")
+    for line in content.splitlines():
+      if line.startswith("#") or not line.strip():
+        continue
+
+      key, value = line.split("=")
+      kafka_config[key] = value.replace("\n", "")
+
+    return kafka_config
+
+if __name__ == "__main__":
+    ServiceCheck().execute()
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/status_params.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/status_params.py
new file mode 100644
index 00000000..57bdf5e0
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/status_params.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+from resource_management.libraries.functions import format
+from resource_management.libraries.script.script import Script
+
+config = Script.get_config()
+
+kafka_pid_dir = config['configurations']['kafka-env']['kafka_pid_dir']
+kafka_pid_file = format("{kafka_pid_dir}/kafka.pid")
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/upgrade.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/upgrade.py
new file mode 100644
index 00000000..45694854
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/upgrade.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+import os
+
+
+from resource_management.core.resources.system import Execute
+from resource_management.libraries.functions import format
+from resource_management.libraries.functions import Direction
+from resource_management.core.exceptions import Fail
+from resource_management.core.logger import Logger
+
+def run_migration(env, upgrade_type):
+  """
+  If the acl migration script is present, then run it for either upgrade or downgrade.
+  That script was introduced in HDP 2.3.4.0 and requires stopping all Kafka brokers first.
+  Requires configs to be present.
+  :param env: Environment.
+  :param upgrade_type: "rolling" or "nonrolling
+  """
+  import params
+
+  if upgrade_type is None:
+    raise Fail('Parameter "upgrade_type" is missing.')
+
+  if params.upgrade_direction is None:
+    raise Fail('Parameter "upgrade_direction" is missing.')
+
+  if not params.kerberos_security_enabled:
+    Logger.info("Skip running the Kafka ACL migration script since cluster security is not enabled.")
+    return
+
+  Logger.info("Upgrade type: {0}, direction: {1}".format(str(upgrade_type), params.upgrade_direction))
+
+  # If the schema upgrade script exists in the version upgrading to, then attempt to upgrade/downgrade it while still using the present bits.
+  kafka_acls_script = None
+  command_suffix = ""
+  if params.upgrade_direction == Direction.UPGRADE:
+    kafka_acls_script = format("{stack_root}/{version}/kafka/bin/kafka-acls.sh")
+    command_suffix = "--upgradeAcls"
+  elif params.upgrade_direction == Direction.DOWNGRADE:
+    kafka_acls_script = format("{stack_root}/{downgrade_from_version}/kafka/bin/kafka-acls.sh")
+    command_suffix = "--downgradeAcls"
+
+  if kafka_acls_script is not None:
+    if os.path.exists(kafka_acls_script):
+      Logger.info("Found Kafka acls script: {0}".format(kafka_acls_script))
+      if params.zookeeper_connect is None:
+        raise Fail("Could not retrieve property kafka-broker/zookeeper.connect")
+
+      acls_command = "{0} --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect={1} {2}".\
+        format(kafka_acls_script, params.zookeeper_connect, command_suffix)
+
+      Execute(acls_command,
+              user=params.kafka_user,
+              logoutput=True)
+    else:
+      Logger.info("Did not find Kafka acls script: {0}".format(kafka_acls_script))
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/utils.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/utils.py
new file mode 100644
index 00000000..2f1fa5e0
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/scripts/utils.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+import re
+
+def get_bare_principal(normalized_principal_name):
+    """
+    Given a normalized principal name (nimbus/c6501.ambari.apache.org@EXAMPLE.COM) returns just the
+    primary component (nimbus)
+    :param normalized_principal_name: a string containing the principal name to process
+    :return: a string containing the primary component value or None if not valid
+    """
+
+    bare_principal = None
+
+    if normalized_principal_name:
+        match = re.match(r"([^/@]+)(?:/[^@])?(?:@.*)?", normalized_principal_name)
+
+    if match:
+        bare_principal = match.group(1)
+
+    return bare_principal
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/input.config-kafka.json.j2 b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/input.config-kafka.json.j2
new file mode 100644
index 00000000..2b424b13
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/input.config-kafka.json.j2
@@ -0,0 +1,92 @@
+{#
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements.  See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership.  The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License.  You may obtain a copy of the License at
+ #
+ #   http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ #}
+{
+  "input":[
+    {
+      "type":"kafka_controller",
+      "rowtype":"service",
+      "path":"{{default('/configurations/kafka-env/kafka_log_dir', '/var/log/kafka')}}/controller.log"
+    },
+    {
+      "type":"kafka_request",
+      "rowtype":"service",
+      "path":"{{default('/configurations/kafka-env/kafka_log_dir', '/var/log/kafka')}}/kafka-request.log"
+    },
+    {
+      "type":"kafka_logcleaner",
+      "rowtype":"service",
+      "path":"{{default('/configurations/kafka-env/kafka_log_dir', '/var/log/kafka')}}/log-cleaner.log"
+    },
+    {
+      "type":"kafka_server",
+      "rowtype":"service",
+      "path":"{{default('/configurations/kafka-env/kafka_log_dir', '/var/log/kafka')}}/server.log"
+    },
+    {
+      "type":"kafka_statechange",
+      "rowtype":"service",
+      "path":"{{default('/configurations/kafka-env/kafka_log_dir', '/var/log/kafka')}}/state-change.log"
+    }
+  ],
+  "filter":[
+    {
+      "filter":"grok",
+      "conditions":{
+        "fields":{
+          "type":[
+            "kafka_controller",
+            "kafka_request",
+            "kafka_logcleaner"
+          ]
+        }
+      },
+      "log4j_format":"[%d] %p %m (%c)%n",
+      "multiline_pattern":"^(\\[%{TIMESTAMP_ISO8601:logtime}\\])",
+      "message_pattern":"(?m)^\\[%{TIMESTAMP_ISO8601:logtime}\\]%{SPACE}%{LOGLEVEL:level}%{SPACE}%{GREEDYDATA:log_message}",
+      "post_map_values":{
+        "logtime":{
+          "map_date":{
+            "target_date_pattern":"yyyy-MM-dd HH:mm:ss,SSS"
+          }
+        }
+      }
+    },
+    {
+      "filter":"grok",
+      "comment":"Suppose to be same log4j pattern as other kafka processes, but some reason thread is not printed",
+      "conditions":{
+        "fields":{
+          "type":[
+            "kafka_server",
+            "kafka_statechange"
+          ]
+        }
+      },
+      "log4j_format":"[%d] %p %m (%c)%n",
+      "multiline_pattern":"^(\\[%{TIMESTAMP_ISO8601:logtime}\\])",
+      "message_pattern":"(?m)^\\[%{TIMESTAMP_ISO8601:logtime}\\]%{SPACE}%{LOGLEVEL:level}%{SPACE}%{GREEDYDATA:log_message}",
+      "post_map_values":{
+        "logtime":{
+          "map_date":{
+            "target_date_pattern":"yyyy-MM-dd HH:mm:ss,SSS"
+          }
+        }
+      }
+    }
+  ]
+}
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka.conf.j2 b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka.conf.j2
new file mode 100644
index 00000000..eeec9ce6
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka.conf.j2
@@ -0,0 +1,20 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+{{kafka_user}}   - nofile   {{kafka_user_nofile_limit}}
+{{kafka_user}}   - nproc    {{kafka_user_nproc_limit}}
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka_client_jaas.conf.j2 b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka_client_jaas.conf.j2
new file mode 100644
index 00000000..873d030b
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka_client_jaas.conf.j2
@@ -0,0 +1,32 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+{% if kerberos_security_enabled %}
+KafkaClient {
+   com.sun.security.auth.module.Krb5LoginModule required
+   useTicketCache=true
+   renewTicket=true
+   serviceName="{{kafka_bare_jaas_principal}}";
+};
+{% endif %}
+Client {
+   com.sun.security.auth.module.Krb5LoginModule required
+   useTicketCache=true
+   renewTicket=true
+   serviceName="zookeeper";
+};
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka_jaas.conf.j2 b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka_jaas.conf.j2
new file mode 100644
index 00000000..68b5e448
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/kafka_jaas.conf.j2
@@ -0,0 +1,99 @@
+{#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+
+/**
+* Example of SASL/PLAIN Configuration
+*
+* KafkaServer {
+*   org.apache.kafka.common.security.plain.PlainLoginModule required
+*   username="admin"
+*   password="admin-secret"
+*   user_admin="admin-secret"
+*   user_alice="alice-secret";
+*   };
+*
+* Example of SASL/SCRAM
+*
+* KafkaServer {
+*   org.apache.kafka.common.security.scram.ScramLoginModule required
+*   username="admin"
+*   password="admin-secret"
+*   };
+*
+* Example of Enabling multiple SASL mechanisms in a broker:
+*
+*   KafkaServer {
+*
+*    com.sun.security.auth.module.Krb5LoginModule required
+*    useKeyTab=true
+*    storeKey=true
+*    keyTab="/etc/security/keytabs/kafka_server.keytab"
+*    principal="kafka/kafka1.hostname.com@EXAMPLE.COM";
+*
+*    org.apache.kafka.common.security.plain.PlainLoginModule required
+*    username="admin"
+*    password="admin-secret"
+*    user_admin="admin-secret"
+*    user_alice="alice-secret";
+*
+*    org.apache.kafka.common.security.scram.ScramLoginModule required
+*    username="scram-admin"
+*    password="scram-admin-secret";
+*    };
+*
+**/
+
+{% if kerberos_security_enabled %}
+
+KafkaServer {
+   com.sun.security.auth.module.Krb5LoginModule required
+   useKeyTab=true
+   keyTab="{{kafka_keytab_path}}"
+   storeKey=true
+   useTicketCache=false
+   serviceName="{{kafka_bare_jaas_principal}}"
+   principal="{{kafka_jaas_principal}}";
+};
+KafkaClient {
+   com.sun.security.auth.module.Krb5LoginModule required
+   useTicketCache=true
+   renewTicket=true
+   serviceName="{{kafka_bare_jaas_principal}}";
+};
+Client {
+   com.sun.security.auth.module.Krb5LoginModule required
+   useKeyTab=true
+   keyTab="{{kafka_keytab_path}}"
+   storeKey=true
+   useTicketCache=false
+   serviceName="zookeeper"
+   principal="{{kafka_jaas_principal}}";
+};
+com.sun.security.jgss.krb5.initiate {
+   com.sun.security.auth.module.Krb5LoginModule required
+   renewTGT=false
+   doNotPrompt=true
+   useKeyTab=true
+   keyTab="{{kafka_keytab_path}}"
+   storeKey=true
+   useTicketCache=false
+   serviceName="{{kafka_bare_jaas_principal}}"
+   principal="{{kafka_jaas_principal}}";
+};
+
+{% endif %}
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/tools-log4j.properties.j2 b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/tools-log4j.properties.j2
new file mode 100644
index 00000000..c4ad326a
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/package/templates/tools-log4j.properties.j2
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=WARN, stderr
+
+log4j.appender.stderr=org.apache.log4j.ConsoleAppender
+log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
+log4j.appender.stderr.layout.ConversionPattern=[%d] %p %m (%c)%n
+log4j.appender.stderr.Target=System.err
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/role_command_order.json b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/role_command_order.json
new file mode 100644
index 00000000..b8633ea1
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/role_command_order.json
@@ -0,0 +1,7 @@
+{
+  "general_deps" : {
+    "_comment" : "dependencies for KAFKA",
+    "KAFKA_BROKER-START" : ["ZOOKEEPER_SERVER-START"],
+    "KAFKA_SERVICE_CHECK-SERVICE_CHECK": ["KAFKA_BROKER-START"]
+  }
+}
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/service_advisor.py b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/service_advisor.py
new file mode 100644
index 00000000..33df7ac2
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/service_advisor.py
@@ -0,0 +1,451 @@
+#!/usr/bin/env ambari-python-wrap
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+# Python imports
+import imp
+import os
+import traceback
+import re
+
+from resource_management.core.logger import Logger
+
+SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+STACKS_DIR = os.path.join(SCRIPT_DIR, '../../../../../stacks/')
+PARENT_FILE = os.path.join(STACKS_DIR, 'service_advisor.py')
+
+try:
+  if "BASE_SERVICE_ADVISOR" in os.environ:
+    PARENT_FILE = os.environ["BASE_SERVICE_ADVISOR"]
+  with open(PARENT_FILE, 'rb') as fp:
+    service_advisor = imp.load_module('service_advisor', fp, PARENT_FILE, ('.py', 'rb', imp.PY_SOURCE))
+except Exception as e:
+  traceback.print_exc()
+  print "Failed to load parent"
+
+class KafkaServiceAdvisor(service_advisor.ServiceAdvisor):
+
+  def __init__(self, *args, **kwargs):
+    self.as_super = super(KafkaServiceAdvisor, self)
+    self.as_super.__init__(*args, **kwargs)
+
+    # Always call these methods
+    self.modifyMastersWithMultipleInstances()
+    self.modifyCardinalitiesDict()
+    self.modifyHeapSizeProperties()
+    self.modifyNotValuableComponents()
+    self.modifyComponentsNotPreferableOnServer()
+    self.modifyComponentLayoutSchemes()
+
+  def modifyMastersWithMultipleInstances(self):
+    """
+    Modify the set of masters with multiple instances.
+    Must be overriden in child class.
+    """
+    # Nothing to do
+    pass
+
+  def modifyCardinalitiesDict(self):
+    """
+    Modify the dictionary of cardinalities.
+    Must be overriden in child class.
+    """
+    # Nothing to do
+    pass
+
+  def modifyHeapSizeProperties(self):
+    """
+    Modify the dictionary of heap size properties.
+    Must be overriden in child class.
+    """
+    pass
+
+  def modifyNotValuableComponents(self):
+    """
+    Modify the set of components whose host assignment is based on other services.
+    Must be overriden in child class.
+    """
+    # Nothing to do
+    pass
+
+  def modifyComponentsNotPreferableOnServer(self):
+    """
+    Modify the set of components that are not preferable on the server.
+    Must be overriden in child class.
+    """
+    # Nothing to do
+    pass
+
+  def modifyComponentLayoutSchemes(self):
+    """
+    Modify layout scheme dictionaries for components.
+    The scheme dictionary basically maps the number of hosts to
+    host index where component should exist.
+    Must be overriden in child class.
+    """
+    # Nothing to do
+    pass
+
+  def getServiceComponentLayoutValidations(self, services, hosts):
+    """
+    Get a list of errors.
+    Must be overriden in child class.
+    """
+
+    return self.getServiceComponentCardinalityValidations(services, hosts, "KAFKA")
+
+  def getServiceConfigurationRecommendations(self, configurations, clusterData, services, hosts):
+    """
+    Entry point.
+    Must be overriden in child class.
+    """
+    #Logger.info("Class: %s, Method: %s. Recommending Service Configurations." %
+    #            (self.__class__.__name__, inspect.stack()[0][3]))
+
+    recommender = KafkaRecommender()
+    recommender.recommendKafkaConfigurationsFromHDP22(configurations, clusterData, services, hosts)
+    recommender.recommendKAFKAConfigurationsFromHDP23(configurations, clusterData, services, hosts)
+    recommender.recommendKAFKAConfigurationsFromHDP26(configurations, clusterData, services, hosts)
+    recommender.recommendKAFKAConfigurationsFromHDP30(configurations, clusterData, services, hosts)
+
+  def getServiceConfigurationsValidationItems(self, configurations, recommendedDefaults, services, hosts):
+    """
+    Entry point.
+    Validate configurations for the service. Return a list of errors.
+    The code for this function should be the same for each Service Advisor.
+    """
+    #Logger.info("Class: %s, Method: %s. Validating Configurations." %
+    #            (self.__class__.__name__, inspect.stack()[0][3]))
+
+    validator = KafkaValidator()
+    # Calls the methods of the validator using arguments,
+    # method(siteProperties, siteRecommendations, configurations, services, hosts)
+    return validator.validateListOfConfigUsingMethod(configurations, recommendedDefaults, services, hosts, validator.validators)
+
+  @staticmethod
+  def isKerberosEnabled(services, configurations):
+    """
+    Determine if Kerberos is enabled for Kafka.
+
+    If kafka-broker/security.inter.broker.protocol exists and is set to "SASL_PLAINTEXT", return True;
+    otherwise return false.
+
+    The value of this property is first tested in the updated configurations (configurations) then
+    tested in the current configuration set (services)
+
+    :type services: dict
+    :param services: the dictionary containing the existing configuration values
+    :type configurations: dict
+    :param configurations: the dictionary containing the updated configuration values
+    :rtype: bool
+    :return: True or False
+    """
+
+    if configurations and "kafka-broker" in configurations and \
+            "security.inter.broker.protocol" in configurations["kafka-broker"]["properties"]:
+      return configurations["kafka-broker"]["properties"]["security.inter.broker.protocol"] == "SASL_PLAINTEXT"
+    elif services and "kafka-broker" in services["configurations"] and \
+            "security.inter.broker.protocol" in services["configurations"]["kafka-broker"]["properties"]:
+      return services["configurations"]["kafka-broker"]["properties"]["security.inter.broker.protocol"] == "SASL_PLAINTEXT"
+    else:
+      return False
+
+
+
+class KafkaRecommender(service_advisor.ServiceAdvisor):
+  """
+  Kafka Recommender suggests properties when adding the service for the first time or modifying configs via the UI.
+  """
+
+  def __init__(self, *args, **kwargs):
+    self.as_super = super(KafkaRecommender, self)
+    self.as_super.__init__(*args, **kwargs)
+
+
+
+  def recommendKafkaConfigurationsFromHDP22(self, configurations, clusterData, services, hosts):
+    kafka_mounts = [
+      ("log.dirs", "KAFKA_BROKER", "/kafka-logs", "multi")
+    ]
+
+    self.updateMountProperties("kafka-broker", kafka_mounts, configurations, services, hosts)
+
+  def recommendKAFKAConfigurationsFromHDP23(self, configurations, clusterData, services, hosts):
+
+    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
+    kafka_broker = self.getServicesSiteProperties(services, "kafka-broker")
+    kafka_env = self.getServicesSiteProperties(services, "kafka-env")
+
+    if not kafka_env: #Kafka check not required
+      return
+
+    security_enabled = KafkaServiceAdvisor.isKerberosEnabled(services, configurations)
+
+    putKafkaBrokerProperty = self.putProperty(configurations, "kafka-broker", services)
+    putKafkaLog4jProperty = self.putProperty(configurations, "kafka-log4j", services)
+    putKafkaBrokerAttributes = self.putPropertyAttribute(configurations, "kafka-broker")
+
+    if security_enabled:
+      self.update_listeners_to_sasl(services, putKafkaBrokerProperty)
+
+      kafka_user = kafka_env.get('kafka_user')
+
+      if kafka_user is not None:
+        kafka_super_users = kafka_broker.get('super.users') if kafka_broker is not None else None
+
+        # kafka_super_super_users is expected to be formatted as:  User:user1;User:user2
+        if kafka_super_users is not None and kafka_super_users != '':
+          # Parse kafka_super_users to get a set of unique user names and rebuild the property value
+          user_names = set()
+          user_names.add(kafka_user)
+          for match in re.findall('User:([^;]*)', kafka_super_users):
+            user_names.add(match)
+          kafka_super_users = 'User:' + ";User:".join(user_names)
+        else:
+          kafka_super_users = 'User:' + kafka_user
+
+        putKafkaBrokerProperty("super.users", kafka_super_users)
+
+      putKafkaBrokerProperty("principal.to.local.class", "kafka.security.auth.KerberosPrincipalToLocal")
+      putKafkaBrokerProperty("zookeeper.set.acl", "true")
+
+    else:  # not security_enabled
+      # remove unneeded properties
+      putKafkaBrokerAttributes('super.users', 'delete', 'true')
+      putKafkaBrokerAttributes('principal.to.local.class', 'delete', 'true')
+
+    # Update ranger-kafka-plugin-properties/ranger-kafka-plugin-enabled to match ranger-env/ranger-kafka-plugin-enabled
+    if "ranger-env" in services["configurations"] \
+      and "ranger-kafka-plugin-properties" in services["configurations"] \
+      and "ranger-kafka-plugin-enabled" in services["configurations"]["ranger-env"]["properties"]:
+      putKafkaRangerPluginProperty = self.putProperty(configurations, "ranger-kafka-plugin-properties", services)
+      ranger_kafka_plugin_enabled = services["configurations"]["ranger-env"]["properties"]["ranger-kafka-plugin-enabled"]
+      putKafkaRangerPluginProperty("ranger-kafka-plugin-enabled", ranger_kafka_plugin_enabled)
+
+
+    ranger_plugin_enabled = False
+    # Only if the RANGER service is installed....
+    if "RANGER" in servicesList:
+      # If ranger-kafka-plugin-properties/ranger-kafka-plugin-enabled,
+      # determine if the Ranger/Kafka plug-in enabled enabled or not
+      if 'ranger-kafka-plugin-properties' in configurations and \
+                      'ranger-kafka-plugin-enabled' in configurations['ranger-kafka-plugin-properties']['properties']:
+        ranger_plugin_enabled = configurations['ranger-kafka-plugin-properties']['properties']['ranger-kafka-plugin-enabled'].lower() == 'yes'
+      # If ranger-kafka-plugin-properties/ranger-kafka-plugin-enabled was not changed,
+      # determine if the Ranger/Kafka plug-in enabled enabled or not
+      elif 'ranger-kafka-plugin-properties' in services['configurations'] and \
+                      'ranger-kafka-plugin-enabled' in services['configurations']['ranger-kafka-plugin-properties']['properties']:
+        ranger_plugin_enabled = services['configurations']['ranger-kafka-plugin-properties']['properties']['ranger-kafka-plugin-enabled'].lower() == 'yes'
+
+    # Determine the value for kafka-broker/authorizer.class.name
+    if ranger_plugin_enabled:
+      # If the Ranger plugin for Kafka is enabled, set authorizer.class.name to
+      # "org.apache.ranger.authorization.kafka.authorizer.RangerKafkaAuthorizer" whether Kerberos is
+      # enabled or not.
+      putKafkaBrokerProperty("authorizer.class.name", 'org.apache.ranger.authorization.kafka.authorizer.RangerKafkaAuthorizer')
+    elif security_enabled:
+      putKafkaBrokerProperty("authorizer.class.name", 'kafka.security.auth.SimpleAclAuthorizer')
+    else:
+      putKafkaBrokerAttributes('authorizer.class.name', 'delete', 'true')
+
+    #If AMS is part of Services, use the KafkaTimelineMetricsReporter for metric reporting. Default is ''.
+    if "AMBARI_METRICS" in servicesList:
+      putKafkaBrokerProperty('kafka.metrics.reporters', 'org.apache.hadoop.metrics2.sink.kafka.KafkaTimelineMetricsReporter')
+
+    if ranger_plugin_enabled:
+      kafkaLog4jRangerLines = [{
+                                 "name": "log4j.appender.rangerAppender",
+                                 "value": "org.apache.log4j.DailyRollingFileAppender"
+                               },
+                               {
+                                 "name": "log4j.appender.rangerAppender.DatePattern",
+                                 "value": "'.'yyyy-MM-dd-HH"
+                               },
+                               {
+                                 "name": "log4j.appender.rangerAppender.File",
+                                 "value": "${kafka.logs.dir}/ranger_kafka.log"
+                               },
+                               {
+                                 "name": "log4j.appender.rangerAppender.layout",
+                                 "value": "org.apache.log4j.PatternLayout"
+                               },
+                               {
+                                 "name": "log4j.appender.rangerAppender.layout.ConversionPattern",
+                                 "value": "%d{ISO8601} %p [%t] %C{6} (%F:%L) - %m%n"
+                               },
+                               {
+                                 "name": "log4j.logger.org.apache.ranger",
+                                 "value": "INFO, rangerAppender"
+                               }]
+
+      # change kafka-log4j when ranger plugin is installed
+      if 'kafka-log4j' in services['configurations'] and 'content' in services['configurations']['kafka-log4j']['properties']:
+        kafkaLog4jContent = services['configurations']['kafka-log4j']['properties']['content']
+        for item in range(len(kafkaLog4jRangerLines)):
+          if kafkaLog4jRangerLines[item]["name"] not in kafkaLog4jContent:
+            kafkaLog4jContent+= '\n' + kafkaLog4jRangerLines[item]["name"] + '=' + kafkaLog4jRangerLines[item]["value"]
+        putKafkaLog4jProperty("content",kafkaLog4jContent)
+
+      zookeeper_host_port = self.getZKHostPortString(services)
+      if zookeeper_host_port:
+        putRangerKafkaPluginProperty = self.putProperty(configurations, 'ranger-kafka-plugin-properties', services)
+        putRangerKafkaPluginProperty('zookeeper.connect', zookeeper_host_port)
+
+  def update_listeners_to_sasl(self, services, putKafkaBrokerProperty):
+    try:
+      listeners = services['configurations']['kafka-broker']['properties']['listeners']
+      if listeners and "SASL" not in listeners:
+        listeners = re.sub(r"(^|\b)PLAINTEXT://", "SASL_PLAINTEXT://", listeners)
+        listeners = re.sub(r"(^|\b)PLAINTEXTSASL://", "SASL_PLAINTEXT://", listeners)
+        listeners = re.sub(r"(^|\b)SSL://", "SASL_SSL://", listeners)
+        putKafkaBrokerProperty('listeners', listeners)
+    except KeyError as e:
+      self.logger.info('Cannot replace PLAINTEXT to SASL_PLAINTEXT in listeners. KeyError: %s' % e)
+
+  def recommendKAFKAConfigurationsFromHDP26(self, configurations, clusterData, services, hosts):
+    if 'kafka-env' in services['configurations'] and 'kafka_user' in services['configurations']['kafka-env']['properties']:
+      kafka_user = services['configurations']['kafka-env']['properties']['kafka_user']
+    else:
+      kafka_user = "kafka"
+
+    if 'ranger-kafka-plugin-properties' in configurations and  'ranger-kafka-plugin-enabled' in configurations['ranger-kafka-plugin-properties']['properties']:
+      ranger_kafka_plugin_enabled = (configurations['ranger-kafka-plugin-properties']['properties']['ranger-kafka-plugin-enabled'].lower() == 'Yes'.lower())
+    elif 'ranger-kafka-plugin-properties' in services['configurations'] and 'ranger-kafka-plugin-enabled' in services['configurations']['ranger-kafka-plugin-properties']['properties']:
+      ranger_kafka_plugin_enabled = (services['configurations']['ranger-kafka-plugin-properties']['properties']['ranger-kafka-plugin-enabled'].lower() == 'Yes'.lower())
+    else:
+      ranger_kafka_plugin_enabled = False
+
+    if ranger_kafka_plugin_enabled and 'ranger-kafka-plugin-properties' in services['configurations'] and 'REPOSITORY_CONFIG_USERNAME' in services['configurations']['ranger-kafka-plugin-properties']['properties']:
+      self.logger.info("Setting Kafka Repo user for Ranger.")
+      putRangerKafkaPluginProperty = self.putProperty(configurations, "ranger-kafka-plugin-properties", services)
+      putRangerKafkaPluginProperty("REPOSITORY_CONFIG_USERNAME",kafka_user)
+    else:
+      self.logger.info("Not setting Kafka Repo user for Ranger.")
+
+  def recommendKAFKAConfigurationsFromHDP30(self, configurations, clusterData, services, hosts):
+    number_services = len(services['services'])
+    for each_service in range(0, number_services):
+      if services['services'][each_service]['components'][0]['StackServiceComponents']['service_name'] == 'KAFKA':
+        num_kakfa_brokers = len(services['services'][each_service]['components'][0]['StackServiceComponents']['hostnames'])
+        putKafkaBrokerProperty = self.putProperty(configurations, "kafka-broker", services)
+        putKafkaBrokerProperty('offsets.topic.replication.factor', str(min(3, num_kakfa_brokers)))
+      if services['services'][each_service]['components'][0]['StackServiceComponents']['service_name'] == 'STREAMSMSGMGR':
+        putKafkaBrokerProperty('producer.metrics.enable', 'true')
+
+class KafkaValidator(service_advisor.ServiceAdvisor):
+  """
+  Kafka Validator checks the correctness of properties whenever the service is first added or the user attempts to
+  change configs via the UI.
+  """
+
+  def __init__(self, *args, **kwargs):
+    self.as_super = super(KafkaValidator, self)
+    self.as_super.__init__(*args, **kwargs)
+
+    self.validators = [("ranger-kafka-plugin-properties", self.validateKafkaRangerPluginConfigurationsFromHDP22),
+                       ("kafka-broker", self.validateKAFKAConfigurationsFromHDP23),
+                       ("kafka-broker", self.validateKAFKAConfigurationsFromHDP30)]
+
+  def validateKafkaRangerPluginConfigurationsFromHDP22(self, properties, recommendedDefaults, configurations, services, hosts):
+    validationItems = []
+    ranger_plugin_properties = self.getSiteProperties(configurations, "ranger-kafka-plugin-properties")
+    ranger_plugin_enabled = ranger_plugin_properties['ranger-kafka-plugin-enabled'] if ranger_plugin_properties else 'No'
+    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
+    security_enabled = KafkaServiceAdvisor.isKerberosEnabled(services, configurations)
+    if 'RANGER' in servicesList and ranger_plugin_enabled.lower() == 'yes':
+      # ranger-hdfs-plugin must be enabled in ranger-env
+      ranger_env = self.getServicesSiteProperties(services, 'ranger-env')
+      if not ranger_env or not 'ranger-kafka-plugin-enabled' in ranger_env or \
+                      ranger_env['ranger-kafka-plugin-enabled'].lower() != 'yes':
+        validationItems.append({"config-name": 'ranger-kafka-plugin-enabled',
+                                "item": self.getWarnItem(
+                                  "ranger-kafka-plugin-properties/ranger-kafka-plugin-enabled must correspond ranger-env/ranger-kafka-plugin-enabled")})
+
+    if ("RANGER" in servicesList) and (ranger_plugin_enabled.lower() == 'yes') and not security_enabled:
+      validationItems.append({"config-name": "ranger-kafka-plugin-enabled",
+                              "item": self.getWarnItem(
+                                "Ranger Kafka plugin should not be enabled in non-kerberos environment.")})
+    return self.toConfigurationValidationProblems(validationItems, "ranger-kafka-plugin-properties")
+
+
+  def validateKAFKAConfigurationsFromHDP23(self, properties, recommendedDefaults, configurations, services, hosts):
+    kafka_broker = properties
+    validationItems = []
+    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
+
+    #Adding Ranger Plugin logic here
+    ranger_plugin_properties = self.getSiteProperties(configurations, "ranger-kafka-plugin-properties")
+    ranger_plugin_enabled = ranger_plugin_properties['ranger-kafka-plugin-enabled'] if ranger_plugin_properties else 'No'
+    prop_name = 'authorizer.class.name'
+    prop_val = "org.apache.ranger.authorization.kafka.authorizer.RangerKafkaAuthorizer"
+    if ("RANGER" in servicesList) and (ranger_plugin_enabled.lower() == 'Yes'.lower()):
+      if kafka_broker[prop_name] != prop_val:
+        validationItems.append({"config-name": prop_name,
+                                "item": self.getWarnItem(
+                                  "If Ranger Kafka Plugin is enabled." \
+                                  "{0} needs to be set to {1}".format(prop_name,prop_val))})
+
+    kafka_broker_properties = self.getSiteProperties(configurations, "kafka-broker")
+    # Find number of services installed, get them all and find kafka service json obj in them.
+    number_services = len(services['services'])
+    for each_service in range(0, number_services):
+      if services['services'][each_service]['components'][0]['StackServiceComponents']['service_name'] == 'KAFKA':
+        num_kakfa_brokers = len(services['services'][each_service]['components'][0]['StackServiceComponents']['hostnames'])
+        if int(kafka_broker_properties['offsets.topic.replication.factor']) > num_kakfa_brokers:
+          validationItems.append({"config-name": 'offsets.topic.replication.factor',
+                                  "item": self.getErrorItem(
+                                    "offsets.topic.replication.factor={0} is greater than the number of kafka brokers={1}. " \
+                                    "It must be less or same as number of kafka brokers." \
+                                      .format(kafka_broker_properties['offsets.topic.replication.factor'], num_kakfa_brokers))})
+
+    if 'KERBEROS' in servicesList and 'security.inter.broker.protocol' in properties:
+      interBrokerValue = properties['security.inter.broker.protocol']
+      prop_name = 'listeners'
+      prop_value =  properties[prop_name]
+      if interBrokerValue and interBrokerValue not in prop_value:
+        validationItems.append({"config-name": "listeners",
+                                "item": self.getWarnItem("If kerberos is enabled " \
+                                                         "{0}  need to contain {1} as one of " \
+                                                         "the protocol".format(prop_name, interBrokerValue))})
+
+
+    return self.toConfigurationValidationProblems(validationItems, "kafka-broker")
+
+  def validateKAFKAConfigurationsFromHDP30(self, properties, recommendedDefaults, configurations, services, hosts):
+    kafka_broker = properties
+    validationItems = []
+    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
+    kafka_broker_properties = self.getSiteProperties(configurations, "kafka-broker")
+    if ("STREAMSMSGMGR" in servicesList):
+      prop_name = 'producer.metrics.enable'
+      prop_val = 'true'
+      try:
+        kafka_broker_producer_metrics_enable = kafka_broker_properties[prop_name]
+        if kafka_broker_producer_metrics_enable.lower() == "false":
+          validationItems.append({"config-name": prop_name,
+                                  "item": self.getWarnItem(
+                                  "Setting {0} to {1} will prevent collection of metrics related to producer message " \
+                                  "count by Kafka brokers.".format(prop_name, kafka_broker_producer_metrics_enable))})
+      except KeyError as e:
+        self.logger.info("Unable to find producer.metrics.enable.")
+        validationItems.append({"config-name": prop_name,
+                                "item": self.getWarnItem(
+                                "After Installing Streams Messaging Manager, {0} with be set to {1}." \
+                                "Please restart kafka for changes to take place.".format(prop_name, prop_val))})
+
+    return self.toConfigurationValidationProblems(validationItems, "kafka-broker")
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/themes/directories.json b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/themes/directories.json
new file mode 100644
index 00000000..49620b6c
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/themes/directories.json
@@ -0,0 +1,98 @@
+{
+  "name": "directories",
+  "description": "Directories theme for KAFKA service",
+  "configuration": {
+    "layouts": [
+      {
+        "name": "directories",
+        "tabs": [
+          {
+            "name": "directories",
+            "display-name": "Directories",
+            "layout": {
+              "tab-columns": "1",
+              "tab-rows": "4",
+              "sections": [
+                {
+                  "name": "subsection-log-dirs",
+                  "display-name": "LOG DIRS",
+                  "row-index": "1",
+                  "column-index": "0",
+                  "row-span": "1",
+                  "column-span": "1",
+                  "section-columns": "1",
+                  "section-rows": "1",
+                  "subsections": [
+                    {
+                      "name": "subsection-log-dirs",
+                      "row-index": "0",
+                      "column-index": "0",
+                      "row-span": "1",
+                      "column-span": "1"
+                    }
+                  ]
+                },
+                {
+                  "name": "subsection-pid-dirs",
+                  "display-name": "PID DIRS",
+                  "row-index": "2",
+                  "column-index": "0",
+                  "row-span": "1",
+                  "column-span": "1",
+                  "section-columns": "1",
+                  "section-rows": "1",
+                  "subsections": [
+                    {
+                      "name": "subsection-pid-dirs",
+                      "row-index": "0",
+                      "column-index": "0",
+                      "row-span": "1",
+                      "column-span": "1"
+                    }
+                  ]
+                }
+              ]
+            }
+          }
+        ]
+      }
+    ],
+    "placement": {
+      "configuration-layout": "default",
+      "configs": [
+        {
+          "config": "kafka-broker/log.dirs",
+          "subsection-name": "subsection-log-dirs"
+        },
+        {
+          "config": "kafka-env/kafka_log_dir",
+          "subsection-name": "subsection-log-dirs"
+        },
+        {
+          "config": "kafka-env/kafka_pid_dir",
+          "subsection-name": "subsection-pid-dirs"
+        }
+      ]
+    },
+    "widgets": [
+      {
+        "config": "kafka-broker/log.dirs",
+        "widget": {
+          "type": "directories"
+        }
+      },
+      {
+        "config": "kafka-env/kafka_log_dir",
+        "widget": {
+          "type": "text-field"
+        }
+      },
+      {
+        "config": "kafka-env/kafka_pid_dir",
+        "widget": {
+          "type": "text-field"
+        }
+      }
+    ]
+  }
+}
\ No newline at end of file
diff --git a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/widgets.json b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/widgets.json
new file mode 100644
index 00000000..03d41f23
--- /dev/null
+++ b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/KAFKA/widgets.json
@@ -0,0 +1,181 @@
+{
+  "layouts": [
+    {
+      "layout_name": "default_kafka_dashboard",
+      "display_name": "Standard Kafka Dashboard",
+      "section_name": "KAFKA_SUMMARY",
+      "widgetLayoutInfo": [
+        {
+          "widget_name": "Broker Topics",
+          "description": "Broker Topics",
+          "widget_type": "GRAPH",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "kafka.server.BrokerTopicMetrics.BytesInPerSec.1MinuteRate",
+              "metric_path": "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesInPerSec/1MinuteRate",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            },
+            {
+              "name": "kafka.server.BrokerTopicMetrics.BytesOutPerSec.1MinuteRate",
+              "metric_path": "metrics/kafka/server/BrokerTopicMetrics/AllTopicsBytesOutPerSec/1MinuteRate",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            },
+            {
+              "name": "kafka.server.BrokerTopicMetrics.MessagesInPerSec.1MinuteRate",
+              "metric_path": "metrics/kafka/server/BrokerTopicMetrics/AllTopicsMessagesInPerSec/1MinuteRate",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            }
+          ],
+          "values": [
+            {
+              "name": "Bytes In",
+              "value": "${kafka.server.BrokerTopicMetrics.BytesInPerSec.1MinuteRate}"
+            },
+            {
+              "name": "Bytes Out",
+              "value": "${kafka.server.BrokerTopicMetrics.BytesOutPerSec.1MinuteRate}"
+            },
+            {
+              "name": "Messages In",
+              "value": "${kafka.server.BrokerTopicMetrics.MessagesInPerSec.1MinuteRate}"
+            }
+          ],
+          "properties": {
+            "graph_type": "LINE",
+            "time_range": "1"
+          }
+        },
+        {
+          "widget_name": "Active Controller Count",
+          "description": "Active Controller Count",
+          "widget_type": "GRAPH",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "kafka.controller.KafkaController.ActiveControllerCount._sum",
+              "metric_path": "metrics/kafka/controller/KafkaController/ActiveControllerCount._sum",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            }
+          ],
+          "values": [
+            {
+              "name": "Active Controller Count",
+              "value": "${kafka.controller.KafkaController.ActiveControllerCount._sum}"
+            }
+          ],
+          "properties": {
+            "graph_type": "LINE",
+            "time_range": "1"
+          }
+        },
+        {
+          "widget_name": "Controller Status",
+          "description": "Controller Status",
+          "widget_type": "GRAPH",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "kafka.controller.ControllerStats.LeaderElectionRateAndTimeMs.1MinuteRate",
+              "metric_path": "metrics/kafka/controller/ControllerStats/LeaderElectionRateAndTimeMs/1MinuteRate",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            },
+            {
+              "name": "kafka.controller.ControllerStats.UncleanLeaderElectionsPerSec.1MinuteRate",
+              "metric_path": "metrics/kafka/controller/ControllerStats/UncleanLeaderElectionsPerSec/1MinuteRate",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            }
+          ],
+          "values": [
+            {
+              "name": "Leader Election Rate And Time",
+              "value": "${kafka.controller.ControllerStats.LeaderElectionRateAndTimeMs.1MinuteRate}"
+            },
+            {
+              "name": "Unclean Leader Election",
+              "value": "${kafka.controller.ControllerStats.UncleanLeaderElectionsPerSec.1MinuteRate}"
+            }
+          ],
+          "properties": {
+            "graph_type": "LINE",
+            "time_range": "1"
+          }
+        },
+        {
+          "widget_name": "Replica MaxLag",
+          "description": "Replica MaxLag",
+          "widget_type": "GRAPH",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "kafka.server.ReplicaFetcherManager.MaxLag.clientId.Replica",
+              "metric_path": "metrics/kafka/server/ReplicaFetcherManager/Replica-MaxLag",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            }
+          ],
+          "values": [
+            {
+              "name": "Replica MaxLag",
+              "value": "${kafka.server.ReplicaFetcherManager.MaxLag.clientId.Replica}"
+            }
+          ],
+          "properties": {
+            "graph_type": "LINE",
+            "time_range": "1"
+          }
+        },
+        {
+          "widget_name": "Replica Manager",
+          "description": "Replica Manager",
+          "widget_type": "GRAPH",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "kafka.server.ReplicaManager.PartitionCount._sum",
+              "metric_path": "metrics/kafka/server/ReplicaManager/PartitionCount._sum",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            },
+            {
+              "name": "kafka.server.ReplicaManager.UnderReplicatedPartitions",
+              "metric_path": "metrics/kafka/server/ReplicaManager/UnderReplicatedPartitions",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            },
+            {
+              "name": "kafka.server.ReplicaManager.LeaderCount._sum",
+              "metric_path": "metrics/kafka/server/ReplicaManager/LeaderCount._sum",
+              "service_name": "KAFKA",
+              "component_name": "KAFKA_BROKER"
+            }
+          ],
+          "values": [
+            {
+              "name": "Partitions count",
+              "value": "${kafka.server.ReplicaManager.PartitionCount._sum}"
+            },
+            {
+              "name": "Under Replicated Partitions",
+              "value": "${kafka.server.ReplicaManager.UnderReplicatedPartitions}"
+            },
+            {
+              "name": "Leader Count",
+              "value": "${kafka.server.ReplicaManager.LeaderCount._sum}"
+            }
+          ],
+          "properties": {
+            "graph_type": "LINE",
+            "time_range": "1"
+          }
+        }
+      ]
+    }
+  ]
+}
\ No newline at end of file