[Zodb-checkins] CVS: ZODB3/ZEO - zeoctl.xml:1.1.16.1 zeoctl.py:1.1.16.1 zeopasswd.py:1.4.2.1 version.txt:1.10.2.1 start.py:1.60.32.1 simul.py:1.17.36.1 schema.xml:1.11.30.1 runzeo.py:1.16.12.1 monitor.py:1.4.2.1 mkzeoinst.py:1.18.24.1 __init__.py:1.20.2.1 StorageServer.py:1.101.2.5 DebugServer.py:1.2.2.1 ClientStorage.py:1.110.2.11

Jeremy Hylton jeremy at zope.com
Tue Dec 23 14:07:06 EST 2003


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

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	zeopasswd.py version.txt start.py simul.py schema.xml 
	runzeo.py monitor.py mkzeoinst.py __init__.py StorageServer.py 
	DebugServer.py ClientStorage.py 
Added Files:
      Tag: ZODB3-mvcc-2-branch
	zeoctl.xml zeoctl.py 
Log Message:
Merge the head to the mvcc branch.

This merge should be the final preparation for merging the branch to
the trunk.


=== Added File ZODB3/ZEO/zeoctl.xml ===
<schema>

  <description>
    This schema describes the configuration of the ZEO storage server
    controller.  It differs from the schema for the storage server
    only in that the "runner" section is required.
  </description>

  <!-- Use the storage types defined by ZODB. -->
  <import package="ZODB"/>

  <!-- Use the ZEO server information structure. -->
  <import package="ZEO"/>

  <import package="zLOG"/>

  <!-- runner control -->
  <import package="zdaemon"/>


  <section type="zeo" name="*" required="yes" attribute="zeo" />

  <section type="runner" name="*" required="yes" attribute="runner" />

  <multisection name="+" type="ZODB.storage"
                attribute="storages"
                required="yes" />

  <section name="*" type="eventlog" attribute="eventlog" required="no" />

</schema>


=== Added File ZODB3/ZEO/zeoctl.py ===
"""Wrapper script for zdctl.py that causes it to use the ZEO schema."""

import os

import ZEO
import zLOG
import zdaemon.zdctl


# Main program
def main(args=None):
    options = zdaemon.zdctl.ZDCtlOptions()
    options.schemadir = os.path.dirname(ZEO.__file__)
    options.schemafile = "zeoctl.xml"
    zdaemon.zdctl.main(args, options)


if __name__ == "__main__":
    main()


=== ZODB3/ZEO/zeopasswd.py 1.4 => 1.4.2.1 ===
--- ZODB3/ZEO/zeopasswd.py:1.4	Thu Oct  2 14:17:22 2003
+++ ZODB3/ZEO/zeopasswd.py	Tue Dec 23 14:05:57 2003
@@ -16,73 +16,107 @@
 
 usage: python zeopasswd.py [options] username [password]
 
