Merge lp:~bigdata-dev/charms/trusty/hdp-hive/cs-jps-quickfix into lp:charms/trusty/hdp-hive

Proposed by Cory Johns
Status: Merged
Merged at revision: 16
Proposed branch: lp:~bigdata-dev/charms/trusty/hdp-hive/cs-jps-quickfix
Merge into: lp:charms/trusty/hdp-hive
Diff against target: 80 lines (+22/-19)
2 files modified
hooks/bdutils.py (+19/-16)
tests/hive-hadoop-sql-cluster.yaml (+3/-3)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/hdp-hive/cs-jps-quickfix
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
amir sanjar (community) Approve
Review via email: mp+250935@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
amir sanjar (asanjar) :
review: Approve
16. By Kevin W Monroe

remove refs to personal branch in test yaml

Revision history for this message
Matt Bruzek (mbruzek) wrote :

I could not get the tests to run from my machine, but the code looks just like the others which looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/bdutils.py'
2--- hooks/bdutils.py 2014-08-15 13:20:52 +0000
3+++ hooks/bdutils.py 2015-02-25 15:34:40 +0000
4@@ -1,4 +1,5 @@
5 #!/usr/bin/python
6+import re
7 import os
8 import pwd
9 import grp
10@@ -124,23 +125,25 @@
11 m = ll[0]+" = "+ll[1].strip().strip(';').strip("\"").strip()
12 #log ("==> {} ".format("\""+m+"\""))
13 os.environ[ll[0]] = ll[1].strip().strip(';').strip("\"").strip()
14-
15+
16+
17+def jps(name):
18+ """
19+ Get PIDs for named Java processes, for any user.
20+ """
21+ pat = re.sub(r'^(.)', r'^[^ ]*java .*[\1]', name)
22+ try:
23+ output = subprocess.check_output(['sudo', 'pgrep', '-f', pat])
24+ except subprocess.CalledProcessError:
25+ return []
26+ return map(int, filter(None, map(str.strip, output.split('\n'))))
27+
28+
29 def is_jvm_service_active(processname):
30- cmd=["jps"]
31- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
32- out, err = p.communicate()
33- if err == None and str(out).find(processname) != -1:
34- return True
35- else:
36- return False
37+ return jps(processname) != []
38+
39
40 def kill_java_process(process):
41- cmd=["jps"]
42- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
43- out, err = p.communicate()
44- cmd = out.split()
45- for i in range(0, len(cmd)):
46- if cmd[i] == process:
47- pid = int(cmd[i-1])
48- os.kill(pid, signal.SIGTERM)
49+ for pid in jps(process):
50+ os.kill(pid, signal.SIGTERM)
51 return 0
52
53=== modified file 'tests/hive-hadoop-sql-cluster.yaml'
54--- tests/hive-hadoop-sql-cluster.yaml 2014-09-18 01:41:58 +0000
55+++ tests/hive-hadoop-sql-cluster.yaml 2015-02-25 15:34:40 +0000
56@@ -1,7 +1,7 @@
57 hdp-hadoop-hive-mysql:
58 services:
59 "compute-node":
60- charm: "cs:~asanjar/trusty/hdp-hadoop"
61+ charm: "hdp-hadoop"
62 num_units: 1
63 annotations:
64 "gui-x": "768"
65@@ -15,13 +15,13 @@
66 "gui-x": "1102.9983551210835"
67 "gui-y": "591.0585428804295"
68 hdphive:
69- charm: "cs:~asanjar/trusty/hdp-hive"
70+ charm: "hdp-hive"
71 num_units: 1
72 annotations:
73 "gui-x": "1105.4991775605417"
74 "gui-y": "284.9414571195705"
75 "yarn-hdfs-master":
76- charm: "cs:~asanjar/trusty/hdp-hadoop"
77+ charm: "hdp-hadoop"
78 num_units: 1
79 annotations:
80 "gui-x": "769.0016448789165"

Subscribers

People subscribed via source and target branches