[CalendarServer-changes] [2272]
CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Apr 1 13:07:01 PDT 2008
Revision: 2272
http://trac.macosforge.org/projects/calendarserver/changeset/2272
Author: wsanchez at apple.com
Date: 2008-04-01 13:07:00 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Pulled up r2249 r2250: randomize cache refresh
Modified Paths:
--------------
CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/config.py
CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/directory/appleopendirectory.py
Modified: CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/config.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/config.py 2008-04-01 16:28:13 UTC (rev 2271)
+++ CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/config.py 2008-04-01 20:07:00 UTC (rev 2272)
@@ -32,6 +32,7 @@
"twistedcaldav.directory.appleopendirectory.OpenDirectoryService": {
"node": "/Search",
"requireComputerRecord": True,
+ "cacheTimeout": 30,
},
}
Modified: CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/directory/appleopendirectory.py 2008-04-01 16:28:13 UTC (rev 2271)
+++ CalendarServer/branches/release/CalendarServer-1.3-dev/twistedcaldav/directory/appleopendirectory.py 2008-04-01 20:07:00 UTC (rev 2272)
@@ -26,6 +26,7 @@
import itertools
import sys
import os
+from random import random
import opendirectory
import dsattributes
@@ -46,8 +47,6 @@
serverPreferences = '/Library/Preferences/com.apple.servermgr_info.plist'
saclGroup = 'com.apple.access_calendar'
-recordListCacheTimeout = 60 * 30 # 30 minutes
-
class OpenDirectoryService(DirectoryService):
"""
Open Directory implementation of L{IDirectoryService}.
@@ -57,7 +56,7 @@
def __repr__(self):
return "<%s %r: %r>" % (self.__class__.__name__, self.realmName, self.node)
- def __init__(self, node="/Search", requireComputerRecord=True, dosetup=True):
+ def __init__(self, node="/Search", requireComputerRecord=True, dosetup=True, cacheTimeout=30):
"""
@param node: an OpenDirectory node name to bind to.
@param requireComputerRecord: C{True} if the directory schema is to be used to determine
@@ -78,6 +77,7 @@
self.requireComputerRecord = requireComputerRecord
self.computerRecords = {}
self.servicetags = set()
+ self.cacheTimeout = cacheTimeout
self._records = {}
self._delayedCalls = set()
@@ -609,11 +609,22 @@
for item in removals:
self._delayedCalls.remove(item)
- self._delayedCalls.add(callLater(recordListCacheTimeout, rot))
+ #
+ # 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.debug("Added %d records to %s OD record cache" % (len(self._records[recordType]["guids"]), recordType), system="OpenDirectoryService")
+ logging.info(
+ "Added %d records to %s OD record cache; expires in %d seconds"
+ % (len(self._records[recordType]["guids"]), recordType, cacheTimeout),
+ system="OpenDirectoryService"
+ )
def _queryDirectory(self, recordType, shortName=None, guid=None):
attrs = [
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080401/821bccbd/attachment.html
More information about the calendarserver-changes
mailing list