-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
103 lines (73 loc) · 2.83 KB
/
main.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from database import MintDatabase
from expire import ExpireThread
from model import MintModel
from session import MintSession
from update import UpdateThread
from vacuum import VacuumThread
from cumin.admin import *
from util import *
log = logging.getLogger("mint.main")
class Mint(object):
def __init__(self, model_dir, broker_uris, database_dsn):
self.model = MintModel(self, model_dir)
self.model.sql_logging_enabled = False
self.session = MintSession(self, broker_uris)
self.database = MintDatabase(self, database_dsn)
self.admin = CuminAdmin(self)
self.update_thread = UpdateThread(self)
self.expire_enabled = True
self.expire_thread = ExpireThread(self)
self.vacuum_enabled = True
self.vacuum_thread = VacuumThread(self)
self.print_event_level = 0
# Space separated list of sasl authentication
# mechanisms, according to the sasl documentation
self.sasl_mech_list = None
# List of agents to bind. Referenced by session.
self.qmf_agents = set()
# List of classes to bind. Referenced by session and update thread.
self.qmf_classes = set()
# If binding was not done by class, this is the final list of
# packages that were bound
self.qmf_packages = set()
# Things we know should not be bound.
self.qmf_package_filter = ["com.redhat.cumin", "com.redhat.cumin.grid"]
def check(self):
log.info("Checking %s", self)
self.model.check()
self.session.check()
self.database.check()
def init(self):
log.info("Initializing %s", self)
def state(cond):
return cond and "enabled" or "disabled"
log.info("Expiration is %s", state(self.expire_enabled))
log.info("Vacuum is %s", state(self.vacuum_enabled))
self.model.init()
self.session.init()
self.database.init()
self.update_thread.init()
self.expire_thread.init()
self.vacuum_thread.init()
def start(self):
log.info("Starting %s", self)
# Scan the qmf class/package binding list
# and do any necessary preprocessing
self.session.init_qmf_classes()
self.update_thread.start()
self.session.start()
if self.expire_enabled:
self.expire_thread.start()
if self.vacuum_enabled:
self.vacuum_thread.start()
def stop(self, skip_vacuum=False):
log.info("Stopping %s", self)
self.update_thread.stop()
if self.expire_enabled:
self.expire_thread.stop()
if self.vacuum_enabled and not skip_vacuum:
self.vacuum_thread.stop()
self.session.stop()
log.info("Session stopped")
def __repr__(self):
return self.__class__.__name__