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
7e69c3ff
Commit
7e69c3ff
authored
Aug 12, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
failure can be of different types according to how TTF is measured
parent
edb0a270
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
22 deletions
+40
-22
dream/simulation/Failure.py
dream/simulation/Failure.py
+36
-20
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+4
-2
No files found.
dream/simulation/Failure.py
View file @
7e69c3ff
...
@@ -34,7 +34,8 @@ from ObjectInterruption import ObjectInterruption
...
@@ -34,7 +34,8 @@ from ObjectInterruption import ObjectInterruption
class
Failure
(
ObjectInterruption
):
class
Failure
(
ObjectInterruption
):
def
__init__
(
self
,
victim
=
None
,
distribution
=
None
,
index
=
0
,
repairman
=
None
,
offshift
=
False
):
def
__init__
(
self
,
victim
=
None
,
distribution
=
None
,
index
=
0
,
repairman
=
None
,
offshift
=
False
,
deteriorationType
=
'constant'
):
#Process.__init__(self)
#Process.__init__(self)
ObjectInterruption
.
__init__
(
self
,
victim
)
ObjectInterruption
.
__init__
(
self
,
victim
)
if
distribution
:
if
distribution
:
...
@@ -53,6 +54,12 @@ class Failure(ObjectInterruption):
...
@@ -53,6 +54,12 @@ class Failure(ObjectInterruption):
self
.
type
=
"Failure"
self
.
type
=
"Failure"
self
.
id
=
0
self
.
id
=
0
# shows how the time to failure is measured
# 'constant' means it counts not matter the state of the victim
# 'onShift' counts only if the victim is onShift
# 'working' counts only working time
self
.
deteriorationType
=
deteriorationType
if
(
self
.
distType
==
"Availability"
):
if
(
self
.
distType
==
"Availability"
):
# --------------------------------------------------------------
# --------------------------------------------------------------
...
@@ -95,10 +102,13 @@ class Failure(ObjectInterruption):
...
@@ -95,10 +102,13 @@ class Failure(ObjectInterruption):
self
.
victim
.
expectedDownTime
=
self
.
env
.
now
+
remainingTimeToFailure
self
.
victim
.
expectedDownTime
=
self
.
env
.
now
+
remainingTimeToFailure
failureNotTriggered
=
True
failureNotTriggered
=
True
if
self
.
deteriorationType
==
'constant'
:
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
else
:
while
failureNotTriggered
:
while
failureNotTriggered
:
timeRestartedCounting
=
self
.
env
.
now
timeRestartedCounting
=
self
.
env
.
now
# TODO: can also wait for interruptionStart signal of the victim and check whether the interruption is caused by a shiftScheduler
# TODO: can also wait for interruptionStart signal of the victim and check whether the interruption is caused by a shiftScheduler
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victim
.
interruptionStart
#offShift
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victim
.
interruptionStart
# the failure should receive a signal if there is a shift-off triggered
# the failure should receive a signal if there is a shift-off triggered
if
self
.
victim
.
interruptionStart
in
receivedEvent
:
if
self
.
victim
.
interruptionStart
in
receivedEvent
:
# TODO: the signal interruptionStart is reset by the time it is received by the victim. not sure if will be still triggered when it is checked here
# TODO: the signal interruptionStart is reset by the time it is received by the victim. not sure if will be still triggered when it is checked here
...
@@ -113,7 +123,10 @@ class Failure(ObjectInterruption):
...
@@ -113,7 +123,10 @@ class Failure(ObjectInterruption):
else
:
else
:
failureNotTriggered
=
False
failureNotTriggered
=
False
# interrupt the victim only if it was not previously interrupted
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
self
.
interruptVictim
()
# interrupt the victim
self
.
victim
.
Up
=
False
self
.
victim
.
Up
=
False
self
.
victim
.
timeLastFailure
=
self
.
env
.
now
self
.
victim
.
timeLastFailure
=
self
.
env
.
now
self
.
outputTrace
(
"is down"
)
self
.
outputTrace
(
"is down"
)
...
@@ -147,6 +160,9 @@ class Failure(ObjectInterruption):
...
@@ -147,6 +160,9 @@ class Failure(ObjectInterruption):
yield
self
.
env
.
timeout
(
self
.
rngTTR
.
generateNumber
())
# wait until the repairing process is over
yield
self
.
env
.
timeout
(
self
.
rngTTR
.
generateNumber
())
# wait until the repairing process is over
# add the failure time only if the victim was interrupted by this failure
if
self
.
victim
.
interruptedBy
==
'Failure'
:
self
.
victim
.
totalFailureTime
+=
self
.
env
.
now
-
failTime
self
.
victim
.
totalFailureTime
+=
self
.
env
.
now
-
failTime
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
victim
.
Up
=
True
self
.
victim
.
Up
=
True
...
...
dream/simulation/ShiftScheduler.py
View file @
7e69c3ff
...
@@ -90,7 +90,9 @@ class ShiftScheduler(ObjectInterruption):
...
@@ -90,7 +90,9 @@ class ShiftScheduler(ObjectInterruption):
yield
self
.
victim
.
endedLastProcessing
yield
self
.
victim
.
endedLastProcessing
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
self
.
interruptVictim
()
# interrupt processing operations if any
# interrupt the victim only if it was not previously interrupted
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
self
.
victim
.
onShift
=
False
# get the victim off-shift
self
.
victim
.
onShift
=
False
# get the victim off-shift
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
outputTrace
(
"is off shift"
)
self
.
outputTrace
(
"is off shift"
)
...
...
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