[Zodb-checkins] CVS: ZODB3/ZEO - StorageServer.py:1.74.2.14

Jeremy Hylton jeremy at zope.com
Wed Aug 27 12:09:00 EDT 2003


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv1940

Modified Files:
      Tag: ZODB3-3_1-branch
	StorageServer.py 
Log Message:
Log a message about the number of objects and size of a transaction.

Need to pass a log method to the DelayedCommitStrategy.  Rename the
self.log attribute, which holds the CommitLog, to self.clog.


=== ZODB3/ZEO/StorageServer.py 1.74.2.13 => 1.74.2.14 ===
--- ZODB3/ZEO/StorageServer.py:1.74.2.13	Wed Aug 27 10:23:46 2003
+++ ZODB3/ZEO/StorageServer.py	Wed Aug 27 11:08:59 2003
@@ -483,7 +483,8 @@
         # (This doesn't require a lock because we're using asyncore)
         self.strategy = self.DelayedCommitStrategyClass(self.storage,
                                                         self.wait,
-                                                        self.queue)
+                                                        self.queue,
+                                                        self.log)
 
         t = Transaction()
         t.id = id
@@ -748,12 +749,13 @@
 class DelayedCommitStrategy:
     """The storage is unavailable, so log to a file."""
 
-    def __init__(self, storage, block, queue):
+    def __init__(self, storage, block, queue, logmethod):
         # the block argument is called when we can't delay any longer
         self.storage = storage
         self.block = block
         self.queue = queue
-        self.log = CommitLog()
+        self.clog = CommitLog()
+        self.log = logmethod
 
         # Store information about the call that blocks
         self.name = None
@@ -765,7 +767,7 @@
         self.status = status
 
     def store(self, oid, serial, data, version):
-        self.log.store(oid, serial, data, version)
+        self.clog.store(oid, serial, data, version)
 
     def tpc_abort(self):
         pass # just forget about this strategy
@@ -812,7 +814,9 @@
         # whether to use another thread.  The real work is done in
         # _prepare().
         assert isinstance(new_strategy, ImmediateCommitStrategy)
-        if self.log.stores > 25:
+        self.log("Preparing to commit transaction: %d objects, %d bytes" %
+                 (self.clog.stores, self.clog.size()), level=zLOG.BLATHER)
+        if self.clog.stores > 25:
             # If there are a lot of stores, fire off a separate thread
             # to avoid blocking other clients.
             return run_in_thread(self._prepare, new_strategy, delay=delay)
@@ -826,7 +830,7 @@
     def _prepare(self, new_strategy):
         # The new strategy will always be an ImmediateCommitStrategy.
         new_strategy.tpc_begin(self.txn, self.tid, self.status)
-        loads, loader = self.log.get_loader()
+        loads, loader = self.clog.get_loader()
         for i in range(loads):
             oid, serial, data, version = loader.load()
             if not new_strategy.store(oid, serial, data, version):




More information about the Zodb-checkins mailing list