[CalendarServer-changes] [11015] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 8 12:22:13 PDT 2013
Revision: 11015
http://trac.calendarserver.org//changeset/11015
Author: sagen at apple.com
Date: 2013-04-08 12:22:13 -0700 (Mon, 08 Apr 2013)
Log Message:
-----------
Landing Glyph's q-no-master branch, plus fix for currentLoad
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/calendarserver/tap/test/test_caldav.py
CalendarServer/trunk/twext/enterprise/queue.py
CalendarServer/trunk/txdav/common/datastore/file.py
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2013-04-08 18:05:27 UTC (rev 11014)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2013-04-08 19:22:13 UTC (rev 11015)
@@ -1427,6 +1427,7 @@
from twisted.internet import reactor
pool = PeerConnectionPool(reactor, store.newTransaction,
7654, schema)
+ store.queuer = store.queuer.transferProposalCallbacks(pool)
controlSocket.addFactory(_QUEUE_ROUTE,
pool.workerListenerFactory())
# TODO: now that we have the shared control socket, we should get
Modified: CalendarServer/trunk/calendarserver/tap/test/test_caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/test/test_caldav.py 2013-04-08 18:05:27 UTC (rev 11014)
+++ CalendarServer/trunk/calendarserver/tap/test/test_caldav.py 2013-04-08 19:22:13 UTC (rev 11015)
@@ -33,11 +33,12 @@
from twisted.internet.interfaces import IProcessTransport, IReactorProcess
from twisted.internet.protocol import ServerFactory
-from twisted.internet.defer import Deferred, inlineCallbacks
+from twisted.internet.defer import Deferred, inlineCallbacks, passthru
from twisted.internet.task import Clock
from twisted.internet import reactor
-from twisted.application.service import IService, IServiceCollection
+from twisted.application.service import (IService, IServiceCollection,
+ MultiService)
from twisted.application import internet
from twext.web2.dav import auth
@@ -62,6 +63,7 @@
_CONTROL_SERVICE_NAME, getSystemIDs
)
from calendarserver.provision.root import RootResource
+from twext.enterprise.queue import PeerConnectionPool, LocalQueuer
from StringIO import StringIO
@@ -358,14 +360,16 @@
writePlist(self.config, self.configFile)
- def makeService(self):
+ def makeService(self, patcher=passthru):
"""
Create a service by calling into CalDAVServiceMaker with
self.configFile
"""
self.options.parseOptions(["-f", self.configFile])
- return CalDAVServiceMaker().makeService(self.options)
+ maker = CalDAVServiceMaker()
+ maker = patcher(maker)
+ return maker.makeService(self.options)
def getSite(self):
@@ -507,8 +511,41 @@
)
+ def test_storeQueuerSetInMaster(self):
+ """
+ In the master, the store's queuer should be set to a
+ L{PeerConnectionPool}, so that work can be distributed to other
+ processes.
+ """
+ self.config["ProcessType"] = "Combined"
+ self.writeConfig()
+ class NotAStore(object):
+ queuer = LocalQueuer(None)
+ def newTransaction(self):
+ return None
+ def callWithNewTransactions(self, x):
+ pass
+ store = NotAStore()
+ def something(proposal):
+ pass
+ store.queuer.callWithNewProposals(something)
+ def patch(maker):
+ def storageServiceStandIn(createMainService, logObserver,
+ uid=None, gid=None):
+ pool = None
+ logObserver = None
+ svc = createMainService(pool, store, logObserver)
+ multi = MultiService()
+ svc.setServiceParent(multi)
+ return multi
+ self.patch(maker, "storageService", storageServiceStandIn)
+ return maker
+ self.makeService(patch)
+ self.assertIsInstance(store.queuer, PeerConnectionPool)
+ self.assertIn(something, store.queuer.proposalCallbacks)
+
class SlaveServiceTest(BaseServiceMakerTests):
"""
Test various configurations of the Slave service
Modified: CalendarServer/trunk/twext/enterprise/queue.py
===================================================================
--- CalendarServer/trunk/twext/enterprise/queue.py 2013-04-08 18:05:27 UTC (rev 11014)
+++ CalendarServer/trunk/twext/enterprise/queue.py 2013-04-08 19:22:13 UTC (rev 11015)
@@ -635,7 +635,7 @@
"""
The total load of all currently connected workers.
"""
- return sum(worker.currentLoad() for worker in self.workers)
+ return sum(worker.currentLoad for worker in self.workers)
def _selectLowestLoadWorker(self):
@@ -646,7 +646,7 @@
@return: a worker connection with the lowest current load.
@rtype: L{ConnectionFromWorker}
"""
- return sorted(self.workers[:], key=lambda w: w.currentLoad())[0]
+ return sorted(self.workers[:], key=lambda w: w.currentLoad)[0]
def performWork(self, table, workID):
Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py 2013-04-08 18:05:27 UTC (rev 11014)
+++ CalendarServer/trunk/txdav/common/datastore/file.py 2013-04-08 19:22:13 UTC (rev 11015)
@@ -77,6 +77,14 @@
)
UIDPATH = "__uids__"
+
+
+class _StubQueuer(object):
+ def transferProposalCallbacks(self, otherQueuer):
+ return otherQueuer
+
+
+
class CommonDataStore(DataStore):
"""
Shared logic for SQL-based data stores, between calendar and addressbook
@@ -87,7 +95,6 @@
@ivar quota: the amount of space granted to each calendar home (in bytes)
for storing attachments, or C{None} if quota should not be enforced.
-
@type quota: C{int} or C{NoneType}
@ivar _propertyStoreClass: The class (or callable object / factory) that
@@ -95,6 +102,10 @@
signature of the L{XattrPropertyStore} type: take 2 arguments
C{(default-user-uid, path-factory)}, return an L{IPropertyStore}
provider.
+
+ @ivar queuer: For compatibility with SQL-based store; currently a
+ non-functional implementation just for tests, but could be fixed to be
+ backed by SQLite or something.
"""
implements(ICalendarStore)
@@ -118,6 +129,8 @@
self._migrating = False
self._enableNotifications = True
self._newTransactionCallbacks = set()
+ # FIXME: see '@ivar queuer' above.
+ self.queuer = _StubQueuer()
def callWithNewTransactions(self, callback):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130408/79a461e8/attachment.html>
More information about the calendarserver-changes
mailing list