[Zodb-checkins] SVN: ZODB/branches/jim-zeo-registerdb/src/ZEO/
checkpointing
Jim Fulton
jim at zope.com
Mon Apr 23 18:48:41 EDT 2007
Log message for revision 74689:
checkpointing
Changed:
U ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py
U ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test
-=-
Modified: ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py
===================================================================
--- ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py 2007-04-23 21:59:50 UTC (rev 74688)
+++ ZODB/branches/jim-zeo-registerdb/src/ZEO/StorageServer.py 2007-04-23 22:48:40 UTC (rev 74689)
@@ -690,10 +690,20 @@
class StorageServerDB:
- def __init__(self, server):
+ def __init__(self, server, storage_id):
self.server = server
+ self.storage_id = storage_id
self.references = ZODB.serial.referencesf
+ def invalidate(self, tid, oids, version=''):
+ self.server.invalidate(
+ None, self.storage_id, tid,
+ [(oid, version) for oid in oids],
+ )
+
+ def invalidateCache(self):
+ pass
+
class StorageServer:
"""The server side implementation of ZEO.
Modified: ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test
===================================================================
--- ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test 2007-04-23 21:59:50 UTC (rev 74688)
+++ ZODB/branches/jim-zeo-registerdb/src/ZEO/tests/registerDB.test 2007-04-23 22:48:40 UTC (rev 74689)
@@ -9,6 +9,9 @@
We'll create a Faux storage that has a registerDB method.
>>> class FauxStorage:
+ ... invalidations = [('trans0', [('ob0', '')]),
+ ... ('trans1', [('ob0', ''), ('ob1', '')]),
+ ... ]
... def registerDB(self, db):
... self.db = db
... def isReadOnly(self):
@@ -16,7 +19,9 @@
... def getName(self):
... return 'faux'
... def lastTransaction(self):
- ... return '\0\0\0\0\0\0\0\0'
+ ... return self.invq[0][0]
+ ... def lastInvalidations(self, size):
+ ... return list(self.invalidations)
We'll create a storage and a storage server using it:
@@ -24,7 +29,7 @@
>>> import ZEO.StorageServer
>>> server = ZEO.StorageServer.StorageServer('addr', dict(t=storage))
-Out storage now has a db attribute that provides IStorageDB. It's
+Our storage now has a db attribute that provides IStorageDB. It's
references method is just the referencesf function from ZODB.Serialize
>>> import ZODB.serialize
@@ -35,33 +40,61 @@
stub that implements the client invalidation calls:
>>> class Client:
- ... def invalidateCache(self):
- ... print 'invalidateCache'
+ ... def __init__(self, name):
+ ... self.name = name
... def invalidateTransaction(self, tid, invalidated):
- ... print 'invalidateTransaction', tid
+ ... print 'invalidateTransaction', tid, self.name
... print invalidated
>>> class Connection:
- ... def __init__(self):
- ... self.client = Client()
+ ... def __init__(self, mgr, obj):
+ ... self.mgr = mgr
+ ... self.obj = obj
+ ... def close(self):
+ ... print 'closed', self.obj.name
+ ... self.mgr.close_conn(self)
+ >>> class ZEOStorage:
+ ... def __init__(self, server, name):
+ ... self.connection = Connection(server, self)
+ ... self.client = Client(name)
+
Now, we'll register the client with the storage server:
- >>> server.register_connection('t', Connection())
+ >>> server.register_connection('t', ZEOStorage(server, 1))
+ >>> server.register_connection('t', ZEOStorage(server, 2))
-Now, if we call invalidateCache, we'll see it propigate to the client:
+Now, if we call invalidate, 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
+ >>> storage.db.invalidate('trans2, ['ob1', 'ob2'])
+ invalidateTransaction trans1 1
[('ob1', ''), ('ob2', '')]
+ invalidateTransaction trans1 2
+ [('ob1', ''), ('ob2', '')]
- >>> storage.db.invalidate('trans1, ['ob1', 'ob2'], 'v')
- invalidateTransaction trans1
+ >>> storage.db.invalidate('trans3, ['ob1', 'ob2'], 'v')
+ invalidateTransaction trans2 1
[('ob1', 'v'), ('ob2', 'v')]
+ invalidateTransaction trans2 2
+ [('ob1', 'v'), ('ob2', 'v')]
+The storage servers queue will reflect the invalidations:
+
+ >>> for tid, invalidated in server.invq['t']:
+ ... print repr(tid), invalidated
+ `trans2` [('ob1', 'v'), ('ob2', 'v')]
+ `trans1` [('ob1', ''), ('ob2', '')]
+
+If we call invalidateCache, the storage server will close each of it's
+connections:
+
+ >>> storage.db.invalidateCache()
+ close 1
+ close 2
+
+The connections will then reopen and revalidate their caches.
+The servers's invalidation queue will get reset
+
+ >>> for tid, invalidated in server.invq['t']:
+ ... print repr(tid), invalidated
More information about the Zodb-checkins
mailing list