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 8ef46dca BIGTOP-3869: Decouple mpack Zookeeper service from Ambari
Core (#1052)
8ef46dca is described below
commit 8ef46dca90e4684c63c53425615b56e84f2aa1ea
Author: Yuqi Gu <[email protected]>
AuthorDate: Fri Nov 25 12:12:44 2022 +0800
BIGTOP-3869: Decouple mpack Zookeeper service from Ambari Core (#1052)
* BIGTOP-3869: Decouple mpack Zookeeper service from Ambari Core
Change-Id: I1a1d280e4c5b7bdca10e0754d3e18c53d517a89a
Signed-off-by: Yuqi Gu <[email protected]>
* Fix Zookeeper service issues deployed by Ambari Mpack
Change-Id: I37afb7a3c6434cc03fda3c512d082249a28b71e4
Signed-off-by: Yuqi Gu <[email protected]>
Signed-off-by: Yuqi Gu <[email protected]>
---
.../stacks/BGTP/1.0/services/ZOOKEEPER/alerts.json | 78 ++++++++++
.../services/ZOOKEEPER/configuration/zoo.cfg.xml | 93 ++++++++++++
.../ZOOKEEPER/configuration/zookeeper-env.xml | 113 +++++++++++++++
.../ZOOKEEPER/configuration/zookeeper-log4j.xml | 125 ++++++++++++++++
.../BGTP/1.0/services/ZOOKEEPER/kerberos.json | 40 ++++++
.../BGTP/1.0/services/ZOOKEEPER/metainfo.xml | 83 ++++++++++-
.../1.0/services/ZOOKEEPER/package/files/zkEnv.sh | 96 +++++++++++++
.../services/ZOOKEEPER/package/files/zkServer.sh | 120 ++++++++++++++++
.../services/ZOOKEEPER/package/files/zkService.sh | 26 ++++
.../services/ZOOKEEPER/package/files/zkSmoke.sh | 93 ++++++++++++
.../services/ZOOKEEPER/package/scripts/__init__.py | 20 +++
.../services/ZOOKEEPER/package/scripts/params.py | 27 ++++
.../ZOOKEEPER/package/scripts/params_linux.py | 112 +++++++++++++++
.../ZOOKEEPER/package/scripts/params_windows.py | 69 +++++++++
.../ZOOKEEPER/package/scripts/service_check.py | 76 ++++++++++
.../ZOOKEEPER/package/scripts/status_params.py | 60 ++++++++
.../ZOOKEEPER/package/scripts/zookeeper.py | 158 +++++++++++++++++++++
.../ZOOKEEPER/package/scripts/zookeeper_client.py | 81 +++++++++++
.../ZOOKEEPER/package/scripts/zookeeper_server.py | 138 ++++++++++++++++++
.../ZOOKEEPER/package/scripts/zookeeper_service.py | 72 ++++++++++
.../package/templates/configuration.xsl.j2 | 42 ++++++
.../templates/input.config-zookeeper.json.j2 | 46 ++++++
.../ZOOKEEPER/package/templates/zoo.cfg.j2 | 55 +++++++
.../templates/zookeeper_client_jaas.conf.j2 | 23 +++
.../package/templates/zookeeper_jaas.conf.j2 | 26 ++++
.../1.0/services/ZOOKEEPER/role_command_order.json | 9 ++
.../1.0/services/ZOOKEEPER/themes/directories.json | 117 +++++++++++++++
27 files changed, 1996 insertions(+), 2 deletions(-)
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/alerts.json
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/alerts.json
new file mode 100644
index 00000000..4b705f76
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/alerts.json
@@ -0,0 +1,78 @@
+{
+ "ZOOKEEPER": {
+ "service": [
+ {
+ "name": "zookeeper_server_process_percent",
+ "label": "Percent ZooKeeper Servers Available",
+ "description": "This alert is triggered if the number of down
ZooKeeper servers in the cluster is greater than the configured critical
threshold. It aggregates the results of ZooKeeper process checks.",
+ "interval": 1,
+ "scope": "SERVICE",
+ "enabled": true,
+ "source": {
+ "type": "AGGREGATE",
+ "alert_name": "zookeeper_server_process",
+ "reporting": {
+ "ok": {
+ "text": "affected: [{1}], total: [{0}]"
+ },
+ "warning": {
+ "text": "affected: [{1}], total: [{0}]",
+ "value": 35
+ },
+ "critical": {
+ "text": "affected: [{1}], total: [{0}]",
+ "value": 70
+ },
+ "units" : "%",
+ "type": "PERCENT"
+ }
+ }
+ }
+ ],
+ "ZOOKEEPER_SERVER": [
+ {
+ "name": "zookeeper_server_process",
+ "label": "ZooKeeper Server Process",
+ "description": "This host-level alert is triggered if the ZooKeeper
server process cannot be determined to be up and listening on the network.",
+ "interval": 1,
+ "scope": "ANY",
+ "source": {
+ "type": "PORT",
+ "uri": "{{zoo.cfg/clientPort}}",
+ "default_port": 2181,
+ "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
+ }
+ },
+ "parameters": [
+ {
+ "name": "socket.command",
+ "display_name": "Socket Command",
+ "value": "ruok",
+ "description": "A socket command which queries ZooKeeper to
respond with its state. The expected response is imok.",
+ "type": "STRING",
+ "visibility": "HIDDEN"
+ },
+ {
+ "name": "socket.command.response",
+ "display_name": "Expected Response",
+ "value": "imok",
+ "description": "The expected response to the socket command.",
+ "type": "STRING",
+ "visibility": "HIDDEN"
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zoo.cfg.xml
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zoo.cfg.xml
new file mode 100644
index 00000000..58778777
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zoo.cfg.xml
@@ -0,0 +1,93 @@
+<?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>tickTime</name>
+ <value>3000</value>
+ <display-name>Length of single Tick</display-name>
+ <description>The length of a single tick in milliseconds, which is the
basic time unit used by ZooKeeper</description>
+ <value-attributes>
+ <type>int</type>
+ <overridable>false</overridable>
+ <unit>ms</unit>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>initLimit</name>
+ <value>10</value>
+ <display-name>Ticks to allow for sync at Init</display-name>
+ <description>Ticks to allow for sync at Init.</description>
+ <value-attributes>
+ <type>int</type>
+ <overridable>false</overridable>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>syncLimit</name>
+ <value>5</value>
+ <display-name>Ticks to allow for sync at Runtime</display-name>
+ <description>Ticks to allow for sync at Runtime.</description>
+ <value-attributes>
+ <type>int</type>
+ <overridable>false</overridable>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>clientPort</name>
+ <value>2181</value>
+ <display-name>Port for running ZK Server</display-name>
+ <description>Port for running ZK Server.</description>
+ <value-attributes>
+ <type>int</type>
+ <overridable>false</overridable>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>dataDir</name>
+ <value>/hadoop/zookeeper</value>
+ <display-name>ZooKeeper directory</display-name>
+ <description>Data directory for ZooKeeper.</description>
+ <value-attributes>
+ <type>directory</type>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>autopurge.snapRetainCount</name>
+ <value>30</value>
+ <description>ZooKeeper purge feature retains the autopurge.snapRetainCount
+ most recent snapshots and the corresponding transaction
+ logs in the dataDir and dataLogDir respectively and deletes the rest.
</description>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>autopurge.purgeInterval</name>
+ <value>24</value>
+ <description>The time interval in hours for which the purge task has to be
triggered.
+ Set to a positive integer (1 and above) to enable the auto
purging.</description>
+ <on-ambari-upgrade add="true"/>
+ </property>
+</configuration>
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zookeeper-env.xml
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zookeeper-env.xml
new file mode 100644
index 00000000..deb06713
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zookeeper-env.xml
@@ -0,0 +1,113 @@
+<?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>zk_user</name>
+ <display-name>ZooKeeper User</display-name>
+ <value>zookeeper</value>
+ <property-type>USER</property-type>
+ <description>ZooKeeper User.</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="true"/>
+ </property>
+ <property>
+ <name>zk_log_dir</name>
+ <value>/var/log/zookeeper</value>
+ <display-name>ZooKeeper Log Dir</display-name>
+ <description>ZooKeeper Log Dir</description>
+ <value-attributes>
+ <type>directory</type>
+ <overridable>false</overridable>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>zk_pid_dir</name>
+ <value>/var/run/zookeeper</value>
+ <display-name>ZooKeeper PID Dir</display-name>
+ <description>ZooKeeper Pid Dir</description>
+ <value-attributes>
+ <type>directory</type>
+ <overridable>false</overridable>
+ <editable-only-at-install>true</editable-only-at-install>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>zk_server_heapsize</name>
+ <value>1024</value>
+ <description>Maximum amount of memory each Zookeeper Server can
use.</description>
+ <display-name>Zookeeper Server Maximum Memory</display-name>
+ <value-attributes>
+ <type>int</type>
+ <minimum>256</minimum>
+ <maximum>32768</maximum>
+ <unit>MB</unit>
+ <increment-step>256</increment-step>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>zookeeper_principal_name</name>
+ <description>ZooKeeper principal name</description>
+ <property-type>KERBEROS_PRINCIPAL</property-type>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <property>
+ <name>zookeeper_keytab_path</name>
+ <description>ZooKeeper keytab path</description>
+ <on-ambari-upgrade add="true"/>
+ </property>
+ <!-- zookeeper-env.sh -->
+ <property>
+ <name>content</name>
+ <display-name>zookeeper-env template</display-name>
+ <description>This is the jinja template for zookeeper-env.sh
file</description>
+ <value>
+export JAVA_HOME={{java64_home}}
+export ZOOKEEPER_HOME={{zk_home}}
+export ZOO_LOG_DIR={{zk_log_dir}}
+export ZOOPIDFILE={{zk_pid_file}}
+export SERVER_JVMFLAGS={{zk_server_heapsize}}
+export JAVA=$JAVA_HOME/bin/java
+export CLASSPATH=$CLASSPATH:/usr/share/zookeeper/*
+
+{% if security_enabled %}
+export SERVER_JVMFLAGS="$SERVER_JVMFLAGS
-Djava.security.auth.login.config={{zk_server_jaas_file}}"
+export CLIENT_JVMFLAGS="$CLIENT_JVMFLAGS
-Djava.security.auth.login.config={{zk_client_jaas_file}}
-Dzookeeper.sasl.client.username={{zk_principal_user}}"
+{% endif %}
+ </value>
+ <value-attributes>
+ <type>content</type>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+</configuration>
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
new file mode 100644
index 00000000..ff9138ed
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
@@ -0,0 +1,125 @@
+<?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" supports_adding_forbidden="false">
+ <property>
+ <name>zookeeper_log_max_backup_size</name>
+ <value>10</value>
+ <description>The maximum size of backup file before the log is
rotated</description>
+ <display-name>ZooKeeper Log: backup file size</display-name>
+ <value-attributes>
+ <unit>MB</unit>
+ </value-attributes>
+ <on-ambari-upgrade add="false"/>
+ </property>
+ <property>
+ <name>zookeeper_log_number_of_backup_files</name>
+ <value>10</value>
+ <description>The number of backup files</description>
+ <display-name>ZooKeeper 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>zookeeper-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.
+#
+#
+#
+
+#
+# ZooKeeper Logging Configuration
+#
+
+# DEFAULT: console appender only
+log4j.rootLogger=INFO, CONSOLE, ROLLINGFILE
+
+# Example with rolling log file
+#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
+
+# Example with rolling log file and tracing
+#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
+
+#
+# Log INFO level and above messages to the console
+#
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p
[%t:%C{1}@%L] - %m%n
+
+#
+# Add ROLLINGFILE to rootLogger to get log file output
+# Log DEBUG level and above messages to a log file
+log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
+log4j.appender.ROLLINGFILE.Threshold=DEBUG
+log4j.appender.ROLLINGFILE.File={{zk_log_dir}}/zookeeper.log
+
+# Max log file size of 10MB
+log4j.appender.ROLLINGFILE.MaxFileSize={{zookeeper_log_max_backup_size}}MB
+# uncomment the next line to limit number of backup files
+#log4j.appender.ROLLINGFILE.MaxBackupIndex={{zookeeper_log_number_of_backup_files}}
+
+log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p
[%t:%C{1}@%L] - %m%n
+
+
+#
+# Add TRACEFILE to rootLogger to get log file output
+# Log DEBUG level and above messages to a log file
+log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
+log4j.appender.TRACEFILE.Threshold=TRACE
+log4j.appender.TRACEFILE.File=zookeeper_trace.log
+
+log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
+### Notice we are including log4j's NDC here (%x)
+log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p
[%t:%C{1}@%L][%x] - %m%n
+ </value>
+ <value-attributes>
+ <type>content</type>
+ <show-property-name>false</show-property-name>
+ </value-attributes>
+ <on-ambari-upgrade add="true"/>
+ </property>
+</configuration>
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/kerberos.json
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/kerberos.json
new file mode 100644
index 00000000..45895a96
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/kerberos.json
@@ -0,0 +1,40 @@
+{
+ "services": [
+ {
+ "name": "ZOOKEEPER",
+ "identities": [
+ {
+ "name": "zookeeper_smokeuser",
+ "reference": "/smokeuser"
+ }
+ ],
+ "components": [
+ {
+ "name": "ZOOKEEPER_SERVER",
+ "identities": [
+ {
+ "name": "zookeeper_zk",
+ "principal": {
+ "value": "zookeeper/_HOST@${realm}",
+ "type" : "service",
+ "configuration": "zookeeper-env/zookeeper_principal_name"
+ },
+ "keytab": {
+ "file": "${keytab_dir}/zk.service.keytab",
+ "owner": {
+ "name": "${zookeeper-env/zk_user}",
+ "access": "r"
+ },
+ "group": {
+ "name": "${cluster-env/user_group}",
+ "access": ""
+ },
+ "configuration": "zookeeper-env/zookeeper_keytab_path"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/metainfo.xml
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/metainfo.xml
index f8f2b5c0..15d2fe46 100644
---
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/metainfo.xml
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/metainfo.xml
@@ -20,8 +20,87 @@
<services>
<service>
<name>ZOOKEEPER</name>
- <version>3.4.6+bigtop</version>
- <extends>common-services/ZOOKEEPER/3.4.5</extends>
+ <displayName>ZooKeeper</displayName>
+ <comment>Centralized service which provides highly reliable distributed
coordination</comment>
+ <version>3.4.5</version>
+ <components>
+
+ <component>
+ <name>ZOOKEEPER_SERVER</name>
+ <displayName>ZooKeeper Server</displayName>
+ <category>MASTER</category>
+ <cardinality>1+</cardinality>
+ <versionAdvertised>true</versionAdvertised>
+ <rollingRestartSupported>true</rollingRestartSupported>
+ <commandScript>
+ <script>scripts/zookeeper_server.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>1200</timeout>
+ </commandScript>
+ <logs>
+ <log>
+ <logId>zookeeper</logId>
+ <primary>true</primary>
+ </log>
+ </logs>
+ </component>
+
+ <component>
+ <name>ZOOKEEPER_CLIENT</name>
+ <displayName>ZooKeeper Client</displayName>
+ <category>CLIENT</category>
+ <cardinality>1+</cardinality>
+ <versionAdvertised>true</versionAdvertised>
+ <commandScript>
+ <script>scripts/zookeeper_client.py</script>
+ <scriptType>PYTHON</scriptType>
+ </commandScript>
+ <configFiles>
+ <configFile>
+ <type>env</type>
+ <fileName>zookeeper-env.sh</fileName>
+ <dictionaryName>zookeeper-env</dictionaryName>
+ </configFile>
+ <configFile>
+ <type>env</type>
+ <fileName>log4j.properties</fileName>
+ <dictionaryName>zookeeper-log4j</dictionaryName>
+ </configFile>
+ </configFiles>
+ </component>
+ </components>
+
+ <osSpecifics>
+ <osSpecific>
+ <osFamily>any</osFamily>
+ <packages>
+ <package>
+ <name>zookeeper</name>
+ </package>
+ </packages>
+ </osSpecific>
+ </osSpecifics>
+
+ <commandScript>
+ <script>scripts/service_check.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>300</timeout>
+ </commandScript>
+
+ <configuration-dependencies>
+ <config-type>zookeeper-log4j</config-type>
+ <config-type>zookeeper-env</config-type>
+ <config-type>zoo.cfg</config-type>
+ </configuration-dependencies>
+ <restartRequiredAfterChange>true</restartRequiredAfterChange>
+
+ <themes>
+ <theme>
+ <fileName>directories.json</fileName>
+ <default>true</default>
+ </theme>
+ </themes>
+
</service>
</services>
</metainfo>
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkEnv.sh
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkEnv.sh
new file mode 100644
index 00000000..fa1b8327
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkEnv.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+
+# 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.
+
+# This script should be sourced into other zookeeper
+# scripts to setup the env variables
+
+# We use ZOOCFGDIR if defined,
+# otherwise we use /etc/zookeeper
+# or the conf directory that is
+# a sibling of this script's directory
+if [ "x$ZOOCFGDIR" = "x" ]
+then
+ if [ -d "/etc/zookeeper" ]
+ then
+ ZOOCFGDIR="/etc/zookeeper"
+ else
+ ZOOCFGDIR="$ZOOBINDIR/../conf"
+ fi
+fi
+
+if [ "x$ZOOCFG" = "x" ]
+then
+ ZOOCFG="zoo.cfg"
+fi
+
+ZOOCFG="$ZOOCFGDIR/$ZOOCFG"
+
+if [ -e "$ZOOCFGDIR/zookeeper-env.sh" ]
+then
+ . "$ZOOCFGDIR/zookeeper-env.sh"
+fi
+
+if [ "x${ZOO_LOG_DIR}" = "x" ]
+then
+ ZOO_LOG_DIR="."
+fi
+
+if [ "x${ZOO_LOG4J_PROP}" = "x" ]
+then
+ ZOO_LOG4J_PROP="INFO,CONSOLE"
+fi
+
+#add the zoocfg dir to classpath
+CLASSPATH="$ZOOCFGDIR:$CLASSPATH"
+
+for i in "$ZOOBINDIR"/../src/java/lib/*.jar
+do
+ CLASSPATH="$i:$CLASSPATH"
+done
+
+#make it work in the release
+for i in "$ZOOBINDIR"/../lib/*.jar
+do
+ CLASSPATH="$i:$CLASSPATH"
+done
+
+#make it work in the release
+for i in "$ZOOBINDIR"/../zookeeper-*.jar
+do
+ CLASSPATH="$i:$CLASSPATH"
+done
+
+#make it work for developers
+for d in "$ZOOBINDIR"/../build/lib/*.jar
+do
+ CLASSPATH="$d:$CLASSPATH"
+done
+
+#make it work for developers
+CLASSPATH="$ZOOBINDIR/../build/classes:$CLASSPATH"
+
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ *) cygwin=false ;;
+esac
+
+if $cygwin
+then
+ CLASSPATH=`cygpath -wp "$CLASSPATH"`
+fi
+
+#echo "CLASSPATH=$CLASSPATH"
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkServer.sh
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkServer.sh
new file mode 100644
index 00000000..dd75a587
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkServer.sh
@@ -0,0 +1,120 @@
+#!/usr/bin/env bash
+
+# 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 this scripted is run out of /usr/bin or some other system bin directory
+# it should be linked to and not copied. Things like java jar files are found
+# relative to the canonical path of this script.
+#
+
+# See the following page for extensive details on setting
+# up the JVM to accept JMX remote management:
+# http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
+# by default we allow local JMX connections
+if [ "x$JMXLOCALONLY" = "x" ]
+then
+ JMXLOCALONLY=false
+fi
+
+if [ "x$JMXDISABLE" = "x" ]
+then
+ echo "JMX enabled by default"
+ # for some reason these two options are necessary on jdk6 on Ubuntu
+ # accord to the docs they are not necessary, but otw jconsole cannot
+ # do a local attach
+ ZOOMAIN="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY
org.apache.zookeeper.server.quorum.QuorumPeerMain"
+else
+ echo "JMX disabled by user request"
+ ZOOMAIN="org.apache.zookeeper.server.quorum.QuorumPeerMain"
+fi
+
+# Only follow symlinks if readlink supports it
+if readlink -f "$0" > /dev/null 2>&1
+then
+ ZOOBIN=`readlink -f "$0"`
+else
+ ZOOBIN="$0"
+fi
+ZOOBINDIR=`dirname "$ZOOBIN"`
+
+. "$ZOOBINDIR"/zkEnv.sh
+
+if [ "x$2" != "x" ]
+then
+ ZOOCFG="$ZOOCFGDIR/$2"
+fi
+
+if $cygwin
+then
+ ZOOCFG=`cygpath -wp "$ZOOCFG"`
+ # cygwin has a "kill" in the shell itself, gets confused
+ KILL=/bin/kill
+else
+ KILL=kill
+fi
+
+echo "Using config: $ZOOCFG"
+
+ZOOPIDFILE=$(grep dataDir "$ZOOCFG" | sed -e 's/.*=//')/zookeeper_server.pid
+
+
+case $1 in
+start)
+ echo "Starting zookeeper ... "
+ $JAVA "-Dzookeeper.log.dir=${ZOO_LOG_DIR}"
"-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
+ -cp "$CLASSPATH" $JVMFLAGS $ZOOMAIN "$ZOOCFG" &
+ /bin/echo -n $! > "$ZOOPIDFILE"
+ echo STARTED
+ ;;
+stop)
+ echo "Stopping zookeeper ... "
+ if [ ! -f "$ZOOPIDFILE" ]
+ then
+ echo "error: could not find file $ZOOPIDFILE"
+ exit 1
+ else
+ $KILL -9 $(cat "$ZOOPIDFILE")
+ rm "$ZOOPIDFILE"
+ echo STOPPED
+ fi
+ ;;
+upgrade)
+ shift
+ echo "upgrading the servers to 3.*"
+ java "-Dzookeeper.log.dir=${ZOO_LOG_DIR}"
"-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
+ -cp "$CLASSPATH" $JVMFLAGS org.apache.zookeeper.server.upgrade.UpgradeMain
${@}
+ echo "Upgrading ... "
+ ;;
+restart)
+ shift
+ "$0" stop ${@}
+ sleep 3
+ "$0" start ${@}
+ ;;
+status)
+ STAT=`echo stat | nc localhost $(grep clientPort "$ZOOCFG" | sed -e
's/.*=//') 2> /dev/null| grep Mode`
+ if [ "x$STAT" = "x" ]
+ then
+ echo "Error contacting service. It is probably not running."
+ else
+ echo $STAT
+ fi
+ ;;
+*)
+ echo "Usage: $0 {start|stop|restart|status}" >&2
+
+esac
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkService.sh
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkService.sh
new file mode 100644
index 00000000..59bfe90d
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkService.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+#
+#
+# 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.
+#
+#
+
+zkcli_script=$1
+user=$2
+conf_dir=$3
+/var/lib/ambari-agent/ambari-sudo.sh su $user -s /bin/bash - -c "source
$conf_dir/zookeeper-env.sh ; echo 'ls /' | $zkcli_script"
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkSmoke.sh
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkSmoke.sh
new file mode 100644
index 00000000..4d1562ee
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/files/zkSmoke.sh
@@ -0,0 +1,93 @@
+#!/usr/bin/env bash
+#
+#
+# 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.
+#
+#
+
+zk_cli_shell=$1
+smoke_user=$2
+conf_dir=$3
+client_port=$4
+security_enabled=$5
+kinit_path_local=$6
+smoke_user_keytab=$7
+smokeuser_principal=$8
+test_output_file=$9
+export ZOOKEEPER_EXIT_CODE=0
+errors_expr="ERROR|Exception"
+acceptable_expr="SecurityException"
+zkhosts=` grep "^\s*server\.[[:digit:]]" $conf_dir/zoo.cfg | cut -f 2 -d '='
| cut -f 1 -d ':' | tr '\n' ' ' `
+zk_node1=`echo $zkhosts | tr ' ' '\n' | head -n 1`
+echo "zk_node1=$zk_node1"
+if [[ $security_enabled == "True" ]]; then
+ kinitcmd="$kinit_path_local -kt $smoke_user_keytab $smokeuser_principal"
+ /var/lib/ambari-agent/ambari-sudo.sh su $smoke_user -s /bin/bash - -c
"$kinitcmd"
+fi
+
+function verify_output() {
+ if [ -f $test_output_file ]; then
+ errors=`grep -E $errors_expr $test_output_file | grep -v $acceptable_expr`
+ if [ "$?" -eq 0 ]; then
+ echo "Error found in the zookeeper smoke test. Exiting."
+ echo $errors
+ exit 1
+ fi
+ fi
+}
+
+function rename_output(){
+ if [ -f $test_output_file ]; then
+ time=$(date +"%s")
+ output_file=$(echo $test_output_file | cut -f 1 -d '.')
+ errors=`mv $test_output_file $output_file$time.out`
+ if [ "$?" -ne 0 ]; then
+ echo "Error found in the zookeeper smoke test. Exiting."
+ echo $errors
+ exit 1
+ fi
+ fi
+}
+
+# Delete /zk_smoketest znode if exists
+/var/lib/ambari-agent/ambari-sudo.sh su $smoke_user -s /bin/bash - -c "source
$conf_dir/zookeeper-env.sh ; echo delete /zk_smoketest | ${zk_cli_shell}
-server $zk_node1:$client_port" 2>&1>$test_output_file
+# Create /zk_smoketest znode on one zookeeper server
+/var/lib/ambari-agent/ambari-sudo.sh su $smoke_user -s /bin/bash - -c "source
$conf_dir/zookeeper-env.sh ; echo create /zk_smoketest smoke_data |
${zk_cli_shell} -server $zk_node1:$client_port" 2>&1>>$test_output_file
+verify_output
+rename_output
+
+for i in $zkhosts ; do
+ echo "Running test on host $i"
+ # Verify the data associated with znode across all the nodes in the
zookeeper quorum
+ /var/lib/ambari-agent/ambari-sudo.sh su $smoke_user -s /bin/bash - -c
"source $conf_dir/zookeeper-env.sh ; echo 'get /zk_smoketest' | ${zk_cli_shell}
-server $i:$client_port"
+ /var/lib/ambari-agent/ambari-sudo.sh su $smoke_user -s /bin/bash - -c
"source $conf_dir/zookeeper-env.sh ; echo 'ls /' | ${zk_cli_shell} -server
$i:$client_port"
+ output=$(/var/lib/ambari-agent/ambari-sudo.sh su $smoke_user -s /bin/bash -
-c "source $conf_dir/zookeeper-env.sh ; echo 'get /zk_smoketest' |
${zk_cli_shell} -server $i:$client_port")
+ echo $output | grep smoke_data
+ if [[ $? -ne 0 ]] ; then
+ echo "Data associated with znode /zk_smoketests is not consistent on host
$i"
+ ((ZOOKEEPER_EXIT_CODE=$ZOOKEEPER_EXIT_CODE+1))
+ fi
+done
+
+/var/lib/ambari-agent/ambari-sudo.sh su $smoke_user -s /bin/bash - -c "source
$conf_dir/zookeeper-env.sh ; echo 'delete /zk_smoketest' | ${zk_cli_shell}
-server $zk_node1:$client_port"
+if [[ "$ZOOKEEPER_EXIT_CODE" -ne "0" ]] ; then
+ echo "Zookeeper Smoke Test: Failed"
+else
+ echo "Zookeeper Smoke Test: Passed"
+fi
+exit $ZOOKEEPER_EXIT_CODE
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/__init__.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/__init__.py
new file mode 100644
index 00000000..35de4bb1
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/__init__.py
@@ -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.
+
+Ambari Agent
+
+"""
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params.py
new file mode 100644
index 00000000..fbefec90
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params.py
@@ -0,0 +1,27 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+from ambari_commons import OSCheck
+
+if OSCheck.is_windows_family():
+ from params_windows import *
+else:
+ from params_linux import *
+
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params_linux.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params_linux.py
new file mode 100644
index 00000000..de4073a4
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params_linux.py
@@ -0,0 +1,112 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+import status_params
+import os
+
+from resource_management.libraries.functions import format
+from resource_management.libraries.functions.version import
format_stack_version
+from resource_management.libraries.functions.default import default
+from resource_management.libraries.functions.stack_features import
check_stack_feature
+from resource_management.libraries.functions import get_kinit_path
+from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions.expect import expect
+
+# server configurations
+config = Script.get_config()
+tmp_dir = Script.get_tmp_dir()
+
+stack_version_formatted = status_params.stack_version_formatted
+stack_root = status_params.stack_root
+
+stack_name = status_params.stack_name
+component_directory = status_params.component_directory
+
+# New Cluster Stack Version that is defined during the RESTART of a Rolling
Upgrade
+version = default("/commandParams/version", None)
+
+# default parameters
+zk_home = "/usr"
+zk_bin = "/usr/lib/zookeeper/bin"
+zk_cli_shell = "/usr/lib/zookeeper/bin/zkCli.sh"
+config_dir = "/etc/zookeeper/conf"
+zk_smoke_out = os.path.join(tmp_dir, "zkSmoke.out")
+
+# hadoop parameters for stacks that support rolling_upgrade
+if stack_version_formatted and
check_stack_feature(StackFeature.ROLLING_UPGRADE, stack_version_formatted):
+ zk_home = format("{stack_root}/current/{component_directory}")
+ zk_bin = format("{stack_root}/current/{component_directory}/bin")
+ zk_cli_shell =
format("{stack_root}/current/{component_directory}/bin/zkCli.sh")
+ config_dir = status_params.config_dir
+
+
+zk_user = config['configurations']['zookeeper-env']['zk_user']
+hostname = config['agentLevelParams']['hostname']
+user_group = config['configurations']['cluster-env']['user_group']
+zk_env_sh_template = config['configurations']['zookeeper-env']['content']
+
+zk_log_dir = config['configurations']['zookeeper-env']['zk_log_dir']
+zk_data_dir = config['configurations']['zoo.cfg']['dataDir']
+zk_pid_dir = status_params.zk_pid_dir
+zk_pid_file = status_params.zk_pid_file
+zk_server_heapsize_value =
str(default('configurations/zookeeper-env/zk_server_heapsize', "1024"))
+zk_server_heapsize_value = zk_server_heapsize_value.strip()
+if len(zk_server_heapsize_value) > 0 and
zk_server_heapsize_value[-1].isdigit():
+ zk_server_heapsize_value = zk_server_heapsize_value + "m"
+zk_server_heapsize = format("-Xmx{zk_server_heapsize_value}")
+
+client_port = default('/configurations/zoo.cfg/clientPort', None)
+
+if 'zoo.cfg' in config['configurations']:
+ zoo_cfg_properties_map = config['configurations']['zoo.cfg']
+else:
+ zoo_cfg_properties_map = {}
+zoo_cfg_properties_map_length = len(zoo_cfg_properties_map)
+
+zk_principal_name =
default("/configurations/zookeeper-env/zookeeper_principal_name",
"zookeeper/[email protected]")
+zk_principal_user = zk_principal_name.split('/')[0]
+zk_principal = zk_principal_name.replace('_HOST',hostname.lower())
+
+java64_home = config['ambariLevelParams']['java_home']
+java_version = expect("/ambariLevelParams/java_version", int)
+
+zookeeper_hosts = config['clusterHostInfo']['zookeeper_server_hosts']
+zookeeper_hosts.sort()
+
+zk_keytab_path =
config['configurations']['zookeeper-env']['zookeeper_keytab_path']
+zk_server_jaas_file = format("{config_dir}/zookeeper_jaas.conf")
+zk_client_jaas_file = format("{config_dir}/zookeeper_client_jaas.conf")
+security_enabled = config['configurations']['cluster-env']['security_enabled']
+
+smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
+smokeuser = config['configurations']['cluster-env']['smokeuser']
+smokeuser_principal =
config['configurations']['cluster-env']['smokeuser_principal_name']
+kinit_path_local =
get_kinit_path(default('/configurations/kerberos-env/executable_search_paths',
None))
+
+# Zookeeper log4j settings
+zookeeper_log_max_backup_size =
default('configurations/zookeeper-log4j/zookeeper_log_max_backup_size',10)
+zookeeper_log_number_of_backup_files =
default('configurations/zookeeper-log4j/zookeeper_log_number_of_backup_files',10)
+
+#log4j.properties
+if ('zookeeper-log4j' in config['configurations']) and ('content' in
config['configurations']['zookeeper-log4j']):
+ log4j_props = config['configurations']['zookeeper-log4j']['content']
+else:
+ log4j_props = None
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params_windows.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params_windows.py
new file mode 100644
index 00000000..87d82c20
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/params_windows.py
@@ -0,0 +1,69 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+from ambari_commons.str_utils import ensure_double_backslashes
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions import is_empty
+import status_params
+
+# server configurations
+config = Script.get_config()
+
+config_dir = None
+stack_root = None
+try:
+ # not used zookeeper_home_dir = os.environ["ZOOKEEPER_HOME"]
+ config_dir = os.environ["ZOOKEEPER_CONF_DIR"]
+ stack_root = os.environ["HADOOP_NODE_INSTALL_ROOT"]
+except:
+ pass
+
+hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
+zk_user = hadoop_user
+
+zk_log_dir = config['configurations']['zookeeper-env']['zk_log_dir']
+zk_data_dir =
ensure_double_backslashes(config['configurations']['zoo.cfg']['dataDir'])
+tickTime = config['configurations']['zoo.cfg']['tickTime']
+initLimit = config['configurations']['zoo.cfg']['initLimit']
+syncLimit = config['configurations']['zoo.cfg']['syncLimit']
+clientPort = config['configurations']['zoo.cfg']['clientPort']
+
+if 'zoo.cfg' in config['configurations']:
+ zoo_cfg_properties_map = config['configurations']['zoo.cfg'].copy()
+ # Fix the data dir - ZK won't start unless the backslashes are doubled
+ zoo_cfg_properties_map['dataDir'] = zk_data_dir
+else:
+ zoo_cfg_properties_map = {}
+zoo_cfg_properties_map_length = len(zoo_cfg_properties_map)
+
+zookeeper_hosts = config['clusterHostInfo']['zookeeper_server_hosts']
+zookeeper_hosts.sort()
+hostname = config['agentLevelParams']['hostname']
+
+_authentication =
config['configurations']['core-site']['hadoop.security.authentication']
+security_enabled = ( not is_empty(_authentication) and _authentication ==
'kerberos')
+user_group = None
+zookeeper_win_service_name = status_params.zookeeper_win_service_name
+
+#log4j.properties
+if (('zookeeper-log4j' in config['configurations']) and ('content' in
config['configurations']['zookeeper-log4j'])):
+ log4j_props = config['configurations']['zookeeper-log4j']['content']
+else:
+ log4j_props = None
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/service_check.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/service_check.py
new file mode 100644
index 00000000..b7c7758f
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/service_check.py
@@ -0,0 +1,76 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions.format import format
+from resource_management.core.resources.system import Execute, File
+from resource_management.core.source import StaticFile
+from ambari_commons import OSConst
+from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+
+class ZookeeperServiceCheck(Script):
+ pass
+
+@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
+class ZookeeperServiceCheckLinux(ZookeeperServiceCheck):
+ def service_check(self, env):
+ import params
+ env.set_params(params)
+
+ File(params.zk_smoke_out,
+ action="delete"
+ )
+
+ File(format("{tmp_dir}/zkSmoke.sh"),
+ mode=0755,
+ content=StaticFile('zkSmoke.sh')
+ )
+
+ if params.security_enabled:
+ smokeUserKeytab=params.smoke_user_keytab
+ smokeUserPrincipal=params.smokeuser_principal
+ else:
+ smokeUserKeytab= "no_keytab"
+ smokeUserPrincipal="no_principal"
+
+
+ cmd_quorum = format("{tmp_dir}/zkSmoke.sh {zk_cli_shell} {smokeuser}
{config_dir} {client_port} "
+ "{security_enabled} {kinit_path_local} {smokeUserKeytab}
{smokeUserPrincipal} {zk_smoke_out}")
+
+ Execute(cmd_quorum,
+ tries=3,
+ try_sleep=5,
+ path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+ logoutput=True
+ )
+
+@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
+class ZookeeperServiceCheckWindows(ZookeeperServiceCheck):
+ def service_check(self, env):
+ import params
+ env.set_params(params)
+
+ smoke_cmd = os.path.join(params.stack_root,"Run-SmokeTests.cmd")
+ service = "Zookeeper"
+ Execute(format("cmd /C {smoke_cmd} {service}"), user=params.zk_user,
logoutput=True, tries=3, try_sleep=20)
+
+if __name__ == "__main__":
+ ZookeeperServiceCheck().execute()
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/status_params.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/status_params.py
new file mode 100644
index 00000000..5c56326c
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/status_params.py
@@ -0,0 +1,60 @@
+#!/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 ambari_commons import OSCheck
+from resource_management.libraries.functions import format
+from resource_management.libraries.functions.default import default
+from resource_management.libraries.functions.version import
format_stack_version
+from resource_management.libraries.functions.stack_features import
check_stack_feature
+from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.functions import get_kinit_path
+from resource_management.libraries.script.script import Script
+
+# a map of the Ambari role to the component name
+# for use with <stack-root>/current/<component>
+SERVER_ROLE_DIRECTORY_MAP = {
+ 'ZOOKEEPER_SERVER' : 'zookeeper-server',
+ 'ZOOKEEPER_CLIENT' : 'zookeeper-client'
+}
+
+component_directory =
Script.get_component_from_role(SERVER_ROLE_DIRECTORY_MAP, "ZOOKEEPER_CLIENT")
+
+config = Script.get_config()
+
+if OSCheck.is_windows_family():
+ zookeeper_win_service_name = "zkServer"
+else:
+ zk_pid_dir = config['configurations']['zookeeper-env']['zk_pid_dir']
+ zk_pid_file = format("{zk_pid_dir}/zookeeper_server.pid")
+
+ # Security related/required params
+ hostname = config['agentLevelParams']['hostname']
+ security_enabled =
config['configurations']['cluster-env']['security_enabled']
+ kinit_path_local =
get_kinit_path(default('/configurations/kerberos-env/executable_search_paths',
None))
+ tmp_dir = Script.get_tmp_dir()
+ zk_user = config['configurations']['zookeeper-env']['zk_user']
+
+ stack_version_unformatted =
str(config['clusterLevelParams']['stack_version'])
+ stack_version_formatted = format_stack_version(stack_version_unformatted)
+ stack_root = Script.get_stack_root()
+
+ config_dir = "/etc/zookeeper/conf"
+ if stack_version_formatted and
check_stack_feature(StackFeature.ROLLING_UPGRADE, stack_version_formatted):
+ config_dir = format("{stack_root}/current/{component_directory}/conf")
+stack_name = default("/clusterLevelParams/stack_name", None)
\ 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/ZOOKEEPER/package/scripts/zookeeper.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper.py
new file mode 100644
index 00000000..6572479e
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper.py
@@ -0,0 +1,158 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+import os
+import sys
+
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions import conf_select,stack_select
+from resource_management.libraries.functions.constants import StackFeature
+from resource_management.libraries.functions.version import compare_versions,
format_stack_version
+from resource_management.libraries.functions.stack_features import
check_stack_feature
+from resource_management.core.resources.system import Directory, File
+from resource_management.core.resources.service import ServiceConfig
+from resource_management.core.source import InlineTemplate, Template
+from ambari_commons import OSConst
+from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+
+@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
+def zookeeper(type = None, upgrade_type=None):
+ import params
+
+ Directory(params.config_dir,
+ owner=params.zk_user,
+ create_parents = True,
+ group=params.user_group
+ )
+
+ File(os.path.join(params.config_dir, "zookeeper-env.sh"),
+ content=InlineTemplate(params.zk_env_sh_template),
+ owner=params.zk_user,
+ group=params.user_group
+ )
+
+
+ configFile("zoo.cfg", template_name="zoo.cfg.j2")
+ configFile("configuration.xsl", template_name="configuration.xsl.j2")
+
+ Directory(params.zk_pid_dir,
+ owner=params.zk_user,
+ create_parents = True,
+ group=params.user_group,
+ mode=0755,
+ )
+
+ Directory(params.zk_log_dir,
+ owner=params.zk_user,
+ create_parents = True,
+ group=params.user_group,
+ mode=0755,
+ )
+
+ Directory(params.zk_data_dir,
+ owner=params.zk_user,
+ create_parents = True,
+ cd_access="a",
+ group=params.user_group,
+ mode=0755,
+ )
+
+ if type == 'server':
+ myid = str(sorted(params.zookeeper_hosts).index(params.hostname) + 1)
+
+ File(os.path.join(params.zk_data_dir, "myid"),
+ mode = 0644,
+ content = myid
+ )
+
+ if (params.log4j_props != None):
+ File(os.path.join(params.config_dir, "log4j.properties"),
+ mode=0644,
+ group=params.user_group,
+ owner=params.zk_user,
+ content=InlineTemplate(params.log4j_props)
+ )
+ elif (os.path.exists(os.path.join(params.config_dir, "log4j.properties"))):
+ File(os.path.join(params.config_dir, "log4j.properties"),
+ mode=0644,
+ group=params.user_group,
+ owner=params.zk_user
+ )
+
+ if params.security_enabled:
+ if type == "server":
+ configFile("zookeeper_jaas.conf", template_name="zookeeper_jaas.conf.j2")
+ configFile("zookeeper_client_jaas.conf",
template_name="zookeeper_client_jaas.conf.j2")
+ else:
+ configFile("zookeeper_client_jaas.conf",
template_name="zookeeper_client_jaas.conf.j2")
+
+ File(os.path.join(params.config_dir, "zoo_sample.cfg"),
+ owner=params.zk_user,
+ group=params.user_group
+ )
+
+@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
+def zookeeper(type = None, upgrade_type=None):
+ import params
+ configFile("zoo.cfg", template_name="zoo.cfg.j2", mode="f")
+ configFile("configuration.xsl", template_name="configuration.xsl.j2",
mode="f")
+
+ ServiceConfig(params.zookeeper_win_service_name,
+ action="change_user",
+ username = params.zk_user,
+ password = Script.get_password(params.zk_user))
+
+
+ Directory(params.zk_data_dir,
+ owner=params.zk_user,
+ mode="(OI)(CI)F",
+ create_parents = True
+ )
+ if (params.log4j_props != None):
+ File(os.path.join(params.config_dir, "log4j.properties"),
+ mode="f",
+ owner=params.zk_user,
+ content=params.log4j_props
+ )
+ elif (os.path.exists(os.path.join(params.config_dir, "log4j.properties"))):
+ File(os.path.join(params.config_dir, "log4j.properties"),
+ mode="f",
+ owner=params.zk_user
+ )
+ if type == 'server':
+ myid = str(sorted(params.zookeeper_hosts).index(params.hostname) + 1)
+ File(os.path.join(params.zk_data_dir, "myid"),
+ owner=params.zk_user,
+ mode = "f",
+ content = myid
+ )
+
+def configFile(name, template_name=None, mode=None):
+ import params
+
+ File(os.path.join(params.config_dir, name),
+ content=Template(template_name),
+ owner=params.zk_user,
+ group=params.user_group,
+ mode=mode
+ )
+
+
+
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_client.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_client.py
new file mode 100644
index 00000000..39daea41
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_client.py
@@ -0,0 +1,81 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+
+import sys
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions import stack_select
+from resource_management.libraries.functions.constants import StackFeature
+from resource_management.libraries.functions.version import
format_stack_version
+from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions.stack_features import
check_stack_feature
+from resource_management.core.logger import Logger
+from resource_management.core.exceptions import ClientComponentHasNoStatus
+from ambari_commons import OSConst
+from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+
+from zookeeper import zookeeper
+
+class ZookeeperClient(Script):
+ def configure(self, env):
+ import params
+ env.set_params(params)
+ zookeeper(type='client')
+ pass
+
+ def start(self, env, upgrade_type=None):
+ import params
+ env.set_params(params)
+ self.configure(env)
+ pass
+
+ def stop(self, env, upgrade_type=None):
+ import params
+ env.set_params(params)
+ pass
+
+ def status(self, env):
+ raise ClientComponentHasNoStatus()
+
+@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
+class ZookeeperClientLinux(ZookeeperClient):
+
+ def install(self, env):
+ self.install_packages(env)
+ self.configure(env)
+
+ def pre_upgrade_restart(self, env, upgrade_type=None):
+ Logger.info("Executing Stack Upgrade pre-restart")
+ import params
+ env.set_params(params)
+
+ if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE,
format_stack_version(params.version)):
+ stack_select.select_packages(params.version)
+
+@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
+class ZookeeperClientWindows(ZookeeperClient):
+ def install(self, env):
+ # client checks env var to determine if it is installed
+ if not os.environ.has_key("ZOOKEEPER_HOME"):
+ self.install_packages(env)
+ self.configure(env)
+
+if __name__ == "__main__":
+ ZookeeperClient().execute()
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_server.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_server.py
new file mode 100644
index 00000000..f0e4ab91
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_server.py
@@ -0,0 +1,138 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+import random
+
+from ambari_commons.constants import UPGRADE_TYPE_NON_ROLLING
+
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions import get_unique_id_and_date
+from resource_management.libraries.functions import stack_select
+from resource_management.libraries.functions import StackFeature
+from resource_management.libraries.functions.version import
format_stack_version
+from resource_management.libraries.functions.stack_features import
check_stack_feature
+from resource_management.libraries.functions.security_commons import
build_expectations, \
+ cached_kinit_executor, get_params_from_filesystem,
validate_security_config_properties, \
+ FILE_TYPE_JAAS_CONF
+from resource_management.core import shell
+from resource_management.core.logger import Logger
+from resource_management.libraries.functions.check_process_status import
check_process_status
+from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions.validate import
call_and_match_output
+from zookeeper import zookeeper
+from zookeeper_service import zookeeper_service
+from ambari_commons import OSConst
+from ambari_commons.os_family_impl import OsFamilyImpl
+
+
+class ZookeeperServer(Script):
+
+ def configure(self, env, upgrade_type=None):
+ import params
+ env.set_params(params)
+ zookeeper(type='server', upgrade_type=upgrade_type)
+
+ def start(self, env, upgrade_type=None):
+ import params
+ env.set_params(params)
+ self.configure(env, upgrade_type=upgrade_type)
+ zookeeper_service(action='start', upgrade_type=upgrade_type)
+
+ def stop(self, env, upgrade_type=None):
+ import params
+ env.set_params(params)
+ zookeeper_service(action='stop', upgrade_type=upgrade_type)
+
+@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
+class ZookeeperServerLinux(ZookeeperServer):
+
+ def install(self, env):
+ self.install_packages(env)
+ self.configure(env)
+
+ def pre_upgrade_restart(self, env, upgrade_type=None):
+ Logger.info("Executing Stack Upgrade pre-restart")
+ import params
+ env.set_params(params)
+
+ if check_stack_feature(StackFeature.ROLLING_UPGRADE,
format_stack_version(params.version)):
+ stack_select.select_packages(params.version)
+
+ def post_upgrade_restart(self, env, upgrade_type=None):
+ # during an express upgrade, there is no quorum, so don't try to perform
the check
+ if upgrade_type == UPGRADE_TYPE_NON_ROLLING:
+ return
+
+ Logger.info("Executing Stack Upgrade post-restart")
+ import params
+ env.set_params(params)
+ zk_server_host = random.choice(params.zookeeper_hosts)
+ cli_shell = format("{zk_cli_shell} -server {zk_server_host}:{client_port}")
+ # Ensure that a quorum is still formed.
+ unique = get_unique_id_and_date()
+ create_command = format("echo 'create /{unique} mydata' | {cli_shell}")
+ list_command = format("echo 'ls /' | {cli_shell}")
+ delete_command = format("echo 'delete /{unique} ' | {cli_shell}")
+
+ quorum_err_message = "Failed to establish zookeeper quorum"
+ call_and_match_output(create_command, 'Created', quorum_err_message,
user=params.zk_user)
+ call_and_match_output(list_command, r"\[.*?" + unique + ".*?\]",
quorum_err_message, user=params.zk_user)
+ shell.call(delete_command, user=params.zk_user)
+
+ if params.client_port:
+ check_leader_command = format("echo stat | nc localhost {client_port} |
grep Mode")
+ code, out = shell.call(check_leader_command, logoutput=False)
+ if code == 0 and out:
+ Logger.info(out)
+
+ def status(self, env):
+ import status_params
+ env.set_params(status_params)
+ check_process_status(status_params.zk_pid_file)
+
+ def get_log_folder(self):
+ import params
+ return params.zk_log_dir
+
+ def get_user(self):
+ import params
+ return params.zk_user
+
+ def get_pid_files(self):
+ import status_params
+ return [status_params.zk_pid_file]
+
+
+@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
+class ZookeeperServerWindows(ZookeeperServer):
+ def install(self, env):
+ from resource_management.libraries.functions.windows_service_utils import
check_windows_service_exists
+ import params
+ if not check_windows_service_exists(params.zookeeper_win_service_name):
+ self.install_packages(env)
+ self.configure(env)
+
+ def status(self, env):
+ from resource_management.libraries.functions.windows_service_utils import
check_windows_service_status
+ import status_params
+ check_windows_service_status(status_params.zookeeper_win_service_name)
+
+if __name__ == "__main__":
+ ZookeeperServer().execute()
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_service.py
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_service.py
new file mode 100644
index 00000000..441483f3
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/scripts/zookeeper_service.py
@@ -0,0 +1,72 @@
+"""
+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.
+
+Ambari Agent
+
+"""
+
+from ambari_commons import OSConst
+from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions.show_logs import show_logs
+from resource_management.core.resources.system import Execute, File
+from resource_management.core.resources.service import Service
+
+@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
+def zookeeper_service(action='start', upgrade_type=None):
+ import params
+
+ cmd = format("env ZOOCFGDIR={config_dir} ZOOCFG=zoo.cfg
{zk_bin}/zkServer.sh")
+
+ if action == 'start':
+ daemon_cmd = format("source {config_dir}/zookeeper-env.sh ; {cmd} start")
+ no_op_test = format("ls {zk_pid_file} >/dev/null 2>&1 && ps -p `cat
{zk_pid_file}` >/dev/null 2>&1")
+
+ try:
+ Execute(daemon_cmd,
+ not_if=no_op_test,
+ user=params.zk_user
+ )
+ except:
+ show_logs(params.zk_log_dir, params.zk_user)
+ raise
+
+ if params.security_enabled:
+ kinit_cmd = format("{kinit_path_local} -kt {smoke_user_keytab}
{smokeuser_principal};")
+
+ Execute(kinit_cmd,
+ user=params.smokeuser
+ )
+
+ elif action == 'stop':
+ daemon_cmd = format("source {config_dir}/zookeeper-env.sh ; {cmd} stop")
+ try:
+ Execute(daemon_cmd,
+ user=params.zk_user
+ )
+ except:
+ show_logs(params.zk_log_dir, params.zk_user)
+ raise
+ File(params.zk_pid_file, action="delete")
+
+@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
+def zookeeper_service(action='start', rolling_restart=False):
+ import params
+ if action == 'start':
+ Service(params.zookeeper_win_service_name, action="start")
+ elif action == 'stop':
+ Service(params.zookeeper_win_service_name, action="stop")
\ 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/ZOOKEEPER/package/templates/configuration.xsl.j2
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/configuration.xsl.j2
new file mode 100644
index 00000000..8830c45e
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/configuration.xsl.j2
@@ -0,0 +1,42 @@
+{#
+# 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.
+#}
+
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html"/>
+<xsl:template match="configuration">
+<html>
+<body>
+<table border="1">
+<tr>
+ <td>name</td>
+ <td>value</td>
+ <td>description</td>
+</tr>
+<xsl:for-each select="property">
+ <tr>
+ <td><a name="{name}"><xsl:value-of select="name"/></a></td>
+ <td><xsl:value-of select="value"/></td>
+ <td><xsl:value-of select="description"/></td>
+ </tr>
+</xsl:for-each>
+</table>
+</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/input.config-zookeeper.json.j2
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/input.config-zookeeper.json.j2
new file mode 100644
index 00000000..cc20847f
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/input.config-zookeeper.json.j2
@@ -0,0 +1,46 @@
+{#
+ # 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":"zookeeper",
+ "rowtype":"service",
+ "path":"{{default('/configurations/zookeeper-env/zk_log_dir',
'/var/log/zookeeper')}}/zookeeper*.log"
+ }
+ ],
+ "filter":[
+ {
+ "filter":"grok",
+ "conditions":{
+ "fields":{
+ "type":["zookeeper"]
+ }
+ },
+ "log4j_format":"%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n",
+ "multiline_pattern":"^(%{TIMESTAMP_ISO8601:logtime})",
+
"message_pattern":"(?m)^%{TIMESTAMP_ISO8601:logtime}%{SPACE}-%{SPACE}%{LOGLEVEL:level}%{SPACE}\\[%{DATA:thread_name}\\@%{INT:line_number}\\]%{SPACE}-%{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/ZOOKEEPER/package/templates/zoo.cfg.j2
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zoo.cfg.j2
new file mode 100644
index 00000000..ffcc58ad
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zoo.cfg.j2
@@ -0,0 +1,55 @@
+{#
+# 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.
+#}
+
+#
+#
+# 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.
+#
+#
+#
+
+{% for key, value in zoo_cfg_properties_map.iteritems() -%}
+ {{key}}={{value}}
+{% endfor %}
+{% for host in zookeeper_hosts -%}
+server.{{loop.index}}={{host}}:2888:3888
+{% endfor %}
+
+4lw.commands.whitelist=*
+
+{% if security_enabled -%}
+authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
+jaasLoginRenew=3600000
+kerberos.removeHostFromPrincipal=true
+kerberos.removeRealmFromPrincipal=true
+{% endif %}
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zookeeper_client_jaas.conf.j2
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zookeeper_client_jaas.conf.j2
new file mode 100644
index 00000000..38f9721b
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zookeeper_client_jaas.conf.j2
@@ -0,0 +1,23 @@
+{#
+# 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.
+#}
+
+Client {
+com.sun.security.auth.module.Krb5LoginModule required
+useKeyTab=false
+useTicketCache=true;
+};
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zookeeper_jaas.conf.j2
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zookeeper_jaas.conf.j2
new file mode 100644
index 00000000..c3e95056
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/package/templates/zookeeper_jaas.conf.j2
@@ -0,0 +1,26 @@
+{#
+# 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.
+#}
+
+Server {
+com.sun.security.auth.module.Krb5LoginModule required
+useKeyTab=true
+storeKey=true
+useTicketCache=false
+keyTab="{{zk_keytab_path}}"
+principal="{{zk_principal}}";
+};
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/role_command_order.json
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/role_command_order.json
new file mode 100644
index 00000000..94bf7861
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/role_command_order.json
@@ -0,0 +1,9 @@
+{
+ "general_deps" : {
+ "_comment" : "dependencies for ZOOKEEPER",
+ "ZOOKEEPER_SERVICE_CHECK-SERVICE_CHECK": ["ZOOKEEPER_SERVER-START"],
+ "ZOOKEEPER_QUORUM_SERVICE_CHECK-SERVICE_CHECK": ["ZOOKEEPER_SERVER-START"],
+ "ZOOKEEPER_SERVER-STOP" : ["HBASE_MASTER-STOP", "HBASE_REGIONSERVER-STOP",
"METRICS_COLLECTOR-STOP"]
+
+ }
+}
diff --git
a/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/themes/directories.json
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/themes/directories.json
new file mode 100644
index 00000000..b234e977
--- /dev/null
+++
b/bigtop-packages/src/common/bigtop-ambari-mpack/bgtp-ambari-mpack/src/main/resources/stacks/BGTP/1.0/services/ZOOKEEPER/themes/directories.json
@@ -0,0 +1,117 @@
+{
+ "name": "directories",
+ "description": "Directories theme for ZOOKEEPER service",
+ "configuration": {
+ "layouts": [
+ {
+ "name": "directories",
+ "tabs": [
+ {
+ "name": "directories",
+ "display-name": "Directories",
+ "layout": {
+ "tab-columns": "1",
+ "tab-rows": "4",
+ "sections": [
+ {
+ "name": "subsection-data-dirs",
+ "display-name": "DATA DIRS",
+ "row-index": "0",
+ "column-index": "0",
+ "row-span": "1",
+ "column-span": "1",
+ "section-columns": "1",
+ "section-rows": "1",
+ "subsections": [
+ {
+ "name": "subsection-data-dirs",
+ "row-index": "0",
+ "column-index": "0",
+ "row-span": "1",
+ "column-span": "1"
+ }
+ ]
+ },
+ {
+ "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": "zoo.cfg/dataDir",
+ "subsection-name": "subsection-data-dirs"
+ },
+ {
+ "config": "zookeeper-env/zk_log_dir",
+ "subsection-name": "subsection-log-dirs"
+ },
+ {
+ "config": "zookeeper-env/zk_pid_dir",
+ "subsection-name": "subsection-pid-dirs"
+ }
+ ]
+ },
+ "widgets": [
+ {
+ "config": "zoo.cfg/dataDir",
+ "widget": {
+ "type": "text-field"
+ }
+ },
+ {
+ "config": "zookeeper-env/zk_log_dir",
+ "widget": {
+ "type": "text-field"
+ }
+ },
+ {
+ "config": "zookeeper-env/zk_pid_dir",
+ "widget": {
+ "type": "text-field"
+ }
+ }
+ ]
+ }
+}