Commit 623078ff authored by Barry Warsaw's avatar Barry Warsaw

Modifications to put the zeoup heartbeat object in a `monitor'

PersistentMapping sitting off the root object.  The zrs heartbeat
object will go in this same location (under a different name of
course).
parent a1b5e3b5
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
Usage: zeoup.py [options] Usage: zeoup.py [options]
The test will connect to a ZEO server, load the root object, and The test will connect to a ZEO server, load the root object, and attempt to
attempt to update the zeoup counter in the root. It will report update the zeoup counter in the root. It will report success if it updates
success if it updates to counter or if it gets a ConflictError. A the counter or if it gets a ConflictError. A ConflictError is considered a
ConflictError is considered a success, because the client was able to success, because the client was able to start a transaction.
start a transaction.
Options: Options:
...@@ -35,13 +34,15 @@ import ZODB ...@@ -35,13 +34,15 @@ import ZODB
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZEO.ClientStorage import ClientStorage from ZEO.ClientStorage import ClientStorage
from ZODB.PersistentMapping import PersistentMapping
ZEO_VERSION = 2 ZEO_VERSION = 2
def check_server(addr, storage, write): def check_server(addr, storage, write):
t0 = time.time() t0 = time.time()
if ZEO_VERSION == 2: if ZEO_VERSION == 2:
cs = ClientStorage(addr, storage=storage, wait=1, # XXX should do retries w/ exponential backoff
cs = ClientStorage(addr, storage=storage, wait=0,
read_only=(not write)) read_only=(not write))
else: else:
cs = ClientStorage(addr, storage=storage, debug=1, cs = ClientStorage(addr, storage=storage, debug=1,
...@@ -56,7 +57,13 @@ def check_server(addr, storage, write): ...@@ -56,7 +57,13 @@ def check_server(addr, storage, write):
cn = db.open() cn = db.open()
root = cn.root() root = cn.root()
try: try:
obj = root['zeoup'] = root.get('zeoup', MinPO(0)) # We store the data in a special `monitor' dict under the root,
# where other tools may also store such heartbeat and bookkeeping
# type data.
monitor = root.get('monitor')
if monitor is None:
monitor = root['monitor'] = PersistentMapping()
obj = monitor['zeoup'] = monitor.get('zeoup', MinPO(0))
obj.value += 1 obj.value += 1
get_transaction().commit() get_transaction().commit()
except ConflictError: except ConflictError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment