[Zodb-checkins] SVN: ZODB/branches/jim-zeo-registerdb/src/ZEO/
Checkpointing.
Jim Fulton
jim at zope.com
Mon Apr 23 07:04:15 EDT 2007
Log message for revision 74661:
Checkpointing.
Changed:
U ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py
A ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test
U ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/testZEO.py
-=-
Modified: ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py
===================================================================
--- ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py 2007-04-23 11:02:51 UTC (rev 74660)
+++ ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py 2007-04-23 11:04:14 UTC (rev 74661)
@@ -30,6 +30,7 @@
import transaction
+import ZODB.serialize
from ZEO import ClientStub
from ZEO.CommitLog import CommitLog
from ZEO.monitor import StorageStats, StatsServer
@@ -687,7 +688,12 @@
else:
return 1
+class StorageServerDB:
+ def __init__(self, server):
+ self.server = server
+ self.references = ZODB.serial.referencesf
+
class StorageServer:
"""The server side implementation of ZEO.
Added: ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test
===================================================================
--- ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test 2007-04-23 11:02:51 UTC (rev 74660)
+++ ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test 2007-04-23 11:04:14 UTC (rev 74661)
@@ -0,0 +1,67 @@
+Storage Servers should call registerDB on storages to propigate invalidations
+=============================================================================
+
+Storages servers propigate invalidations from their storages. Among
+other things, this allows client storages to be used in storage
+servers, allowing storage-server fan out, spreading read load over
+multiple storage servers.
+
+We'll create a Faux storage that has a registerDB method.
+
+ >>> class FauxStorage:
+ ... def registerDB(self, db):
+ ... self.db = db
+ ... def isReadOnly(self):
+ ... return False
+ ... def getName(self):
+ ... return 'faux'
+ ... def lastTransaction(self):
+ ... return '\0\0\0\0\0\0\0\0'
+
+We'll create a storage and a storage server using it:
+
+ >>> storage = FauxStorage()
+ >>> import ZEO.StorageServer
+ >>> server = ZEO.StorageServer.StorageServer('addr', dict(t=storage))
+
+Out storage now has a db attribute that provides IStorageDB. It's
+references method is just the referencesf function from ZODB.Serialize
+
+ >>> import ZODB.serialize
+ >>> storage.db.references is ZODB.serialize.referencesf
+ True
+
+To see the effects of the invalidation messages, we'll create a client
+stub that implements the client invalidation calls:
+
+ >>> class Client:
+ ... def invalidateCache(self):
+ ... print 'invalidateCache'
+ ... def invalidateTransaction(self, tid, invalidated):
+ ... print 'invalidateTransaction', tid
+ ... print invalidated
+
+ >>> class Connection:
+ ... def __init__(self):
+ ... self.client = Client()
+
+Now, we'll register the client with the storage server:
+
+ >>> server.register_connection('t', Connection())
+
+Now, if we call invalidateCache, we'll see it propigate to the client:
+
+ >>> storage.db.invalidateCache()
+ invalidateCache
+
+And likewise if we call invalidate:
+
+ >>> storage.db.invalidate('trans1, ['ob1', 'ob2'])
+ invalidateTransaction trans1
+ [('ob1', ''), ('ob2', '')]
+
+ >>> storage.db.invalidate('trans1, ['ob1', 'ob2'], 'v')
+ invalidateTransaction trans1
+ [('ob1', 'v'), ('ob2', 'v')]
+
+
Property changes on: ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/testZEO.py 2007-04-23 11:02:51 UTC (rev 74660)
+++ ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/testZEO.py 2007-04-23 11:04:14 UTC (rev 74661)
@@ -790,6 +790,7 @@
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(setUp=ZODB.tests.util.setUp,
tearDown=ZODB.tests.util.tearDown))
+ suite.addTest(doctest.DocFileSuite('registerDB.test'))
for klass in test_classes:
sub = unittest.makeSuite(klass, "check")
suite.addTest(sub)
More information about the Zodb-checkins
mailing list