ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject git commit: AMBARI-4301. Add Storm for Monitoring/Management via new stack definition. (Arsen Babych via aonishuk)
Date Wed, 15 Jan 2014 15:38:24 GMT
Updated Branches:
  refs/heads/trunk af56baa0b -> a3b53446e


AMBARI-4301. Add Storm for Monitoring/Management via new stack definition. (Arsen Babych via
aonishuk)


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

Branch: refs/heads/trunk
Commit: a3b53446ef6fab413e62a962fe086b1eeb2cbd22
Parents: af56baa
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Wed Jan 15 17:08:06 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Wed Jan 15 17:38:31 2014 +0200

----------------------------------------------------------------------
 .../hooks/before-INSTALL/scripts/params.py      |   3 +
 .../scripts/shared_initialization.py            |   6 ++
 .../stacks/HDP/2.0.8/role_command_order.json    |   7 +++
 .../services/STORM/configuration/global.xml     |  39 ++++++++++++
 .../services/STORM/configuration/storm-site.xml |   4 +-
 .../HDP/2.0.8/services/STORM/metainfo.xml       |  37 +++++++++--
 .../services/STORM/package/files/wordCount.jar  | Bin 0 -> 690588 bytes
 .../STORM/package/scripts/drpc_server.py        |  62 +++++++++++++++++++
 .../STORM/package/scripts/logviewer_server.py   |  62 +++++++++++++++++++
 .../services/STORM/package/scripts/nimbus.py    |  38 +++++-------
 .../services/STORM/package/scripts/params.py    |   9 +++
 .../services/STORM/package/scripts/service.py   |  62 +++++++++++++++++++
 .../STORM/package/scripts/service_check.py      |  14 ++++-
 .../STORM/package/scripts/status_params.py      |  16 +++++
 .../services/STORM/package/scripts/storm.py     |  39 ++++++++++++
 .../STORM/package/scripts/supervisor.py         |  49 +++++----------
 .../services/STORM/package/scripts/ui_server.py |  62 +++++++++++++++++++
 17 files changed, 448 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/params.py
index fa19ca3..dc6d770 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/params.py
@@ -37,6 +37,7 @@ hdfs_user = config['configurations']['global']['hdfs_user']
 zk_user = config['configurations']['global']['zk_user']
 gmetad_user = config['configurations']['global']["gmetad_user"]
 gmond_user = config['configurations']['global']["gmond_user"]
+storm_user = config['configurations']['global']['storm_user']
 
 user_group = config['configurations']['global']['user_group']
 proxyuser_group =  config['configurations']['global']['proxyuser_group']
@@ -58,6 +59,7 @@ jtnode_host = default("/clusterHostInfo/jtnode_host", [])
 namenode_host = default("/clusterHostInfo/namenode_host", [])
 zk_hosts = default("/clusterHostInfo/zookeeper_hosts", [])
 ganglia_server_hosts = default("/clusterHostInfo/ganglia_server_host", [])
+storm_server_hosts = default("/clusterHostInfo/nimbus_hosts", [])
 
 has_resourcemanager = not len(rm_host) == 0
 has_slaves = not len(slave_hosts) == 0
@@ -68,6 +70,7 @@ has_hive_server_host = not len(hive_server_host)  == 0
 has_hbase_masters = not len(hbase_master_hosts) == 0
 has_zk_host = not len(zk_hosts) == 0
 has_ganglia_server = not len(ganglia_server_hosts) == 0
+has_storm_server = not len(storm_server_hosts) == 0
 
 is_namenode_master = hostname in namenode_host
 is_jtnode_master = hostname in jtnode_host

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/shared_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/shared_initialization.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/shared_initialization.py
index 26a7592..cf6c2c5 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/shared_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/hooks/before-INSTALL/scripts/shared_initialization.py
@@ -91,6 +91,12 @@ def setup_users():
     User(params.zk_user,
          gid=params.user_group)
 
