[rhmessaging-commits] rhmessaging commits: r2858 - mgmt/trunk/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Nov 21 10:40:40 EST 2008


Author: nunofsantos
Date: 2008-11-21 10:40:40 -0500 (Fri, 21 Nov 2008)
New Revision: 2858

Modified:
   mgmt/trunk/mint/python/mint/__init__.py
   mgmt/trunk/mint/python/mint/update.py
Log:
change handling of class keys to reflect new string representation in qmf.console

Modified: mgmt/trunk/mint/python/mint/__init__.py
===================================================================
--- mgmt/trunk/mint/python/mint/__init__.py	2008-11-20 23:07:47 UTC (rev 2857)
+++ mgmt/trunk/mint/python/mint/__init__.py	2008-11-21 15:40:40 UTC (rev 2858)
@@ -350,9 +350,7 @@
     self.connCloseListener = connCloseListener
 
   def __pythonValueToDB(self, key, value):
-    if key == "qmfClassKey":
-      value = u"'%s'" % unicode(value, "raw_unicode_escape").replace("'", "''")
-    elif type(value) == types.DictType:
+    if type(value) == types.DictType:
       value = u"'%s'" % pickle.dumps(value).replace("'", "''")
     elif value is None:
       value = "NULL"
@@ -438,8 +436,7 @@
     finally:
       self.unlock()
 
-    pname, cname, hash = classKey.split(", ")
-    seq = self.mgmtSession._sendMethodRequest(broker, (pname, cname, hash), objId, methodName, args)
+    seq = self.mgmtSession._sendMethodRequest(broker, classKey, objId, methodName, args)
 
     if seq is not None:
       self.lock()
@@ -486,7 +483,7 @@
 
   def objectProps(self, broker, record):
     """ Invoked when an object is updated. """
-    if record.getClassKey()[1] == "job":
+    if record.getClassKey().getClassName() == "job":
       priority = 1
     else:
       priority = 0
@@ -494,7 +491,7 @@
 
   def objectStats(self, broker, record):
     """ Invoked when an object is updated. """
-    if record.getClassKey()[1] == "job":
+    if record.getClassKey().getClassName() == "job":
       priority = 1
     else:
       priority = 0

Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py	2008-11-20 23:07:47 UTC (rev 2857)
+++ mgmt/trunk/mint/python/mint/update.py	2008-11-21 15:40:40 UTC (rev 2858)
@@ -28,6 +28,8 @@
     self.enqueueCount = 0
     self.dequeueCount = 0
 
+    self.commitThreshold = 100
+
   def enqueue(self, update, priority=0):
     try:
       self.updates.put((priority, update))
@@ -56,7 +58,8 @@
 
       try:
         update.process(self.model, conn)
-        if self.dequeueCount % 100 == 0:
+        if self.model.cache.isDirty() and (self.dequeueCount % self.commitThreshold == 0 or self.updates.qsize() == 0):
+          # commit only every "commitThreshold" updates, or whenever the update queue is empty
           conn.commit()
           self.model.cache.commit()
       except:
@@ -130,8 +133,8 @@
     ModelUpdate.__init__(self, broker, obj)
 
   def process(self, model, conn):
-    pkg, cls, hash = self.qmfObj.getClassKey()
-    origCls = cls
+    clsKey = self.qmfObj.getClassKey()
+    origCls = cls = clsKey.getClassName()
     if cls in mint.schema.schemaReservedWordsMap:
       cls = mint.schema.schemaReservedWordsMap.get(cls)
     cls = cls[0].upper()+cls[1:]  
@@ -162,7 +165,7 @@
 
     attrs["sourceScopeId"] = idFirst
     attrs["sourceObjectId"] = idSecond
-    attrs["qmfClassKey"] = "%s, %s, %s" % (pkg, origCls, hash)
+    attrs["qmfClassKey"] = clsKey
     attrs["managedBroker"] = str(self.broker.getBrokerId())
 
     cursor = conn.cursor()
@@ -215,9 +218,7 @@
     ModelUpdate.__init__(self, broker, obj)
 
   def process(self, model, conn):
-    pkg, cls, hash = self.qmfObj.getClassKey()
-
-    origCls = cls
+    origCls = cls = self.qmfObj.getClassKey().getClassName()
     if cls in mint.schema.schemaReservedWordsMap:
       cls = mint.schema.schemaReservedWordsMap.get(cls)
     cls = cls[0].upper()+cls[1:]  




More information about the rhmessaging-commits mailing list