Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
zoe
main
Commits
31a4d207
Commit
31a4d207
authored
Jan 09, 2017
by
Daniele Venzano
Browse files
Create a scheduler interface and move the current scheduler into the scheduler package
parent
016d9d21
Changes
4
Hide whitespace changes
Inline
Side-by-side
zoe_master/execution_manager.py
View file @
31a4d207
...
...
@@ -59,8 +59,7 @@ def restart_resubmit_scheduler(state: SQLManager, scheduler: ZoeScheduler):
scheduler
.
incoming
(
e
)
def
execution_delete
(
scheduler
:
ZoeScheduler
,
execution
:
Execution
):
"""Remove an execution
from the scheduler
, must only be called if the execution is NOT running."""
def
execution_delete
(
execution
:
Execution
):
"""Remove an execution, must only be called if the execution is NOT running."""
assert
not
execution
.
is_active
()
exec_logs
.
delete
(
execution
)
scheduler
.
remove_execution
(
execution
)
zoe_master/scheduler/__init__.py
0 → 100644
View file @
31a4d207
zoe_master/scheduler/base_scheduler.py
0 → 100644
View file @
31a4d207
# 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 base class for Zoe schedulers"""
import
zoe_lib.sql_manager
class
ZoeBaseScheduler
:
"""The base class for Zoe schedulers"""
def
__init__
(
self
,
state
:
zoe_lib
.
sql_manager
.
SQLManager
):
self
.
state
=
state
def
trigger
(
self
):
"""Trigger a scheduler run."""
raise
NotImplementedError
def
incoming
(
self
,
execution
:
zoe_lib
.
sql_manager
.
Execution
):
"""
This method adds the execution to the end of the FIFO queue and triggers the scheduler.
:param execution: The execution
:return:
"""
raise
NotImplementedError
def
terminate
(
self
,
execution
:
zoe_lib
.
sql_manager
.
Execution
)
->
None
:
"""
Inform the master that an execution has been terminated. This can be done asynchronously.
:param execution: the terminated execution
:return: None
"""
raise
NotImplementedError
def
quit
(
self
):
"""Stop the scheduler."""
raise
NotImplementedError
def
stats
(
self
):
"""Scheduler statistics."""
raise
NotImplementedError
zoe_master/scheduler.py
→
zoe_master/scheduler
/scheduler
.py
View file @
31a4d207
...
...
@@ -22,13 +22,15 @@ from zoe_lib.sql_manager import Execution
from
zoe_master.exceptions
import
ZoeStartExecutionFatalException
,
ZoeStartExecutionRetryException
from
zoe_master.zapp_to_docker
import
execution_to_containers
,
terminate_execution
from
zoe_master.scheduler.base_scheduler
import
ZoeBaseScheduler
log
=
logging
.
getLogger
(
__name__
)
class
ZoeScheduler
:
class
ZoeS
impleS
cheduler
(
ZoeBaseScheduler
)
:
"""The Scheduler class."""
def
__init__
(
self
):
def
__init__
(
self
,
state
):
super
().
__init__
(
state
)
self
.
fifo_queue
=
[]
self
.
trigger_semaphore
=
threading
.
Semaphore
(
0
)
self
.
async_threads
=
[]
...
...
@@ -68,13 +70,6 @@ class ZoeScheduler:
th
.
start
()
self
.
async_threads
.
append
(
th
)
def
remove_execution
(
self
,
execution
:
Execution
):
"""Removes the execution form the queue."""
try
:
self
.
fifo_queue
.
remove
(
execution
)
except
ValueError
:
pass
def
loop_start_th
(
self
):
"""The Scheduler thread loop."""
auto_trigger_base
=
60
# seconds
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment