You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2013/11/28 17:16:52 UTC
git commit: AMBARI-3778. Oozie on HDP2. Using resource management lib
(Andrew Onischuk via dlysnichenko)
Updated Branches:
refs/heads/trunk c0f0abd68 -> 4de106385
AMBARI-3778. Oozie on HDP2. Using resource management lib (Andrew Onischuk via dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4de10638
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4de10638
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4de10638
Branch: refs/heads/trunk
Commit: 4de1063853751bdd3c460014aba46512e373721f
Parents: c0f0abd
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Nov 28 17:38:58 2013 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Nov 28 18:16:38 2013 +0200
----------------------------------------------------------------------
.../libraries/functions/__init__.py | 4 +-
.../libraries/functions/default.py | 7 +-
.../libraries/functions/get_kinit_path.py | 20 ++++
.../functions/get_unique_id_and_date.py | 12 +++
.../services/HBASE/package/scripts/params.py | 8 +-
.../HDP/2.0._/services/OOZIE/metainfo.xml | 69 +++++++++++---
.../services/OOZIE/package/files/oozieSmoke2.sh | 95 +++++++++++++++++++
.../OOZIE/package/files/wrap_ooziedb.sh | 31 ++++++
.../services/OOZIE/package/scripts/oozie.py | 99 ++++++++++++++++++++
.../OOZIE/package/scripts/oozie_client.py | 30 ++++++
.../OOZIE/package/scripts/oozie_server.py | 44 +++++++++
.../OOZIE/package/scripts/oozie_service.py | 44 +++++++++
.../services/OOZIE/package/scripts/params.py | 55 +++++++++++
.../OOZIE/package/scripts/service_check.py | 42 +++++++++
.../OOZIE/package/templates/oozie-env.sh.j2 | 64 +++++++++++++
.../package/templates/oozie-log4j.properties.j2 | 74 +++++++++++++++
16 files changed, 677 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-agent/src/main/python/resource_management/libraries/functions/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/functions/__init__.py b/ambari-agent/src/main/python/resource_management/libraries/functions/__init__.py
index 122ff77..5cce150 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/functions/__init__.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/functions/__init__.py
@@ -21,4 +21,6 @@ Ambari Agent
"""
from resource_management.libraries.functions.default import *
-from resource_management.libraries.functions.format import *
\ No newline at end of file
+from resource_management.libraries.functions.format import *
+from resource_management.libraries.functions.get_kinit_path import *
+from resource_management.libraries.functions.get_unique_id_and_date import *
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-agent/src/main/python/resource_management/libraries/functions/default.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/functions/default.py b/ambari-agent/src/main/python/resource_management/libraries/functions/default.py
index 80c6585..3a2665a 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/functions/default.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/functions/default.py
@@ -21,9 +21,11 @@ Ambari Agent
"""
__all__ = ["default"]
-
+import logging
from resource_management.libraries.script import Script
+
default_subdict='/configurations/global'
+log = logging.getLogger('resource_management')
def default(name, default_value=None):
subdicts = filter(None, name.split('/'))
@@ -36,6 +38,7 @@ def default(name, default_value=None):
if x in curr_dict:
curr_dict = curr_dict[x]
else:
+ log.debug("Cannot find configuration: '%s'. Using '%s' value as default" % (name, default_value))
return default_value
- return curr_dict
+ return curr_dict
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-agent/src/main/python/resource_management/libraries/functions/get_kinit_path.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/functions/get_kinit_path.py b/ambari-agent/src/main/python/resource_management/libraries/functions/get_kinit_path.py
new file mode 100644
index 0000000..e2daa58
--- /dev/null
+++ b/ambari-agent/src/main/python/resource_management/libraries/functions/get_kinit_path.py
@@ -0,0 +1,20 @@
+__all__ = ["get_kinit_path"]
+import os
+
+def get_kinit_path(pathes_list):
+ """
+ @param pathes: comma separated list
+ """
+ kinit_path = ""
+
+ for x in pathes_list:
+ if not x:
+ continue
+
+ path = os.path.join(x,"kinit")
+
+ if os.path.isfile(path):
+ kinit_path = path
+ break
+
+ return kinit_path
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-agent/src/main/python/resource_management/libraries/functions/get_unique_id_and_date.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/functions/get_unique_id_and_date.py b/ambari-agent/src/main/python/resource_management/libraries/functions/get_unique_id_and_date.py
new file mode 100644
index 0000000..3bafdbf
--- /dev/null
+++ b/ambari-agent/src/main/python/resource_management/libraries/functions/get_unique_id_and_date.py
@@ -0,0 +1,12 @@
+__all__ = ["get_unique_id_and_date"]
+import datetime
+from resource_management.core.shell import checked_call
+
+def get_unique_id_and_date():
+ code, out = checked_call("hostid")
+ id = out.strip()
+
+ now = datetime.datetime.now()
+ date = now.strftime("%M%d%y")
+
+ return "id{id}_date{date}".format(id=id, date=date)
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/HBASE/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/HBASE/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/HBASE/package/scripts/params.py
index b1988d4..4ff208c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/HBASE/package/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/HBASE/package/scripts/params.py
@@ -57,7 +57,7 @@ rs_hosts = default('hbase_rs_hosts', config['clusterHostInfo']['slave_hosts']) #
smoke_test_user = config['configurations']['global']['smokeuser']
smokeuser_permissions = default('smokeuser_permissions', "RWXCA")
-service_check_data = functions.get_unique_id_and_date()
+service_check_data = get_unique_id_and_date()
if security_enabled:
@@ -75,11 +75,11 @@ if security_enabled:
master_jaas_princ = format("{_master_principal_name}@{_kerberos_domain}")
regionserver_jaas_princ = format("{_regionserver_primary_name}@{_kerberos_domain}")
-master_keytab_path = default('configurations/hbase-site/hbase.master.keytab.file')
+master_keytab_path = default('/configurations/hbase-site/hbase.master.keytab.file')
regionserver_keytab_path = default('/configurations/hbase-site/hbase.regionserver.keytab.file')
smoke_user_keytab = default('smokeuser_keytab')
hbase_user_keytab = default('hbase_user_keytab')
-kinit_path_local = functions.get_kinit_path([default('kinit_path_local'),"/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
+kinit_path_local = get_kinit_path([default('kinit_path_local'),"/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
# fix exeuteHadoop calls for secured cluster
-# to string template...
+# to string template...
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/metainfo.xml
index 515e669..50209f0 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/metainfo.xml
@@ -16,23 +16,64 @@
limitations under the License.
-->
<metainfo>
- <user>root</user>
- <comment>System for workflow coordination and execution of Apache Hadoop jobs. This also includes the installation of the optional Oozie Web Console which relies on and will install the <a target="_blank" href="http://www.sencha.com/products/extjs/license/">ExtJS</a> Library.</comment>
- <version>4.0.0.2.0.6.0</version>
-
- <components>
+ <schemaVersion>2.0</schemaVersion>
+ <services>
+ <service>
+ <name>OOZIE</name>
+ <comment>System for workflow coordination and execution of Apache Hadoop jobs. This also includes the installation of the optional Oozie Web Console which relies on and will install the <a target="_blank" href="http://www.sencha.com/products/extjs/license/">ExtJS</a> Library.
+ </comment>
+ <version>4.0.0.2.0.6.0</version>
+ <components>
<component>
- <name>OOZIE_SERVER</name>
- <category>MASTER</category>
+ <name>OOZIE_SERVER</name>
+ <category>MASTER</category>
+ <commandScript>
+ <script>scripts/oozie_server.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>600</timeout>
+ </commandScript>
</component>
<component>
- <name>OOZIE_CLIENT</name>
- <category>CLIENT</category>
+ <name>OOZIE_CLIENT</name>
+ <category>CLIENT</category>
+ <commandScript>
+ <script>scripts/oozie_client.py</script>
+ <scriptType>PYTHON</scriptType>
+ </commandScript>
</component>
- </components>
- <configuration-dependencies>
- <config-type>global</config-type>
- <config-type>oozie-site</config-type>
- </configuration-dependencies>
+ </components>
+
+ <osSpecifics>
+ <osSpecific>
+ <osType>centos6</osType>
+ <packages>
+ <package>
+ <type>rpm</type>
+ <name>oozie.noarch</name>
+ </package>
+ <package>
+ <type>rpm</type>
+ <name>oozie-client.noarch</name>
+ </package>
+ <package>
+ <type>rpm</type>
+ <name>extjs-2.2-1</name>
+ </package>
+ </packages>
+ </osSpecific>
+ </osSpecifics>
+
+ <commandScript>
+ <script>scripts/service_check.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>300</timeout>
+ </commandScript>
+
+ <configuration-dependencies>
+ <config-type>global</config-type>
+ <config-type>oozie-site</config-type>
+ </configuration-dependencies>
+ </service>
+ </services>
</metainfo>
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/oozieSmoke2.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/oozieSmoke2.sh b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/oozieSmoke2.sh
new file mode 100644
index 0000000..2cb5a7a
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/oozieSmoke2.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+#
+#
+# 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.
+#
+#
+function getValueFromField {
+ xmllint $1 | grep "<name>$2</name>" -C 2 | grep '<value>' | cut -d ">" -f2 | cut -d "<" -f1
+ return $?
+}
+
+function checkOozieJobStatus {
+ local job_id=$1
+ local num_of_tries=$2
+ #default num_of_tries to 10 if not present
+ num_of_tries=${num_of_tries:-10}
+ local i=0
+ local rc=1
+ local cmd="source ${oozie_conf_dir}/oozie-env.sh ; /usr/bin/oozie job -oozie ${OOZIE_SERVER} -info $job_id"
+ su - ${smoke_test_user} -c "$cmd"
+ while [ $i -lt $num_of_tries ] ; do
+ cmd_output=`su - ${smoke_test_user} -c "$cmd"`
+ (IFS='';echo $cmd_output)
+ act_status=$(IFS='';echo $cmd_output | grep ^Status | cut -d':' -f2 | sed 's| ||g')
+ echo "workflow_status=$act_status"
+ if [ "RUNNING" == "$act_status" ]; then
+ #increment the couner and get the status again after waiting for 15 secs
+ sleep 15
+ (( i++ ))
+ elif [ "SUCCEEDED" == "$act_status" ]; then
+ rc=0;
+ break;
+ else
+ rc=1
+ break;
+ fi
+ done
+ return $rc
+}
+
+export oozie_conf_dir=$1
+export hadoop_conf_dir=$2
+export smoke_test_user=$3
+export security_enabled=$4
+export smoke_user_keytab=$5
+export kinit_path_local=$6
+
+export OOZIE_EXIT_CODE=0
+export JOBTRACKER=`getValueFromField ${hadoop_conf_dir}/yarn-site.xml yarn.resourcemanager.address`
+export NAMENODE=`getValueFromField ${hadoop_conf_dir}/core-site.xml fs.defaultFS`
+export OOZIE_SERVER=`getValueFromField ${oozie_conf_dir}/oozie-site.xml oozie.base.url | tr '[:upper:]' '[:lower:]'`
+export OOZIE_EXAMPLES_DIR=`rpm -ql oozie-client | grep 'oozie-examples.tar.gz$' | xargs dirname`
+cd $OOZIE_EXAMPLES_DIR
+
+tar -zxf oozie-examples.tar.gz
+sed -i "s|nameNode=hdfs://localhost:8020|nameNode=$NAMENODE|g" examples/apps/map-reduce/job.properties
+sed -i "s|nameNode=hdfs://localhost:9000|nameNode=$NAMENODE|g" examples/apps/map-reduce/job.properties
+sed -i "s|jobTracker=localhost:8021|jobTracker=$JOBTRACKER|g" examples/apps/map-reduce/job.properties
+sed -i "s|jobTracker=localhost:9001|jobTracker=$JOBTRACKER|g" examples/apps/map-reduce/job.properties
+sed -i "s|jobTracker=localhost:8032|jobTracker=$JOBTRACKER|g" examples/apps/map-reduce/job.properties
+sed -i "s|oozie.wf.application.path=hdfs://localhost:9000|oozie.wf.application.path=$NAMENODE|g" examples/apps/map-reduce/job.properties
+
+if [[ $security_enabled == "true" ]]; then
+ kinitcmd="${kinit_path_local} -kt ${smoke_user_keytab} ${smoke_test_user}; "
+else
+ kinitcmd=""
+fi
+
+su - ${smoke_test_user} -c "hdfs dfs -rm -r examples"
+su - ${smoke_test_user} -c "hdfs dfs -rm -r input-data"
+su - ${smoke_test_user} -c "hdfs dfs -copyFromLocal $OOZIE_EXAMPLES_DIR/examples examples"
+su - ${smoke_test_user} -c "hdfs dfs -copyFromLocal $OOZIE_EXAMPLES_DIR/examples/input-data input-data"
+
+cmd="${kinitcmd}source ${oozie_conf_dir}/oozie-env.sh ; /usr/bin/oozie -Doozie.auth.token.cache=false job -oozie $OOZIE_SERVER -config $OOZIE_EXAMPLES_DIR/examples/apps/map-reduce/job.properties -run"
+echo $cmd
+job_info=`su - ${smoke_test_user} -c "$cmd" | grep "job:"`
+job_id="`echo $job_info | cut -d':' -f2`"
+checkOozieJobStatus "$job_id"
+OOZIE_EXIT_CODE="$?"
+exit $OOZIE_EXIT_CODE
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/wrap_ooziedb.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/wrap_ooziedb.sh b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/wrap_ooziedb.sh
new file mode 100644
index 0000000..97a513c
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/files/wrap_ooziedb.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+#
+# 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.
+#
+#
+OUT=`cd /var/tmp/oozie && /usr/lib/oozie/bin/ooziedb.sh "$@" 2>&1`
+EC=$?
+echo $OUT
+GRVAR=`echo ${OUT} | grep -o "java.lang.Exception: DB schema exists"`
+if [ ${EC} -ne 0 ] && [ -n "$GRVAR" ]
+then
+ exit 0
+else
+ exit $EC
+fi
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie.py
new file mode 100644
index 0000000..88be4ae
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie.py
@@ -0,0 +1,99 @@
+from resource_management import *
+
+def oozie(is_server=False # TODO: see if see can remove this
+ ):
+ import params
+
+ XmlConfig( "oozie-site.xml",
+ conf_dir = params.conf_dir,
+ configurations = params.config['configurations']['oozie-site'],
+ owner = params.oozie_user,
+ group = params.user_group,
+ mode = 0664
+ )
+
+ Directory( params.conf_dir,
+ owner = params.oozie_user,
+ group = params.user_group
+ )
+
+ TemplateConfig( format("{conf_dir}/oozie-env.sh"),
+ owner = params.oozie_user
+ )
+
+ TemplateConfig( format("{conf_dir}/oozie-log4j.properties"),
+ owner = params.oozie_user
+ )
+
+ if params.jdbc_driver_name == "com.mysql.jdbc.Driver" or params.jdbc_driver_name == "oracle.jdbc.driver.OracleDriver":
+ Execute(format("/bin/sh -c 'cd /usr/lib/ambari-agent/ &&\
+ curl -kf --retry 5 {jdk_location}{check_db_connection_jar_name}\
+ -o {check_db_connection_jar_name}'"),
+ not_if = format("[ -f {check_db_connection_jar} ]")
+ )
+
+ oozie_ownership( )
+
+ if is_server:
+ oozie_server_specific( )
+
+def oozie_ownership(
+):
+ import params
+
+ File ( format("{conf_dir}/adminusers.txt"),
+ owner = params.oozie_user,
+ group = params.user_group
+ )
+
+ File ( format("{conf_dir}/hadoop-config.xml"),
+ owner = params.oozie_user,
+ group = params.user_group
+ )
+
+ File ( format("{conf_dir}/oozie-default.xml"),
+ owner = params.oozie_user,
+ group = params.user_group
+ )
+
+ Directory ( format("{conf_dir}/action-conf"),
+ owner = params.oozie_user,
+ group = params.user_group
+ )
+
+ File ( format("{conf_dir}/action-conf/hive.xml"),
+ owner = params.oozie_user,
+ group = params.user_group
+ )
+
+def oozie_server_specific(
+):
+ import params
+
+ oozie_server_directorties = [params.oozie_pid_dir, params.oozie_log_dir, params.oozie_tmp_dir, params.oozie_data_dir, params.oozie_lib_dir, params.oozie_webapps_dir]
+ Directory( oozie_server_directorties,
+ owner = params.oozie_user,
+ mode = 0755,
+ recursive = True
+ )
+
+ cmd1 = "cd /usr/lib/oozie && tar -xvf oozie-sharelib.tar.gz"
+ cmd2 = format("cd /usr/lib/oozie && mkdir -p {oozie_tmp_dir}")
+
+ # this is different for HDP1
+ cmd3 = format("cd /usr/lib/oozie && chown {oozie_user}:{user_group} {oozie_tmp_dir} && mkdir -p {oozie_libext_dir} && cp {ext_js_path} {oozie_libext_dir}")
+ if params.jdbc_driver_name=="com.mysql.jdbc.Driver" or params.jdbc_driver_name=="oracle.jdbc.driver.OracleDriver":
+ cmd3 += format(" && cp {jdbc_driver_jar} {oozie_libext_dir}")
+
+ # this is different for HDP1
+ cmd4 = format("cd {oozie_tmp_dir} && /usr/lib/oozie/bin/oozie-setup.sh prepare-war")
+
+ no_op_test = format("ls {pid_file} >/dev/null 2>&1 && ps `cat {pid_file}` >/dev/null 2>&1")
+ Execute( [cmd1, cmd2, cmd3],
+ not_if = no_op_test
+ )
+ Execute( cmd4,
+ user = params.oozie_user,
+ not_if = no_op_test
+ )
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_client.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_client.py
new file mode 100644
index 0000000..017d46c
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_client.py
@@ -0,0 +1,30 @@
+import sys
+from resource_management import *
+
+from oozie import oozie
+from oozie_service import oozie_service
+
+
+class OozieClient(Script):
+ def install(self, env):
+ Package('oozie-client.noarch')
+ self.configure(env)
+
+ def configure(self, env):
+ import params
+ env.set_params(params)
+
+ oozie(is_server=False)
+
+def main():
+ command_type = sys.argv[1] if len(sys.argv)>1 else "install"
+ print "Running "+command_type
+ command_data_file = '/root/workspace/Oozie/input.json'
+ basedir = '/root/workspace/Oozie/main'
+ sys.argv = ["", command_type, command_data_file, basedir]
+
+ OozieClient().execute()
+
+if __name__ == "__main__":
+ #main()
+ OozieClient().execute()
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_server.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_server.py
new file mode 100644
index 0000000..d4d8401
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_server.py
@@ -0,0 +1,44 @@
+import sys
+from resource_management import *
+
+from oozie import oozie
+from oozie_service import oozie_service
+
+
+class OozieServer(Script):
+ def install(self, env):
+ Package('oozie.noarch')
+ Package('oozie-client.noarch')
+ Package('extjs-2.2-1')
+ self.configure(env)
+
+ def configure(self, env):
+ import params
+ env.set_params(params)
+
+ oozie(is_server=True)
+
+ def start(self, env):
+ import params
+ env.set_params(params)
+
+ oozie_service(action='start')
+
+ def stop(self, env):
+ import params
+ env.set_params(params)
+
+ oozie_service(action='stop')
+
+def main():
+ command_type = sys.argv[1] if len(sys.argv)>1 else "start"
+ print "Running "+command_type
+ command_data_file = '/root/workspace/Oozie/input.json'
+ basedir = '/root/workspace/Oozie/main'
+ sys.argv = ["", command_type, command_data_file, basedir]
+
+ OozieServer().execute()
+
+if __name__ == "__main__":
+ #main()
+ OozieServer().execute()
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
new file mode 100644
index 0000000..1f6096b
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
@@ -0,0 +1,44 @@
+from resource_management import *
+
+def oozie_service(action = 'start'): # 'start' or 'stop'
+ import params
+
+ kinit_if_needed = format("{kinit_path_local} -kt {oozie_keytab} {oozie_principal};") if params.security_enabled else ""
+ no_op_test = format("ls {pid_file} >/dev/null 2>&1 && ps `cat {pid_file}` >/dev/null 2>&1")
+
+ if action == 'start':
+ start_cmd = format("su - {oozie_user} -c 'cd {oozie_tmp_dir} && /usr/lib/oozie/bin/oozie-start.sh'")
+
+ if params.jdbc_driver_name == "com.mysql.jdbc.Driver" or params.jdbc_driver_name == "oracle.jdbc.driver.OracleDriver":
+ db_connection_check_command = format("{java_home}/bin/java -cp {check_db_connection_jar}:{jdbc_driver_jar} org.apache.ambari.server.DBConnectionVerification {oozie_jdbc_connection_url} {oozie_metastore_user_name} {oozie_metastore_user_passwd} {jdbc_driver_name}")
+ else:
+ db_connection_check_command = None
+
+ cmd1 = format("cd {oozie_tmp_dir} && /usr/lib/oozie/bin/ooziedb.sh create -sqlfile oozie.sql -run")
+ cmd2 = format("{kinit_if_needed} hadoop dfs -put /usr/lib/oozie/share {oozie_hdfs_user_dir} ; hadoop dfs -chmod -R 755 {oozie_hdfs_user_dir}/share")
+
+ if db_connection_check_command:
+ Execute( db_connection_check_command)
+
+ Execute( cmd1,
+ user = params.oozie_user,
+ not_if = no_op_test,
+ ignore_failures = True
+ )
+
+ Execute( cmd2,
+ user = params.oozie_user,
+ not_if = format("{kinit_if_needed} hadoop dfs -ls /user/oozie/share | awk 'BEGIN {{count=0;}} /share/ {{count++}} END {{if (count > 0) {{exit 0}} else {{exit 1}}}}'")
+ )
+
+ Execute( start_cmd,
+ not_if = no_op_test
+ )
+ elif action == 'stop':
+ stop_cmd = format("su - {oozie_user} -c 'cd {oozie_tmp_dir} && /usr/lib/oozie/bin/oozie-stop.sh' && rm -f {pid_file}")
+ Execute( stop_cmd,
+ only_if = no_op_test
+ )
+
+
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/params.py
new file mode 100644
index 0000000..8e24cc5
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/params.py
@@ -0,0 +1,55 @@
+from resource_management import *
+
+# server configurations
+config = Script.get_config()
+
+oozie_user = config['configurations']['global']['oozie_user']
+smokeuser = config['configurations']['global']['smokeuser']
+conf_dir = "/etc/oozie/conf"
+hadoop_conf_dir = "/etc/hadoop/conf"
+user_group = config['configurations']['global']['user_group']
+jdk_location = config['hostLevelParams']['jdk_location']
+check_db_connection_jar_name = "DBConnectionVerification.jar"
+check_db_connection_jar = format("/usr/lib/ambari-agent/{check_db_connection_jar_name}")
+hadoop_prefix = "/usr"
+oozie_tmp_dir = "/var/tmp/oozie"
+oozie_hdfs_user_dir = format("/user/{oozie_user}")
+oozie_pid_dir = config['configurations']['global']['oozie_pid_dir']
+pid_file = format("{oozie_pid_dir}/oozie.pid")
+hadoop_jar_location = "/usr/lib/hadoop/"
+# for HDP1 it's "/usr/share/HDP-oozie/ext.zip"
+ext_js_path = "/usr/share/HDP-oozie/ext-2.2.zip"
+oozie_libext_dir = "/usr/lib/oozie/libext"
+lzo_enabled = config['configurations']['global']['lzo_enabled']
+security_enabled = config['configurations']['global']['security_enabled']
+
+kinit_path_local = get_kinit_path([default('kinit_path_local'),"/usr/bin", "/usr/kerberos/bin", "/usr/sbin"])
+oozie_service_keytab = default("/configurations/oozie-site/oozie.service.HadoopAccessorService.keytab.file")
+oozie_principal = default("/configurations/oozie-site/oozie.service.HadoopAccessorService.kerberos.principal")
+smokeuser_keytab = default("/configurations/global/smokeuser_keytab")
+oozie_keytab = default("keytab_path")
+
+oracle_driver_jar_name = "ojdbc6.jar"
+java_share_dir = "/usr/share/java"
+
+java_home = config['configurations']['global']['java64_home']
+oozie_metastore_user_name = config['configurations']['oozie-site']['oozie.service.JPAService.jdbc.username']
+oozie_metastore_user_passwd = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.password","")
+oozie_jdbc_connection_url = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.url", "")
+oozie_log_dir = config['configurations']['global']['oozie_log_dir']
+oozie_data_dir = config['configurations']['global']['oozie_data_dir']
+oozie_lib_dir = "/var/lib/oozie/"
+oozie_webapps_dir = "/var/lib/oozie/oozie-server/webapps/"
+
+jdbc_driver_name = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.driver", "")
+
+if jdbc_driver_name == "com.mysql.jdbc.Driver":
+ jdbc_driver_jar = "/usr/share/java/mysql-connector-java.jar"
+elif jdbc_driver_name == "oracle.jdbc.driver.OracleDriver":
+ jdbc_driver_jar = "/usr/share/java/ojdbc6.jar"
+else:
+ jdbc_driver_jar = ""
+
+
+
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/service_check.py b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/service_check.py
new file mode 100644
index 0000000..068f370
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/service_check.py
@@ -0,0 +1,42 @@
+from resource_management import *
+
+class OozieServiceCheck(Script):
+ def service_check(self, env):
+ import params
+ env.set_params(params)
+
+ # on HDP1 this file is different
+ smoke_test_file_name = 'oozieSmoke2.sh'
+
+ oozie_smoke_shell_file( smoke_test_file_name)
+
+def oozie_smoke_shell_file(
+ file_name
+):
+ import params
+
+ File( format("/tmp/{file_name}"),
+ content = StaticFile(file_name),
+ mode = 0755
+ )
+
+ Execute( format("/tmp/{file_name}"),
+ command = format("sh /tmp/{file_name} {conf_dir} {hadoop_conf_dir} {smokeuser} {security_enabled} {smokeuser_keytab} {kinit_path_local}"),
+ tries = 3,
+ try_sleep = 5,
+ logoutput = True
+ )
+
+def main():
+ import sys
+ command_type = 'service_check'
+ command_data_file = '/root/workspace/Oozie/input.json'
+ basedir = '/root/workspace/Oozie/main'
+ sys.argv = ["", command_type, command_data_file, basedir]
+
+ OozieServiceCheck().execute()
+
+if __name__ == "__main__":
+ OozieServiceCheck().execute()
+ #main()
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-env.sh.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-env.sh.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-env.sh.j2
new file mode 100644
index 0000000..270a1a8
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-env.sh.j2
@@ -0,0 +1,64 @@
+#!/bin/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.
+#
+
+#Set JAVA HOME
+export JAVA_HOME={{java_home}}
+
+# Set Oozie specific environment variables here.
+
+# Settings for the Embedded Tomcat that runs Oozie
+# Java System properties for Oozie should be specified in this variable
+#
+# export CATALINA_OPTS=
+
+# Oozie configuration file to load from Oozie configuration directory
+#
+# export OOZIE_CONFIG_FILE=oozie-site.xml
+
+# Oozie logs directory
+#
+export OOZIE_LOG={{oozie_log_dir}}
+
+# Oozie pid directory
+#
+export CATALINA_PID={{pid_file}}
+
+#Location of the data for oozie
+export OOZIE_DATA={{oozie_data_dir}}
+
+# Oozie Log4J configuration file to load from Oozie configuration directory
+#
+# export OOZIE_LOG4J_FILE=oozie-log4j.properties
+
+# Reload interval of the Log4J configuration file, in seconds
+#
+# export OOZIE_LOG4J_RELOAD=10
+
+# The port Oozie server runs
+#
+# export OOZIE_HTTP_PORT=11000
+
+# The host name Oozie server runs on
+#
+# export OOZIE_HTTP_HOSTNAME=`hostname -f`
+
+# The base URL for callback URLs to Oozie
+#
+# export OOZIE_BASE_URL="http://${OOZIE_HTTP_HOSTNAME}:${OOZIE_HTTP_PORT}/oozie"
+export JAVA_LIBRARY_PATH=/usr/lib/hadoop/lib/native/Linux-amd64-64
http://git-wip-us.apache.org/repos/asf/ambari/blob/4de10638/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-log4j.properties.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-log4j.properties.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-log4j.properties.j2
new file mode 100644
index 0000000..e4a2662
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/templates/oozie-log4j.properties.j2
@@ -0,0 +1,74 @@
+#
+# 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.
+#
+
+# 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. See accompanying LICENSE file.
+#
+
+# If the Java System property 'oozie.log.dir' is not defined at Oozie start up time
+# XLogService sets its value to '${oozie.home}/logs'
+
+log4j.appender.oozie=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.oozie.DatePattern='.'yyyy-MM-dd-HH
+log4j.appender.oozie.File=${oozie.log.dir}/oozie.log
+log4j.appender.oozie.Append=true
+log4j.appender.oozie.layout=org.apache.log4j.PatternLayout
+log4j.appender.oozie.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+log4j.appender.oozieops=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.oozieops.DatePattern='.'yyyy-MM-dd
+log4j.appender.oozieops.File=${oozie.log.dir}/oozie-ops.log
+log4j.appender.oozieops.Append=true
+log4j.appender.oozieops.layout=org.apache.log4j.PatternLayout
+log4j.appender.oozieops.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+log4j.appender.oozieinstrumentation=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.oozieinstrumentation.DatePattern='.'yyyy-MM-dd
+log4j.appender.oozieinstrumentation.File=${oozie.log.dir}/oozie-instrumentation.log
+log4j.appender.oozieinstrumentation.Append=true
+log4j.appender.oozieinstrumentation.layout=org.apache.log4j.PatternLayout
+log4j.appender.oozieinstrumentation.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+log4j.appender.oozieaudit=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.oozieaudit.DatePattern='.'yyyy-MM-dd
+log4j.appender.oozieaudit.File=${oozie.log.dir}/oozie-audit.log
+log4j.appender.oozieaudit.Append=true
+log4j.appender.oozieaudit.layout=org.apache.log4j.PatternLayout
+log4j.appender.oozieaudit.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+log4j.appender.openjpa=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.openjpa.DatePattern='.'yyyy-MM-dd
+log4j.appender.openjpa.File=${oozie.log.dir}/oozie-jpa.log
+log4j.appender.openjpa.Append=true
+log4j.appender.openjpa.layout=org.apache.log4j.PatternLayout
+log4j.appender.openjpa.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
+
+log4j.logger.openjpa=INFO, openjpa
+log4j.logger.oozieops=INFO, oozieops
+log4j.logger.oozieinstrumentation=ALL, oozieinstrumentation
+log4j.logger.oozieaudit=ALL, oozieaudit
+log4j.logger.org.apache.oozie=INFO, oozie
+log4j.logger.org.apache.hadoop=WARN, oozie
+log4j.logger.org.mortbay=WARN, oozie
+log4j.logger.org.hsqldb=WARN, oozie
+log4j.logger.org.apache.hadoop.security.authentication.server=INFO, oozie