[rhmessaging-commits] rhmessaging commits: r1625 - mgmt/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Jan 29 16:57:51 EST 2008


Author: nunofsantos
Date: 2008-01-29 16:57:51 -0500 (Tue, 29 Jan 2008)
New Revision: 1625

Modified:
   mgmt/mint/python/mint/__init__.py
   mgmt/mint/python/mint/schema.py
   mgmt/mint/python/mint/schemaparser.py
Log:
turn on lazyUpdates, do explicit syncUpdates; try/except around setting of fields from schema

Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py	2008-01-29 21:00:40 UTC (rev 1624)
+++ mgmt/mint/python/mint/__init__.py	2008-01-29 21:57:51 UTC (rev 1625)
@@ -78,6 +78,7 @@
           #print "\n\n=============== %s %d NOT found, creating\n\n" % (objType.__name__, idOriginal)
           obj = objType.__new__(objType)
           obj.__init__()
+          obj.syncUpdate()
           self.idMap[idOriginal] = obj
         else:
           #print "\n\n=============== %s %d NOT found, NOT creating\n\n" % (objType.__name__, idOriginal)
@@ -98,6 +99,7 @@
         
           reg.broker = obj
           obj.registration = reg
+          obj.syncUpdate()
 
     return obj
 
@@ -178,7 +180,13 @@
       convertedKey = self.convertRefKey(parentKey)
       d[convertedKey] = connectedBroker.getByOriginalId(schema.schemaNameToClassMap[convertedKey], d.pop(parentKey))
     obj = connectedBroker.getByOriginalId(schema.schemaNameToClassMap[objectName], d["idOriginal"], create=True)
-    obj.set(**d)
+
+    try:
+      obj.set(**d)
+    except TypeError, detail:
+      self.log("Schema mismatch: %s" % details)
+
+    obj.syncUpdate()
     self.log("END CONFIG---------------------------------------------------\n")
     return obj
 
@@ -195,17 +203,24 @@
     objStats = objNameStats.__new__(objNameStats)
     objStats.__init__()
 
-    # XXX the following statement blows up with an "unexpected keyword
-    # argument" error if the broker sends down stats that we don't
-    # know about; we should simply carry on, instead
-
-    objStats.set(**d)
+    try:
+      objStats.set(**d)
+    except TypeError, detail:
+      self.log("Schema mismatch: %s" % details)
+    
+    objStats.syncUpdate()
     d = dict()
     if (timestamps[2] != 0):
       d["deletionTime"] = datetime.fromtimestamp(timestamps[2]/1000000000)
     d["statsPrev"] = obj.statsCurr
     d["statsCurr"] = objStats
-    obj.set(**d)
+
+    try:
+      obj.set(**d)
+    except TypeError, detail:
+      self.log("Schema mismatch: %s" % details)
+
+    obj.syncUpdate()
     self.log("END INST---------------------------------------------------\n")
     return objStats
 

Modified: mgmt/mint/python/mint/schema.py
===================================================================
--- mgmt/mint/python/mint/schema.py	2008-01-29 21:00:40 UTC (rev 1624)
+++ mgmt/mint/python/mint/schema.py	2008-01-29 21:57:51 UTC (rev 1625)
@@ -2,6 +2,9 @@
 from datetime import datetime
 
 class System(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -12,6 +15,9 @@
   sysId = StringCol(length=1000, default=None)
 
 class SystemStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   system = ForeignKey('System', cascade='null', default=None)
@@ -20,6 +26,9 @@
 
 
 class Broker(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -41,32 +50,35 @@
   clusterName = StringCol(length=1000, default=None)
   version = StringCol(length=1000, default=None)
 
-  def joinCluster(self, model, managedBrokerLabel, callbackMethod, clusterName):
+  def joinCluster(self, model, managedBroker, callbackMethod, clusterName):
     actualArgs = dict()
     actualArgs["clusterName"] = clusterName
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "joinCluster", args=actualArgs, packageName="qpid")
 
-  def leaveCluster(self, model, managedBrokerLabel, callbackMethod):
+  def leaveCluster(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "leaveCluster", args=actualArgs, packageName="qpid")
 
-  def echo(self, model, managedBrokerLabel, callbackMethod, sequence, body):
+  def echo(self, model, managedBroker, callbackMethod, sequence, body):
     """Request a response to test the path to the management agent"""
     actualArgs = dict()
     actualArgs["sequence"] = sequence
     actualArgs["body"] = body
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "echo", args=actualArgs, packageName="qpid")
 
 System.sqlmeta.addJoin(SQLMultipleJoin('Broker', joinMethodName='brokers'))
 
 
 class BrokerStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   broker = ForeignKey('Broker', cascade='null', default=None)
