[CalendarServer-changes] [8386] CalendarServer/branches/users/glyph/parallel-upgrade

source_changes at macosforge.org source_changes at macosforge.org
Sat Dec 3 00:38:17 PST 2011


Revision: 8386
          http://trac.macosforge.org/projects/calendarserver/changeset/8386
Author:   glyph at apple.com
Date:     2011-12-03 00:38:17 -0800 (Sat, 03 Dec 2011)
Log Message:
-----------
start moving configuration over to caldavd plugin

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/caldav.py
    CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/upgrade/migrate.py

Modified: CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/caldav.py	2011-12-03 08:38:07 UTC (rev 8385)
+++ CalendarServer/branches/users/glyph/parallel-upgrade/calendarserver/tap/caldav.py	2011-12-03 08:38:17 UTC (rev 8386)
@@ -34,15 +34,20 @@
 
 from zope.interface import implements
 
+from twisted.plugin import IPlugin
+
 from twisted.python.log import FileLogObserver, ILogObserver
 from twisted.python.logfile import LogFile
 from twisted.python.usage import Options, UsageError
-from twisted.plugin import IPlugin
+
 from twisted.internet.defer import gatherResults, Deferred
 from twisted.internet import reactor as _reactor
 from twisted.internet.process import ProcessExitedAlready
 from twisted.internet.protocol import Protocol, Factory
 from twisted.internet.protocol import ProcessProtocol
+
+from twisted.protocols.amp import AMP, Command, String, Integer#, ListOf
+
 from twisted.application.internet import TCPServer, UNIXServer
 from twisted.application.service import MultiService, IServiceMaker
 from twisted.application.service import Service
@@ -58,6 +63,7 @@
 from twext.web2.metafd import ConnectionLimiter, ReportingHTTPService
 
 from txdav.common.datastore.upgrade.migrate import UpgradeToDatabaseService
+from txdav.common.datastore.upgrade.migrate import StoreSpawnerService
 from txdav.common.datastore.upgrade.sql.upgrade import UpgradeDatabaseSchemaService,\
     UpgradeDatabaseDataService
 
@@ -1315,6 +1321,73 @@
         return args
 
 
+class ConfigureChild(Command):
+    """
+    Configure a child process, most especially with all the information that it
+    needs in order to construct a data store.
+    """
+
+    arguments = [
+        # The name of the class to delegate to once configuration is complete.
+        ("delegateTo", String()),
+        ("pidfile", String()),
+        ("logID", String()),
+        ("configFile", String()),
+
+        ## same as in config; no need to propagate it
+        # ("processCount", Integer()),
+
+        ## only needed for request processing
+        # ("inheritFDs", ListOf(Integer())),
+        # ("inheritSSLFDs", ListOf(Integer())),
+        # ("metaFD", String(optional=True)),
+
+        ## shared connection pool!
+        ("connectionPoolFD", Integer(optional=True)),
+    ]
+
+
+class ChildConfigurator(AMP):
+    """
+    Protocol which can configure a child process.
+    """
+
+    @ConfigureChild.responder
+    def conf(self, delegateTo, pidfile, logID, configFile, connectionPoolFD=None):
+        """
+        Do the configuration.
+        """
+        # This stuff needs to be done by somebody in caldavd.py
+        from twistedcaldav.config import config
+        from calendarserver.tap.util import getDBPool, storeFromConfig
+        config.load(configFile)
+        pool, txnf = getDBPool(config)
+        if pool is not None:
+            from twisted.internet import reactor
+            pool.startService()
+            reactor.addSystemEventTrigger("before", "shutdown",
+                                          pool.stopService)
+        # XXX: SharedConnectionPool needs to be relayed out of band, as
+        # calendarserver.tap.caldav does with its own thing.
+        dbstore = storeFromConfig(config, txnf)
+        dbstore.setMigrating(True)
+        return {}
+
+
+
+class ConfiguredChildSpawner(StoreSpawnerService):
+    """
+    L{StoreSpawnerService} that will load a full configuration into each child.
+    """
+
+    def spawnWithStore(self, here, there):
+        """
+        Spawn the child with a store based on a configuration.
+        """
+        return {}
+
+
+
 class ControlPortTCPServer(TCPServer):
     """ This TCPServer retrieves the port number that was actually assigned
         when the service was started, and stores that into config.ControlPort

Modified: CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/upgrade/migrate.py
===================================================================
--- CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/upgrade/migrate.py	2011-12-03 08:38:07 UTC (rev 8385)
+++ CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/upgrade/migrate.py	2011-12-03 08:38:17 UTC (rev 8386)
@@ -166,22 +166,7 @@
         )
         return {}
 
-        # This stuff needs to be done by somebody in caldavd.py
-        from twistedcaldav.config import config
-        from calendarserver.tap.util import getDBPool, storeFromConfig
-        config.load(filename)
-        pool, txnf = getDBPool(config)
-        if pool is not None:
-            pool.startService()
-            reactor.addSystemEventTrigger("before", "shutdown",
-                                          pool.stopService)
-        # XXX: SharedConnectionPool needs to be relayed out of band, as
-        # calendarserver.tap.caldav does with its own thing.
-        dbstore = storeFromConfig(config, txnf)
-        dbstore.setMigrating(True)
-        return {}
 
-
     @OneUpgrade.responder
     def oneUpgrade(self, uid, homeType):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111203/b9d65d75/attachment.html>


More information about the calendarserver-changes mailing list