[rhmessaging-commits] rhmessaging commits: r3775 - in mgmt/trunk: mint/python/mint and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Jan 8 17:35:57 EST 2010


Author: justi9
Date: 2010-01-08 17:35:57 -0500 (Fri, 08 Jan 2010)
New Revision: 3775

Added:
   mgmt/trunk/mint/python/mint/vacuum.py
Modified:
   mgmt/trunk/cumin/python/cumin/model.py
   mgmt/trunk/mint/python/mint/main.py
Log:
Do periodic vacuuming in the update queue

Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py	2010-01-08 22:33:13 UTC (rev 3774)
+++ mgmt/trunk/cumin/python/cumin/model.py	2010-01-08 22:35:57 UTC (rev 3775)
@@ -28,6 +28,7 @@
         self.mint.updateEnabled = False
         self.mint.pollEnabled = False
         self.mint.expireEnabled = False
+        self.mint.vacuumEnabled = False
 
         self.lock = Lock()
 

Modified: mgmt/trunk/mint/python/mint/main.py
===================================================================
--- mgmt/trunk/mint/python/mint/main.py	2010-01-08 22:33:13 UTC (rev 3774)
+++ mgmt/trunk/mint/python/mint/main.py	2010-01-08 22:35:57 UTC (rev 3775)
@@ -7,10 +7,11 @@
 from parsley.threadingex import Lifecycle
 
 from database import MintDatabase
+from expire import ExpireThread
 from model import MintModel
+from poll import PollThread
 from update import UpdateThread
-from poll import PollThread
-from expire import ExpireThread
+from vacuum import VacuumThread
 
 log = logging.getLogger("mint.main")
 
@@ -33,6 +34,9 @@
     self.expireThreshold = self.config.expire_threshold
     self.expireThread = ExpireThread(self)
 
+    self.vacuumEnabled = True
+    self.vacuumThread = VacuumThread(self)
+
   def check(self):
     self.database.check()
     self.model.check()
@@ -51,6 +55,7 @@
     self.updateThread.init()
     self.pollThread.init()
     self.expireThread.init()
+    self.vacuumThread.init()
 
   def do_start(self):
     self.model.start()
@@ -64,6 +69,9 @@
     if self.expireEnabled:
       self.expireThread.start()
 
+    if self.vacuumEnabled:
+      self.vacuumThread.start()
+
   def do_stop(self):
     self.model.stop()
 
@@ -76,6 +84,9 @@
     if self.expireEnabled:
       self.expireThread.stop()
 
+    if self.vacuumEnabled:
+      self.vacuumThread.stop()
+
 class MintConfig(Config):
   def __init__(self):
     super(MintConfig, self).__init__()

Added: mgmt/trunk/mint/python/mint/vacuum.py
===================================================================
--- mgmt/trunk/mint/python/mint/vacuum.py	                        (rev 0)
+++ mgmt/trunk/mint/python/mint/vacuum.py	2010-01-08 22:35:57 UTC (rev 3775)
@@ -0,0 +1,35 @@
+from update import *
+from util import *
+
+log = logging.getLogger("mint.vacuum")
+
+class VacuumThread(MintDaemonThread):
+  def __init__(self, app):
+    super(VacuumThread, self).__init__(app)
+
+  def run(self):
+    while True:
+      if self.stopRequested:
+        break
+
+      up = VacuumUpdate(self.app.model)
+      self.app.updateThread.enqueue(up)
+
+      sleep(60 * 10)
+
+class VacuumUpdate(ModelUpdate):
+  def __init__(self, model):
+    super(VacuumUpdate, self).__init__(model, None, None)
+
+  def process(self, thread):
+    log.info("Vacuuming")
+
+    thread.conn.commit()
+
+    level = thread.conn.isolation_level
+    thread.conn.set_isolation_level(0)
+
+    cursor = thread.cursor()
+    cursor.execute("vacuum")
+
+    thread.conn.set_isolation_level(level)



More information about the rhmessaging-commits mailing list