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

Rename packets for consistency:

- FinishTransaction -> AskFinishTransaction
- LockInformation -> AskLockInformation

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1658 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c3c3762d
...@@ -651,7 +651,7 @@ class Application(object): ...@@ -651,7 +651,7 @@ class Application(object):
# Call finish on master # Call finish on master
oid_list = self.local_var.data_dict.keys() oid_list = self.local_var.data_dict.keys()
p = Packets.FinishTransaction(oid_list, self.local_var.tid) p = Packets.AskFinishTransaction(oid_list, self.local_var.tid)
self._askPrimary(p) self._askPrimary(p)
if not self.isTransactionFinished(): if not self.isTransactionFinished():
......
...@@ -219,13 +219,13 @@ class EventHandler(object): ...@@ -219,13 +219,13 @@ class EventHandler(object):
def answerNewOIDs(self, conn, num_oids): def answerNewOIDs(self, conn, num_oids):
raise UnexpectedPacketError raise UnexpectedPacketError
def finishTransaction(self, conn, oid_list, tid): def askFinishTransaction(self, conn, oid_list, tid):
raise UnexpectedPacketError raise UnexpectedPacketError
def answerTransactionFinished(self, conn, tid): def answerTransactionFinished(self, conn, tid):
raise UnexpectedPacketError raise UnexpectedPacketError
def lockInformation(self, conn, tid): def askLockInformation(self, conn, tid):
raise UnexpectedPacketError raise UnexpectedPacketError
def answerInformationLocked(self, conn, tid): def answerInformationLocked(self, conn, tid):
...@@ -397,9 +397,9 @@ class EventHandler(object): ...@@ -397,9 +397,9 @@ class EventHandler(object):
d[Packets.CommitTransaction] = self.commitTransaction d[Packets.CommitTransaction] = self.commitTransaction
d[Packets.AskBeginTransaction] = self.askBeginTransaction d[Packets.AskBeginTransaction] = self.askBeginTransaction
d[Packets.AnswerBeginTransaction] = self.answerBeginTransaction d[Packets.AnswerBeginTransaction] = self.answerBeginTransaction
d[Packets.FinishTransaction] = self.finishTransaction d[Packets.AskFinishTransaction] = self.askFinishTransaction
d[Packets.AnswerTransactionFinished] = self.answerTransactionFinished d[Packets.AnswerTransactionFinished] = self.answerTransactionFinished
d[Packets.LockInformation] = self.lockInformation d[Packets.AskLockInformation] = self.askLockInformation
d[Packets.AnswerInformationLocked] = self.answerInformationLocked d[Packets.AnswerInformationLocked] = self.answerInformationLocked
d[Packets.InvalidateObjects] = self.invalidateObjects d[Packets.InvalidateObjects] = self.invalidateObjects
d[Packets.NotifyUnlockInformation] = self.notifyUnlockInformation d[Packets.NotifyUnlockInformation] = self.notifyUnlockInformation
......
...@@ -139,13 +139,13 @@ class PacketLogger(EventHandler): ...@@ -139,13 +139,13 @@ class PacketLogger(EventHandler):
def answerNewOIDs(self, conn, num_oids): def answerNewOIDs(self, conn, num_oids):
pass pass
def finishTransaction(self, conn, oid_list, tid): def askFinishTransaction(self, conn, oid_list, tid):
pass pass
def answerTransactionFinished(self, conn, tid): def answerTransactionFinished(self, conn, tid):
pass pass
def lockInformation(self, conn, tid): def askLockInformation(self, conn, tid):
pass pass
def answerInformationLocked(self, conn, tid): def answerInformationLocked(self, conn, tid):
......
...@@ -53,7 +53,7 @@ class ClientServiceHandler(MasterHandler): ...@@ -53,7 +53,7 @@ class ClientServiceHandler(MasterHandler):
oid_list = self.app.getNewOIDList(num_oids) oid_list = self.app.getNewOIDList(num_oids)
conn.answer(Packets.AnswerNewOIDs(oid_list)) conn.answer(Packets.AnswerNewOIDs(oid_list))
def finishTransaction(self, conn, oid_list, tid): def askFinishTransaction(self, conn, oid_list, tid):
app = self.app app = self.app
# If the given transaction ID is later than the last TID, the peer # If the given transaction ID is later than the last TID, the peer
# is crazy. # is crazy.
...@@ -78,7 +78,7 @@ class ClientServiceHandler(MasterHandler): ...@@ -78,7 +78,7 @@ class ClientServiceHandler(MasterHandler):
used_uuid_set = set() used_uuid_set = set()
for c in app.em.getConnectionList(): for c in app.em.getConnectionList():
if c.getUUID() in uuid_set: if c.getUUID() in uuid_set:
c.ask(Packets.LockInformation(tid), timeout=60) c.ask(Packets.AskLockInformation(tid), timeout=60)
used_uuid_set.add(c.getUUID()) used_uuid_set.add(c.getUUID())
app.tm.prepare(tid, oid_list, used_uuid_set, conn.getPeerId()) app.tm.prepare(tid, oid_list, used_uuid_set, conn.getPeerId())
......
...@@ -626,7 +626,7 @@ class AnswerBeginTransaction(Packet): ...@@ -626,7 +626,7 @@ class AnswerBeginTransaction(Packet):
(tid, ) = unpack('8s', body) (tid, ) = unpack('8s', body)
return (tid, ) return (tid, )
class FinishTransaction(Packet): class AskFinishTransaction(Packet):
""" """
Finish a transaction. C -> PM. Finish a transaction. C -> PM.
""" """
...@@ -654,7 +654,7 @@ class AnswerTransactionFinished(Packet): ...@@ -654,7 +654,7 @@ class AnswerTransactionFinished(Packet):
(tid, ) = unpack('8s', body) (tid, ) = unpack('8s', body)
return (_decodeTID(tid), ) return (_decodeTID(tid), )
class LockInformation(Packet): class AskLockInformation(Packet):
""" """
Lock information on a transaction. PM -> S. Lock information on a transaction. PM -> S.
""" """
...@@ -1288,9 +1288,9 @@ class PacketRegistry(dict): ...@@ -1288,9 +1288,9 @@ class PacketRegistry(dict):
CommitTransaction = register(0x0011, CommitTransaction) CommitTransaction = register(0x0011, CommitTransaction)
AskBeginTransaction = register(0x0012, AskBeginTransaction) AskBeginTransaction = register(0x0012, AskBeginTransaction)
AnswerBeginTransaction = register(0x8012, AnswerBeginTransaction) AnswerBeginTransaction = register(0x8012, AnswerBeginTransaction)
FinishTransaction = register(0x0013, FinishTransaction) AskFinishTransaction = register(0x0013, AskFinishTransaction)
AnswerTransactionFinished = register(0x8013, AnswerTransactionFinished) AnswerTransactionFinished = register(0x8013, AnswerTransactionFinished)
LockInformation = register(0x0014, LockInformation) AskLockInformation = register(0x0014, AskLockInformation)
AnswerInformationLocked = register(0x8014, AnswerInformationLocked) AnswerInformationLocked = register(0x8014, AnswerInformationLocked)
InvalidateObjects = register(0x0015, InvalidateObjects) InvalidateObjects = register(0x0015, InvalidateObjects)
NotifyUnlockInformation = register(0x0016, NotifyUnlockInformation) NotifyUnlockInformation = register(0x0016, NotifyUnlockInformation)
......
...@@ -235,7 +235,7 @@ class DatabaseManager(object): ...@@ -235,7 +235,7 @@ class DatabaseManager(object):
user information, a description and extension information.""" user information, a description and extension information."""
raise NotImplementedError raise NotImplementedError
def finishTransaction(self, tid): def askFinishTransaction(self, tid):
"""Finish a transaction specified by a given ID, by moving """Finish a transaction specified by a given ID, by moving
temporarily data to a finished area.""" temporarily data to a finished area."""
raise NotImplementedError raise NotImplementedError
......
...@@ -106,7 +106,7 @@ class HiddenHandler(BaseMasterHandler): ...@@ -106,7 +106,7 @@ class HiddenHandler(BaseMasterHandler):
def commitTransaction(self, conn, tid): def commitTransaction(self, conn, tid):
pass pass
def lockInformation(self, conn, tid): def askLockInformation(self, conn, tid):
pass pass
def notifyUnlockInformation(self, conn, tid): def notifyUnlockInformation(self, conn, tid):
......
...@@ -56,7 +56,7 @@ class MasterOperationHandler(BaseMasterHandler): ...@@ -56,7 +56,7 @@ class MasterOperationHandler(BaseMasterHandler):
elif state == CellStates.OUT_OF_DATE: elif state == CellStates.OUT_OF_DATE:
app.replicator.addPartition(offset) app.replicator.addPartition(offset)
def lockInformation(self, conn, tid): def askLockInformation(self, conn, tid):
if not tid in self.app.tm: if not tid in self.app.tm:
raise ProtocolError('Unknown transaction') raise ProtocolError('Unknown transaction')
self.app.tm.lock(tid) self.app.tm.lock(tid)
......
...@@ -268,8 +268,8 @@ class NeoTestBase(unittest.TestCase): ...@@ -268,8 +268,8 @@ class NeoTestBase(unittest.TestCase):
def checkAnswerInformationLocked(self, conn, **kw): def checkAnswerInformationLocked(self, conn, **kw):
return self.checkAnswerPacket(conn, Packets.AnswerInformationLocked, **kw) return self.checkAnswerPacket(conn, Packets.AnswerInformationLocked, **kw)
def checkLockInformation(self, conn, **kw): def checkAskLockInformation(self, conn, **kw):
return self.checkAskPacket(conn, Packets.LockInformation, **kw) return self.checkAskPacket(conn, Packets.AskLockInformation, **kw)
def checkNotifyUnlockInformation(self, conn, **kw): def checkNotifyUnlockInformation(self, conn, **kw):
return self.checkNotifyPacket(conn, Packets.NotifyUnlockInformation, **kw) return self.checkNotifyPacket(conn, Packets.NotifyUnlockInformation, **kw)
...@@ -298,8 +298,8 @@ class NeoTestBase(unittest.TestCase): ...@@ -298,8 +298,8 @@ class NeoTestBase(unittest.TestCase):
def checkAskStoreTransaction(self, conn, **kw): def checkAskStoreTransaction(self, conn, **kw):
return self.checkAskPacket(conn, Packets.AskStoreTransaction, **kw) return self.checkAskPacket(conn, Packets.AskStoreTransaction, **kw)
def checkFinishTransaction(self, conn, **kw): def checkAskFinishTransaction(self, conn, **kw):
return self.checkAskPacket(conn, Packets.FinishTransaction, **kw) return self.checkAskPacket(conn, Packets.AskFinishTransaction, **kw)
def checkAskNewTid(self, conn, **kw): def checkAskNewTid(self, conn, **kw):
return self.checkAskPacket(conn, Packets.AskBeginTransaction, **kw) return self.checkAskPacket(conn, Packets.AskBeginTransaction, **kw)
......
...@@ -133,7 +133,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -133,7 +133,7 @@ class ClientApplicationTests(NeoTestBase):
app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), }) app.cp = Mock({ 'getConnForCell': ReturnValues(None, conn), })
app.tpc_vote(txn) app.tpc_vote(txn)
def finishTransaction(self, app): def askFinishTransaction(self, app):
txn = app.local_var.txn txn = app.local_var.txn
tid = app.local_var.tid tid = app.local_var.tid
packet = Packets.AnswerTransactionFinished(tid) packet = Packets.AnswerTransactionFinished(tid)
...@@ -630,7 +630,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -630,7 +630,7 @@ class ClientApplicationTests(NeoTestBase):
self.assertRaises(NEOStorageError, app.tpc_finish, txn, hook) self.assertRaises(NEOStorageError, app.tpc_finish, txn, hook)
self.assertTrue(self.f_called) self.assertTrue(self.f_called)
self.assertEquals(self.f_called_with_tid, tid) self.assertEquals(self.f_called_with_tid, tid)
self.checkFinishTransaction(app.master_conn) self.checkAskFinishTransaction(app.master_conn)
self.checkDispatcherRegisterCalled(app, app.master_conn) self.checkDispatcherRegisterCalled(app, app.master_conn)
def test_tpc_finish3(self): def test_tpc_finish3(self):
...@@ -656,7 +656,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -656,7 +656,7 @@ class ClientApplicationTests(NeoTestBase):
app.tpc_finish(txn, hook) app.tpc_finish(txn, hook)
self.assertTrue(self.f_called) self.assertTrue(self.f_called)
self.assertEquals(self.f_called_with_tid, tid) self.assertEquals(self.f_called_with_tid, tid)
self.checkFinishTransaction(app.master_conn) self.checkAskFinishTransaction(app.master_conn)
#self.checkDispatcherRegisterCalled(app, app.master_conn) #self.checkDispatcherRegisterCalled(app, app.master_conn)
self.assertEquals(app.local_var.tid, None) self.assertEquals(app.local_var.tid, None)
self.assertEquals(app.local_var.txn, None) self.assertEquals(app.local_var.txn, None)
...@@ -699,17 +699,17 @@ class ClientApplicationTests(NeoTestBase): ...@@ -699,17 +699,17 @@ class ClientApplicationTests(NeoTestBase):
txn1 = self.beginTransaction(app, tid=tid1) txn1 = self.beginTransaction(app, tid=tid1)
self.storeObject(app, oid=oid1, data='O1V1') self.storeObject(app, oid=oid1, data='O1V1')
self.voteTransaction(app) self.voteTransaction(app)
self.finishTransaction(app) self.askFinishTransaction(app)
# commit version 1 of object 2 # commit version 1 of object 2
txn2 = self.beginTransaction(app, tid=tid2) txn2 = self.beginTransaction(app, tid=tid2)
self.storeObject(app, oid=oid2, data='O1V2') self.storeObject(app, oid=oid2, data='O1V2')
self.voteTransaction(app) self.voteTransaction(app)
self.finishTransaction(app) self.askFinishTransaction(app)
# commit version 2 of object 2 # commit version 2 of object 2
txn3 = self.beginTransaction(app, tid=tid3) txn3 = self.beginTransaction(app, tid=tid3)
self.storeObject(app, oid=oid2, data='O2V2') self.storeObject(app, oid=oid2, data='O2V2')
self.voteTransaction(app) self.voteTransaction(app)
self.finishTransaction(app) self.askFinishTransaction(app)
# undo 1 -> no previous revision # undo 1 -> no previous revision
u1p1 = Packets.AnswerTransactionInformation(tid1, '', '', '', (oid1, )) u1p1 = Packets.AnswerTransactionInformation(tid1, '', '', '', (oid1, ))
u1p2 = protocol.oidNotFound('oid not found') u1p2 = protocol.oidNotFound('oid not found')
...@@ -747,7 +747,7 @@ class ClientApplicationTests(NeoTestBase): ...@@ -747,7 +747,7 @@ class ClientApplicationTests(NeoTestBase):
self.assertRaises(ConflictError, app.undo, tid3, txn4, wrapper) self.assertRaises(ConflictError, app.undo, tid3, txn4, wrapper)
self.assertEquals(len(wrapper.mockGetNamedCalls('tryToResolveConflict')), 1) self.assertEquals(len(wrapper.mockGetNamedCalls('tryToResolveConflict')), 1)
self.assertEquals(app.undo(tid3, txn4, wrapper), (tid4, [oid2, ])) self.assertEquals(app.undo(tid3, txn4, wrapper), (tid4, [oid2, ]))
self.finishTransaction(app) self.askFinishTransaction(app)
def test_undoLog(self): def test_undoLog(self):
app = self.getApp() app = self.getApp()
......
...@@ -89,7 +89,7 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -89,7 +89,7 @@ class MasterClientHandlerTests(NeoTestBase):
service.askNewOIDs(conn, 1) service.askNewOIDs(conn, 1)
self.assertTrue(loid < self.app.loid) self.assertTrue(loid < self.app.loid)
def test_09_finishTransaction(self): def test_09_askFinishTransaction(self):
service = self.service service = self.service
uuid = self.identifyToMasterNode() uuid = self.identifyToMasterNode()
# give an older tid than the PMN known, must abort # give an older tid than the PMN known, must abort
...@@ -98,7 +98,7 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -98,7 +98,7 @@ class MasterClientHandlerTests(NeoTestBase):
oid_list = [] oid_list = []
upper, lower = unpack('!LL', self.app.tm.getLastTID()) upper, lower = unpack('!LL', self.app.tm.getLastTID())
new_tid = pack('!LL', upper, lower + 10) new_tid = pack('!LL', upper, lower + 10)
self.checkProtocolErrorRaised(service.finishTransaction, conn, oid_list, new_tid) self.checkProtocolErrorRaised(service.askFinishTransaction, conn, oid_list, new_tid)
old_node = self.app.nm.getByUUID(uuid) old_node = self.app.nm.getByUUID(uuid)
self.app.nm.remove(old_node) self.app.nm.remove(old_node)
self.app.pt.dropNode(old_node) self.app.pt.dropNode(old_node)
...@@ -118,8 +118,8 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -118,8 +118,8 @@ class MasterClientHandlerTests(NeoTestBase):
tid = self.app.tm.getLastTID() tid = self.app.tm.getLastTID()
conn = self.getFakeConnection(client_uuid, self.client_address) conn = self.getFakeConnection(client_uuid, self.client_address)
self.app.em = Mock({"getConnectionList" : [conn, storage_conn]}) self.app.em = Mock({"getConnectionList" : [conn, storage_conn]})
service.finishTransaction(conn, oid_list, tid) service.askFinishTransaction(conn, oid_list, tid)
self.checkLockInformation(storage_conn) self.checkAskLockInformation(storage_conn)
self.assertEquals(len(self.app.tm.getPendingList()), 1) self.assertEquals(len(self.app.tm.getPendingList()), 1)
apptid = self.app.tm.getPendingList()[0] apptid = self.app.tm.getPendingList()[0]
self.assertEquals(tid, apptid) self.assertEquals(tid, apptid)
......
...@@ -144,20 +144,20 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -144,20 +144,20 @@ class StorageMasterHandlerTests(NeoTestBase):
def _getConnection(self): def _getConnection(self):
return Mock({}) return Mock({})
def test_lockInformation1(self): def test_askLockInformation1(self):
""" Unknown transaction """ """ Unknown transaction """
self.app.tm = Mock({'__contains__': False}) self.app.tm = Mock({'__contains__': False})
conn = self._getConnection() conn = self._getConnection()
tid = self.getNextTID() tid = self.getNextTID()
handler = self.operation handler = self.operation
self.assertRaises(ProtocolError, handler.lockInformation, conn, tid) self.assertRaises(ProtocolError, handler.askLockInformation, conn, tid)
def test_lockInformation2(self): def test_askLockInformation2(self):
""" Lock transaction """ """ Lock transaction """
self.app.tm = Mock({'__contains__': True}) self.app.tm = Mock({'__contains__': True})
conn = self._getConnection() conn = self._getConnection()
tid = self.getNextTID() tid = self.getNextTID()
self.operation.lockInformation(conn, tid) self.operation.askLockInformation(conn, tid)
calls = self.app.tm.mockGetNamedCalls('lock') calls = self.app.tm.mockGetNamedCalls('lock')
self.assertEqual(len(calls), 1) self.assertEqual(len(calls), 1)
calls[0].checkArgs(tid) calls[0].checkArgs(tid)
......
...@@ -438,7 +438,7 @@ class StorageMySQSLdbTests(NeoTestBase): ...@@ -438,7 +438,7 @@ class StorageMySQSLdbTests(NeoTestBase):
result = self.db.query('select * from ttrans') result = self.db.query('select * from ttrans')
self.assertEquals(len(result), 0) self.assertEquals(len(result), 0)
def test_25_finishTransaction(self): def test_25_askFinishTransaction(self):
# data set # data set
tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02' tid1, tid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02' oid1, oid2 = '\x00' * 7 + '\x01', '\x00' * 7 + '\x02'
......
...@@ -272,14 +272,14 @@ class ProtocolTests(NeoTestBase): ...@@ -272,14 +272,14 @@ class ProtocolTests(NeoTestBase):
p_oid_list = p.decode()[0] p_oid_list = p.decode()[0]
self.assertEqual(p_oid_list, oid_list) self.assertEqual(p_oid_list, oid_list)
def test_36_finishTransaction(self): def test_36_askFinishTransaction(self):
oid1 = self.getNextTID() oid1 = self.getNextTID()
oid2 = self.getNextTID() oid2 = self.getNextTID()
oid3 = self.getNextTID() oid3 = self.getNextTID()
oid4 = self.getNextTID() oid4 = self.getNextTID()
tid = self.getNextTID() tid = self.getNextTID()
oid_list = [oid1, oid2, oid3, oid4] oid_list = [oid1, oid2, oid3, oid4]
p = Packets.FinishTransaction(oid_list, tid) p = Packets.AskFinishTransaction(oid_list, tid)
p_oid_list, ptid = p.decode() p_oid_list, ptid = p.decode()
self.assertEqual(ptid, tid) self.assertEqual(ptid, tid)
self.assertEqual(p_oid_list, oid_list) self.assertEqual(p_oid_list, oid_list)
...@@ -290,9 +290,9 @@ class ProtocolTests(NeoTestBase): ...@@ -290,9 +290,9 @@ class ProtocolTests(NeoTestBase):
ptid = p.decode()[0] ptid = p.decode()[0]
self.assertEqual(ptid, tid) self.assertEqual(ptid, tid)
def test_38_lockInformation(self): def test_38_askLockInformation(self):
tid = self.getNextTID() tid = self.getNextTID()
p = Packets.LockInformation(tid) p = Packets.AskLockInformation(tid)
ptid = p.decode()[0] ptid = p.decode()[0]
self.assertEqual(ptid, tid) self.assertEqual(ptid, tid)
......
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