[CalendarServer-changes] [11248] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri May 24 14:32:33 PDT 2013


Revision: 11248
          http://trac.calendarserver.org//changeset/11248
Author:   sagen at apple.com
Date:     2013-05-24 14:32:33 -0700 (Fri, 24 May 2013)
Log Message:
-----------
Move the kick-off of scheduled work items from the master to the requestProcessingService so that work will happen in the workers

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/caldav.py
    CalendarServer/trunk/twistedcaldav/upgrade.py

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2013-05-24 20:34:56 UTC (rev 11247)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2013-05-24 21:32:33 UTC (rev 11248)
@@ -111,6 +111,8 @@
 from calendarserver.push.amppush import AMPPushMaster, AMPPushForwarder
 from calendarserver.push.applepush import ApplePushNotifierService
 from txdav.caldav.datastore.scheduling.imip.inbound import MailRetriever
+from twistedcaldav.directory.directory import scheduleNextGroupCachingUpdate
+from txdav.caldav.datastore.scheduling.imip.inbound import scheduleNextMailPoll
 
 try:
     from calendarserver.version import version
@@ -494,6 +496,37 @@
 
 
 
+class WorkSchedulingService(Service, LoggingMixIn):
+    """
+    A Service to kick off the initial scheduling of periodic work items.
+    """
+
+    def __init__(self, store, doImip, doGroupCaching):
+        """
+        @param store: the Store to use for enqueuing work
+        @param doImip: whether to schedule imip polling
+        @type doImip: boolean
+        @param doGroupCaching: whether to schedule group caching
+        @type doImip: boolean
+        """
+        self.store = store
+        self.doImip = doImip
+        self.doGroupCaching = doGroupCaching
+
+
+    @inlineCallbacks
+    def startService(self):
+        # Note: the "seconds in the future" args are being set to the LogID
+        # numbers to spread them out.  This is only needed until 
+        # ultimatelyPerform( ) handles groups correctly.  Once that is fixed
+        # these can be set to zero seconds in the future.
+        if self.doImip:
+            yield scheduleNextMailPoll(self.store, int(config.LogID))
+        if self.doGroupCaching:
+            yield scheduleNextGroupCachingUpdate(self.store, int(config.LogID))
+
+
+
 class ReExecService(MultiService, LoggingMixIn):
     """
     A MultiService which catches SIGHUP and re-exec's the process.
@@ -672,7 +705,6 @@
             return failure
 
 
-
 class CalDAVServiceMaker (LoggingMixIn):
     implements(IPlugin, IServiceMaker)
 
@@ -955,6 +987,13 @@
         connectionService.setName(CalDAVService.connectionServiceName)
         connectionService.setServiceParent(service)
 
+        # Service to schedule initial work
+        WorkSchedulingService(
+            store,
+            config.Scheduling.iMIP.Enabled,
+            (config.GroupCaching.Enabled and config.GroupCaching.EnableUpdater)
+        ).setServiceParent(service)
+
         # For calendarserver.tap.test.test_caldav.BaseServiceMakerTests.getSite():
         connectionService.underlyingSite = underlyingSite
 

Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py	2013-05-24 20:34:56 UTC (rev 11247)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py	2013-05-24 21:32:33 UTC (rev 11248)
@@ -42,7 +42,6 @@
 from twistedcaldav.directory.calendaruserproxyloader import XMLCalendarUserProxyLoader
 from twistedcaldav.directory.directory import DirectoryService
 from twistedcaldav.directory.directory import GroupMembershipCacheUpdater
-from twistedcaldav.directory.directory import scheduleNextGroupCachingUpdate
 from twistedcaldav.directory.principal import DirectoryCalendarPrincipalResource
 from twistedcaldav.directory.resourceinfo import ResourceInfoDatabase
 from twistedcaldav.directory.xmlfile import XMLDirectoryService
@@ -67,7 +66,6 @@
 from calendarserver.tools.util import getDirectory
 
 from txdav.caldav.datastore.scheduling.imip.mailgateway import migrateTokensToStore
-from txdav.caldav.datastore.scheduling.imip.inbound import scheduleNextMailPoll
 
 
 deadPropertyXattrPrefix = namedAny(
@@ -1063,16 +1061,8 @@
             # Migrate mail tokens from sqlite to store
             yield migrateTokensToStore(self.config.DataRoot, self.store)
 
-            # Set mail polling in motion
-            if self.config.Scheduling.iMIP.Enabled:
-                yield scheduleNextMailPoll(self.store, 0)
+            
 
-            if (self.config.GroupCaching.Enabled and
-                self.config.GroupCaching.EnableUpdater):
-                # Set in motion the work queue based updates:
-                yield scheduleNextGroupCachingUpdate(self.store, 0)
-
-
     @inlineCallbacks
     def processInboxItems(self):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130524/21b2161b/attachment-0001.html>


More information about the calendarserver-changes mailing list