+  if params.has_storm_server:
+    User(params.storm_user,
+         gid=params.user_group,
+         groups=[params.user_group]
+    )
+
 def set_uid(user, user_dirs):
   """
   user_dirs - comma separated directories

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/role_command_order.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/role_command_order.json b/ambari-server/src/main/resources/stacks/HDP/2.0.8/role_command_order.json
index 84610ca..416945d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/role_command_order.json
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/role_command_order.json
@@ -5,6 +5,11 @@
     "_comment" : "dependencies for all cases",
     "NAGIOS_SERVER-INSTALL" : ["HIVE_CLIENT-INSTALL", "HCAT-INSTALL",
         "MAPREDUCE_CLIENT-INSTALL", "OOZIE_CLIENT-INSTALL"],
+    "NIMBUS-START" : ["ZOOKEEPER_SERVER-START"],
+    "SUPERVISOR-START" : ["NIMBUS-START"],
+    "STORM_UI_SERVER-START" : ["NIMBUS-START"],
+    "DRPC_SERVER-START" : ["NIMBUS-START"],
+    "LOGVIEWER_SERVER-START" : ["NIMBUS-START"],
     "HBASE_MASTER-START": ["ZOOKEEPER_SERVER-START"],
     "HBASE_REGIONSERVER-START": ["HBASE_MASTER-START"],
     "OOZIE_SERVER-START": ["JOBTRACKER-START", "TASKTRACKER-START"],
@@ -29,8 +34,10 @@
     "SQOOP_SERVICE_CHECK-SERVICE_CHECK": ["JOBTRACKER-START", "TASKTRACKER-START"],
     "ZOOKEEPER_SERVICE_CHECK-SERVICE_CHECK": ["ZOOKEEPER_SERVER-START"],
     "ZOOKEEPER_QUORUM_SERVICE_CHECK-SERVICE_CHECK": ["ZOOKEEPER_SERVER-START"],
+    "STORM_SERVICE_CHECK-SERVICE_CHECK": ["NIMBUS-START", "SUPERVISOR-START"],
     "ZOOKEEPER_SERVER-STOP" : ["HBASE_MASTER-STOP", "HBASE_REGIONSERVER-STOP"],
     "HBASE_MASTER-STOP": ["HBASE_REGIONSERVER-STOP"],
+    "NIMBUS-STOP" : ["SUPERVISOR-STOP", "STORM_UI_SERVER-STOP", "DRPC_SERVER-STOP", "LOGVIEWER_SERVER-STOP"],
     "TASKTRACKER-UPGRADE": ["JOBTRACKER-UPGRADE"],
     "MAPREDUCE_CLIENT-UPGRADE": ["TASKTRACKER-UPGRADE", "JOBTRACKER-UPGRADE"],
     "ZOOKEEPER_SERVER-UPGRADE": ["MAPREDUCE_CLIENT-UPGRADE"],

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/global.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/global.xml
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/global.xml
new file mode 100644
index 0000000..5cc9170
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/global.xml
@@ -0,0 +1,39 @@
+<?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>storm_user</name>
+    <value>storm</value>
+    <description></description>
+  </property>
+  <property>
+    <name>storm_log_dir</name>
+    <value>/var/log/storm</value>
+    <description></description>
+  </property>
+  <property>
+    <name>storm_pid_dir</name>
+    <value>/var/run/storm</value>
+    <description></description>
+  </property>
+</configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/storm-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/storm-site.xml
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/storm-site.xml
index 975b3a6..f81b3c3 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/storm-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/configuration/storm-site.xml
@@ -163,7 +163,7 @@
   </property>
   <property>
     <name>ui.port</name>
-    <value>8080</value>
+    <value>8744</value>
     <description></description>
   </property>
   <property>
@@ -238,7 +238,7 @@
   </property>
   <property>
     <name>supervisor.slots.ports</name>
-    <value>[6700, 6701, 6702, 6703]</value>
+    <value>[6700, 6701]</value>
     <description></description>
   </property>
   <property>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/metainfo.xml
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/metainfo.xml
index 01a2d90..95dd954 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/metainfo.xml
@@ -44,7 +44,39 @@
             <timeout>600</timeout>
           </commandScript>
         </component>
+
+        <component>
+          <name>STORM_UI_SERVER</name>
+          <category>MASTER</category>
+          <commandScript>
+            <script>scripts/ui_server.py</script>
+            <scriptType>PYTHON</scriptType>
+            <timeout>600</timeout>
+          </commandScript>
+        </component>
+
+        <component>
+          <name>DRPC_SERVER</name>
+          <category>MASTER</category>
+          <commandScript>
+            <script>scripts/drpc_server.py</script>
+            <scriptType>PYTHON</scriptType>
+            <timeout>600</timeout>
+          </commandScript>
+        </component>
+
+        <component>
+          <name>LOGVIEWER_SERVER</name>
+          <category>MASTER</category>
+          <commandScript>
+            <script>scripts/logviewer_server.py</script>
+            <scriptType>PYTHON</scriptType>
+            <timeout>600</timeout>
+          </commandScript>
+        </component>
       </components>
+
+
       <!--
       <osSpecifics>
         <osSpecific>
@@ -54,10 +86,6 @@
               <type>rpm</type>
               <name>storm</name>
             </package>
-            <package>
-              <type>rpm</type>
-              <name>supervisor</name>
-            </package>
         </osSpecific>
       </osSpecifics> -->
 
@@ -69,6 +97,7 @@
 
       <configuration-dependencies>
         <config-type>storm-site</config-type>
+        <config-type>global</config-type>
       </configuration-dependencies>
     </service>
   </services>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/files/wordCount.jar
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/files/wordCount.jar
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/files/wordCount.jar
new file mode 100644
index 0000000..aed64be
Binary files /dev/null and b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/files/wordCount.jar
differ

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/drpc_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/drpc_server.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/drpc_server.py
new file mode 100644
index 0000000..325f86a
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/drpc_server.py
@@ -0,0 +1,62 @@
+#!/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 *
+from storm import storm
+from service import service
+from service_check import ServiceCheck
+
+
+class DrpcServer(Script):
+  def install(self, env):
+    self.install_packages(env)
+    # TODO remove
+    Execute("yum install http://s3.amazonaws.com/dev.hortonworks.com/storm/storm-0.9.1.2.0.6.1-1.el6.noarch.rpm
-y",
+            ignore_failures = True)
+
+    self.configure(env)
+
+  def configure(self, env):
+    import params
+    env.set_params(params)
+
+    storm()
+
+  def start(self, env):
+    import params
+    env.set_params(params)
+    self.configure(env)
+
+    service("drpc", action="start")
+
+  def stop(self, env):
+    import params
+    env.set_params(params)
+
+    service("drpc", action="stop")
+
+  def status(self, env):
+    import status_params
+    env.set_params(status_params)
+    check_process_status(status_params.pid_drpc)
+
+if __name__ == "__main__":
+  DrpcServer().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/logviewer_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/logviewer_server.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/logviewer_server.py
new file mode 100644
index 0000000..c209036
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/logviewer_server.py
@@ -0,0 +1,62 @@
+#!/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 *
+from storm import storm
+from service import service
+from service_check import ServiceCheck
+
+
+class LogviewerServer(Script):
+  def install(self, env):
+    self.install_packages(env)
+    # TODO remove
+    Execute("yum install http://s3.amazonaws.com/dev.hortonworks.com/storm/storm-0.9.1.2.0.6.1-1.el6.noarch.rpm
-y",
+            ignore_failures = True)
+
+    self.configure(env)
+
+  def configure(self, env):
+    import params
+    env.set_params(params)
+
+    storm()
+
+  def start(self, env):
+    import params
+    env.set_params(params)
+    self.configure(env)
+
+    service("logviewer", action="start")
+
+  def stop(self, env):
+    import params
+    env.set_params(params)
+
+    service("logviewer", action="stop")
+
+  def status(self, env):
+    import status_params
+    env.set_params(status_params)
+    check_process_status(status_params.pid_logviewer)
+
+if __name__ == "__main__":
+  LogviewerServer().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/nimbus.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/nimbus.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/nimbus.py
index 6ed1e39..7210314 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/nimbus.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/nimbus.py
@@ -20,49 +20,43 @@ limitations under the License.
 
 import sys
 from resource_management import *
+from storm import storm
+from service import service
+from service_check import ServiceCheck
+
 
-         
 class Nimbus(Script):
   def install(self, env):
     self.install_packages(env)
+    # TODO remove
+    Execute("yum install http://s3.amazonaws.com/dev.hortonworks.com/storm/storm-0.9.1.2.0.6.1-1.el6.noarch.rpm
-y",
+            ignore_failures = True)
+
     self.configure(env)
-    
+
   def configure(self, env):
     import params
     env.set_params(params)
-    
-    print "Configure."
-    
+
+    storm()
+
   def start(self, env):
     import params
     env.set_params(params)
     self.configure(env)
 
-    print "Start."
-    
+    service("nimbus", action="start")
+
   def stop(self, env):
     import params
     env.set_params(params)
 
-    print "Stop."
+    service("nimbus", action="stop")
 
   def status(self, env):
     import status_params
     env.set_params(status_params)
-    
-    #pid_file = format("{pid_dir}/?.pid")
-    #check_process_status(pid_file)
+    check_process_status(status_params.pid_nimbus)
 
-# for testing
-def main():
-  command_type = "install"
-  command_data_file = '/root/storm.json'
-  basedir = '/root/ambari/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package'
-  stroutputf = '/1.txt'
-  sys.argv = ["", command_type, command_data_file, basedir, stroutputf]
-  
-  Nimbus().execute()
-  
 if __name__ == "__main__":
   Nimbus().execute()
-  #main()

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/params.py
index b722187..57ff774 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/params.py
@@ -23,3 +23,12 @@ import status_params
 
 # server configurations
 config = Script.get_config()
+
+storm_user = config['configurations']['global']['storm_user']
+log_dir = config['configurations']['global']['storm_log_dir']
+pid_dir = status_params.pid_dir
+conf_dir = "/etc/storm/conf"
+local_dir = config['configurations']['storm-site']['storm.local.dir']
+user_group = config['configurations']['global']['user_group']
+java64_home = config['hostLevelParams']['java_home']
+nimbus_host = config['configurations']['storm-site']['nimbus.host']

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service.py
new file mode 100644
index 0000000..721acf1
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+
+
+from resource_management import *
+from resource_management.core.shell import call
+import subprocess
+
+
+def service(
+    name,
+    action='start'):
+  import params
+  import status_params
+
+  pid_file = status_params.pid_files[name]
+
+  if action == "start":
+    cmd = ["/usr/bin/storm", name]
+    if name == "ui":
+      crt_pid_cmd = format("pgrep -f \"^java.+backtype.storm.ui.core$\" > {pid_file}")
+    else :
+      crt_pid_cmd = format("pgrep -f \"^java.+backtype.storm.daemon.{name}$\" > {pid_file}")
+
+    no_op_test = format("ls {pid_file} >/dev/null 2>&1 && ps `cat {pid_file}`
>/dev/null 2>&1")
+
+    #Execute(cmd,
+    #        not_if=no_op_test,
+    #        user=params.storm_user
+    #)
+
+    #TODO run from storm user
+
+    if call(no_op_test)[0]:
+      subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env={"PATH":format("{java64_home}/bin:/bin")})
+
+    Execute(crt_pid_cmd,
+            logoutput=True,
+            tries=6,
+            try_sleep=10
+    )
+
+  elif action == "stop":
+    cmd = format("kill `cat {pid_file}` >/dev/null 2>&1 && rm -f {pid_file}")
+    Execute(cmd)

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service_check.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service_check.py
index 582ea55..1cfbc48 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/service_check.py
@@ -25,7 +25,19 @@ class ServiceCheck(Script):
     import params
     env.set_params(params)
 
-    print "Service check."
+    unique = get_unique_id_and_date()
+
+    File("/tmp/wordCount.jar",
+         content=StaticFile("wordCount.jar")
+    )
+
+    cmd = format("env PATH=$PATH:{java64_home}/bin storm jar /tmp/wordCount.jar storm.starter.WordCountTopology
WordCount{unique} -c nimbus.host={nimbus_host}")
+
+    Execute(cmd,
+            logoutput=True
+    )
+
+    Execute(format("env PATH=$PATH:{java64_home}/bin storm kill WordCount{unique}"))
 
 if __name__ == "__main__":
   ServiceCheck().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/status_params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/status_params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/status_params.py
index 5561e10..70b034a 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/status_params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/status_params.py
@@ -17,3 +17,19 @@ See the License for the specific language governing permissions and
 limitations under the License.
 
 """
