Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pybatsim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
batsim
pybatsim
Commits
fa0e85cb
Commit
fa0e85cb
authored
Jan 08, 2019
by
MERCIER Michael
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[core] make event socket optional
parent
48d7370a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
22 deletions
+24
-22
batsim/batsim.py
batsim/batsim.py
+15
-14
batsim/cmds/launcher.py
batsim/cmds/launcher.py
+1
-1
batsim/tools/launcher.py
batsim/tools/launcher.py
+8
-7
No files found.
batsim/batsim.py
View file @
fa0e85cb
...
...
@@ -22,21 +22,23 @@ class Batsim(object):
WORKLOAD_JOB_SEPARATOR_REPLACEMENT
=
"%"
def
__init__
(
self
,
scheduler
,
network_handler
=
None
,
event_handler
=
None
,
network_endpoint
,
timeout
,
event_endpoint
=
None
,
validatingmachine
=
None
):
self
.
logger
=
logging
.
getLogger
(
__name__
)
self
.
running_simulation
=
False
if
network_handler
is
None
:
network_handler
=
NetworkHandler
(
'tcp://*:28000'
)
if
event_handler
is
None
:
event_handler
=
NetworkHandler
(
'tcp://127.0.0.1:28001'
,
type
=
zmq
.
PUB
)
self
.
network
=
network_handler
self
.
event_publisher
=
event_handler
self
.
network
=
NetworkHandler
(
network_endpoint
,
timeout
=
timeout
)
self
.
network
.
bind
()
# event hendler is optional
self
.
event_publisher
=
None
if
event_endpoint
is
not
None
:
self
.
event_publisher
=
NetworkHandler
(
event_endpoint
,
type
=
zmq
.
PUB
)
self
.
event_publisher
.
bind
()
self
.
jobs
=
dict
()
...
...
@@ -64,9 +66,6 @@ class Batsim(object):
self
.
no_more_static_jobs
=
False
self
.
network
.
bind
()
self
.
event_publisher
.
bind
()
self
.
scheduler
.
bs
=
self
# import pdb; pdb.set_trace()
# Wait the "simulation starts" message to read the number of machines
...
...
@@ -78,7 +77,8 @@ class Batsim(object):
"""Sends a message to subscribed event listeners (e.g. external processes which want to
observe the simulation).
"""
self
.
event_publisher
.
send_string
(
event
)
if
self
.
event_publisher
is
not
None
:
self
.
event_publisher
.
send_string
(
event
)
def
time
(
self
):
return
self
.
_current_time
...
...
@@ -592,7 +592,8 @@ class Batsim(object):
if
finished_received
:
self
.
network
.
close
()
self
.
event_publisher
.
close
()
if
self
.
event_publisher
is
not
None
:
self
.
event_publisher
.
close
()
return
not
finished_received
...
...
batsim/cmds/launcher.py
View file @
fa0e85cb
...
...
@@ -11,7 +11,7 @@ Options:
-d --debug Be more verbose.
-p --protect Protect the scheduler using a validating machine.
-s --socket-endpoint=<endpoint> Batsim socket endpoint to use [default: tcp://*:28000]
-e --event-socket-endpoint=<endpoint> Socket endpoint to use to publish scheduler events
[default: tcp://*:29000]
-e --event-socket-endpoint=<endpoint> Socket endpoint to use to publish scheduler events
-o --options=<options_string> A Json string to pass to the scheduler [default: {}]
-O --options-file=<options_file> A file containing the json options
-t --timeout=<timeout> How long to wait for responses from Batsim [default: 2000]
...
...
batsim/tools/launcher.py
View file @
fa0e85cb
...
...
@@ -100,11 +100,11 @@ def instanciate_scheduler(name, options):
def
launch_scheduler
(
scheduler
,
socket_endpoint
=
"tcp://*:28000"
,
event_socket_endpoint
=
"tcp://*:28001"
,
options
=
{}
,
timeout
=
2000
,
protect
=
True
):
socket_endpoint
,
event_socket_endpoint
,
options
,
timeout
,
protect
):
if
protect
:
vm
=
ValidatingMachine
...
...
@@ -116,8 +116,9 @@ def launch_scheduler(scheduler,
#try:
bs
=
Batsim
(
scheduler
,
NetworkHandler
(
socket_endpoint
,
timeout
),
NetworkHandler
(
event_socket_endpoint
,
type
=
zmq
.
PUB
),
socket_endpoint
,
timeout
,
event_socket_endpoint
,
validatingmachine
=
vm
)
aborted
=
False
# try:
...
...
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