ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject git commit: AMBARI-7807. Integrate Kafka with Ambari. (Sriharsha Chintalapani via Jaimin Jetly)
Date Thu, 16 Oct 2014 17:11:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 7092d80d3 -> 799a0d54a


AMBARI-7807. Integrate Kafka with Ambari. (Sriharsha Chintalapani via Jaimin Jetly)


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

Branch: refs/heads/trunk
Commit: 799a0d54ad0dd560c37482c24290cd954d9bfeeb
Parents: 7092d80
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Thu Oct 16 10:08:55 2014 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Thu Oct 16 10:10:46 2014 -0700

----------------------------------------------------------------------
 .../NAGIOS/package/files/nagios_alerts.php      |   1 +
 .../services/NAGIOS/package/scripts/params.py   |  33 +-
 .../templates/hadoop-servicegroups.cfg.j2       |   7 +
 .../package/templates/hadoop-services.cfg.j2    |  14 +
 .../stacks/HDP/2.2/role_command_order.json      |   2 +
 .../KAFKA/configuration/kafka-broker.xml        | 324 +++++++++++++++++++
 .../services/KAFKA/configuration/kafka-env.xml  |  55 ++++
 .../KAFKA/configuration/kafka-log4j.xml         | 116 +++++++
 .../stacks/HDP/2.2/services/KAFKA/metainfo.xml  |  74 +++++
 .../2.2/services/KAFKA/package/scripts/kafka.py |  64 ++++
 .../KAFKA/package/scripts/kafka_broker.py       |  63 ++++
 .../services/KAFKA/package/scripts/params.py    |  57 ++++
 .../KAFKA/package/scripts/properties_config.py  |  32 ++
 .../KAFKA/package/scripts/service_check.py      |  58 ++++
 .../KAFKA/package/scripts/status_params.py      |  26 ++
 .../stacks/2.2/KAFKA/test_kafka_broker.py       |  48 +++
 .../test/python/stacks/2.2/configs/default.json |  82 ++++-
 ambari-web/app/data/HDP2/site_properties.js     |  93 ++++++
 ambari-web/app/models/service_config.js         |   4 +
 ambari-web/app/models/stack_service.js          |   5 +
 20 files changed, 1144 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/nagios_alerts.php
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/nagios_alerts.php b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/nagios_alerts.php
index 878f0dc..c7aa517 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/nagios_alerts.php
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/files/nagios_alerts.php
@@ -418,6 +418,7 @@ function hdp_mon_generate_response( $response_data )
       case "STORM":
       case "FALCON":
       case "KNOX":