+from resource_management import *
+
+config = Script.get_config()
+
+pid_dir = config['configurations']['global']['storm_pid_dir']
+pid_nimbus = format("{pid_dir}/nimbus.pid")
+pid_supervisor = format("{pid_dir}/supervisor.pid")
+pid_drpc = format("{pid_dir}/drpc.pid")
+pid_ui = format("{pid_dir}/ui.pid")
+pid_logviewer = format("{pid_dir}/logviewer.pid")
+
+pid_files = {"logviewer":pid_logviewer,
+             "ui": pid_ui,
+             "nimbus": pid_nimbus,
+             "supervisor": pid_supervisor,
+             "drpc": pid_drpc}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/storm.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/storm.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/storm.py
new file mode 100644
index 0000000..d38909c
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/storm.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+
+from resource_management import *
+from yaml_config import yaml_config
+import sys
+
+def storm():
+  import params
+
+  Directory([params.log_dir, params.pid_dir, params.local_dir],
+            owner=params.storm_user,
+            group=params.user_group,
+            recursive=True
+  )
+
+  yaml_config( "storm.yaml",
+               conf_dir = params.conf_dir,
+               configurations = params.config['configurations']['storm-site'],
+               owner = params.storm_user,
+               group = params.user_group
+  )
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/supervisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/supervisor.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/supervisor.py
index b4ce483..eafb48f 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/supervisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/supervisor.py
@@ -21,58 +21,43 @@ limitations under the License.
 import sys
 from resource_management import *
 from yaml_config import yaml_config
