[haizea-commit] r467 - trunk/src/haizea/resourcemanager

haizea-commit at mailman.cs.uchicago.edu haizea-commit at mailman.cs.uchicago.edu
Thu Aug 7 05:18:58 CDT 2008


Author: borja
Date: 2008-08-07 05:18:58 -0500 (Thu, 07 Aug 2008)
New Revision: 467

Modified:
   trunk/src/haizea/resourcemanager/accounting.py
   trunk/src/haizea/resourcemanager/resourcepool.py
   trunk/src/haizea/resourcemanager/rm.py
   trunk/src/haizea/resourcemanager/scheduler.py
Log:
stats -> accounting

Modified: trunk/src/haizea/resourcemanager/accounting.py
===================================================================
--- trunk/src/haizea/resourcemanager/accounting.py	2008-08-07 10:10:23 UTC (rev 466)
+++ trunk/src/haizea/resourcemanager/accounting.py	2008-08-07 10:18:58 UTC (rev 467)
@@ -23,7 +23,7 @@
 from haizea.common.utils import pickle
 from errno import EEXIST
 
-class StatsData(object):
+class AccountingData(object):
     def __init__(self):
         # Counters
         self.counters = {}
@@ -52,9 +52,9 @@
                 slowdowns[lease_id] = lease.get_slowdown()
         return slowdowns
 
-class StatsCollection(object):
+class AccountingDataCollection(object):
     def __init__(self, rm, datafile):
-        self.data = StatsData()
+        self.data = AccountingData()
         self.rm = rm
         self.datafile = datafile   
         self.starttime = None

Modified: trunk/src/haizea/resourcemanager/resourcepool.py
===================================================================
--- trunk/src/haizea/resourcemanager/resourcepool.py	2008-08-07 10:10:23 UTC (rev 466)
+++ trunk/src/haizea/resourcemanager/resourcepool.py	2008-08-07 10:18:58 UTC (rev 467)
@@ -189,7 +189,7 @@
                     
         self.getNode(nod_id).printFiles()
         
-        self.rm.stats.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
+        self.rm.accounting.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
     
     def verifyFileTransfer(self):
         pass
@@ -272,7 +272,7 @@
         img.addMapping(lease_id, vnode)
         self.getNode(pnode).addFile(img)
         self.getNode(pnode).printFiles()
-        self.rm.stats.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
+        self.rm.accounting.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
         return img
         
     def checkImage(self, pnode, lease_id, vnode, imagefile):
@@ -298,7 +298,7 @@
                 img.addMapping(lease_id, vnode)
                 node.addFile(img)
                 node.printFiles()
-                self.rm.stats.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
+                self.rm.accounting.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
     
     def isInPool(self, pnode, imagefile, time):
         return self.getNode(pnode).isInPool(imagefile, after=time)
@@ -332,7 +332,7 @@
 
         node.printFiles()
         
-        self.rm.stats.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
+        self.rm.accounting.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
         
     def addRAMFileToNode(self, pnode, lease_id, vnode, size):
         node = self.getNode(pnode)
@@ -341,7 +341,7 @@
         f = RAMImageFile("RAM_L%iV%i" % (lease_id, vnode), size, lease_id, vnode)
         node.addFile(f)        
         node.printFiles()
-        self.rm.stats.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
+        self.rm.accounting.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
 
     def removeRAMFileFromNode(self, pnode, lease_id, vnode):
         node = self.getNode(pnode)
@@ -349,7 +349,7 @@
         node.printFiles()
         node.removeRAMFile(lease_id, vnode)
         node.printFiles()
-        self.rm.stats.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
+        self.rm.accounting.append_stat(constants.COUNTER_DISKUSAGE, self.getMaxDiskUsage())
         
     def getMaxDiskUsage(self):
         return max([n.getTotalFileSize() for n in self.nodes])

Modified: trunk/src/haizea/resourcemanager/rm.py
===================================================================
--- trunk/src/haizea/resourcemanager/rm.py	2008-08-07 10:10:23 UTC (rev 466)
+++ trunk/src/haizea/resourcemanager/rm.py	2008-08-07 10:18:58 UTC (rev 467)
@@ -31,7 +31,7 @@
 * RealClock: A clock that advances in realtime.
 """
 
-import haizea.resourcemanager.stats as stats
+import haizea.resourcemanager.accounting as accounting
 import haizea.common.constants as constants
 from haizea.resourcemanager.frontends.tracefile import TracefileFrontend
 from haizea.resourcemanager.frontends.opennebula import OpenNebulaFrontend
@@ -122,7 +122,7 @@
             self.frontends = [OpenNebulaFrontend(self)]
             
         # Statistics collection 
-        self.stats = stats.StatsCollection(self, self.config.get("datafile"))
+        self.accounting = accounting.AccountingDataCollection(self, self.config.get("datafile"))
 
     def daemonize(self):
         """Daemonizes the Haizea process.
