-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdistiller.py
56 lines (42 loc) · 1.27 KB
/
distiller.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
#!/usr/bin/python
import beanstalkc
import sys
import threading
from time import sleep
from server.inserter import Inserter
from server.preprocess import TraceProcessor
from server.reducer import TraceReducer
from utils.config_import import DistillerConfig
def check_beanstalk():
try:
beanstalkc.Connection(host='127.0.0.1', port=11300)
except beanstalkc.SocketError:
print "Could not connect to beanstalkd!"
sys.exit()
def main(config_file):
try:
config = DistillerConfig(config_file, 'server')
if "trace" in config.operations:
# Insert seeds into beanstalk
inserter = Inserter(config)
t1 = threading.Thread(target=inserter.insert_seed)
t1.start()
# Start trace preprocessor
sleep(10)
processor = TraceProcessor(config)
t2 = threading.Thread(target=processor.go)
t2.start()
t1.join()
t2.join()
if "reduce" in config.operations:
reducer = TraceReducer(config)
reducer.go()
finally:
pass
def usage():
print "Usage:", sys.argv[0], "<config.yml>"
if __name__ == "__main__":
if len(sys.argv) != 2:
usage()
else:
main(sys.argv[1])