--C/--configuration URL -- configuration file or URL
--d/--delete -- delete user instead of updating password
+Specify either a configuration file:
+
+    -C/--configuration -- ZConfig configuration file
+
+or the individual options:
+
+    -f/--filename -- authentication database filename
+    -p/--protocol -- authentication protocol name
+    -r/--realm -- authentication database realm
+
+Additional options:
+
+    -d/--delete -- delete user instead of updating password
 """
 
 import getopt
 import getpass
 import sys
+import os
 
 import ZConfig
 import ZEO
 
 def usage(msg):
-    print msg
     print __doc__
+    print msg
     sys.exit(2)
 
 def options(args):
     """Password-specific options loaded from regular ZEO config file."""
-
-    schema = ZConfig.loadSchema(os.path.join(os.path.dirname(ZEO.__file__),
-                                             "schema.xml"))
-
     try:
-        options, args = getopt.getopt(args, "C:", ["configure="])
+        opts, args = getopt.getopt(args, "dr:p:f:C:", ["configure=", 
+                                                          "protocol=", 
+                                                          "filename=",
+                                                          "realm"])
     except getopt.error, msg:
         usage(msg)
     config = None
-    delete = False
-    for k, v in options:
+    delete = 0
+    auth_protocol = None
+    auth_db = "" 
+    auth_realm = None
+    for k, v in opts:
         if k == '-C' or k == '--configure':
+            schemafile = os.path.join(os.path.dirname(ZEO.__file__),
+                                                     "schema.xml")
+            schema = ZConfig.loadSchema(schemafile)
             config, nil = ZConfig.loadConfig(schema, v)
         if k == '-d' or k == '--delete':
-            delete = True
-    if config is None:
-        usage("Must specifiy configuration file")
+            delete = 1
+        if k == '-p' or k == '--protocol':
+            auth_protocol = v
+        if k == '-f' or k == '--filename':
+            auth_db = v
+        if k == '-r' or k == '--realm':
+            auth_realm = v
+
+    if config is not None:
+        if auth_protocol or auth_db:
+            usage("Error: Conflicting options; use either -C *or* -p and -f")
+        auth_protocol = config.zeo.authentication_protocol
+        auth_db = config.zeo.authentication_database
+        auth_realm = config.zeo.authentication_realm
+    elif not (auth_protocol and auth_db):
+        usage("Error: Must specifiy configuration file or protocol and database")
 
     password = None
     if delete:
         if not args:
-            usage("Must specify username to delete")
+            usage("Error: Must specify a username to delete")
         elif len(args) > 1:
-            usage("Too many arguments")
+            usage("Error: Too many arguments")
         username = args[0]
     else:
         if not args:
-            usage("Must specify username")
+            usage("Error: Must specify a username")
         elif len(args) > 2:
-            usage("Too many arguments")
+            usage("Error: Too many arguments")
         elif len(args) == 1:
             username = args[0]
         else:
             username, password = args
 
-    return config.zeo, delete, username, password
+    return auth_protocol, auth_db, auth_realm, delete, username, password
 
-def main(args=None):
-    options, delete, username, password = options(args)
-    p = options.authentication_protocol
+def main(args=None, dbclass=None):
+    p, auth_db, auth_realm, delete, username, password = options(args)
     if p is None:
-        usage("ZEO configuration does not specify authentication-protocol")
+        usage("Error: configuration does not specify auth protocol")
     if p == "digest":
         from ZEO.auth.auth_digest import DigestDatabase as Database
     elif p == "srp":
         from ZEO.auth.auth_srp import SRPDatabase as Database
-    if options.authentication_database is None:
-        usage("ZEO configuration does not specify authentication-database")
-    db = Database(options.authentication_database)
+    elif dbclass:
+        # dbclass is used for testing tests.auth_plaintext, see testAuth.py
+        Database = dbclass
+    else:
+        raise ValueError, "Unknown database type %r" % p
+    if auth_db is None:
+        usage("Error: configuration does not specify auth database")
+    db = Database(auth_db, auth_realm)
     if delete:
         db.del_user(username)
     else:
@@ -92,4 +126,5 @@
     db.save()
 
 if __name__ == "__main__":
-    main(sys.argv)
+    main(sys.argv[1:])
+


=== ZODB3/ZEO/version.txt 1.10 => 1.10.2.1 ===
--- ZODB3/ZEO/version.txt:1.10	Thu Oct  2 14:17:22 2003
+++ ZODB3/ZEO/version.txt	Tue Dec 23 14:05:57 2003
@@ -1 +1 @@
-2.2c1
+2.3a0


=== ZODB3/ZEO/start.py 1.60 => 1.60.32.1 ===
--- ZODB3/ZEO/start.py:1.60	Mon Jan 20 13:05:50 2003
+++ ZODB3/ZEO/start.py	Tue Dec 23 14:05:57 2003
@@ -13,8 +13,6 @@
 ##############################################################################
 """Start the ZEO storage server."""
 
-from __future__ import nested_scopes
-
 import sys, os, getopt
 import types
 import errno


=== ZODB3/ZEO/simul.py 1.17 => 1.17.36.1 ===
--- ZODB3/ZEO/simul.py:1.17	Fri Jan  3 17:07:38 2003
+++ ZODB3/ZEO/simul.py	Tue Dec 23 14:05:57 2003
@@ -108,21 +108,21 @@
     struct_unpack = struct.unpack
     while 1:
         # Read a record and decode it
-        r = f_read(8)
-        if len(r) < 8:
+        r = f_read(10)
+        if len(r) < 10:
             break
-        offset += 8
-        ts, code = struct_unpack(">ii", r)
+        offset += 10
+        ts, code, lenoid = struct_unpack(">iiH", r)
         if ts == 0:
             # Must be a misaligned record caused by a crash
             ##print "Skipping 8 bytes at offset", offset-8
             continue
-        r = f_read(16)
-        if len(r) < 16:
+        r = f_read(8 + lenoid)
+        if len(r) < 8 + lenoid:
             break
-        offset += 16
+        offset += 8 + lenoid
         records += 1
-        oid, serial = struct_unpack(">8s8s", r)
+        serial, oid = struct_unpack(">8s%ds" % lenoid, r)
         # Decode the code
         dlen, version, code, current = (code & 0x7fffff00,
                                         code & 0x80,


=== ZODB3/ZEO/schema.xml 1.11 => 1.11.30.1 ===
--- ZODB3/ZEO/schema.xml:1.11	Wed Mar 26 14:40:15 2003
+++ ZODB3/ZEO/schema.xml	Tue Dec 23 14:05:57 2003
@@ -1,5 +1,8 @@
 <schema>
 
+  <!-- note that zeoctl.xml is a closely related schema which should
+       match this schema, but should require the "runner" section -->
+
   <description>
     This schema describes the configuration of the ZEO storage server
     process.
@@ -13,8 +16,13 @@
 
   <import package="zLOG"/>
 
+  <!-- runner control -->
+  <import package="zdaemon"/>
+
 
   <section type="zeo" name="*" required="yes" attribute="zeo" />
+
+  <section type="runner" name="*" required="no" attribute="runner" />
 
   <multisection name="+" type="ZODB.storage"
                 attribute="storages"


=== ZODB3/ZEO/runzeo.py 1.16 => 1.16.12.1 ===
--- ZODB3/ZEO/runzeo.py:1.16	Mon Jul 14 23:35:18 2003
+++ ZODB3/ZEO/runzeo.py	Tue Dec 23 14:05:57 2003
@@ -21,7 +21,7 @@
 -a/--address ADDRESS -- server address of the form PORT, HOST:PORT, or PATH
                         (a PATH must contain at least one "/")
 -f/--filename FILENAME -- filename for FileStorage
--t/--timeout TIMEOUT -- transaction timeout in secondes (default no timeout)
+-t/--timeout TIMEOUT -- transaction timeout in seconds (default no timeout)
 -h/--help -- print this usage message and exit
 -m/--monitor ADDRESS -- address of monitor server ([HOST:]PORT or PATH)
 
@@ -99,9 +99,9 @@
 class ZEOOptions(ZDOptions, ZEOOptionsMixin):
 
     logsectionname = "eventlog"
+    schemadir = os.path.dirname(ZEO.__file__)
 
     def __init__(self):
-        self.schemadir = os.path.dirname(ZEO.__file__)
         ZDOptions.__init__(self)
         self.add_zeo_options()
         self.add("storages", "storages",
@@ -196,7 +196,7 @@
             transaction_timeout=self.options.transaction_timeout,
             monitor_address=self.options.monitor_address,
             auth_protocol=self.options.auth_protocol,
-            auth_filename=self.options.auth_database,  # XXX option spelling
+            auth_database=self.options.auth_database,  # XXX option spelling
             auth_realm=self.options.auth_realm)
 
     def loop_forever(self):
@@ -286,9 +286,14 @@
     """Log a debugging message."""
     _log(msg, zLOG.DEBUG)
 
+# XXX It would be nice if a program that extended this one (like
+# runzrs) could change the label.
+
+_label = "RUNZEO:%d" % os.getpid()
+
 def _log(msg, severity=zLOG.INFO, error=None):
     """Internal: generic logging function."""
-    zLOG.LOG("RUNSVR", severity, msg, "", error)
+    zLOG.LOG(_label, severity, msg, "", error)
 
 
 # Main program


=== ZODB3/ZEO/monitor.py 1.4 => 1.4.2.1 ===


=== ZODB3/ZEO/mkzeoinst.py 1.18 => 1.18.24.1 ===
--- ZODB3/ZEO/mkzeoinst.py:1.18	Fri Apr  4 00:16:50 2003
+++ ZODB3/ZEO/mkzeoinst.py	Tue Dec 23 14:05:57 2003
@@ -20,11 +20,10 @@
 options (all of which have default values), create the following:
 
 <home>/etc/zeo.conf     -- ZEO config file
-<home>/etc/zeoctl.conf  -- zdctl+zdrun config file
 <home>/var/             -- Directory for data files: Data.fs etc.
 <home>/log/             -- Directory for log files: zeo.log and zeoctl.log
 <home>/bin/runzeo       -- the zeo server runner
-<home>/bin/zeoctl       -- start/stop script (a shim for zdctl.py)
+<home>/bin/zeoctl       -- start/stop script (a shim for zeoctl.py)
 
 The script will not overwrite existing files; instead, it will issue a
 warning if an existing file is found that differs from the file that
@@ -39,9 +38,10 @@
 import stat
 import getopt
 
-zeo_conf_template = """# ZEO configuration file
+zeo_conf_template = """\
+# ZEO configuration file
 
-%%define INSTANCE_HOME %(instance_home)s
+%%define INSTANCE %(instance_home)s
 
 <zeo>
   address %(port)d
@@ -52,52 +52,42 @@
 </zeo>
 
 <filestorage 1>
-  path $INSTANCE_HOME/var/Data.fs
+  path $INSTANCE/var/Data.fs
 </filestorage>
 
 <eventlog>
   level info
   <logfile>
-    path $INSTANCE_HOME/log/zeo.log
+    path $INSTANCE/log/zeo.log
   </logfile>
 </eventlog>
-"""
-
-runner_conf_template = """# %(package)sctl configuration file
-
-%%define INSTANCE_HOME %(instance_home)s
 
 <runner>
-  program $INSTANCE_HOME/bin/runzeo
-  socket-name $INSTANCE_HOME/etc/%(package)s.zdsock
+  program $INSTANCE/bin/runzeo
+  socket-name $INSTANCE/etc/%(package)s.zdsock
   daemon true
   forever false
   backoff-limit 10
   exit-codes 0, 2
-  directory $INSTANCE_HOME
+  directory $INSTANCE
   default-to-interactive true
   # user zope
   python %(python)s
   zdrun %(zope_home)s/zdaemon/zdrun.py
+
   # This logfile should match the one in the %(package)s.conf file.
   # It is used by zdctl's logtail command, zdrun/zdctl doesn't write it.
-  logfile $INSTANCE_HOME/log/%(package)s.log
+  logfile $INSTANCE/log/%(package)s.log
 </runner>
-
-<eventlog>
-  level info
-  <logfile>
-    path $INSTANCE_HOME/log/%(package)sctl.log
-  </logfile>
-</eventlog>
 """
 