@@ -177,14 +177,14 @@
         self.logger.status("Starting resource manager", constants.RM)
 
         # Create counters to keep track of interesting data.
-        self.stats.create_counter(constants.COUNTER_ARACCEPTED, constants.AVERAGE_NONE)
-        self.stats.create_counter(constants.COUNTER_ARREJECTED, constants.AVERAGE_NONE)
-        self.stats.create_counter(constants.COUNTER_IMACCEPTED, constants.AVERAGE_NONE)
-        self.stats.create_counter(constants.COUNTER_IMREJECTED, constants.AVERAGE_NONE)
-        self.stats.create_counter(constants.COUNTER_BESTEFFORTCOMPLETED, constants.AVERAGE_NONE)
-        self.stats.create_counter(constants.COUNTER_QUEUESIZE, constants.AVERAGE_TIMEWEIGHTED)
-        self.stats.create_counter(constants.COUNTER_DISKUSAGE, constants.AVERAGE_NONE)
-        self.stats.create_counter(constants.COUNTER_CPUUTILIZATION, constants.AVERAGE_TIMEWEIGHTED)
+        self.accounting.create_counter(constants.COUNTER_ARACCEPTED, constants.AVERAGE_NONE)
+        self.accounting.create_counter(constants.COUNTER_ARREJECTED, constants.AVERAGE_NONE)
+        self.accounting.create_counter(constants.COUNTER_IMACCEPTED, constants.AVERAGE_NONE)
+        self.accounting.create_counter(constants.COUNTER_IMREJECTED, constants.AVERAGE_NONE)
+        self.accounting.create_counter(constants.COUNTER_BESTEFFORTCOMPLETED, constants.AVERAGE_NONE)
+        self.accounting.create_counter(constants.COUNTER_QUEUESIZE, constants.AVERAGE_TIMEWEIGHTED)
+        self.accounting.create_counter(constants.COUNTER_DISKUSAGE, constants.AVERAGE_NONE)
+        self.accounting.create_counter(constants.COUNTER_CPUUTILIZATION, constants.AVERAGE_TIMEWEIGHTED)
         
         if self.daemon:
             self.daemonize()
@@ -199,21 +199,21 @@
         self.logger.status("Stopping resource manager", constants.RM)
         
         # Stop collecting data (this finalizes counters)
-        self.stats.stop()
+        self.accounting.stop()
 
         # TODO: When gracefully stopping mid-scheduling, we need to figure out what to
         #       do with leases that are still running.
 
-        self.logger.status("  Completed best-effort leases: %i" % self.stats.data.counters[constants.COUNTER_BESTEFFORTCOMPLETED], constants.RM)
-        self.logger.status("  Accepted AR leases: %i" % self.stats.data.counters[constants.COUNTER_ARACCEPTED], constants.RM)
-        self.logger.status("  Rejected AR leases: %i" % self.stats.data.counters[constants.COUNTER_ARREJECTED], constants.RM)
+        self.logger.status("  Completed best-effort leases: %i" % self.accounting.data.counters[constants.COUNTER_BESTEFFORTCOMPLETED], constants.RM)
+        self.logger.status("  Accepted AR leases: %i" % self.accounting.data.counters[constants.COUNTER_ARACCEPTED], constants.RM)
+        self.logger.status("  Rejected AR leases: %i" % self.accounting.data.counters[constants.COUNTER_ARREJECTED], constants.RM)
         
         # In debug mode, dump the lease descriptors.
         for lease in self.scheduler.completedleases.entries.values():
             lease.print_contents()
             
         # Write all collected data to disk
-        self.stats.save_to_disk()
+        self.accounting.save_to_disk()
         
     def process_requests(self, nexttime):
         """Process any new requests in the request frontend
@@ -414,7 +414,7 @@
         tracefile request frontend.
         """
         self.rm.logger.status("Starting simulated clock", constants.CLOCK)
-        self.rm.stats.start(self.get_start_time())
+        self.rm.accounting.start(self.get_start_time())
         prevstatustime = self.time
         done = False
         # Main loop
@@ -455,11 +455,11 @@
     def __print_status(self):
         """Prints status summary."""
         self.logger.status("STATUS ---Begin---", constants.RM)
