From cf913fbcc6c1504da9f801b0f94b7e3d5129bd3b Mon Sep 17 00:00:00 2001 From: Dmitry Mescheryakov Date: Mon, 28 Apr 2014 20:58:15 +0400 Subject: [PATCH] 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 --- sahara/cli/sahara_all.py | 2 +- sahara/cli/sahara_api.py | 2 +- sahara/main.py | 12 ++++-------- sahara/service/periodic.py | 6 +++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/sahara/cli/sahara_all.py b/sahara/cli/sahara_all.py index 3a0ac9be..262dd821 100644 --- a/sahara/cli/sahara_all.py +++ b/sahara/cli/sahara_all.py @@ -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), diff --git a/sahara/cli/sahara_api.py b/sahara/cli/sahara_api.py index 49db5a74..f1e94633 100644 --- a/sahara/cli/sahara_api.py +++ b/sahara/cli/sahara_api.py @@ -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) diff --git a/sahara/main.py b/sahara/main.py index e4a7edc9..9a0c86b8 100644 --- a/sahara/main.py +++ b/sahara/main.py @@ -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) diff --git a/sahara/service/periodic.py b/sahara/service/periodic.py index ab897853..85d75d6e 100644 --- a/sahara/service/periodic.py +++ b/sahara/service/periodic.py @@ -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,