Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
10eef807
Commit
10eef807
authored
Jul 16, 2014
by
Ioannis Papagiannopoulos
Committed by
Georgios Dagkakis
Sep 01, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
failure to signal Router if it is not initiated fixed
parent
59855e0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
16 deletions
+26
-16
dream/simulation/RoutingQueue.py
dream/simulation/RoutingQueue.py
+26
-16
No files found.
dream/simulation/RoutingQueue.py
View file @
10eef807
...
@@ -53,7 +53,7 @@ class RoutingQueue(Queue):
...
@@ -53,7 +53,7 @@ class RoutingQueue(Queue):
activeObjectQueue
=
self
.
Res
.
users
activeObjectQueue
=
self
.
Res
.
users
#if we have only one possible receiver just check if the Queue holds one or more entities
#if we have only one possible receiver just check if the Queue holds one or more entities
if
(
callerObject
==
None
):
if
(
callerObject
==
None
):
return
len
(
activeObjectQueue
)
>
0
return
len
(
activeObjectQueue
)
>
0
thecaller
=
callerObject
thecaller
=
callerObject
# local flag to control whether the callerObject can receive any of the entities in the buffers internal queue
# local flag to control whether the callerObject can receive any of the entities in the buffers internal queue
isInRouting
=
False
isInRouting
=
False
...
@@ -89,12 +89,15 @@ class RoutingQueue(Queue):
...
@@ -89,12 +89,15 @@ class RoutingQueue(Queue):
def
removeEntity
(
self
,
entity
=
None
):
def
removeEntity
(
self
,
entity
=
None
):
activeEntity
=
Queue
.
removeEntity
(
self
,
entity
)
#run the default method
activeEntity
=
Queue
.
removeEntity
(
self
,
entity
)
#run the default method
# check if the queue is empty, if yes then try to signal the router, operators may need reallocation
# check if the queue is empty, if yes then try to signal the router, operators may need reallocation
if
self
.
level
:
try
:
if
not
len
(
self
.
getActiveObjectQueue
()):
if
self
.
level
:
from
Globals
import
G
if
not
len
(
self
.
getActiveObjectQueue
()):
if
not
G
.
Router
.
invoked
:
from
Globals
import
G
G
.
Router
.
invoked
=
True
if
not
G
.
Router
.
invoked
:
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
except
:
pass
return
activeEntity
return
activeEntity
# =======================================================================
# =======================================================================
...
@@ -104,22 +107,26 @@ class RoutingQueue(Queue):
...
@@ -104,22 +107,26 @@ class RoutingQueue(Queue):
def
getEntity
(
self
):
def
getEntity
(
self
):
activeEntity
=
Queue
.
getEntity
(
self
)
#run the default behavior
activeEntity
=
Queue
.
getEntity
(
self
)
#run the default behavior
# update the receiver object of the entity just received according to the routing of the parent batch
# update the receiver object of the entity just received according to the routing of the parent batch
route
=
activeEntity
.
parentBatch
.
routing
()
activeEntity
.
receiver
=
None
activeEntity
.
receiver
=
None
try
:
try
:
for
nextObj
in
self
.
next
:
for
nextObj
in
self
.
next
:
if
nextObj
in
e
ntity
.
parentBatch
.
routing
():
if
nextObj
in
activeE
ntity
.
parentBatch
.
routing
():
e
ntity
.
receiver
=
nextObj
activeE
ntity
.
receiver
=
nextObj
break
break
# if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None
# if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None
except
:
except
:
pass
pass
# if the level is reached then try to signal the Router to reallocate the operators
# if the level is reached then try to signal the Router to reallocate the operators
if
self
.
level
:
try
:
if
len
(
self
.
getActiveObjectQueue
())
==
self
.
level
:
if
self
.
level
:
from
Globals
import
G
if
len
(
self
.
getActiveObjectQueue
())
==
self
.
level
:
if
not
G
.
Router
.
invoked
:
from
Globals
import
G
G
.
Router
.
invoked
=
True
if
not
G
.
Router
.
invoked
:
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
except
:
pass
return
activeEntity
return
activeEntity
# =======================================================================
# =======================================================================
...
@@ -137,4 +144,7 @@ class RoutingQueue(Queue):
...
@@ -137,4 +144,7 @@ class RoutingQueue(Queue):
self
.
activeQSorter
()
self
.
activeQSorter
()
# sort again according to the existence or not of receiver attribute of the entities
# sort again according to the existence or not of receiver attribute of the entities
activeObjectQueue
=
self
.
getActiveObjectQueue
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
receiver
,
reverse
=
True
)
# if no entity.receiver, then show preference to these entities
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
receiver
==
None
,
reverse
=
True
)
# if there is entity.receiver then check if it is the same as the self.receiver of the queue (if any)
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
receiver
==
self
.
receiver
,
reverse
=
True
)
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