[CalendarServer-changes] [2250] CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 25 14:36:12 PDT 2008


Revision: 2250
          http://trac.macosforge.org/projects/calendarserver/changeset/2250
Author:   wsanchez at apple.com
Date:     2008-03-25 14:36:11 -0700 (Tue, 25 Mar 2008)

Log Message:
-----------
Max fuzz factor is 60 minutes.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py

Modified: CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	2008-03-25 19:41:06 UTC (rev 2249)
+++ CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	2008-03-25 21:36:11 UTC (rev 2250)
@@ -26,7 +26,7 @@
 import itertools
 import sys
 import os
-from random import randint
+from random import random
 
 import opendirectory
 import dsattributes
@@ -609,13 +609,18 @@
                 for item in removals:
                     self._delayedCalls.remove(item)
 
-            cacheTimeout = self.cacheTimeout * 60 # Convert to seconds
-            cacheTimeout += randint(-int(cacheTimeout/2), int(cacheTimeout/2)) # Add fuzz factor
+            #
+            # Add jitter/fuzz factor to avoid stampede for large OD query
+            # Max out the jitter at 60 minutes
+            #
+            cacheTimeout = min(self.cacheTimeout, 60) * 60
+            cacheTimeout = (cacheTimeout * random()) - (cacheTimeout / 2)
+            cacheTimeout += self.cacheTimeout * 60
             self._delayedCalls.add(callLater(cacheTimeout, rot))
 
             self._records[recordType] = storage
 
-            logging.err(
+            logging.info(
                 "Added %d records to %s OD record cache; expires in %d seconds"
                 % (len(self._records[recordType]["guids"]), recordType, cacheTimeout),
                 system="OpenDirectoryService"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080325/06ad93f6/attachment.html 


More information about the calendarserver-changes mailing list