You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/08/07 22:04:43 UTC

[30/38] git commit: SLIDER-298. Add an application package template

SLIDER-298. Add an application package template


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/609fcd32
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/609fcd32
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/609fcd32

Branch: refs/heads/feature/SLIDER-149_Support_a_YARN_service_registry
Commit: 609fcd327c4ee814e4f33b0357bdef9e77caf0fc
Parents: ec76068
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Wed Aug 6 13:55:14 2014 -0700
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Wed Aug 6 13:55:14 2014 -0700

----------------------------------------------------------------------
 app-packages/app-pkg-template/README.txt        |  34 +++++++++++
 app-packages/app-pkg-template/appConfig.json    |  21 +++++++
 app-packages/app-pkg-template/metainfo.xml      |  57 +++++++++++++++++++
 app-packages/app-pkg-template/myapp-1.0.0.zip   | Bin 0 -> 5455 bytes
 .../package/files/myapp-1.0.0.tar.REPLACE       |  16 ++++++
 .../package/scripts/myapp_master.py             |  46 +++++++++++++++
 .../app-pkg-template/package/scripts/params.py  |  30 ++++++++++
 app-packages/app-pkg-template/resources.json    |  16 ++++++
 8 files changed, 220 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/README.txt
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/README.txt b/app-packages/app-pkg-template/README.txt
new file mode 100644
index 0000000..00dfdbc
--- /dev/null
+++ b/app-packages/app-pkg-template/README.txt
@@ -0,0 +1,34 @@
+<!---
+   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.
+-->
+
+How to create a Slider app package for myapp?
+
+To create the app package you will need the application tarball copied to a specific location.
+
+E.g.
+  cp ~/Downloads/myapp-1.0.0.tar package/files/
+
+Create a zip package at the root of the package (<slider enlistment>/app-packages/myapp/)
+  zip -r myapp-1.0.0.zip .
+
+Verify the content using  
+  zip -Tv myapp-1.0.0.zip
+
+While appConfig.json and resources.json are not required for the package they work
+well as the default configuration for Slider apps. So its advisable that when you
+create an application package for Slider, include sample/default resources.json and
+appConfig.json for a one-node Yarn cluster.

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/appConfig.json
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/appConfig.json b/app-packages/app-pkg-template/appConfig.json
new file mode 100644
index 0000000..a6f61f9
--- /dev/null
+++ b/app-packages/app-pkg-template/appConfig.json
@@ -0,0 +1,21 @@
+{
+  "schema": "http://example.org/specification/v2.0.0",
+  "metadata": {
+  },
+  "global": {
+    "application.def": "package/myapp-1.0.0.zip",
+    "java_home": "/usr/jdk64/jdk1.7.0_45",
+
+    "site.global.app_user": "yarn",
+    "site.global.app_root": "${AGENT_WORK_ROOT}/app/install/myapp-1.0.0",
+
+    "site.global.listen_port": "${MYAPP_COMPONENT.ALLOCATED_PORT}"
+  },
+  "components": {
+    "slider-appmaster": {
+      "jvm.heapsize": "256M"
+    },
+    "MYAPP_COMPONENT": {
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/metainfo.xml
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/metainfo.xml b/app-packages/app-pkg-template/metainfo.xml
new file mode 100644
index 0000000..c6e1485
--- /dev/null
+++ b/app-packages/app-pkg-template/metainfo.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<metainfo>
+  <schemaVersion>2.0</schemaVersion>
+  <application>
+    <name>MyApp</name>
+    <comment>MyApp is an app that can run on YARN.</comment>
+    <version>1.0.0</version>
+    <exportedConfigs>None</exportedConfigs>
+
+    <components>
+      <component>
+        <name>MYAPP_COMPONENT</name>
+        <category>MASTER</category>
+        <exports>
+          <export>
+            <name>host_port</name>
+            <value>${THIS_HOST}:${site.global.listen_port}</value>
+          </export>
+        </exports>
+        <commandScript>
+          <script>scripts/myapp_component.py</script>
+          <scriptType>PYTHON</scriptType>
+        </commandScript>
+      </component>
+    </components>
+
+    <osSpecifics>
+      <osSpecific>
+        <osType>any</osType>
+        <packages>
+          <package>
+            <type>tarball</type>
+            <name>files/myapp-1.0.0.tar</name>
+          </package>
+        </packages>
+      </osSpecific>
+    </osSpecifics>
+
+  </application>
+</metainfo>

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/myapp-1.0.0.zip
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/myapp-1.0.0.zip b/app-packages/app-pkg-template/myapp-1.0.0.zip
new file mode 100644
index 0000000..80dbbb7
Binary files /dev/null and b/app-packages/app-pkg-template/myapp-1.0.0.zip differ

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/package/files/myapp-1.0.0.tar.REPLACE
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/package/files/myapp-1.0.0.tar.REPLACE b/app-packages/app-pkg-template/package/files/myapp-1.0.0.tar.REPLACE
new file mode 100644
index 0000000..2114587
--- /dev/null
+++ b/app-packages/app-pkg-template/package/files/myapp-1.0.0.tar.REPLACE
@@ -0,0 +1,16 @@
+# 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.
+
+Replace this file with a tarball of the myapp version you want to package.

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/package/scripts/myapp_master.py
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/package/scripts/myapp_master.py b/app-packages/app-pkg-template/package/scripts/myapp_master.py
new file mode 100644
index 0000000..e6bc867
--- /dev/null
+++ b/app-packages/app-pkg-template/package/scripts/myapp_master.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+
+import sys
+from resource_management import *
+
+class MyApp_Component(Script):
+  def install(self, env):
+    self.install_packages(env)
+
+  def configure(self, env):
+    import params
+    env.set_params(params)
+
+  def start(self, env):
+    import params
+    env.set_params(params)
+    self.configure(env)
+
+  def stop(self, env):
+    import params
+    env.set_params(params)
+
+  def status(self, env):
+    import params
+    env.set_params(params)
+
+if __name__ == "__main__":
+  MyApp_Component().execute()

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/package/scripts/params.py b/app-packages/app-pkg-template/package/scripts/params.py
new file mode 100644
index 0000000..e81bda0
--- /dev/null
+++ b/app-packages/app-pkg-template/package/scripts/params.py
@@ -0,0 +1,30 @@
+#!/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 *
+
+# server configurations
+config = Script.get_config()
+
+app_root = config['configurations']['global']['app_root']
+java64_home = config['hostLevelParams']['java_home']
+app_user = config['configurations']['global']['app_user']
+port = config['configurations']['global']['listen_port']
+

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/609fcd32/app-packages/app-pkg-template/resources.json
----------------------------------------------------------------------
diff --git a/app-packages/app-pkg-template/resources.json b/app-packages/app-pkg-template/resources.json
new file mode 100644
index 0000000..0e95879
--- /dev/null
+++ b/app-packages/app-pkg-template/resources.json
@@ -0,0 +1,16 @@
+{
+  "schema" : "http://example.org/specification/v2.0.0",
+  "metadata" : {
+  },
+  "global" : {
+  },
+  "components": {
+    "slider-appmaster": {
+    },
+    "MYAPP_COMPONENT": {
+      "yarn.role.priority": "1",
+      "yarn.component.instances": "1",
+      "yarn.memory": "256"
+    }
+  }
+}
\ No newline at end of file