Commit bc0ce9e3 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rename tid to ttid to clarify the meaning.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2611 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d700898b
......@@ -747,14 +747,14 @@ class Application(object):
self._waitAnyMessage(False)
def onStoreTimeout(self, conn, msg_id, tid, oid):
def onStoreTimeout(self, conn, msg_id, ttid, oid):
# NOTE: this method is called from poll thread, don't use
# local_var !
# Stop expecting the timed-out store request.
queue = self.dispatcher.forget(conn, msg_id)
# Ask the storage if someone locks the object.
# Shorten timeout to react earlier to an unresponding storage.
conn.ask(Packets.AskHasLock(tid, oid), timeout=5, queue=queue)
conn.ask(Packets.AskHasLock(ttid, oid), timeout=5, queue=queue)
return True
@profiler_decorator
......
......@@ -202,7 +202,7 @@ class EventHandler(object):
def askBeginTransaction(self, conn, tid):
raise UnexpectedPacketError
def answerBeginTransaction(self, conn, tid):
def answerBeginTransaction(self, conn, ttid):
raise UnexpectedPacketError
def askNewOIDs(self, conn, num_oids):
......@@ -211,7 +211,7 @@ class EventHandler(object):
def answerNewOIDs(self, conn, num_oids):
raise UnexpectedPacketError
def askFinishTransaction(self, conn, tid, oid_list):
def askFinishTransaction(self, conn, ttid, oid_list):
raise UnexpectedPacketError
def answerTransactionFinished(self, conn, ttid, tid):
......@@ -226,27 +226,27 @@ class EventHandler(object):
def invalidateObjects(self, conn, tid, oid_list):
raise UnexpectedPacketError
def notifyUnlockInformation(self, conn, tid):
def notifyUnlockInformation(self, conn, ttid):
raise UnexpectedPacketError
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, data_serial, tid, unlock):
compression, checksum, data, data_serial, ttid, unlock):
raise UnexpectedPacketError
def answerStoreObject(self, conn, conflicting, oid, serial):
raise UnexpectedPacketError
def abortTransaction(self, conn, tid):
def abortTransaction(self, conn, ttid):
raise UnexpectedPacketError
def askStoreTransaction(self, conn, tid, user, desc,
def askStoreTransaction(self, conn, ttid, user, desc,
ext, oid_list):
raise UnexpectedPacketError
def answerStoreTransaction(self, conn, tid):
def answerStoreTransaction(self, conn, ttid):
raise UnexpectedPacketError
def askObject(self, conn, oid, serial, tid):
def askObject(self, conn, oid, serial, ttid):
raise UnexpectedPacketError
def answerObject(self, conn, oid, serial_start,
......@@ -327,13 +327,13 @@ class EventHandler(object):
def notifyReplicationDone(self, conn, offset):
raise UnexpectedPacketError
def askObjectUndoSerial(self, conn, tid, ltid, undone_tid, oid_list):
def askObjectUndoSerial(self, conn, ttid, ltid, undone_tid, oid_list):
raise UnexpectedPacketError
def answerObjectUndoSerial(self, conn, object_tid_dict):
raise UnexpectedPacketError
def askHasLock(self, conn, tid, oid):
def askHasLock(self, conn, ttid, oid):
raise UnexpectedPacketError
def answerHasLock(self, conn, oid, status):
......@@ -375,7 +375,7 @@ class EventHandler(object):
def answerLastTransaction(self, conn, tid):
raise UnexpectedPacketError
def askCheckCurrentSerial(self, conn, tid, serial, oid):
def askCheckCurrentSerial(self, conn, ttid, serial, oid):
raise UnexpectedPacketError
answerCheckCurrentSerial = answerStoreObject
......
......@@ -30,8 +30,8 @@ SLOW_STORE = 2
class ClientOperationHandler(BaseClientAndStorageOperationHandler):
def _askObject(self, oid, serial, tid):
return self.app.dm.getObject(oid, serial, tid)
def _askObject(self, oid, serial, ttid):
return self.app.dm.getObject(oid, serial, ttid)
def connectionLost(self, conn, new_state):
uuid = conn.getUUID()
......@@ -39,31 +39,31 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
assert node is not None, conn
self.app.nm.remove(node)
def abortTransaction(self, conn, tid):
self.app.tm.abort(tid)
def abortTransaction(self, conn, ttid):
self.app.tm.abort(ttid)
def askStoreTransaction(self, conn, tid, user, desc, ext, oid_list):
self.app.tm.register(conn.getUUID(), tid)
self.app.tm.storeTransaction(tid, oid_list, user, desc, ext, False)
conn.answer(Packets.AnswerStoreTransaction(tid))
def askStoreTransaction(self, conn, ttid, user, desc, ext, oid_list):
self.app.tm.register(conn.getUUID(), ttid)
self.app.tm.storeTransaction(ttid, oid_list, user, desc, ext, False)
conn.answer(Packets.AnswerStoreTransaction(ttid))
def _askStoreObject(self, conn, oid, serial, compression, checksum, data,
data_serial, tid, unlock, request_time):
if tid not in self.app.tm:
data_serial, ttid, unlock, request_time):
if ttid not in self.app.tm:
# transaction was aborted, cancel this event
neo.logging.info('Forget store of %s:%s by %s delayed by %s',
dump(oid), dump(serial), dump(tid),
dump(oid), dump(serial), dump(ttid),
dump(self.app.tm.getLockingTID(oid)))
# send an answer as the client side is waiting for it
conn.answer(Packets.AnswerStoreObject(0, oid, serial))
return
try:
self.app.tm.storeObject(tid, serial, oid, compression,
self.app.tm.storeObject(ttid, serial, oid, compression,
checksum, data, data_serial, unlock)
except ConflictError, err:
# resolvable or not
tid_or_serial = err.getTID()
conn.answer(Packets.AnswerStoreObject(1, oid, tid_or_serial))
ttid_or_serial = err.getTID()
conn.answer(Packets.AnswerStoreObject(1, oid, ttid_or_serial))
except DelayedError:
# locked by a previous transaction, retry later
# If we are unlocking, we want queueEvent to raise
......@@ -71,8 +71,8 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
# response.
try:
self.app.queueEvent(self._askStoreObject, conn, (oid, serial,
compression, checksum, data, data_serial, tid,
unlock, request_time), key=(oid, tid),
compression, checksum, data, data_serial, ttid,
unlock, request_time), key=(oid, ttid),
raise_on_duplicate=unlock)
except AlreadyPendingError:
conn.answer(Errors.AlreadyPending(dump(oid)))
......@@ -84,16 +84,16 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
conn.answer(Packets.AnswerStoreObject(0, oid, serial))
def askStoreObject(self, conn, oid, serial,
compression, checksum, data, data_serial, tid, unlock):
compression, checksum, data, data_serial, ttid, unlock):
# register the transaction
self.app.tm.register(conn.getUUID(), tid)
self.app.tm.register(conn.getUUID(), ttid)
if data_serial is not None:
assert data == '', repr(data)
# Change data to None here, to do it only once, even if store gets
# delayed.
data = None
self._askStoreObject(conn, oid, serial, compression, checksum, data,
data_serial, tid, unlock, time.time())
data_serial, ttid, unlock, time.time())
def askTIDsFrom(self, conn, min_tid, max_tid, length, partition_list):
app = self.app
......@@ -122,14 +122,14 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
app.pt.getPartitions(), partition_list)
conn.answer(Packets.AnswerTIDs(tid_list))
def askObjectUndoSerial(self, conn, tid, ltid, undone_tid, oid_list):
def askObjectUndoSerial(self, conn, ttid, ltid, undone_tid, oid_list):
app = self.app
findUndoTID = app.dm.findUndoTID
getObjectFromTransaction = app.tm.getObjectFromTransaction
object_tid_dict = {}
for oid in oid_list:
current_serial, undo_serial, is_current = findUndoTID(oid, tid,
ltid, undone_tid, getObjectFromTransaction(tid, oid))
current_serial, undo_serial, is_current = findUndoTID(oid, ttid,
ltid, undone_tid, getObjectFromTransaction(ttid, oid))
if current_serial is None:
p = Errors.OidNotFound(dump(oid))
break
......@@ -138,12 +138,12 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
p = Packets.AnswerObjectUndoSerial(object_tid_dict)
conn.answer(p)
def askHasLock(self, conn, tid, oid):
def askHasLock(self, conn, ttid, oid):
locking_tid = self.app.tm.getLockingTID(oid)
neo.logging.info('%r check lock of %r:%r', conn, dump(tid), dump(oid))
neo.logging.info('%r check lock of %r:%r', conn, dump(ttid), dump(oid))
if locking_tid is None:
state = LockState.NOT_LOCKED
elif locking_tid is tid:
elif locking_tid is ttid:
state = LockState.GRANTED
else:
state = LockState.GRANTED_TO_OTHER
......@@ -161,20 +161,20 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
p = Packets.AnswerObjectHistory(oid, history_list)
conn.answer(p)
def askCheckCurrentSerial(self, conn, tid, serial, oid):
self._askCheckCurrentSerial(conn, tid, serial, oid, time.time())
def askCheckCurrentSerial(self, conn, ttid, serial, oid):
self._askCheckCurrentSerial(conn, ttid, serial, oid, time.time())
def _askCheckCurrentSerial(self, conn, tid, serial, oid, request_time):
if tid not in self.app.tm:
def _askCheckCurrentSerial(self, conn, ttid, serial, oid, request_time):
if ttid not in self.app.tm:
# transaction was aborted, cancel this event
neo.logging.info('Forget serial check of %s:%s by %s delayed by '
'%s', dump(oid), dump(serial), dump(tid),
'%s', dump(oid), dump(serial), dump(ttid),
dump(self.app.tm.getLockingTID(oid)))
# send an answer as the client side is waiting for it
conn.answer(Packets.AnswerStoreObject(0, oid, serial))
return
try:
self.app.tm.checkCurrentSerial(tid, serial, oid)
self.app.tm.checkCurrentSerial(ttid, serial, oid)
except ConflictError, err:
# resolvable or not
conn.answer(Packets.AnswerCheckCurrentSerial(1, oid,
......@@ -182,8 +182,8 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
except DelayedError:
# locked by a previous transaction, retry later
try:
self.app.queueEvent(self._askCheckCurrentSerial, conn, (tid,
serial, oid, request_time), key=(oid, tid))
self.app.queueEvent(self._askCheckCurrentSerial, conn, (ttid,
serial, oid, request_time), key=(oid, ttid))
except AlreadyPendingError:
conn.answer(Errors.AlreadyPending(dump(oid)))
else:
......
......@@ -60,11 +60,11 @@ class MasterOperationHandler(BaseMasterHandler):
if not conn.isClosed():
conn.answer(Packets.AnswerInformationLocked(tid))
def notifyUnlockInformation(self, conn, tid):
if not tid in self.app.tm:
def notifyUnlockInformation(self, conn, ttid):
if not ttid in self.app.tm:
raise ProtocolError('Unknown transaction')
# TODO: send an answer
self.app.tm.unlock(tid)
self.app.tm.unlock(ttid)
def askPack(self, conn, tid):
app = self.app
......
This diff is collapsed.
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