Commit d777fb53 authored by Daniele Venzano's avatar Daniele Venzano

Expose Scheduler choice in the configuration file

parent 31a4d207
Scheduler classes
=================
.. autoclass:: zoe_master.scheduler.ZoeScheduler
.. autoclass:: zoe_master.scheduler.ZoeBaseScheduler
:members:
......@@ -86,6 +86,8 @@ def load_configuration(test_conf=None):
argparser.add_argument('--service-log-path', help='Save service logs in this directory, EXPERIMENTAL', default='')
argparser.add_argument('--scheduler-class', help='Scheduler class to use for scheduling ZApps', default='ZoeSimpleScheduler')
opts = argparser.parse_args()
if opts.debug:
argparser.print_values()
......
......@@ -20,7 +20,7 @@
import logging
from zoe_master.master_api import APIManager
from zoe_master.scheduler import ZoeScheduler
import zoe_master.scheduler
from zoe_master.execution_manager import restart_resubmit_scheduler
from zoe_master.monitor import ZoeMonitor
from zoe_master.consistency import ZoeSwarmChecker
......@@ -56,7 +56,7 @@ def main():
state = SQLManager(args)
log.info("Initializing scheduler")
scheduler = ZoeScheduler()
scheduler = getattr(zoe_master.scheduler, config.get_conf().scheduler_class)(state)
monitor = ZoeMonitor(state)
checker = ZoeSwarmChecker(state)
......
......@@ -20,7 +20,7 @@ import logging
from zoe_lib.sql_manager import Execution, SQLManager
from zoe_lib import exec_logs
from zoe_master.scheduler import ZoeScheduler
from zoe_master.scheduler import ZoeBaseScheduler
log = logging.getLogger(__name__)
......@@ -32,18 +32,18 @@ def _digest_application_description(state: SQLManager, execution: Execution):
state.service_new(execution.id, name, service_descr['name'], service_descr)
def execution_submit(state: SQLManager, scheduler: ZoeScheduler, execution: Execution):
def execution_submit(state: SQLManager, scheduler: ZoeBaseScheduler, execution: Execution):
"""Submit a new execution to the scheduler."""
_digest_application_description(state, execution)
scheduler.incoming(execution)
def execution_terminate(scheduler: ZoeScheduler, execution: Execution):
def execution_terminate(scheduler: ZoeBaseScheduler, execution: Execution):
"""Remove an execution form the scheduler."""
scheduler.terminate(execution)
def restart_resubmit_scheduler(state: SQLManager, scheduler: ZoeScheduler):
def restart_resubmit_scheduler(state: SQLManager, scheduler: ZoeBaseScheduler):
"""Restart work after a restart of the process."""
sched_execs = state.execution_list(status=Execution.SCHEDULED_STATUS)
for e in sched_execs:
......
......@@ -26,14 +26,14 @@ from zoe_lib.sql_manager import SQLManager
import zoe_master.execution_manager
from zoe_master.exceptions import ZoeException
from zoe_master.scheduler import ZoeScheduler
from zoe_master.scheduler import ZoeBaseScheduler
log = logging.getLogger(__name__)
class APIManager:
"""The API Manager."""
def __init__(self, metrics: BaseMetricSender, scheduler: ZoeScheduler, state: SQLManager) -> None:
def __init__(self, metrics: BaseMetricSender, scheduler: ZoeBaseScheduler, state: SQLManager) -> None:
self.context = zmq.Context()
self.zmq_s = self.context.socket(zmq.REP)
self.listen_uri = config.get_conf().api_listen_uri
......@@ -84,7 +84,7 @@ class APIManager:
exec_id = message['exec_id']
execution = self.state.execution_list(id=exec_id, only_one=True)
if execution is not None:
zoe_master.execution_manager.execution_delete(self.scheduler, execution)
zoe_master.execution_manager.execution_delete(execution)
self._reply_ok()
elif message['command'] == 'scheduler_stats':
data = self.scheduler.stats()
......
# Copyright (c) 2017, Daniele Venzano
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The Zoe schedulers"""
from .base_scheduler import ZoeBaseScheduler
from .scheduler import ZoeSimpleScheduler
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment