Commit e1a00cbf authored by Chris McDonough's avatar Chris McDonough

Disabled conflict resolution for sake of stability. Stress tests now pass as a result.

parent f3b4033d
......@@ -85,27 +85,20 @@
"""
A storage implementation which uses RAM to persist objects, much like
MappingStorage, but unlike MappingStorage needs not be packed to get rid of
MappingStorage. Unlike MappingStorage, it needs not be packed to get rid of
non-cyclic garbage. This is a ripoff of Jim's Packless bsddb3 storage.
$Id: TemporaryStorage.py,v 1.2 2001/11/13 21:44:33 matt Exp $
$Id: TemporaryStorage.py,v 1.3 2001/11/17 22:50:31 chrism Exp $
"""
__version__ ='$Revision: 1.2 $'[11:-2]
__version__ ='$Revision: 1.3 $'[11:-2]
from zLOG import LOG
from struct import pack, unpack
from ZODB.referencesf import referencesf
from ZODB import POSException
from ZODB.BaseStorage import BaseStorage
try:
from ZODB.ConflictResolution import ConflictResolvingStorage
except:
LOG('Temporary Storage', 100,
('Not able to use ConflictResolvingStorage for TemporaryStorage, '
'this is suboptimal. Upgrade to Zope 2.3.2 or later to '
'make use of conflict resolution.'))
class ConflictResolvingStorage: pass
from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial
class ReferenceCountError(POSException.POSError):
""" An error occured while decrementing a reference to an object in
......@@ -117,7 +110,7 @@ class TemporaryStorageError(POSException.POSError):
available tempfile space and RAM consumption and restart the server
process."""
class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
class TemporaryStorage(BaseStorage):# , ConflictResolvingStorage):
def __init__(self, name='TemporaryStorage'):
"""
......@@ -158,40 +151,40 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
finally:
self._lock_release()
def loadSerial(self, oid, serial):
""" only a stub to make conflict resolution work! """
self._lock_acquire()
try:
return self._opickle[oid]
finally:
self._lock_release()
## This loadSerial doesn't work for resolution of conficts. :-( I
## haven't figured out why that's the case. As a result, I'm disabling
## conflict resolution in the storage until I have time to figure out why.
## def loadSerial(self, oid, serial):
## """ only a stub to make conflict resolution work! """
## self._lock_acquire()
## try:
## return self._opickle[oid]
## finally:
## self._lock_release()
def store(self, oid, serial, data, version, transaction):
if transaction is not self._transaction:
raise POSException.StorageTransactionError(self, transaction)
if version:
raise POSException.Unsupported, ("TemporaryStorage is incompatible "
"with versions",)
raise POSException.Unsupported, (
"TemporaryStorage is incompatible with versions"
)
self._lock_acquire()
try:
if self._index.has_key(oid):
oserial=self._index[oid]
if serial != oserial:
if hasattr(self, 'tryToResolveConflict'):
data=self.tryToResolveConflict(
oid, oserial, serial, data
)
if not data:
raise POSException.ConflictError, (serial,oserial)
else:
raise POSException.ConflictError, (serial,oserial)
serial=self._serial
raise POSException.ConflictError, (serial, oserial)
## data=self.tryToResolveConflict(oid, oserial, serial, data)
## if not data:
## raise POSException.ConflictError, (serial,oserial)
else:
oserial = serial
newserial=self._serial
self._tmp.append((oid, data))
return serial
## return serial == oserial and newserial or ResolvedSerial
return newserial
finally:
self._lock_release()
......
if __name__=='__main__':
import sys
sys.path.insert(0, '../../..')
sys.path.insert(0, '..')
import ZODB
from Products.TemporaryFolder import TemporaryStorage
import sys, os, unittest
from ZODB.tests import StorageTestBase, BasicStorage, \
Synchronization, ConflictResolution, \
Corruption, RevisionStorage
class TemporaryStorageTests(
StorageTestBase.StorageTestBase,
BasicStorage.BasicStorage,
Synchronization.SynchronizedStorage,
#ConflictResolution.ConflictResolvingStorage,
#RevisionStorage.RevisionStorage
):
def open(self, **kwargs):
self._storage = TemporaryStorage.TemporaryStorage('foo')
def setUp(self):
self.open()
StorageTestBase.StorageTestBase.setUp(self)
def tearDown(self):
StorageTestBase.StorageTestBase.tearDown(self)
def test_suite():
suite = unittest.makeSuite(TemporaryStorageTests, 'check')
suite2 = unittest.makeSuite(Corruption.FileStorageCorruptTests, 'check')
suite.addTest(suite2)
return suite
def main():
alltests=test_suite()
runner = unittest.TextTestRunner()
runner.run(alltests)
def debug():
test_suite().debug()
def pdebug():
import pdb
pdb.run('debug()')
if __name__=='__main__':
if len(sys.argv) > 1:
globals()[sys.argv[1]]()
else:
main()
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