[haizea-commit] r811 - in branches/1.1/src/haizea: common core
haizea-commit at mailman.cs.uchicago.edu
haizea-commit at mailman.cs.uchicago.edu
Thu Jun 24 13:24:42 CDT 2010
Author: borja
Date: 2010-06-24 13:24:42 -0500 (Thu, 24 Jun 2010)
New Revision: 811
Modified:
branches/1.1/src/haizea/common/constants.py
branches/1.1/src/haizea/core/configfile.py
branches/1.1/src/haizea/core/manager.py
Log:
Added option to interrupt simulation after a given amount of (simulated) time has passed.
Modified: branches/1.1/src/haizea/common/constants.py
===================================================================
--- branches/1.1/src/haizea/common/constants.py 2010-06-22 22:18:18 UTC (rev 810)
+++ branches/1.1/src/haizea/common/constants.py 2010-06-24 18:24:42 UTC (rev 811)
@@ -52,6 +52,7 @@
STOPWHEN_ALLDONE = "all-leases-done"
STOPWHEN_BESUBMITTED="besteffort-submitted"
STOPWHEN_BEDONE="besteffort-done"
+STOPWHEN_EXACT="exact"
REUSE_NONE="none"
REUSE_IMAGECACHES="image-caches"
Modified: branches/1.1/src/haizea/core/configfile.py
===================================================================
--- branches/1.1/src/haizea/core/configfile.py 2010-06-22 22:18:18 UTC (rev 810)
+++ branches/1.1/src/haizea/core/configfile.py 2010-06-24 18:24:42 UTC (rev 811)
@@ -524,7 +524,8 @@
default = constants.STOPWHEN_ALLDONE,
valid = [constants.STOPWHEN_ALLDONE,
constants.STOPWHEN_BESUBMITTED,
- constants.STOPWHEN_BEDONE],
+ constants.STOPWHEN_BEDONE,
+ constants.STOPWHEN_EXACT],
doc = """
When using the simulated clock, this specifies when the
simulation must end. Valid options are:
@@ -534,9 +535,20 @@
- besteffort-submitted: When all best-effort leases have been
submitted.
- besteffort-done: When all best-effort leases have been
- completed.
+ completed.
+ - exact: Stop at a specific time (use option stop-when-time)
"""),
+ Option(name = "stop-when-time",
+ getter = "stop-when-time",
+ type = OPTTYPE_STRING,
+ required = False,
+ required_if = [(("simulation","stop-when"),constants.STOPWHEN_EXACT)],
+ doc = """
+ A time in format DD:HH:MM:SS at which the simulation should be
+ stopped (useful for debugging)
+ """),
+
Option(name = "status-message-interval",
getter = "status-message-interval",
type = OPTTYPE_INT,
Modified: branches/1.1/src/haizea/core/manager.py
===================================================================
--- branches/1.1/src/haizea/core/manager.py 2010-06-22 22:18:18 UTC (rev 810)
+++ branches/1.1/src/haizea/core/manager.py 2010-06-24 18:24:42 UTC (rev 811)
@@ -64,7 +64,7 @@
import socket
from time import sleep
from math import ceil
-from mx.DateTime import now, TimeDelta
+from mx.DateTime import now, TimeDelta, Parser
DAEMON_STDOUT = DAEMON_STDIN = "/dev/null"
DAEMON_STDERR = "/var/tmp/haizea.err"
@@ -868,6 +868,7 @@
# We can also be done if we've specified that we want to stop when
# the best-effort requests are all done or when they've all been submitted.
stopwhen = self.manager.config.get("stop-when")
+
besteffort = self.manager.scheduler.leases.get_leases(type = Lease.BEST_EFFORT)
pendingbesteffort = [r for r in tracefrontend.requests if r.get_type() == Lease.BEST_EFFORT]
if stopwhen == constants.STOPWHEN_BEDONE:
@@ -876,6 +877,12 @@
elif stopwhen == constants.STOPWHEN_BESUBMITTED:
if len(pendingbesteffort) == 0:
self.done = True
+ elif stopwhen == constants.STOPWHEN_ALLDONE:
+ pass
+ elif stopwhen == constants.STOPWHEN_EXACT:
+ t = Parser.DateTimeDeltaFromString(self.manager.config.get("stop-when-time"))
+ if self.time >= self.starttime + t:
+ self.done = True
# If we didn't arrive at a new time, and we're not done, we've fallen into
# an infinite loop. This is A Bad Thing(tm).
More information about the Haizea-commit
mailing list