You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/11/04 14:37:09 UTC

[42/50] [abbrv] ambari git commit: AMBARI-13618: Add configure / start / stop / status operations for Apache HAWQ's PXF (mithmatt via jaoki)

AMBARI-13618: Add configure / start / stop / status operations for Apache HAWQ's PXF (mithmatt via jaoki)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 4763c759cc728d9fd8f24402c90012ae527985e5
Parents: 1e86d69
Author: Jun Aoki <ja...@apache.org>
Authored: Tue Nov 3 12:14:45 2015 -0800
Committer: Jun Aoki <ja...@apache.org>
Committed: Tue Nov 3 12:14:45 2015 -0800

----------------------------------------------------------------------
 .../PXF/3.0.0.0/configuration/pxf-site.xml      |  19 +++
 .../common-services/PXF/3.0.0.0/metainfo.xml    |   2 +-
 .../PXF/3.0.0.0/package/scripts/params.py       |  42 +++++++
 .../PXF/3.0.0.0/package/scripts/pxf.py          | 120 +++++++++++++++++++
 .../PXF/3.0.0.0/package/scripts/pxfservice.py   |  41 -------
 .../PXF/3.0.0.0/package/templates/pxf-env.j2    |  34 ++++++
 6 files changed, 216 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4763c759/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/configuration/pxf-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/configuration/pxf-site.xml b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/configuration/pxf-site.xml
new file mode 100644
index 0000000..0b3a36e
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/configuration/pxf-site.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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> 
+</configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4763c759/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/metainfo.xml b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/metainfo.xml
index 4df1bd6..f578d64 100644
--- a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/metainfo.xml
+++ b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/metainfo.xml
@@ -32,7 +32,7 @@
           <category>SLAVE</category>
           <cardinality>1+</cardinality>
           <commandScript>
-            <script>scripts/pxfservice.py</script>
+            <script>scripts/pxf.py</script>
             <scriptType>PYTHON</scriptType>
             <timeout>600</timeout>
           </commandScript>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4763c759/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/params.py b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/params.py
new file mode 100644
index 0000000..a4986c9
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/params.py
@@ -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.
+"""
+
+from resource_management import Script
+
+config = Script.get_config()
+
+
+pxf_service_name = "pxf-service"
+stack_name = str(config["hostLevelParams"]["stack_name"])
+
+# Users and Groups
+pxf_user = "pxf"
+pxf_group = pxf_user
+hdfs_superuser_group = config["configurations"]["hdfs-site"]["dfs.permissions.superusergroup"]
+user_group = config["configurations"]["cluster-env"]["user_group"]
+tomcat_group = "tomcat"
+
+# Directories
+pxf_conf_dir = "/etc/pxf/conf"
+pxf_instance_dir = "/var/pxf"
+
+# Java home path
+java_home = config["hostLevelParams"]["java_home"] if "java_home" in config["hostLevelParams"] else None
+
+# Timeouts
+default_exec_timeout = 600

http://git-wip-us.apache.org/repos/asf/ambari/blob/4763c759/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxf.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxf.py b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxf.py
new file mode 100644
index 0000000..dd0031c
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxf.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from resource_management import Script
+
+from resource_management.libraries.resources.xml_config import XmlConfig
+from resource_management.core.resources.accounts import User
+from resource_management.core.resources.system import Directory, File, Execute
+from resource_management.core.source import Template
+
+
+
+class Pxf(Script):
+  """
+  Contains the interface definitions for methods like install,
+  start, stop, status, etc. for the PXF
+  """
+
+  def install(self, env):
+    self.install_packages(env)
+    self.configure(env)
+
+
+  def configure(self, env):
+    import params
+    env.set_params(params)
+    self.__setup_user_group()
+    self.__generate_config_files()
+    # pxf-service init exits safely when it is already initialized
+    self.__execute_service_command("init")
+
+
+  def start(self, env):
+    self.configure(env)
+    self.__grant_permissions()
+    self.__execute_service_command("restart")
+
+
+  def stop(self, env):
+    self.__execute_service_command("stop")
+
+
+  def status(self, env):
+    try:
+      self.__execute_service_command("status")
+    except Exception:
+      raise ComponentIsNotRunning()
+
+
+  def __execute_service_command(self, command):
+    import params
+    Execute("service {0} {1}".format(params.pxf_service_name, command),
+              timeout=params.default_exec_timeout,
+              logoutput=True)
+
+
+  def __setup_user_group(self):
+    """
+    Creates PXF user with the required groups and bash as default shell
+    """
+    import params
+    User(params.pxf_user,
+         groups=[params.hdfs_superuser_group, params.user_group, params.tomcat_group],
+         shell="/bin/bash")
+
+
+  def __generate_config_files(self):
+    """
+    Generates pxf-env.sh file from jinja template and sets the classpath for HDP
+    """
+    import params
+    import shutil
+
+    hdp_stack = "HDP"
+
+    # Create file pxf-env.sh from jinja template
+    File("{0}/pxf-env.sh".format(params.pxf_conf_dir),
+         content = Template("pxf-env.j2"))
+
+    # Classpath is set for PHD by default. If stack is HDP, set classpath for HDP
+    if(params.stack_name == hdp_stack):
+      shutil.copy2("{0}/pxf-privatehdp.classpath".format(params.pxf_conf_dir),
+                   "{0}/pxf-private.classpath".format(params.pxf_conf_dir))
+
+    XmlConfig("pxf-site.xml",
+              conf_dir=params.pxf_conf_dir,
+              configurations=params.config['configurations']['pxf-site'],
+              configuration_attributes=params.config['configuration_attributes']['pxf-site'])
+
+
+  def __grant_permissions(self):
+    """
+    Grants permission to pxf:pxf for PXF instance directory
+    """
+    import params
+    Directory(params.pxf_instance_dir,
+              owner=params.pxf_user,
+              group=params.pxf_group,
+              recursive=True)
+
+
+if __name__ == "__main__":
+  Pxf().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/4763c759/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxfservice.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxfservice.py b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxfservice.py
deleted file mode 100644
index c267794..0000000
--- a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/scripts/pxfservice.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python
-
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-from resource_management import Script
-
-class PxfService(Script):
-  def install(self, env):
-    self.install_packages(env)
-    self.configure(env)
-
-  def configure(self, env):
-    pass
-
-  def start(self, env):
-    pass
-
-  def stop(self, env):
-    pass
-
-  def status(self, env):
-    pass
-
-if __name__ == "__main__":
-  PxfService().execute()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/4763c759/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/templates/pxf-env.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/templates/pxf-env.j2 b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/templates/pxf-env.j2
new file mode 100644
index 0000000..03f2420
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/PXF/3.0.0.0/package/templates/pxf-env.j2
@@ -0,0 +1,34 @@
+#!/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.
+
+
+# THIS FILE SHOULD MATCH WITH https://github.com/apache/incubator-hawq/blob/master/pxf/pxf-service/src/scripts/pxf-env.sh
+
+# Path to HDFS native libraries
+export LD_LIBRARY_PATH=/usr/lib/hadoop/lib/native:${LD_LIBRARY_PATH}
+
+# Path to JAVA
+export JAVA_HOME={{java_home}}
+
+# Path to Log directory
+export PXF_LOGDIR=/var/log/pxf
+export CATALINA_OUT=${PXF_LOGDIR}/catalina.out
+
+# Path to Run directory
+export PXF_RUNDIR=/var/run/pxf
+