-zdctl_template = """#!/bin/sh
-# %(PACKAGE)s instance start script
+zeoctl_template = """\
+#!/bin/sh
+# %(PACKAGE)s instance control script
 
 # The following two lines are for chkconfig.  On Red Hat Linux (and
 # some other systems), you can copy or symlink this script into
-# /etc/rc.d/init.d/ and then run chkconfig(8), to automatically start
+# /etc/rc.d/init.d/ and then use chkconfig(8) to automatically start
 # %(PACKAGE)s at boot time.
 
 # chkconfig: 345 90 10
@@ -105,33 +95,32 @@
 
 PYTHON="%(python)s"
 ZOPE_HOME="%(zope_home)s"
-INSTANCE_HOME="%(instance_home)s"
 
-CONFIG_FILE="$INSTANCE_HOME/etc/%(package)sctl.conf"
+CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
 
 PYTHONPATH="$ZOPE_HOME"
 export PYTHONPATH
 
-ZDCTL="$ZOPE_HOME/zdaemon/zdctl.py"
+ZEOCTL="$ZOPE_HOME/ZEO/zeoctl.py"
 
-exec "$PYTHON" "$ZDCTL" -C "$CONFIG_FILE" ${1+"$@"}
+exec "$PYTHON" "$ZEOCTL" -C "$CONFIG_FILE" ${1+"$@"}
 """
 
-runzeo_template = """#!/bin/sh
+runzeo_template = """\
+#!/bin/sh
 # %(PACKAGE)s instance start script
 
 PYTHON="%(python)s"
 ZOPE_HOME="%(zope_home)s"
-INSTANCE_HOME="%(instance_home)s"
 
-CONFIG_FILE="$INSTANCE_HOME/etc/%(package)s.conf"
+CONFIG_FILE="%(instance_home)s/etc/%(package)s.conf"
 
 PYTHONPATH="$ZOPE_HOME"
 export PYTHONPATH
 
-ZEO_RUN="$ZOPE_HOME/ZEO/runzeo.py"
+RUNZEO="$ZOPE_HOME/ZEO/runzeo.py"
 
-exec "$PYTHON" "$ZEO_RUN" -C "$CONFIG_FILE" ${1+"$@"}
+exec "$PYTHON" "$RUNZEO" -C "$CONFIG_FILE" ${1+"$@"}
 """
 
 def main():
