[CalendarServer-changes] [2249] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 25 12:41:08 PDT 2008
Revision: 2249
http://trac.macosforge.org/projects/calendarserver/changeset/2249
Author: wsanchez at apple.com
Date: 2008-03-25 12:41:06 -0700 (Tue, 25 Mar 2008)
Log Message:
-----------
Add cacheTimeout option to OpenDirectory.
Add fuzz factor to timeout to we don't stampede OD.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/config.py
CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
Modified: CalendarServer/trunk/twistedcaldav/config.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/config.py 2008-03-25 18:56:21 UTC (rev 2248)
+++ CalendarServer/trunk/twistedcaldav/config.py 2008-03-25 19:41:06 UTC (rev 2249)
@@ -30,6 +30,7 @@
"twistedcaldav.directory.appleopendirectory.OpenDirectoryService": {
"node": "/Search",
"requireComputerRecord": True,
+ "cacheTimeout": 30,
},
}
Modified: CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py 2008-03-25 18:56:21 UTC (rev 2248)
+++ CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py 2008-03-25 19:41:06 UTC (rev 2249)
@@ -26,6 +26,7 @@
import itertools
import sys
import os
+from random import randint
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,17 @@
for item in removals:
self._delayedCalls.remove(item)
- self._delayedCalls.add(callLater(recordListCacheTimeout, rot))
+ cacheTimeout = self.cacheTimeout * 60 # Convert to seconds
+ cacheTimeout += randint(-int(cacheTimeout/2), int(cacheTimeout/2)) # Add fuzz factor
+ 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.err(
+ "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/20080325/aaa31c2d/attachment.html
More information about the calendarserver-changes
mailing list