-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapplauncher.py
87 lines (70 loc) · 2.02 KB
/
applauncher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from subprocess import Popen, PIPE
from argparse import ArgumentParser
import multiprocessing
from time import sleep
from monitor.monitor import monitor_devs_ng, monitor_cpu
import os
import sys
def HadoopTest(hosts):
basedir = "./hadoop"
confdir = basedir + "/conf"
done = "./output/done.json"
emulator = basedir + "/emulator.py"
if os.path.isfile(done):
os.remove(done)
f = open(confdir + "/slaves", 'w')
for h in hosts:
f.write(h.IP() + "\n")
f.close()
f = open(confdir + "/masters", 'w')
f.write(hosts[0].IP() + "\n")
f.close()
print "Starting monitor ..."
output_dir="output"
monitors = []
# Start network usage monitor
monitor = multiprocessing.Process(target = monitor_devs_ng, args =
('%s/rate.txt' % output_dir, 0.01))
monitor.start()
monitors.append(monitor)
# Start CPU usage monitor
monitor = multiprocessing.Process(target=monitor_cpu, args=('%s/cpu.txt' % output_dir,))
monitor.start()
monitors.append(monitor)
print "Running Hadoop simulation ..."
for h in hosts:
h.popen('%s %s > ./output/output-%s.txt 2> ./output/error-%s.txt' % (emulator, h.IP(), h.IP(), h.IP()), shell = True)
while True:
if os.path.isfile(done):
break
sleep(1)
print "Stopping monitor ..."
for monitor in monitors:
monitor.terminate()
os.system("killall -9 bwm-ng")
os.system("killall -9 top")
sleep(5)
print "Done."
def IperfTest(hosts):
basedir = "./benchmarks"
done = "./output/done.json"
emulator = basedir + "/emulator.py"
if os.path.isfile(done):
os.remove(done)
print "Starting monitor ..."
output_dir="output"
monitor = multiprocessing.Process(target = monitor_devs_ng, args =
('%s/rate.txt' % output_dir, 0.1))
monitor.start()
print "Running tests ..."
for h in hosts:
h.popen('%s %s > ./output/output-%s.txt 2> ./output/error-%s.txt' % (emulator, h.IP(), h.IP(), h.IP()), shell = True)
while True:
if os.path.isfile(done):
break
sleep(1)
print "Stopping monitor ..."
monitor.terminate()
os.system("killall -9 bwm-ng")
sleep(5)
print "Done."