Author: justi9
Date: 2008-12-15 10:44:28 -0500 (Mon, 15 Dec 2008)
New Revision: 2999
Modified:
mgmt/trunk/mint/python/mint/update.py
Log:
Skip stat updates that are too old; only adjust stat update timestamps, not all
timestamps
Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py 2008-12-15 15:43:39 UTC (rev 2998)
+++ mgmt/trunk/mint/python/mint/update.py 2008-12-15 15:44:28 UTC (rev 2999)
@@ -1,6 +1,5 @@
import sys
import logging
-import datetime
import types
import pickle
import psycopg2
@@ -14,6 +13,7 @@
from sql import *
from collections import deque
from util import *
+from datetime import datetime, timedelta
log = logging.getLogger("mint.update")
@@ -164,10 +164,7 @@
def processTimestamp(self, name, tstamp, results):
if tstamp:
- tnow = datetime.now()
t = datetime.fromtimestamp(tstamp / 1000000000)
- t = t > tnow and tnow or t
-
results[name] = t
class PropertyUpdate(ModelUpdate):
@@ -311,16 +308,22 @@
# Just drop it; we'll get more stats later
return
+ timestamps = self.object.getTimestamps()
+
+ tnow = datetime.now()
+ t = datetime.fromtimestamp(timestamps[0] / 1000000000)
+
+ if t < tnow - timedelta(seconds=30):
+ log.debug("Update is %i seconds old; skipping it", (tnow -t).seconds)
+ return
+
try:
attrs = self.processAttributes(self.object.getStatistics(), statsCls)
except ReferenceException:
# Drop it
return
- timestamps = self.object.getTimestamps()
-
- self.processTimestamp("qmfUpdateTime", timestamps[0], attrs)
-
+ attrs["qmfUpdateTime"] = t > tnow and tnow or t
attrs["%s_id" % cls.sqlmeta.table] = id
cursor = conn.cursor()
Show replies by date