@@ -193,8 +182,7 @@
         makedir(home, "log")
         makedir(home, "bin")
         makefile(zeo_conf_template, home, "etc", "zeo.conf", **params)
-        makefile(runner_conf_template, home, "etc", "zeoctl.conf", **params)
-        makexfile(zdctl_template, home, "bin", "zeoctl", **params)
+        makexfile(zeoctl_template, home, "bin", "zeoctl", **params)
         makexfile(runzeo_template, home, "bin", "runzeo", **params)
 
 


=== ZODB3/ZEO/__init__.py 1.20 => 1.20.2.1 ===
--- ZODB3/ZEO/__init__.py:1.20	Thu Oct  2 14:17:22 2003
+++ ZODB3/ZEO/__init__.py	Tue Dec 23 14:05:57 2003
@@ -21,4 +21,4 @@
 
 """
 
-version = "2.2c1"
+version = "2.3a0"


=== ZODB3/ZEO/StorageServer.py 1.101.2.4 => 1.101.2.5 ===
--- ZODB3/ZEO/StorageServer.py:1.101.2.4	Tue Dec  2 02:10:29 2003
+++ ZODB3/ZEO/StorageServer.py	Tue Dec 23 14:05:57 2003
@@ -20,8 +20,6 @@
 exported for invocation by the server.
 """
 
