[CalendarServer-changes] [13727] CalendarServer/trunk/txdav/dps/client.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Jul 3 15:49:23 PDT 2014


Revision: 13727
          http://trac.calendarserver.org//changeset/13727
Author:   sagen at apple.com
Date:     2014-07-03 15:49:23 -0700 (Thu, 03 Jul 2014)
Log Message:
-----------
Log timing of DPS calls; skip looking for members of non-groups"

Modified Paths:
--------------
    CalendarServer/trunk/txdav/dps/client.py

Modified: CalendarServer/trunk/txdav/dps/client.py
===================================================================
--- CalendarServer/trunk/txdav/dps/client.py	2014-07-03 22:48:36 UTC (rev 13726)
+++ CalendarServer/trunk/txdav/dps/client.py	2014-07-03 22:49:23 UTC (rev 13727)
@@ -15,6 +15,7 @@
 ##
 
 import cPickle as pickle
+import time
 import uuid
 
 from twext.python.log import Logger
@@ -25,7 +26,7 @@
 import twext.who.idirectory
 from twext.who.util import ConstantsContainer
 from twisted.internet import reactor
-from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.internet.defer import inlineCallbacks, returnValue, succeed
 from twisted.internet.protocol import ClientCreator
 from twisted.protocols import amp
 from twisted.python.constants import Names, NamedConstant
@@ -59,13 +60,9 @@
 
 
 ## MOVE2WHO TODOs:
-## SACLs
 ## LDAP
-## Tests from old twistedcaldav/directory
-## Cmd line tools
 ## Store based directory service (records in the store, i.e.
 ##    locations/resources)
-## Separate store for DPS (augments and delegates separate from calendar data)
 ## Store autoAcceptGroups in the group db?
 
 @implementer(IDirectoryService, IStoreDirectoryService)
@@ -189,6 +186,20 @@
         returnValue(results)
 
 
+    def _logResultTiming(self, command, startTime, results):
+        duration = time.time() - startTime
+        numResults = 0
+        if "fields" in results:
+            numResults = 1
+        if "fieldsList" in results:
+            numResults = len(results["fieldsList"])
+        log.debug(
+            "DPS call {command} duration={duration:.2f}s, results={numResults}",
+            command=command, duration=duration, numResults=numResults
+        )
+
+
+
     @inlineCallbacks
     def _call(self, command, postProcess, **kwds):
         """
@@ -204,9 +215,11 @@
             L{Deferred} which fires with the post-processed results
         @type postProcess: callable
         """
+        startTime = time.time()
         results = yield self._sendCommand(command, **kwds)
         if results.get("continuation", None) is None:
             # We have all the results
+            self._logResultTiming(command, startTime, results)
             returnValue(postProcess(results))
 
         # There are more results to fetch, so loop until the continuation
@@ -225,6 +238,7 @@
         for result in multi:
             results["fieldsList"].extend(result["fieldsList"])
 
+        self._logResultTiming(command, startTime, results)
         returnValue(postProcess(results))
 
 
@@ -367,11 +381,14 @@
 
 
     def members(self):
-        return self.service._call(
-            MembersCommand,
-            self.service._processMultipleRecords,
-            uid=self.uid.encode("utf-8")
-        )
+        if self.recordType == RecordType.group:
+            return self.service._call(
+                MembersCommand,
+                self.service._processMultipleRecords,
+                uid=self.uid.encode("utf-8")
+            )
+        else:
+            return succeed([])
 
 
     def groups(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140703/391f0f81/attachment.html>


More information about the calendarserver-changes mailing list