Run periodics in sahara-engine instead of sahara-api

Periodics should run in engine, not in api, because they don't
interact with the user. On the other hand they do require remote
operations.

Change-Id: I00273de0632ee99ca21e9ddd796755172af2a4da
This commit is contained in:
Dmitry Mescheryakov 2014-04-28 20:58:15 +04:00
parent 4e24c3ca5b
commit cf913fbcc6
4 changed files with 9 additions and 13 deletions

View File

@ -52,7 +52,7 @@ def main():
app = server.make_app()
server.setup_sahara_api(app, 'all-in-one')
server.setup_sahara_api('all-in-one')
server.setup_sahara_engine()
wsgi.server(eventlet.listen((cfg.CONF.host, cfg.CONF.port), backlog=500),

View File

@ -52,7 +52,7 @@ def main():
app = server.make_app()
server.setup_sahara_api(app, 'distributed')
server.setup_sahara_api('distributed')
wsgi.server(eventlet.listen((cfg.CONF.host, cfg.CONF.port), backlog=500),
app, log=logging.WritableLogger(LOG), debug=False)

View File

@ -95,20 +95,16 @@ def setup_common(possible_topdir, service_name):
plugins_base.setup_plugins()
def setup_sahara_api(app, mode):
periodic.setup(app)
#TODO(dmitryme): move periodics to engine, until then the remote
# initialization here is a temporal hack
remote_driver = _get_remote_driver()
remote.setup_remote(remote_driver, None)
def setup_sahara_api(mode):
ops = _get_ops_driver(mode)
service_api.setup_service_api(ops)
edp_api.setup_edp_api(ops)
def setup_sahara_engine():
periodic.setup()
engine = _get_infrastructure_engine()
service_ops.setup_ops(engine)

View File

@ -102,7 +102,7 @@ class SaharaPeriodicTasks(periodic_task.PeriodicTasks):
context.set_ctx(None)
def setup(app):
def setup():
if CONF.periodic_enable:
if CONF.periodic_fuzzy_delay:
initial_delay = random.randint(0, CONF.periodic_fuzzy_delay)
@ -111,9 +111,9 @@ def setup(app):
else:
initial_delay = None
app.tg = threadgroup.ThreadGroup()
tg = threadgroup.ThreadGroup()
pt = SaharaPeriodicTasks()
app.tg.add_dynamic_timer(
tg.add_dynamic_timer(
pt.run_periodic_tasks,
initial_delay=initial_delay,
periodic_interval_max=CONF.periodic_interval_max,