Commit b9a6955e authored by Guido van Rossum's avatar Guido van Rossum

I don't like subsystem or label names with spaces in them. In the

StorageServer class, instead of "ZEO Server:<pid>", use
"StorageServer:<pid>".  In the ZEOServer class, instead of "ZEO
Server:<pid>:<name>", use "ZEOStorage:<pid>:<name>".

Also log a message when a StorageServer instance is created, showing
the pid, the read_only parameter, the storage names, and for each
storage whether it is RO (read-only) or RW (read-write).

Also clean up a few comments, removing one XXX that seems out of
date, and use %r instead of %s in some log messages.
parent 0efde65a
...@@ -45,7 +45,7 @@ pickler = cPickle.Pickler() ...@@ -45,7 +45,7 @@ pickler = cPickle.Pickler()
pickler.fast = 1 # Don't use the memo pickler.fast = 1 # Don't use the memo
dump = pickler.dump dump = pickler.dump
def log(message, level=zLOG.INFO, label="ZEO Server:%s" % os.getpid(), def log(message, level=zLOG.INFO, label="StorageServer:%s" % os.getpid(),
error=None): error=None):
zLOG.LOG(label, level, message, error=error) zLOG.LOG(label, level, message, error=error)
...@@ -55,9 +55,13 @@ class StorageServerError(StorageError): ...@@ -55,9 +55,13 @@ class StorageServerError(StorageError):
class StorageServer: class StorageServer:
def __init__(self, addr, storages, read_only=0): def __init__(self, addr, storages, read_only=0):
# XXX should read_only be a per-storage option? not yet...
self.addr = addr self.addr = addr
self.storages = storages self.storages = storages
msg = ", ".join(
["%s:%s" % (name, storage.isReadOnly() and "RO" or "RW")
for name, storage in storages.items()])
log("StorageServer (pid=%d) created %s with storages: %s" %
(os.getpid(), read_only and "RO" or "RW", msg))
for s in storages.values(): for s in storages.values():
s._waiting = [] s._waiting = []
self.read_only = read_only self.read_only = read_only
...@@ -123,7 +127,7 @@ class ZEOStorage: ...@@ -123,7 +127,7 @@ class ZEOStorage:
def notifyDisconnected(self): def notifyDisconnected(self):
# When this storage closes, we must ensure that it aborts # When this storage closes, we must ensure that it aborts
# any pending transaction. Not sure if this is the clearest way. # any pending transaction. Not sure if this is the cleanest way.
if self._transaction is not None: if self._transaction is not None:
self._log("disconnected during transaction %s" % self._transaction) self._log("disconnected during transaction %s" % self._transaction)
self.tpc_abort(self._transaction.id) self.tpc_abort(self._transaction.id)
...@@ -144,7 +148,7 @@ class ZEOStorage: ...@@ -144,7 +148,7 @@ class ZEOStorage:
name = getattr(self.__storage, '__name__', None) name = getattr(self.__storage, '__name__', None)
if name is None: if name is None:
name = str(self.__storage) name = str(self.__storage)
zLOG.LOG("ZEO Server:%s:%s" % (pid, name), level, msg, error=error) zLOG.LOG("ZEOStorage:%s:%s" % (pid, name), level, msg, error=error)
def setup_delegation(self): def setup_delegation(self):
"""Delegate several methods to the storage""" """Delegate several methods to the storage"""
...@@ -177,7 +181,7 @@ class ZEOStorage: ...@@ -177,7 +181,7 @@ class ZEOStorage:
This method must be the first one called by the client. This method must be the first one called by the client.
""" """
self._log("register(%s, %s)" % (storage_id, read_only)) self._log("register(%r, %s)" % (storage_id, read_only))
storage = self.server.storages.get(storage_id) storage = self.server.storages.get(storage_id)
if storage is None: if storage is None:
self._log("unknown storage_id: %s" % storage_id) self._log("unknown storage_id: %s" % storage_id)
...@@ -190,7 +194,7 @@ class ZEOStorage: ...@@ -190,7 +194,7 @@ class ZEOStorage:
self.__storage = storage self.__storage = storage
self.setup_delegation() self.setup_delegation()
self.server.register_connection(storage_id, self) self.server.register_connection(storage_id, self)
self._log("registered storage %s: %s" % (storage_id, storage)) self._log("registered storage %r: %s" % (storage_id, storage))
def get_info(self): def get_info(self):
return {'length': len(self.__storage), return {'length': len(self.__storage),
......
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