+from storm import storm
+from service import service
+
 
-         
 class Supervisor(Script):
   def install(self, env):
     self.install_packages(env)
+    # TODO remove
+    Execute("yum install http://s3.amazonaws.com/dev.hortonworks.com/storm/storm-0.9.1.2.0.6.1-1.el6.noarch.rpm
-y",
+            ignore_failures = True)
     self.configure(env)
-    
+
   def configure(self, env):
     import params
     env.set_params(params)
-    
-    # example
-    #yaml_config( "storm.yaml",
-    #        #conf_dir = params.conf_dir,
-    #        conf_dir = "/etc/storm/conf",
-    #        configurations = params.config['configurations']['storm-site'],
-    #        #owner = params.storm_user,
-    #        #group = params.user_group
-    #)
-    
-    print "Configure."
-    
+    storm()
+
   def start(self, env):
     import params
     env.set_params(params)
     self.configure(env)
 
-    print "Start."
-    
+    service("supervisor", action="start")
+
   def stop(self, env):
     import params
     env.set_params(params)
 
-    print "Stop."
+    service("supervisor", action="stop")
 
   def status(self, env):
     import status_params
     env.set_params(status_params)
-    
-    #pid_file = format("{pid_dir}/?.pid")
-    #check_process_status(pid_file)
-
-# for testing
-def main():
-  command_type = "install"
-  command_data_file = '/root/storm.json'
-  basedir = '/root/ambari/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package'
-  stroutputf = '/1.txt'
-  sys.argv = ["", command_type, command_data_file, basedir, stroutputf]
-  
-  Supervisor().execute()
-  
+
+    check_process_status(status_params.pid_supervisor)
+
+
 if __name__ == "__main__":
   Supervisor().execute()
-  #main()
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3b53446/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/ui_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/ui_server.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/ui_server.py
new file mode 100644
index 0000000..58deec6
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.8/services/STORM/package/scripts/ui_server.py
@@ -0,0 +1,62 @@
+#!/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 *
+from storm import storm
+from service import service
+from service_check import ServiceCheck
+
+
+class UiServer(Script):
+  def install(self, env):
+    self.install_packages(env)
+    # TODO remove
+    Execute("yum install http://s3.amazonaws.com/dev.hortonworks.com/storm/storm-0.9.1.2.0.6.1-1.el6.noarch.rpm
-y",
+            ignore_failures = True)
+
+    self.configure(env)
+
+  def configure(self, env):
+    import params
+    env.set_params(params)
+
+    storm()
+
+  def start(self, env):
+    import params
+    env.set_params(params)
+    self.configure(env)
+
+    service("ui", action="start")
+
+  def stop(self, env):
+    import params
+    env.set_params(params)
+
+    service("ui", action="stop")
+
+  def status(self, env):
+    import status_params
+    env.set_params(status_params)
+    check_process_status(status_params.pid_ui)
+
+if __name__ == "__main__":
+  UiServer().execute()


Mime
View raw message