[Erp5-report] r46041 romain - in /erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage:...
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Jul 30 17:36:01 CEST 2012
Author: romain
Date: Mon Jul 30 17:36:01 2012
New Revision: 46041
URL: http://svn.erp5.org?rev=46041&view=rev
Log:
Directly contact the Zeo servers instead of one Zope.
This allows to drop the circular dependency between Zope and Tidstorage.
Use the patched transaction module to trigger registration of Zeo.
Changed the configuration file format to use parsable JSON, instead of
hardcoded string.
Modified:
erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py
erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py
Modified: erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py
URL: http://svn.erp5.org/erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py?rev=46041&r1=46040&r2=46041&view=diff
==============================================================================
--- erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py [utf8] (original)
+++ erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py [utf8] Mon Jul 30 17:36:01 2012
@@ -92,6 +92,11 @@ import SocketServer
import threading
import traceback
from ..ExchangeProtocol import ClientDisconnected, ExchangeProtocol
+from ZEO import ClientStorage
+from .. import transaction_transaction
+from ZODB import DB
+import transaction
+import json
class TransactionException(Exception):
pass
@@ -461,15 +466,23 @@ class BootstrapContent(threading.Thread)
serialize_url = None
for storage_id in to_check_storage_id_set:
if can_bootstrap and storage_id not in tid_storage.dump_transcient().keys():
- serialize_url = base_url % (storage_id_to_object_path_dict[storage_id], )
try:
- # Query a Zope, which will contact this process in return to store
- # the new TID number, making the given storage known.
- page = urllib.urlopen(serialize_url)
+ # Query a Zeo. The patched transaction will contact this process
+ # in return to store the new TID number, making the given storage
+ # known.
+ address_list, zeo_storage_id = json.loads(storage_id)
+ zeo_client_storage = ClientStorage.ClientStorage(
+ ((address_list[0][0].encode('UTF-8'), address_list[0][1]),),
+ zeo_storage_id.encode('UTF-8'))
+ db = DB(zeo_client_storage)
+ conn = db.open()
+ root = conn.root()
+ root._p_changed = 1
+ transaction.commit()
except Exception, message:
- log('Exception during bootstrap (%r):\n%s' % (serialize_url, ''.join(traceback.format_exception(*sys.exc_info()))))
+ log('Exception during bootstrap (%r):\n%s' % (storage_id, ''.join(traceback.format_exception(*sys.exc_info()))))
else:
- log('Opened %r: %r' % (serialize_url, page.read()))
+ log('Opened %r' % storage_id)
# Let some time for zope to contact TIDStorage back and fill the gaps.
time.sleep(5)
known_storage_id_set = sets.ImmutableSet(tid_storage.dump_transcient().keys())
@@ -724,6 +737,11 @@ def main():
tid_file = openTIDLog()
sys.stdout = sys.stderr = openLog()
+ TID_STORAGE_ADDRESS = (options.address, options.port)
+ def getZopeId_patched():
+ return '%s:%s' % TID_STORAGE_ADDRESS
+ transaction_transaction.getZopeId = getZopeId_patched
+ transaction_transaction.TID_STORAGE_ADDRESS = TID_STORAGE_ADDRESS
pidfile = open(options.pidfile_name, 'w')
if options.fork:
Modified: erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py
URL: http://svn.erp5.org/erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py?rev=46041&r1=46040&r2=46041&view=diff
==============================================================================
--- erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py [utf8] (original)
+++ erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/transaction_transaction.py [utf8] Mon Jul 30 17:36:01 2012
@@ -33,6 +33,7 @@ import socket
import thread
import struct
import sys
+import json
GET_LAST_COMMITED_TID_METHOD_ID = 'getLastCommitedTID'
from App.config import getConfiguration
@@ -105,7 +106,7 @@ def getFilestorageToTIDMapping(resource_
tid = getLastCommitedTID()
_addr = tuple([tuple(x) for x in getattr(storage, '_addr', [])])
_storage = getattr(storage, '_storage', '')
- datafs_id = repr((_addr, _storage))
+ datafs_id = json.dumps((_addr, _storage))
assert datafs_id not in datafs_tid_update_dict
if tid is None:
datafs_tid_update_dict[datafs_id] = None
More information about the Erp5-report
mailing list