[haizea-commit] r496 - in trunk/src/haizea: common resourcemanager

haizea-commit at mailman.cs.uchicago.edu haizea-commit at mailman.cs.uchicago.edu
Mon Sep 15 11:52:22 CDT 2008


Author: borja
Date: 2008-09-15 11:52:21 -0500 (Mon, 15 Sep 2008)
New Revision: 496

Modified:
   trunk/src/haizea/common/constants.py
   trunk/src/haizea/resourcemanager/configfile.py
   trunk/src/haizea/resourcemanager/rm.py
Log:
Add option to stop Haizea (in OpenNebula mode) when there are no leases left to process.

Modified: trunk/src/haizea/common/constants.py
===================================================================
--- trunk/src/haizea/common/constants.py	2008-09-15 16:50:37 UTC (rev 495)
+++ trunk/src/haizea/common/constants.py	2008-09-15 16:52:21 UTC (rev 496)
@@ -108,4 +108,5 @@
 EVENT_END_VM=0
 
 LOGLEVEL_VDEBUG = 5
-LOGLEVEL_STATUS = 25
\ No newline at end of file
+LOGLEVEL_STATUS = 25
+

Modified: trunk/src/haizea/resourcemanager/configfile.py
===================================================================
--- trunk/src/haizea/resourcemanager/configfile.py	2008-09-15 16:50:37 UTC (rev 495)
+++ trunk/src/haizea/resourcemanager/configfile.py	2008-09-15 16:52:21 UTC (rev 496)
@@ -562,7 +562,7 @@
 
      Option(name        = "onevm",
             getter      = "onevm",
-            type        = OPTTYPE_INT,
+            type        = OPTTYPE_STRING,
             required    = True,
             doc         = """
             Location of OpenNebula "onevm" command.                
@@ -577,6 +577,20 @@
             Rate at which VMs are estimated to suspend (in MB of
             memory per second)                
             """),
+            
+     Option(name        = "stop-when-no-more-leases",
+            getter      = "stop-when-no-more-leases",
+            type        = OPTTYPE_BOOLEAN,
+            required    = False,
+            default     = False,
+            doc         = """
+            This option is useful for testing and running experiments.
+            If set to True, Haizea will stop when there are no more leases
+            to process (which allows you to tun Haizea+OpenNebula unattended,
+            and count on it stopping when there are no more leases to process).
+            For now, this only makes sense if you're seeding Haizea with requests from
+            the start (otherwise, it will start and immediately stop).
+            """),            
     ]
     sections.append(opennebula)
     

Modified: trunk/src/haizea/resourcemanager/rm.py
===================================================================
--- trunk/src/haizea/resourcemanager/rm.py	2008-09-15 16:50:37 UTC (rev 495)
+++ trunk/src/haizea/resourcemanager/rm.py	2008-09-15 16:52:21 UTC (rev 496)
@@ -248,7 +248,7 @@
         # Get requests from frontend
         requests = []
         for frontend in self.frontends:
-            requests += frontend.getAccumulatedRequests()
+            requests += frontend.get_accumulated_requests()
         requests.sort(key=operator.attrgetter("submit_time"))
         
         for req in requests:
@@ -492,7 +492,7 @@
         tracefrontend = self.__get_trace_frontend()
         nextchangepoint = self.rm.get_next_changepoint()
         nextprematureend = self.rm.scheduler.slottable.getNextPrematureEnd(self.time)
-        nextreqtime = tracefrontend.getNextReqTime()
+        nextreqtime = tracefrontend.get_next_request_time()
         self.logger.debug("Next change point (in slot table): %s" % nextchangepoint)
         self.logger.debug("Next request time: %s" % nextreqtime)
         self.logger.debug("Next premature end: %s" % nextprematureend)
@@ -526,7 +526,7 @@
             
         # If there's no more leases in the system, and no more pending requests,
         # then we're done.
-        if not self.rm.exists_leases_in_rm() and not tracefrontend.existsPendingReq():
+        if not self.rm.exists_leases_in_rm() and not tracefrontend.exists_more_requests():
             done = True
         
         # We can also be done if we've specified that we want to stop when
@@ -667,11 +667,22 @@
                 nextwakeup = self.nextperiodicwakeup
                 self.logger.status("Going back to sleep. Waking up at %s to see if something interesting has happened by then." % nextwakeup)
             
+            # The only exit condition from the real clock is if the stop_when_no_more_leases
+            # is set to True, and there's no more work left to do.
+            stop_when_no_more_leases = self.rm.config.get("stop-when-no-more-leases")
+            if stop_when_no_more_leases and not self.rm.exists_leases_in_rm():
+                done = True
+            
             # Sleep
-            if not self.fastforward:
-                sleep((nextwakeup - now()).seconds)
-            else:
-                self.lastwakeup = nextwakeup
+            if not done:
+                if not self.fastforward:
+                    sleep((nextwakeup - now()).seconds)
+                else:
+                    self.lastwakeup = nextwakeup
+
+        # Stop the resource manager
+        self.logger.status("Stopping real clock")
+        self.rm.stop()
           
     def print_stats(self, loglevel):
         """See docstring in base Clock class."""



More information about the Haizea-commit mailing list