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