-        self.logger.status("STATUS Completed best-effort leases: %i" % self.rm.stats.data.counters[constants.COUNTER_BESTEFFORTCOMPLETED], constants.RM)
-        self.logger.status("STATUS Queue size: %i" % self.rm.stats.data.counters[constants.COUNTER_QUEUESIZE], constants.RM)
+        self.logger.status("STATUS Completed best-effort leases: %i" % self.rm.accounting.data.counters[constants.COUNTER_BESTEFFORTCOMPLETED], constants.RM)
+        self.logger.status("STATUS Queue size: %i" % self.rm.accounting.data.counters[constants.COUNTER_QUEUESIZE], constants.RM)
         self.logger.status("STATUS Best-effort reservations: %i" % self.rm.scheduler.numbesteffortres, constants.RM)
-        self.logger.status("STATUS Accepted AR leases: %i" % self.rm.stats.data.counters[constants.COUNTER_ARACCEPTED], constants.RM)
-        self.logger.status("STATUS Rejected AR leases: %i" % self.rm.stats.data.counters[constants.COUNTER_ARREJECTED], constants.RM)
+        self.logger.status("STATUS Accepted AR leases: %i" % self.rm.accounting.data.counters[constants.COUNTER_ARACCEPTED], constants.RM)
+        self.logger.status("STATUS Rejected AR leases: %i" % self.rm.accounting.data.counters[constants.COUNTER_ARREJECTED], constants.RM)
         self.logger.status("STATUS ----End----", constants.RM)        
     
     def __get_next_time(self):
@@ -529,7 +529,7 @@
         # an infinite loop. This is A Bad Thing(tm).
         if newtime == prevtime and done != True:
             self.rm.logger.error("Simulated clock has fallen into an infinite loop. Dumping state..." , constants.CLOCK)
-            self.rm.printStats("ERROR", verbose=True)
+            self.rm.print_stats("ERROR", verbose=True)
             raise Exception, "Simulated clock has fallen into an infinite loop."
         
         return newtime, done