+      case "KAFKA":
       case "PUPPET":
         break;
       default:

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
index e1100c4..5a0ffbb 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
@@ -91,8 +91,12 @@ nagios_principal_name = default("/configurations/nagios-env/nagios_principal_nam
 
 oozie_server_port = get_port_from_url(config['configurations']['oozie-site']['oozie.base.url'])
 namenode_host = default("/clusterHostInfo/namenode_host", None)
+_rm_host = default("/clusterHostInfo/rm_host", None)
+if type(_rm_host) is list:
+  rm_hosts_in_str = ','.join(_rm_host)
 
 has_namenode = not namenode_host == None
+has_rm = not _rm_host == None
 
 # - test for HDFS or HCFS (glusterfs)
 if 'namenode_host' in config['clusterHostInfo']:
@@ -110,15 +114,18 @@ dfs_http_policy = HADOOP_HTTP_POLICY
 yarn_http_policy = HADOOP_HTTP_POLICY
 mapreduce_http_policy = HADOOP_HTTP_POLICY
 
-# 
-if 'dfs.http.policy' in config['configurations']['hdfs-site']:
-  dfs_http_policy = config['configurations']['hdfs-site']['dfs.http.policy']
-
-if 'yarn.http.policy' in config['configurations']['yarn-site']:
-  yarn_http_policy = config['configurations']['yarn-site']['yarn.http.policy']
+#
+if has_namenode:
+  if 'dfs.http.policy' in config['configurations']['hdfs-site']:
+    dfs_http_policy = config['configurations']['hdfs-site']['dfs.http.policy']
+  if dfs_http_policy == HADOOP_HTTPS_POLICY:
+    hdfs_ssl_enabled = True
+if has_rm:
+  if 'yarn.http.policy' in config['configurations']['yarn-site']:
+    yarn_http_policy = config['configurations']['yarn-site']['yarn.http.policy']
 
-if 'mapreduce.jobhistory.http.policy' in config['configurations']['mapred-site']:
-  mapreduce_http_policy = config['configurations']['mapred-site']['mapreduce.jobhistory.http.policy']
+  if 'mapreduce.jobhistory.http.policy' in config['configurations']['mapred-site']:
+    mapreduce_http_policy = config['configurations']['mapred-site']['mapreduce.jobhistory.http.policy']
 
 if dfs_http_policy == HADOOP_HTTPS_POLICY:
   hdfs_ssl_enabled = True
@@ -177,8 +184,9 @@ if has_namenode:
     datanode_port = get_port_from_url(config['configurations']['hdfs-site'][dfs_datanode_webui_property])
 
 nm_port = yarn_nodemanager_default_port
-if yarn_nodemanager_webui_property in config['configurations']['yarn-site']:
-  nm_port = get_port_from_url(config['configurations']['yarn-site'][yarn_nodemanager_webui_property])
+if has_rm:
+  if yarn_nodemanager_webui_property in config['configurations']['yarn-site']:
+    nm_port = get_port_from_url(config['configurations']['yarn-site'][yarn_nodemanager_webui_property])
   
 flume_port = "4159"
 hbase_master_rpc_port = default('/configurations/hbase-site/hbase.master.port', "60000")
@@ -197,6 +205,7 @@ storm_rest_api_port = "8745"
 falcon_port = config['configurations']['falcon-env']['falcon_port']
 ahs_port = get_port_from_url(config['configurations']['yarn-site'][yarn_timeline_service_webui_property])
 knox_gateway_port = config['configurations']['gateway-site']['gateway.port']
+kafka_broker_port = config['configurations']['kafka-broker']['port']
 
 # use sensible defaults for checkpoint as they are required by Nagios and 
 # may not be part of hdfs-site.xml on an upgrade
@@ -316,6 +325,7 @@ _falcon_host = default("/clusterHostInfo/falcon_server_hosts", None)
 _hbase_rs_hosts = default("/clusterHostInfo/hbase_rs_hosts", _slave_hosts)
 _hue_server_host = default("/clusterHostInfo/hue_server_host", None)
 _knox_gateway_host =  default("/clusterHostInfo/knox_gateway_hosts", None)
+_kafka_broker_host =  default("/clusterHostInfo/kafka_broker_hosts", None)
 all_hosts = config['clusterHostInfo']['all_hosts']
 
 if 'namenode_host' in config['clusterHostInfo']:
@@ -351,5 +361,6 @@ hostgroup_defs = {
     'storm_rest_api' : _storm_rest_api_hosts,
     'falcon-server' : _falcon_host,
     'ats-servers' : _app_timeline_server_hosts,
-    'knox-gateway' : _knox_gateway_host
+    'knox-gateway' : _knox_gateway_host,
+    'kafka-broker' : _kafka_broker_host
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-servicegroups.cfg.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-servicegroups.cfg.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-servicegroups.cfg.j2
index 0aa4b68..c5ca5bb 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-servicegroups.cfg.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-servicegroups.cfg.j2
@@ -119,3 +119,10 @@ define servicegroup {
 }
 {% endif %}
 
+{%if hostgroup_defs['kafka-broker'] %}
+define servicegroup {
+  servicegroup_name  KAFKA
+  alias  KAFKA Checks
+}
+{% endif %}
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
index f94a6ca..155d750 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-services.cfg.j2
@@ -801,4 +801,18 @@ define service {
 }
 {% endif %}
 
+{% if hostgroup_defs['kafka-broker'] %}
+# KNOX Checks
+define service {
+        hostgroup_name          kafka-broker
+        use                     hadoop-service
+        service_description     KAFKA::Kafka Broker process
+        servicegroups           KAFKA
+        check_command           check_tcp_wrapper!{{ kafka_broker_port }}!-w 1 -c 1
+        normal_check_interval   1
+        retry_check_interval    0.5
+        max_check_attempts      3
+}
+{% endif %}
+
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/role_command_order.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/role_command_order.json b/ambari-server/src/main/resources/stacks/HDP/2.2/role_command_order.json
index f8eb4c7..a7d9c0f 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/role_command_order.json
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/role_command_order.json
@@ -40,6 +40,8 @@
     "FLUME_SERVICE_CHECK-SERVICE_CHECK": ["FLUME_HANDLER-START"],
     "FALCON_SERVICE_CHECK-SERVICE_CHECK": ["FALCON_SERVER-START"],
     "SLIDER_SERVICE_CHECK-SERVICE_CHECK" : ["NODEMANAGER-START", "RESOURCEMANAGER-START"],
+    "KAFKA_BROKER-START" : ["ZOOKEEPER_SERVER-START"],
+    "KAFKA_SERVICE_CHECK-SERVICE_CHECK": ["KAFKA_BROKER-START"],
     "ZOOKEEPER_SERVER-STOP" : ["HBASE_MASTER-STOP", "HBASE_REGIONSERVER-STOP"],
     "HBASE_MASTER-STOP": ["HBASE_REGIONSERVER-STOP"],
     "NIMBUS-STOP" : ["SUPERVISOR-STOP", "STORM_UI_SERVER-STOP", "DRPC_SERVER-STOP"]

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-broker.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-broker.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-broker.xml
new file mode 100644
index 0000000..cbedca3
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-broker.xml
@@ -0,0 +1,324 @@
+<?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>
+  <property>
+    <name>log.dirs</name>
+    <value></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>
+  </property>
+  <property>
+    <name>port</name>
+    <value>6667</value>
+    <description>
+      The port on which the server accepts client connections.
+    </description>
+  </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 you must create this path yourself prior to starting the broker and consumers must use the
+      same connection string.
+    </description>
+  </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>
+  </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>
+  </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>
+  </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>
+  </property>
+  <property>
+    <name>socket.send.buffer.bytes</name>
+    <value>102400</value>
+    <description>
+      The SO_SNDBUFF buffer the server prefers for socket connections.
+    </description>
+  </property>
+  <property>
+    <name>socket.receive.buffer.bytes</name>
+    <value>102400</value>
+    <description>
+      The SO_RCVBUFF buffer the server prefers for socket connections.
+    </description>
+  </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>
+  </property>
+  <property>
+    <name>num.partitions</name>
+    <value>1</value>
+    <description>
+       	The default number of partitions per topic.
+    </description>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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 general you probably don't need to mess with this value.
+    </description>
+  </property>
+  <property>
+    <name>log.flush.interval.messages</name>
+    <value>10000</value>
+    <description>The number of messages written to a log partition before we force an fsync on the log. Setting this higher will improve performance a lot but will increase the window of data at risk in the event of a crash (though that is usually best addressed through replication). If both this setting and log.flush.interval.ms are both used the log will be flushed when either criteria is met.
+    </description>
+  </property>
+  <property>
+    <name>log.flush.scheduler.interval.ms</name>
+    <value>3000</value>
+    <description>
+      The frequency in ms that the log flusher checks whether any log is eligible to be flushed to disk.
+    </description>
+  </property>
+  <property>
+    <name>log.flush.interval.ms</name>
+    <value>3000</value>
+    <description>
+      The maximum time between fsync calls on the log. If used in conjuction with log.flush.interval.messages the log will be flushed when either criteria is met.
+    </description>
+  </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>
+  </property>
+  <property>
+    <name>controller.socket.timeout.ms</name>
+    <value>30000</value>
+    <property>The socket timeout for commands from the partition management controller to the replicas.</property>
+  </property>
+  <property>
+    <name>controller.message.queue.size</name>
+    <value>10</value>
+    <description>The buffer size for controller-to-broker-channels</description>
+  </property>
+  <property>
+    <name>default.replication.factor</name>
+    <value>1</value>
+    <description>The default replication factor for automatically created topics.</description>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </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>
+  </property>
+  <property>
+    <name>zookeeper.session.timeout.ms</name>
+    <value>6000</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>
+  </property>
+  <property>
+    <name>zookeeper.connection.timeout.ms</name>
+    <value>6000</value>
+    <description>The maximum amount of time that the client waits to establish a connection to zookeeper.</description>
+  </property>
+  <property>
+    <name>zookeeper.sync.time.ms</name>
+    <value>2000</value>
+    <description>How far a ZK follower can be behind a ZK leader.</description>
+  </property>
+  <property>
+    <name>controlled.shutdown.enable</name>
+    <value>false</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>
+  </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>
+  </property>
+  <property>
+    <name>controlled.shutdown.retry.backoff.ms</name>
+    <value>5000</value>
+    <description>
+      Backoff time between shutdown retries.
+    </description>
+  </property>
+  <!--
+  <property>
+    <name>kafka.metrics.reporters</name>
+    <value>kafka.ganglia.KafkaGangliaMetricsReporter</value>
+    <description>
+      kafka ganglia metrics reporter
+    </description>
+  </property>
+
+  <property>
+    <name>kafka.ganglia.metrics.reporter.enabled</name>
+    <value>true</value>
+    <description>
+      kafka ganglia metrics reporter enable
+    </description>
+  </property>
+  -->
+  <property>
+    <name>kafka.ganglia.metrics.host</name>
+    <value>localhost</value>
+    <description> Ganglia host </description>
+  </property>
+  <property>
+    <name>kafka.ganglia.metrics.port</name>
+    <value>8649</value>
+    <description> Ganglia port </description>
+  </property>
+  <property>
+    <name>kafka.ganglia.metrics.group</name>
+    <value>kafka</value>
+    <description>Ganglia group name </description>
+  </property>
+</configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-env.xml
new file mode 100644
index 0000000..7ad4396
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-env.xml
@@ -0,0 +1,55 @@
+<?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>
+  <property>
+    <name>kafka_user</name>
+    <value>kafka</value>
+    <property-type>USER</property-type>
+    <description></description>
+  </property>
+  <property>
+    <name>kafka_log_dir</name>
+    <value>/var/log/kafka</value>
+    <description></description>
+  </property>
+  <property>
+    <name>kafka_pid_dir</name>
+    <value>/var/run/kafka</value>
+    <description></description>
+  </property>
+
+  <!-- kafka-env.sh -->
+  <property>
+    <name>content</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
+    </value>
+  </property>
+</configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-log4j.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-log4j.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-log4j.xml
new file mode 100644
index 0000000..901859e
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/configuration/kafka-log4j.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_final="false">
+
+  <property>
+    <name>content</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] %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] %p %m (%c)%n
+
+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] %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] %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] %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] %p %m (%c)%n
+
+# 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>
+  </property>
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/metainfo.xml
new file mode 100644
index 0000000..a8c34fd
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/metainfo.xml
@@ -0,0 +1,74 @@
+<?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>0.8.1.2.2.0.0</version>
+      <components>
+        <component>
+          <name>KAFKA_BROKER</name>
+          <displayName>Kafka Broker</displayName>
+          <category>MASTER</category>
+          <cardinality>1+</cardinality>
+          <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>600</timeout>
+          </commandScript>
+        </component>
+      </components>
+      <osSpecifics>
+        <osSpecific>
+          <osFamily>any</osFamily>
+          <packages>
+            <package>
+              <name>kafka_2_2_0_0_*</name>
+            </package>
+          </packages>
+        </osSpecific>
+      </osSpecifics>
+      <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>
+      </configuration-dependencies>
+      <restartRequiredAfterChange>true</restartRequiredAfterChange>
+    </service>
+  </services>
+</metainfo>

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka.py
new file mode 100644
index 0000000..269b0ae
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka.py
@@ -0,0 +1,64 @@
+#!/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 import *
+from properties_config import properties_config
+import sys
+from copy import deepcopy
+
+def kafka():
+    import params
+
+    Directory([params.log_dir, params.pid_dir, params.conf_dir],
+              owner=params.kafka_user,
+              group=params.user_group,
+              recursive=True
+          )
+    brokerid = str(sorted(params.kafka_hosts).index(params.hostname))
+    kafka_server_config = mutable_config_dict(params.config['configurations']['kafka-broker'])
+    kafka_server_config['broker.id'] = brokerid
+    kafka_server_config['hostname'] = params.hostname
+    conf_dir = params.conf_dir
+    properties_config("server.properties",
+                      conf_dir=params.conf_dir,
+                      configurations=kafka_server_config,
+                      owner=params.kafka_user,
+                      group=params.user_group,
+                      brokerid=brokerid)
+
+    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=params.log4j_props
+         )
+
+
+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

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka_broker.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka_broker.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka_broker.py
new file mode 100644
index 0000000..77c6b8b
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/kafka_broker.py
@@ -0,0 +1,63 @@
+"""
+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 *
+import sys
+
+from kafka import kafka
+
+class KafkaBroker(Script):
+  def install(self, env):
+    self.install_packages(env)
+    self.configure(env)
+
+  def configure(self, env):
+    import params
+    env.set_params(params)
+    kafka()
+
+  def start(self, env):
+    import params
+    env.set_params(params)
+    self.configure(env)
+    daemon_cmd = format('source {params.conf_dir}/kafka-env.sh ; {params.kafka_bin} start')
+    no_op_test = format('ls {params.pid_file} >/dev/null 2>&1 && ps `cat {params.pid_file}` >/dev/null 2>&1')
+    Execute(daemon_cmd,
+            user=params.kafka_user,
+            not_if=no_op_test
+    )
+
+  def stop(self, env):
+    import params
+    env.set_params(params)
+    self.configure(env)
+    daemon_cmd = format('source {params.conf_dir}/kafka-env.sh; {params.kafka_bin} stop')
+    Execute(daemon_cmd,
+            user=params.kafka_user,
+    )
+    Execute (format("rm -f {params.pid_file}"))
+
+
+  def status(self, env):
+    import status_params
+    env.set_params(status_params)
+    check_process_status(status_params.kafka_pid_file)
+
+if __name__ == "__main__":
+  KafkaBroker().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/params.py
new file mode 100644
index 0000000..fa68914
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/params.py
@@ -0,0 +1,57 @@
+#!/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 import *
+import status_params
+
+# server configurations
+config = Script.get_config()
+
+#RPM versioning support
+rpm_version = default("/configurations/cluster-env/rpm_version", None)
+
+
+if rpm_version:
+    kafka_home = '/usr/hdp/current/kafka-broker/'
+    kafka_bin = kafka_home+'bin/kafka'
+else:
+    kafka_home = '/usr/lib/kafka/'
+    kafka_bin = kafka_home+'/bin/kafka'
+
+
+conf_dir = "/etc/kafka/conf"
+kafka_user = config['configurations']['kafka-env']['kafka_user']
+log_dir = config['configurations']['kafka-env']['kafka_log_dir']
+pid_dir = status_params.kafka_pid_dir
+pid_file = pid_dir+"/kafka.pid"
+hostname = config['hostname']
+user_group = config['configurations']['cluster-env']['user_group']
+java64_home = config['hostLevelParams']['java_home']
+kafka_env_sh_template = config['configurations']['kafka-env']['content']
+kafka_hosts = config['clusterHostInfo']['zookeeper_hosts']
+kafka_hosts.sort()
+
+zookeeper_hosts = config['clusterHostInfo']['zookeeper_hosts']
+zookeeper_hosts.sort()
+
+if (('kafka-log4j' in config['configurations']) and ('content' in config['configurations']['kafka-log4j'])):
+    log4j_props = config['configurations']['kafka-log4j']['content']
+else:
+    log4j_props = None

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/properties_config.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/properties_config.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/properties_config.py
new file mode 100644
index 0000000..56bab2c
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/properties_config.py
@@ -0,0 +1,32 @@
+#!/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
+from resource_management import *
+
+def properties_inline_template(configurations):
+  return source.InlineTemplate('''{% for key, value in configurations_dict.items() %}{{ key }}={{ value }}
+{% endfor %}''', configurations_dict=configurations)
+
+def properties_config(filename, configurations = None, conf_dir = None,
+                      mode = None, owner = None, group = None, brokerid = None):
+    config_content = properties_inline_template(configurations)
+    File (format("{conf_dir}/{filename}"), content = config_content, owner = owner,
+          group = group, mode = mode)

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/service_check.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/service_check.py
new file mode 100644
index 0000000..4b76ef1
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/service_check.py
@@ -0,0 +1,58 @@
+#!/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 import *
+import  sys,subprocess,os
+
+class ServiceCheck(Script):
+    def service_check(self, env):
+        import params
+        env.set_params(params)
+        kafka_config=self.read_kafka_config(params.conf_dir)
+        self.set_env(params.conf_dir)
+        create_topic_cmd_created_output = "Created topic \"ambari_kafka_service_check\"."
+        create_topic_cmd_exists_output = "Topic \"ambari_kafka_service_check\" already exists."
+        create_topic_cmd = [params.kafka_home+'/bin/kafka-topics.sh', '--zookeeper '+kafka_config['zookeeper.connect'],
+                            '--create --topic ambari_kafka_service_check', '--partitions 1 --replication-factor 1']
+        create_topic_process = subprocess.Popen(create_topic_cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+        out, err = create_topic_process.communicate()
+        if out.find(create_topic_cmd_created_output) != -1 or out.find(create_topic_cmd_exists_output) != -1:
+            sys.exit(0)
+        else:
+            sys.exit(1)
+
+    def read_kafka_config(self,kafka_conf_dir):
+        conf_file = open(kafka_conf_dir+"/server.properties","r")
+        kafka_config = {}
+        for line in conf_file:
+            key,value = line.split("=")
+            kafka_config[key] = value.replace("\n","")
+        return kafka_config
+
+    def set_env(self, kafka_conf_dir):
+        command = ['bash', '-c', 'source '+kafka_conf_dir+'/kafka-env.sh && env']
+        proc = subprocess.Popen(command, stdout = subprocess.PIPE)
+        for line in proc.stdout:
+            (key, _, value) = line.partition("=")
+            os.environ[key] = value.replace("\n","")
+        proc.communicate()
+
+if __name__ == "__main__":
+    ServiceCheck().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/status_params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/status_params.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/KAFKA/package/scripts/status_params.py
new file mode 100644
index 0000000..fcb0816
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/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 import *
+
+config = Script.get_config()
+
+kafka_pid_dir = config['configurations']['kafka-env']['kafka_pid_dir']
+kafka_pid_file = format("{kafka_pid_dir}/kafka.pid")

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/test/python/stacks/2.2/KAFKA/test_kafka_broker.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.2/KAFKA/test_kafka_broker.py b/ambari-server/src/test/python/stacks/2.2/KAFKA/test_kafka_broker.py
new file mode 100644
index 0000000..438a590
--- /dev/null
+++ b/ambari-server/src/test/python/stacks/2.2/KAFKA/test_kafka_broker.py
@@ -0,0 +1,48 @@
+#!/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 stacks.utils.RMFTestCase import *
+
+
+class TestKafkaBroker(RMFTestCase):
+
+  def test_configure_default(self):
+    self.executeScript("2.2/services/KAFKA/package/scripts/kafka_broker.py",
+                         classname = "KafkaBroker",
+                         command = "configure",
+                         config_file="default.json"
+    )
+
+    self.assertResourceCalled('Directory', '/var/log/kafka',
+                              owner = 'kafka',
+                              group = 'hadoop',
+                              recursive = True
+    )
+
+    self.assertResourceCalled('Directory', '/var/run/kafka',
+                              owner = 'kafka',
+                              group = 'hadoop',
+                              recursive = True
+    )
+
+    self.assertResourceCalled('Directory', '/etc/kafka/conf',
+                              owner = 'kafka',
+                              group = 'hadoop',
+                              recursive = True
+    )

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-server/src/test/python/stacks/2.2/configs/default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.2/configs/default.json b/ambari-server/src/test/python/stacks/2.2/configs/default.json
index 5e984fe..4c2ada9 100644
--- a/ambari-server/src/test/python/stacks/2.2/configs/default.json
+++ b/ambari-server/src/test/python/stacks/2.2/configs/default.json
@@ -87,8 +87,65 @@
         "knox_group": "knox",
         "knox_pid_dir": "/var/run/knox",
         "knox_user": "knox"
+      },
+      "kafka-env": {
+        "content": "\n#!/bin/bash\n\n# Set KAFKA specific environment variables here.\n\n# The java implementation to use.\nexport JAVA_HOME={{java64_home}}\nexport PATH=$PATH:$JAVA_HOME/bin",
+        "kafka_user": "kafka",
+        "kafka_log_dir": "/var/log/kafka",
+        "kafka_pid_dir": "/var/run/kafka"
+      },
+      "kafka-log4j": {
+        "content": "\n#\n#\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements.  See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership.  The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License.  You may obtain a copy of the License at\n#\n#   http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied.  See the License for the\n# specific language governing permissions and limitations\n# under the License.\n#\n#\n#\nkafka.logs.dir=logs\n\nlog4j.rootLogger=INFO, stdout\n\nlog4j.appender.stdout=org.apache.log4j.ConsoleAppender\nlog4j.appender.stdout.layout=org.apache.log
 4j.PatternLayout\nlog4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n\n\nlog4j.appender.kafkaAppender=org.apache.log4j.DailyRollingFileAppender\nlog4j.appender.kafkaAppender.DatePattern='.'yyyy-MM-dd-HH\nlog4j.appender.kafkaAppender.File=${kafka.logs.dir}/server.log\nlog4j.appender.kafkaAppender.layout=org.apache.log4j.PatternLayout\nlog4j.appender.kafkaAppender.layout.ConversionPattern=[%d] %p %m (%c)%n\n\nlog4j.appender.stateChangeAppender=org.apache.log4j.DailyRollingFileAppender\nlog4j.appender.stateChangeAppender.DatePattern='.'yyyy-MM-dd-HH\nlog4j.appender.stateChangeAppender.File=${kafka.logs.dir}/state-change.log\nlog4j.appender.stateChangeAppender.layout=org.apache.log4j.PatternLayout\nlog4j.appender.stateChangeAppender.layout.ConversionPattern=[%d] %p %m (%c)%n\n\nlog4j.appender.requestAppender=org.apache.log4j.DailyRollingFileAppender\nlog4j.appender.requestAppender.DatePattern='.'yyyy-MM-dd-HH\nlog4j.appender.requestAppender.File=${kafka.logs.dir}/kafka-requ
 est.log\nlog4j.appender.requestAppender.layout=org.apache.log4j.PatternLayout\nlog4j.appender.requestAppender.layout.ConversionPattern=[%d] %p %m (%c)%n\n\nlog4j.appender.cleanerAppender=org.apache.log4j.DailyRollingFileAppender\nlog4j.appender.cleanerAppender.DatePattern='.'yyyy-MM-dd-HH\nlog4j.appender.cleanerAppender.File=${kafka.logs.dir}/log-cleaner.log\nlog4j.appender.cleanerAppender.layout=org.apache.log4j.PatternLayout\nlog4j.appender.cleanerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n\n\nlog4j.appender.controllerAppender=org.apache.log4j.DailyRollingFileAppender\nlog4j.appender.controllerAppender.DatePattern='.'yyyy-MM-dd-HH\nlog4j.appender.controllerAppender.File=${kafka.logs.dir}/controller.log\nlog4j.appender.controllerAppender.layout=org.apache.log4j.PatternLayout\nlog4j.appender.controllerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n\n\n# Turn on all our debugging info\n#log4j.logger.kafka.producer.async.DefaultEventHandler=DEBUG, kafkaAppender\n#log4j.log
 ger.kafka.client.ClientUtils=DEBUG, kafkaAppender\n#log4j.logger.kafka.perf=DEBUG, kafkaAppender\n#log4j.logger.kafka.perf.ProducerPerformance$ProducerThread=DEBUG, kafkaAppender\n#log4j.logger.org.I0Itec.zkclient.ZkClient=DEBUG\nlog4j.logger.kafka=INFO, kafkaAppender\nlog4j.logger.kafka.network.RequestChannel$=WARN, requestAppender\nlog4j.additivity.kafka.network.RequestChannel$=false\n\n#log4j.logger.kafka.network.Processor=TRACE, requestAppender\n#log4j.logger.kafka.server.KafkaApis=TRACE, requestAppender\n#log4j.additivity.kafka.server.KafkaApis=false\nlog4j.logger.kafka.request.logger=WARN, requestAppender\nlog4j.additivity.kafka.request.logger=false\n\nlog4j.logger.kafka.controller=TRACE, controllerAppender\nlog4j.additivity.kafka.controller=false\n\nlog4j.logger.kafka.log.LogCleaner=INFO, cleanerAppender\nlog4j.additivity.kafka.log.LogCleaner=false\n\nlog4j.logger.state.change.logger=TRACE, stateChangeAppender\nlog4j.additivity.state.change.logger=false"
+      },
+      "kafka-broker": {
+        "log.segment.bytes": "1073741824",
+        "socket.send.buffer.bytes": "102400",
+        "num.network.threads": "3",
+        "log.flush.scheduler.interval.ms": "3000",
+        "kafka.ganglia.metrics.host": "localhost",
+        "zookeeper.session.timeout.ms": "6000",
+        "replica.lag.time.max.ms": "10000",
+        "num.io.threads": "8",
+        "kafka.ganglia.metrics.group": "kafka",
+        "replica.lag.max.messages": "4000",
+        "port": "6667",
+        "log.retention.bytes": "-1",
+        "fetch.purgatory.purge.interval.requests": "10000",
+        "producer.purgatory.purge.interval.requests": "10000",
+        "default.replication.factor": "1",
+        "replica.high.watermark.checkpoint.interval.ms": "5000",
+        "zookeeper.connect": "c6402.ambari.apache.org:2181",
+        "controlled.shutdown.retry.backoff.ms": "5000",
+        "num.partitions": "1",
+        "log.flush.interval.messages": "10000",
+        "replica.fetch.min.bytes": "1",
+        "queued.max.requests": "500",
+        "controlled.shutdown.max.retries": "3",
+        "replica.fetch.wait.max.ms": "500",
+        "controlled.shutdown.enable": "false",
+        "log.roll.hours": "168",
+        "log.cleanup.interval.mins": "10",
+        "replica.socket.receive.buffer.bytes": "65536",
+        "zookeeper.connection.timeout.ms": "6000",
+        "replica.fetch.max.bytes": "1048576",
+        "num.replica.fetchers": "1",
+        "socket.request.max.bytes": "104857600",
+        "message.max.bytes": "1000000",
+        "zookeeper.sync.time.ms": "2000",
+        "socket.receive.buffer.bytes": "102400",
+        "controller.message.queue.size": "10",
+        "log.flush.interval.ms": "3000",
+        "log.dirs": "/tmp/log/dir",
+        "controller.socket.timeout.ms": "30000",
+        "replica.socket.timeout.ms": "30000",
+        "auto.create.topics.enable": "true",
+        "log.index.size.max.bytes": "10485760",
+        "kafka.ganglia.metrics.port": "8649",
+        "log.index.interval.bytes": "4096",
+        "log.retention.hours": "168"
       }
 
+
     },
     "configuration_attributes": {
         "yarn-site": {
@@ -114,7 +171,10 @@
         },
       "knox-env": {},
       "gateway-site": {},
-      "users-ldif": {}
+      "users-ldif": {},
+      "kafka-env": {},
+      "kafka-log4j": {},
+      "kafka-broker": {}
     },
     "configurationTags": {
         "slider-client": {
@@ -143,6 +203,15 @@
       },
       "users-ldif": {
         "tag": "version1"
+      },
+      "kafka-env": {
+        "tag": "version1"
+      },
+      "kafka-log4j": {
+        "tag": "version1"
+      },
+      "kafka-broker": {
+        "tag": "version1"
       }
     },
     "commandId": "7-1",
@@ -163,6 +232,13 @@
         ],
       "knox_gateway_hosts": [
         "jaimin-knox-1.c.pramod-thangali.internal"
-      ]
-    }
+      ],
+      "kafka_broker_hosts": [
+        "c6402.ambari.apache.org"
+      ],
+       "zookeeper_hosts": [
+         "c6401.ambari.apache.org"
+        ]
+
+}
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index f6b1862..0b0d769 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -1693,6 +1693,99 @@ module.exports =
       "category": "Advanced knox-env.xml"
     },
 
+  /********************************************* KAFKA *****************************/
+    {
+      "id": "puppet var",
+      "name": "kafka_broker_host",
+      "displayName": "Kafka Broker host",
+      "value": "",
+      "defaultValue": "",
+      "description": "The host that has been assigned to run Kafka Broker",
+      "displayType": "masterHost",
+      "isOverridable": false,
+      "isVisible": true,
+      "isRequiredByAgent": false,
+      "serviceName": "KAFKA",
+      "filename": "kafka-broker.xml",
+      "category": "KAFKA_BROKER",
+      "index": 0
+    },
+    {
+      "id": "site property",
+      "name": "log.dirs",
+      "displayName": "log.dirs",
+      "value": "",
+      "defaultValue": "",
+      "displayType": "directories",
+      "serviceName": "KAFKA",
+      "filename": "kafka-broker.xml",
+      "category": "KAFKA_BROKER",
+      "index": 0
+    },
+    {
+      "id": "site property",
+      "name": "port",
+      "displayName": "port",
+      "value": "",
+      "defaultValue": "",
+      "displayType": "int",
+      "serviceName": "KAFKA",
+      "filename": "kafka-broker.xml",
+      "category": "KAFKA_BROKER",
+      "index": 0
+    },
+    {
+      "id": "site property",
+      "name": "log.roll.hours",
+      "displayName": "log.roll.hours",
+      "value": "",
+      "defaultValue": "",
+      "displayType": "advanced",
+      "serviceName": "KAFKA",
+      "filename": "kafka-broker.xml",
+      "category": "KAFKA_BROKER",
+      "index": 0
+    },
+    {
+      "id": "site property",
+      "name": "log.retention.hours",
+      "displayName": "log.retention.hours",
+      "value": "",
+      "defaultValue": "",
+      "displayType": "advanced",
+      "serviceName": "KAFKA",
+      "filename": "kafka-broker.xml",
+      "category": "KAFKA_BROKER",
+      "index": 0
+    },
+    {
+      "id": "site property",
+      "name": "zookeeper.connect",
+      "displayName": "zookeeper.connect",
+      "value": "",
+      "defaultValue": "",
+      "displayType": "advanced",
+      "serviceName": "KAFKA",
+      "filename": "kafka-broker.xml",
+      "category": "KAFKA_BROKER",
+      "index": 0
+    },
+    {
+      "id": "site property",
+      "name": "kafka_pid_dir",
+      "displayName": "Kafka PID dir",
+      "value": "",
+      "defaultValue": "",
+      "isReconfigurable": false,
+      "isOverridable": false,
+      "displayType": "directory",
+      "serviceName": "KAFKA",
+      "filename": "kafka-broker.xml",
+      "category": "Advanced kafka-env.xml",
+      "index": 0
+    },
+
+
   /********************************************* flume-agent *****************************/
     {
       "id": "site property",

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 664ca62..89e3adc 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -481,10 +481,14 @@ App.ServiceConfigProperty = Ember.Object.extend({
       case 'knox_gateway_host':
         this.set('value', masterComponentHostsInDB.findProperty('component', 'KNOX_GATEWAY').hostName);
         break;
+      case 'kafka_broker_host':
+        this.set('value', masterComponentHostsInDB.findProperty('component', 'KAFKA_BROKER').hostName);
+        break;
       case 'hbase.zookeeper.quorum':
         var zkHosts = masterComponentHostsInDB.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
         this.setDefaultValue("(\\w*)", zkHosts);
         break;
+      case 'zookeeper.connect':
       case 'hive.zookeeper.quorum':
       case 'templeton.zookeeper.hosts':
       case 'slider.zookeeper.quorum':

http://git-wip-us.apache.org/repos/asf/ambari/blob/799a0d54/ambari-web/app/models/stack_service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_service.js b/ambari-web/app/models/stack_service.js
index 7f64212..4c86b20 100644
--- a/ambari-web/app/models/stack_service.js
+++ b/ambari-web/app/models/stack_service.js
@@ -318,6 +318,11 @@ App.StackService.configCategories = function () {
         App.ServiceConfigCategory.create({ name: 'KNOX_GATEWAY', displayName: 'Knox Gateway'})
       ]);
       break;
+    case 'KAFKA':
+      serviceConfigCategories.pushObjects([
+        App.ServiceConfigCategory.create({ name: 'KAFKA_BROKER', displayName: 'Kafka Broker'})
+      ]);
+      break;
     case 'PIG':
       break;
     case 'SQOOP':


Mime
View raw message