-from __future__ import nested_scopes
-
 import asyncore
 import cPickle
 import os
@@ -425,7 +423,7 @@
             self.locked = 0
             self.timeout.end(self)
             self.stats.lock_time = None
-            self.log("Transaction released storage lock")
+            self.log("Transaction released storage lock", zLOG.BLATHER)
             # _handle_waiting() can start another transaction (by
             # restarting a waiting one) so must be done last
             self._handle_waiting()


=== ZODB3/ZEO/DebugServer.py 1.2 => 1.2.2.1 ===
--- ZODB3/ZEO/DebugServer.py:1.2	Thu Oct  2 14:17:22 2003
+++ ZODB3/ZEO/DebugServer.py	Tue Dec 23 14:05:57 2003
@@ -13,8 +13,6 @@
 ##############################################################################
 """A debugging version of the server that records network activity."""
 
-from __future__ import nested_scopes
-
 import struct
 import time
 


=== ZODB3/ZEO/ClientStorage.py 1.110.2.10 => 1.110.2.11 ===
--- ZODB3/ZEO/ClientStorage.py:1.110.2.10	Sun Dec 14 13:56:55 2003
+++ ZODB3/ZEO/ClientStorage.py	Tue Dec 23 14:05:57 2003
@@ -35,7 +35,7 @@
 from ZEO.zrpc.client import ConnectionManager
 
 from ZODB import POSException
-from ZODB.TimeStamp import TimeStamp
+from persistent.TimeStamp import TimeStamp
 from zLOG import LOG, PROBLEM, INFO, BLATHER, ERROR
 
 def log2(type, msg, subsys="ZCS:%d" % os.getpid()):
@@ -326,6 +326,9 @@
     def _wait(self, timeout=None):
         if timeout is not None:
             deadline = time.time() + timeout
+            log2(BLATHER, "Setting deadline to %f" % deadline)
+        else:
+            deadline = None
         # Wait for a connection to be established.
         self._rpc_mgr.connect(sync=1)
         # When a synchronous connect() call returns, there is
@@ -343,19 +346,22 @@
                     break
                 log2(INFO, "Waiting for cache verification to finish")
         else:
-            self._wait_sync()
+            self._wait_sync(deadline)
 
-    def _wait_sync(self):
+    def _wait_sync(self, deadline=None):
         # If there is no mainloop running, this code needs
         # to call poll() to cause asyncore to handle events.
         while 1:
             if self._ready.isSet():
                 break
+            if deadline and time.time() > deadline:
+                log2(PROBLEM, "Timed out waiting for connection")
+                break
             log2(INFO, "Waiting for cache verification to finish")
             if self._connection is None:
                 # If the connection was closed while we were
                 # waiting for it to become ready, start over.
-                return self._wait()
+                return self._wait(deadline - time.time())
             else:
                 self._connection.pending(30)
 




More information about the Zodb-checkins mailing list