[CalendarServer-changes] [13940] CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav /datastore/scheduling

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 4 13:14:20 PDT 2014


Revision: 13940
          http://trac.calendarserver.org//changeset/13940
Author:   cdaboo at apple.com
Date:     2014-09-04 13:14:20 -0700 (Thu, 04 Sep 2014)
Log Message:
-----------
Additional debug logging for auto-accept processing.

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py
    CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py

Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py	2014-09-03 18:36:05 UTC (rev 13939)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/freebusy.py	2014-09-04 20:14:20 UTC (rev 13940)
@@ -106,6 +106,7 @@
     event_details=None,
     logItems=None,
     accountingItems=None,
+    allowCache=True,
 ):
     """
     Run a free busy report on the specified calendar collection
@@ -127,6 +128,7 @@
     @param event_details: a C{list} into which to store extended VEVENT details if not C{None}
     @param logItems: a C{dict} to store logging info to
     @param accountingItems: a C{dict} to store accounting info to
+    @param allowCache: if C{True} the FB cache will be used, otherwise it will never be used
     """
 
     # First check the privilege on this collection
@@ -178,12 +180,12 @@
             rich_options["resource"] = True
 
     # Try cache
-    resources = (yield FBCacheEntry.getCacheEntry(calresource, attendee_uid, timerange)) if config.EnableFreeBusyCache else None
+    resources = (yield FBCacheEntry.getCacheEntry(calresource, attendee_uid, timerange)) if config.EnableFreeBusyCache and allowCache else None
 
     if resources is None:
 
         if accountingItems is not None:
-            accountingItems["fb-uncached"] = accountingItems.get("fb-uncached", 0) + 1
+            accountingItems["fb-cached"] = False
 
         caching = False
         if config.EnableFreeBusyCache:
@@ -233,7 +235,7 @@
 
     else:
         if accountingItems is not None:
-            accountingItems["fb-cached"] = accountingItems.get("fb-cached", 0) + 1
+            accountingItems["fb-cached"] = True
 
         # Log extended item
         if logItems is not None:

Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py	2014-09-03 18:36:05 UTC (rev 13939)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/txdav/caldav/datastore/scheduling/processing.py	2014-09-04 20:14:20 UTC (rev 13940)
@@ -555,7 +555,7 @@
                         self.recipient.principal,
                         json.dumps(accounting) + "\r\n",
                         filename=self.uid.encode("base64")[:-1] + ".txt"
-                )
+                    )
 
                 # Only store inbox item when reply is not sent or always for users
                 store_inbox = store_inbox or self.recipient.principal.getCUType() == "INDIVIDUAL"
@@ -676,11 +676,10 @@
             processed_message, delete_original, rids = iTipProcessing.processCancel(self.message, self.recipient_calendar, autoprocessing=autoprocessed)
             if processed_message:
                 if autoprocessed and accountingEnabled("AutoScheduling", self.recipient.principal):
-                    accounting = {
-                        "action": "cancel",
-                        "when": PyCalendarDateTime.getNowUTC().getText(),
-                        "deleting": delete_original,
-                    }
+                    accounting = collections.OrderedDict()
+                    accounting["when"] = PyCalendarDateTime.getNowUTC().getText()
+                    accounting["deleting"] = delete_original
+                    accounting["action"] = "cancel"
                     emitAccounting(
                         "AutoScheduling",
                         self.recipient.principal,
@@ -807,11 +806,10 @@
         """
 
         if accountingEnabled("AutoScheduling", self.recipient.principal):
-            accounting = {
-                "when": PyCalendarDateTime.getNowUTC().getText(),
-                "automode": automode,
-                "changed": False,
-            }
+            accounting = collections.OrderedDict()
+            accounting["when"] = PyCalendarDateTime.getNowUTC().getText()
+            accounting["automode"] = automode
+            accounting["changed"] = False
         else:
             accounting = None
 
@@ -869,7 +867,6 @@
         fbset = [fbcalendar for fbcalendar in fbset if fbcalendar.isUsedForFreeBusy()]
         if accounting is not None:
             accounting["fbset"] = [testcal.name() for testcal in fbset]
-            accounting["tr"] = []
 
         for testcal in fbset:
 
@@ -878,6 +875,10 @@
             tz = testcal.getTimezone()
             tzinfo = tz.gettimezone() if tz is not None else PyCalendarTimezone(utc=True)
 
+            if accounting is not None:
+                accounting[testcal.name()] = {}
+                accounting[testcal.name()]["tr"] = []
+
             # Now do search for overlapping time-range and set instance.free based
             # on whether there is an overlap or not.
             # NB Do this in reverse order so that the date farthest in the future is tested first - that will
@@ -904,25 +905,42 @@
                             end=str(makeTimedUTC(instance.end)),
                         )
 
-                        yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True, accountingItems=accounting if len(instances) == 1 else None)
+                        if accounting is None:
+                            yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True)
+                        else:
+                            # Do this twice if cache is used and compare results
+                            details1 = {}
+                            yield generateFreeBusyInfo(testcal, fbinfo, tr, 0, uid, servertoserver=True, accountingItems=details1)
+                            if "useCache" not in accounting[testcal.name()]:
+                                accounting[testcal.name()]["useCache"] = details1
 
+                            if accounting[testcal.name()]["useCache"]["fb-cached"]:
+                                fbinfo_nocache = ([], [], [])
+                                details2 = {}
+                                yield generateFreeBusyInfo(testcal, fbinfo_nocache, tr, 0, uid, servertoserver=True, accountingItems=details2, allowCache=False)
+                                if "noCache" not in accounting[testcal.name()]:
+                                    accounting[testcal.name()]["noCache"] = details2
+                                if fbinfo != fbinfo_nocache:
+                                    log.error("Auto-accept free busy cache inconsistent with database query")
+                                    accounting[testcal.name()]["badCache"] = (details1, details2)
+
                         # If any fbinfo entries exist we have an overlap
                         if len(fbinfo[0]) or len(fbinfo[1]) or len(fbinfo[2]):
                             instance.free = False
                         if accounting is not None:
-                            accounting["tr"].insert(0, (tr.attributes["start"], tr.attributes["end"], instance.free,))
+                            accounting[testcal.name()]["tr"].insert(0, (tr.attributes["start"], tr.attributes["end"], instance.free,))
                     except QueryMaxResources:
                         instance.free = False
                         log.info("Exceeded number of matches whilst trying to find free-time.")
                         if accounting is not None:
-                            accounting["problem"] = "Exceeded number of matches"
+                            accounting[testcal.name()]["problem"] = "Exceeded number of matches"
 
             # If everything is declined we can exit now
             if not any([instance.free for instance in instances]):
                 break
 
-        if accounting is not None:
-            accounting["tr"] = accounting["tr"][:30]
+            if accounting is not None:
+                accounting[testcal.name()]["tr"] = accounting[testcal.name()]["tr"][:30]
 
         # Now adjust the instance.partstat currently set to "NEEDS-ACTION" to the
         # value determined by auto-accept logic based on instance.free state. However,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140904/9c6ea63b/attachment.html>


More information about the calendarserver-changes mailing list