@@ -604,7 +604,7 @@
         foreground) or a SIGTERM signal is received.
         """
         self.rm.logger.status("Starting clock", constants.CLOCK)
-        self.rm.stats.start(self.get_start_time())
+        self.rm.accounting.start(self.get_start_time())
         
         signal.signal(signal.SIGINT, self.signalhandler_gracefulstop)
         signal.signal(signal.SIGTERM, self.signalhandler_gracefulstop)

Modified: trunk/src/haizea/resourcemanager/scheduler.py
===================================================================
--- trunk/src/haizea/resourcemanager/scheduler.py	2008-08-07 10:10:23 UTC (rev 466)
+++ trunk/src/haizea/resourcemanager/scheduler.py	2008-08-07 10:18:58 UTC (rev 467)
@@ -148,9 +148,9 @@
                 self.handlers[type(rr)].on_start(self, l, rr)
 
         util = self.slottable.getUtilization(nowtime)
-        self.rm.stats.append_stat(constants.COUNTER_CPUUTILIZATION, util)
+        self.rm.accounting.append_stat(constants.COUNTER_CPUUTILIZATION, util)
         # TODO: Should be moved to rm.py
-        self.rm.stats.tick()
+        self.rm.accounting.tick()
         
         
     def register_handler(self, type, on_start, on_end):
@@ -159,7 +159,7 @@
     
     def enqueue(self, lease_req):
         """Queues a best-effort lease request"""
-        self.rm.stats.incr_counter(constants.COUNTER_QUEUESIZE, lease_req.id)
+        self.rm.accounting.incr_counter(constants.COUNTER_QUEUESIZE, lease_req.id)
         self.queue.enqueue(lease_req)
         self.rm.logger.info("Received (and queueing) best-effort lease request #%i, %i nodes for %s." % (lease_req.id, lease_req.numnodes, lease_req.duration.requested), constants.SCHED)
 
@@ -237,7 +237,7 @@
         try:
             self.__schedule_ar_lease(lease_req, avoidpreempt=True, nexttime=nexttime)
             self.scheduledleases.add(lease_req)
-            self.rm.stats.incr_counter(constants.COUNTER_ARACCEPTED, lease_req.id)
+            self.rm.accounting.incr_counter(constants.COUNTER_ARACCEPTED, lease_req.id)
             accepted = True
         except SchedException, msg:
             # Our first try avoided preemption, try again
@@ -248,10 +248,10 @@
                 self.rm.logger.debug("LEASE-%i Trying again without avoiding preemption" % lease_req.id, constants.SCHED)
                 self.__schedule_ar_lease(lease_req, nexttime, avoidpreempt=False)
                 self.scheduledleases.add(lease_req)
-                self.rm.stats.incr_counter(constants.COUNTER_ARACCEPTED, lease_req.id)
+                self.rm.accounting.incr_counter(constants.COUNTER_ARACCEPTED, lease_req.id)
                 accepted = True
             except SchedException, msg:
-                self.rm.stats.incr_counter(constants.COUNTER_ARREJECTED, lease_req.id)
+                self.rm.accounting.incr_counter(constants.COUNTER_ARREJECTED, lease_req.id)
                 self.rm.logger.debug("LEASE-%i Scheduling exception: %s" % (lease_req.id, msg), constants.SCHED)
 
         if accepted:
@@ -302,7 +302,7 @@
                     self.rm.logger.debug("  ResReq  : %s" % lease_req.requested_resources, constants.SCHED)
                     self.__schedule_besteffort_lease(lease_req, nexttime)
                     self.scheduledleases.add(lease_req)
-                    self.rm.stats.decr_counter(constants.COUNTER_QUEUESIZE, lease_req.id)
+                    self.rm.accounting.decr_counter(constants.COUNTER_QUEUESIZE, lease_req.id)
                 except SchedException, msg:
                     # Put back on queue
                     newqueue.enqueue(lease_req)
@@ -389,10 +389,10 @@
         try:
             self.__schedule_immediate_lease(lease_req, nexttime=nexttime)
             self.scheduledleases.add(lease_req)
-            self.rm.stats.incr_counter(constants.COUNTER_IMACCEPTED, lease_req.id)
+            self.rm.accounting.incr_counter(constants.COUNTER_IMACCEPTED, lease_req.id)
             self.rm.logger.info("Immediate lease request #%i has been accepted." % lease_req.id, constants.SCHED)
         except SchedException, msg:
-            self.rm.stats.incr_counter(constants.COUNTER_IMREJECTED, lease_req.id)
+            self.rm.accounting.incr_counter(constants.COUNTER_IMREJECTED, lease_req.id)
             self.rm.logger.debug("LEASE-%i Scheduling exception: %s" % (lease_req.id, msg), constants.SCHED)
         
         
@@ -435,7 +435,7 @@
             req.vmimagemap = {}
             self.scheduledleases.remove(req)
             self.queue.enqueue_in_order(req)
-            self.rm.stats.incr_counter(constants.COUNTER_QUEUESIZE, req.id)
+            self.rm.accounting.incr_counter(constants.COUNTER_QUEUESIZE, req.id)
         else:
             susptype = self.rm.config.get("suspension")
             timebeforesuspend = time - vmrr.start
@@ -468,7 +468,7 @@
                 req.vmimagemap = {}
                 self.scheduledleases.remove(req)
                 self.queue.enqueue_in_order(req)
-                self.rm.stats.incr_counter(constants.COUNTER_QUEUESIZE, req.id)
+                self.rm.accounting.incr_counter(constants.COUNTER_QUEUESIZE, req.id)
         self.rm.logger.edebug("Lease after preemption:", constants.SCHED)
         req.print_contents()
         
@@ -546,7 +546,7 @@
             for vnode, pnode in l.vmimagemap.items():
                 self.rm.resourcepool.removeImage(pnode, l.id, vnode)
             if isinstance(l, ds.BestEffortLease):
-                self.rm.stats.incr_counter(constants.COUNTER_BESTEFFORTCOMPLETED, l.id)
+                self.rm.accounting.incr_counter(constants.COUNTER_BESTEFFORTCOMPLETED, l.id)
        
         if isinstance(l, ds.BestEffortLease):
             if rr.backfill_reservation == True:
@@ -596,7 +596,7 @@
         l.state = constants.LEASE_STATE_SUSPENDED
         self.scheduledleases.remove(l)
         self.queue.enqueue_in_order(l)
-        self.rm.stats.incr_counter(constants.COUNTER_QUEUESIZE, l.id)
+        self.rm.accounting.incr_counter(constants.COUNTER_QUEUESIZE, l.id)
         l.print_contents()
         self.updateNodeVMState(rr.nodes.values(), constants.DOING_IDLE, l.id)
         self.rm.logger.debug("LEASE-%i End of handleEndSuspend" % l.id, constants.SCHED)
@@ -631,7 +631,7 @@
 
 
     def __enqueue_in_order(self, req):
-        self.rm.stats.incr_counter(constants.COUNTER_QUEUESIZE, req.id)
+        self.rm.accounting.incr_counter(constants.COUNTER_QUEUESIZE, req.id)
         self.queue.enqueue_in_order(req)
 
     



More information about the Haizea-commit mailing list