@@ -75,6 +87,9 @@
 
 
 class Vhost(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -89,6 +104,9 @@
 
 
 class VhostStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   vhost = ForeignKey('Vhost', cascade='null', default=None)
@@ -97,6 +115,9 @@
 
 
 class Queue(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -110,17 +131,20 @@
   autoDelete = BoolCol(default=None)
   exclusive = BoolCol(default=None)
 
-  def purge(self, model, managedBrokerLabel, callbackMethod):
+  def purge(self, model, managedBroker, callbackMethod):
     """Discard all messages on queue"""
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "purge", args=actualArgs, packageName="qpid")
 
 Vhost.sqlmeta.addJoin(SQLMultipleJoin('Queue', joinMethodName='queues'))
 
 
 class QueueStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   queue = ForeignKey('Queue', cascade='null', default=None)
@@ -171,6 +195,9 @@
 
 
 class Exchange(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -186,6 +213,9 @@
 
 
 class ExchangeStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   exchange = ForeignKey('Exchange', cascade='null', default=None)
@@ -206,6 +236,9 @@
 
 
 class Binding(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -223,6 +256,9 @@
 
 
 class BindingStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   binding = ForeignKey('Binding', cascade='null', default=None)
@@ -232,6 +268,9 @@
 
 
 class Client(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -242,16 +281,19 @@
   vhost = ForeignKey('Vhost', cascade='null', default=None)
   address = StringCol(length=1000, default=None)
 
-  def close(self, model, managedBrokerLabel, callbackMethod):
+  def close(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
 
 Vhost.sqlmeta.addJoin(SQLMultipleJoin('Client', joinMethodName='clients'))
 
 
 class ClientStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   client = ForeignKey('Client', cascade='null', default=None)
@@ -266,6 +308,9 @@
 
 
 class Session(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -279,28 +324,28 @@
   client = ForeignKey('Client', cascade='null', default=None)
   detachedLifespan = IntCol(default=None)
 
-  def solicitAck(self, model, managedBrokerLabel, callbackMethod):
+  def solicitAck(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "solicitAck", args=actualArgs, packageName="qpid")
 
-  def detach(self, model, managedBrokerLabel, callbackMethod):
+  def detach(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "detach", args=actualArgs, packageName="qpid")
 
-  def resetLifespan(self, model, managedBrokerLabel, callbackMethod):
+  def resetLifespan(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "resetLifespan", args=actualArgs, packageName="qpid")
 
-  def close(self, model, managedBrokerLabel, callbackMethod):
+  def close(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
 
 Vhost.sqlmeta.addJoin(SQLMultipleJoin('Session', joinMethodName='sessions'))
@@ -309,6 +354,9 @@
 
 
 class SessionStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   session = ForeignKey('Session', cascade='null', default=None)
@@ -320,6 +368,9 @@
 
 
 class Destination(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -330,30 +381,33 @@
   session = ForeignKey('Session', cascade='null', default=None)
   name = StringCol(length=1000, default=None)
 
-  def throttle(self, model, managedBrokerLabel, callbackMethod, strength):
+  def throttle(self, model, managedBroker, callbackMethod, strength):
     """Apply extra rate limiting to destination: 0 = Normal, 10 = Maximum"""
     actualArgs = dict()
     actualArgs["strength"] = strength
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "throttle", args=actualArgs, packageName="qpid")
 
-  def stop(self, model, managedBrokerLabel, callbackMethod):
+  def stop(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "stop", args=actualArgs, packageName="qpid")
 
-  def start(self, model, managedBrokerLabel, callbackMethod):
+  def start(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "start", args=actualArgs, packageName="qpid")
 
 Session.sqlmeta.addJoin(SQLMultipleJoin('Destination', joinMethodName='destinations'))
 
 
 class DestinationStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   destination = ForeignKey('Destination', cascade='null', default=None)
@@ -367,6 +421,9 @@
 
 
 class Producer(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -383,6 +440,9 @@
 
 
 class ProducerStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   producer = ForeignKey('Producer', cascade='null', default=None)
@@ -393,6 +453,9 @@
 
 
 class Consumer(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   creationTime = TimestampCol(default=None)
@@ -403,10 +466,10 @@
   destination = ForeignKey('Destination', cascade='null', default=None)
   queue = ForeignKey('Queue', cascade='null', default=None)
 
-  def close(self, model, managedBrokerLabel, callbackMethod):
+  def close(self, model, managedBroker, callbackMethod):
     actualArgs = dict()
     methodId = model.registerCallback(callbackMethod)
-    model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+    model.managedBroker.method(methodId, self.idOriginal, \
       classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
 
 Destination.sqlmeta.addJoin(SQLMultipleJoin('Consumer', joinMethodName='consumers'))
@@ -415,6 +478,9 @@
 
 
 class ConsumerStats(SQLObject):
+  class sqlmeta:
+    lazyUpdate = True
+
   idOriginal = BigIntCol(default=None)
   recTime = TimestampCol(default=None)
   consumer = ForeignKey('Consumer', cascade='null', default=None)

Modified: mgmt/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/mint/python/mint/schemaparser.py	2008-01-29 21:00:40 UTC (rev 1624)
+++ mgmt/mint/python/mint/schemaparser.py	2008-01-29 21:57:51 UTC (rev 1625)
@@ -57,6 +57,10 @@
       attrib = tableTo.lower() + "s"
     self.additionalPythonOutput += "\n%s.sqlmeta.addJoin(SQLMultipleJoin('%s', joinMethodName='%s'))\n" % (tableFrom, tableTo, attrib)
 
+  def generateLazyUpdate(self, lazyUpdate=True):
+    self.pythonOutput += "  class sqlmeta:\n"
+    self.pythonOutput += "    lazyUpdate = %s\n\n" % (lazyUpdate)
+
   def generateClassAttribs(self, schemaName, elements):
     for elem in elements:
       if (elem["@name"].endswith("Ref")):
@@ -85,6 +89,7 @@
       statsPythonName = self.style.dbTableToPythonClass(schemaName + "_stats")
     self.currentClass = pythonName
     self.pythonOutput += "\nclass %s(SQLObject):\n" % (pythonName)
+    self.generateLazyUpdate()
     self.generateAttrib("idOriginal", "BigIntCol")
     self.generateTimestampAttrib("rec")
     if (stats):




More information about the rhmessaging-commits mailing list