-
Notifications
You must be signed in to change notification settings - Fork 0
/
conductor.py
executable file
·66 lines (51 loc) · 1.55 KB
/
conductor.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
#!/usr/bin/env python3
import cgi
import http.server
import io
import mimetypes
import os
import socketserver
import sys
import threading
import time
import urllib
import conductor_web
import conductor_backend
if len(sys.argv) != 2:
print(f'Usage: {sys.argv[0]} SCALE_FACTOR', file=sys.stderr)
sys.exit(1)
scale_factor = sys.argv[1]
# rest server config
hostName = "localhost"
serverPort = 8080
# backend config
explainer_mapi_url = 'mapi:monetdb://localhost:50000/SF-0_01'
minion_mapi_url = f'mapi:monetdb://HOSTNAME:50000/SF-{scale_factor.replace(".", "_")}'
# left here by Ansible who got it from Terraform
cluster_name = open(os.path.expanduser('~/.cluster_name')).read().strip()
small_pool_filter = dict(
cluster=cluster_name,
cluster_groups='minions',
size='small')
large_pool_filter = dict(
cluster=cluster_name,
cluster_groups='minions',
size='large')
backend = conductor_backend.make_backend(
conductor_backend.Connector(explainer_mapi_url),
conductor_backend.Connector(minion_mapi_url),
dict(SMALL=small_pool_filter, LARGE=large_pool_filter),
)
class ThreadingSimpleServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
pass
if __name__ == "__main__":
restserver = ThreadingSimpleServer(
(hostName, serverPort), conductor_web.ConductorRequestHandler)
restserver.backend = backend
print("Server started http://%s:%s" % (hostName, serverPort))
try:
restserver.serve_forever()
except KeyboardInterrupt:
pass
restserver.server_close()
print("Server stopped.")