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

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Nov 10 16:45:06 EST 2008


Author: eallen
Date: 2008-11-10 16:45:06 -0500 (Mon, 10 Nov 2008)
New Revision: 2780

Modified:
   mgmt/trunk/mint/python/mint/update.py
Log:
Don't allow recTimes to be in the future. This prevents statistics graph drawing problems because of differences in machine times. 

Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py	2008-11-10 15:39:44 UTC (rev 2779)
+++ mgmt/trunk/mint/python/mint/update.py	2008-11-10 21:45:06 UTC (rev 2780)
@@ -13,6 +13,12 @@
 
 log = logging.getLogger("mint.update")
 
+def time_unwarp(t):
+    """ don't allow future dates """
+    
+    tnow = datetime.now()
+    return t > tnow and tnow or t
+    
 class ModelUpdateThread(Thread):
   def __init__(self, model):
     super(ModelUpdateThread, self).__init__()
@@ -180,7 +186,8 @@
     # XXX move these down to the try/except
 
     attrs["managedBroker"] = self.conn.id
-    attrs["recTime"] = datetime.fromtimestamp(self.timestamps[0]/1000000000)
+    attrs["recTime"] = time_unwarp(datetime.fromtimestamp \
+        (self.timestamps[0]/1000000000))
     attrs["creationTime"] = datetime.fromtimestamp \
         (self.timestamps[1]/1000000000)
 
@@ -263,8 +270,8 @@
       # insertion in db is deferred until parent info is received
       return 
 
-    attrs["recTime"] = datetime.fromtimestamp(self.timestamps[0]/1000000000)
-
+    attrs["recTime"] = time_unwarp(datetime.fromtimestamp \
+                                   (self.timestamps[0]/1000000000))
     # Set the stat->obj reference
     attrs[cls.__name__[0].lower() + cls.__name__[1:]] = obj
 
@@ -346,3 +353,4 @@
 
       self.conn.brokerId = uuid
       self.conn.sessionId = self.data.sessionId
+




More information about the rhmessaging-commits mailing list