Commit 2dc8f28a authored by Grégory Wisniewski's avatar Grégory Wisniewski

Make packet arguments order consistent.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2101 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 395c6df8
...@@ -771,7 +771,7 @@ class Application(object): ...@@ -771,7 +771,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.AskFinishTransaction(oid_list, tid) p = Packets.AskFinishTransaction(tid, oid_list)
self._askPrimary(p) self._askPrimary(p)
if not self.isTransactionFinished(): if not self.isTransactionFinished():
......
...@@ -115,7 +115,7 @@ class PrimaryNotificationsHandler(BaseHandler): ...@@ -115,7 +115,7 @@ class PrimaryNotificationsHandler(BaseHandler):
def stopOperation(self, conn): def stopOperation(self, conn):
logging.critical("master node ask to stop operation") logging.critical("master node ask to stop operation")
def invalidateObjects(self, conn, oid_list, tid): def invalidateObjects(self, conn, tid, oid_list):
app = self.app app = self.app
app._cache_lock_acquire() app._cache_lock_acquire()
try: try:
......
...@@ -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, oid_list, tid): def askFinishTransaction(self, conn, tid, oid_list):
raise UnexpectedPacketError raise UnexpectedPacketError
def answerTransactionFinished(self, conn, tid): def answerTransactionFinished(self, conn, tid):
...@@ -223,7 +223,7 @@ class EventHandler(object): ...@@ -223,7 +223,7 @@ class EventHandler(object):
def answerInformationLocked(self, conn, tid): def answerInformationLocked(self, conn, tid):
raise UnexpectedPacketError raise UnexpectedPacketError
def invalidateObjects(self, conn, oid_list, tid): def invalidateObjects(self, conn, tid, oid_list):
raise UnexpectedPacketError raise UnexpectedPacketError
def notifyUnlockInformation(self, conn, tid): def notifyUnlockInformation(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 askFinishTransaction(self, conn, oid_list, tid): def askFinishTransaction(self, conn, tid, oid_list):
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.
......
...@@ -71,7 +71,7 @@ class StorageServiceHandler(BaseServiceHandler): ...@@ -71,7 +71,7 @@ class StorageServiceHandler(BaseServiceHandler):
# - Invalidate Objects to the other client nodes # - Invalidate Objects to the other client nodes
nm = app.nm nm = app.nm
transaction_node = t.getNode() transaction_node = t.getNode()
invalidate_objects = Packets.InvalidateObjects(t.getOIDList(), tid) invalidate_objects = Packets.InvalidateObjects(tid, t.getOIDList())
answer_transaction_finished = Packets.AnswerTransactionFinished(tid) answer_transaction_finished = Packets.AnswerTransactionFinished(tid)
for client_node in nm.getClientList(only_identified=True): for client_node in nm.getClientList(only_identified=True):
c = client_node.getConnection() c = client_node.getConnection()
......
...@@ -750,7 +750,7 @@ class AskFinishTransaction(Packet): ...@@ -750,7 +750,7 @@ class AskFinishTransaction(Packet):
_list_entry_format = '8s' _list_entry_format = '8s'
_list_entry_len = calcsize(_list_entry_format) _list_entry_len = calcsize(_list_entry_format)
def _encode(self, oid_list, tid): def _encode(self, tid, oid_list):
body = [pack(self._header_format, tid, len(oid_list))] body = [pack(self._header_format, tid, len(oid_list))]
body.extend(oid_list) body.extend(oid_list)
return ''.join(body) return ''.join(body)
...@@ -766,7 +766,7 @@ class AskFinishTransaction(Packet): ...@@ -766,7 +766,7 @@ class AskFinishTransaction(Packet):
oid = unpack(list_entry_format, body[offset:next_offset])[0] oid = unpack(list_entry_format, body[offset:next_offset])[0]
offset = next_offset offset = next_offset
oid_list.append(oid) oid_list.append(oid)
return (oid_list, tid) return (tid, oid_list)
class AnswerTransactionFinished(Packet): class AnswerTransactionFinished(Packet):
""" """
...@@ -809,7 +809,7 @@ class InvalidateObjects(Packet): ...@@ -809,7 +809,7 @@ class InvalidateObjects(Packet):
_list_entry_format = '8s' _list_entry_format = '8s'
_list_entry_len = calcsize(_list_entry_format) _list_entry_len = calcsize(_list_entry_format)
def _encode(self, oid_list, tid): def _encode(self, tid, oid_list):
body = [pack(self._header_format, tid, len(oid_list))] body = [pack(self._header_format, tid, len(oid_list))]
body.extend(oid_list) body.extend(oid_list)
return ''.join(body) return ''.join(body)
...@@ -825,7 +825,7 @@ class InvalidateObjects(Packet): ...@@ -825,7 +825,7 @@ class InvalidateObjects(Packet):
oid = unpack(list_entry_format, body[offset:next_offset])[0] oid = unpack(list_entry_format, body[offset:next_offset])[0]
offset = next_offset offset = next_offset
oid_list.append(oid) oid_list.append(oid)
return (oid_list, tid) return (tid, oid_list)
class NotifyUnlockInformation(Packet): class NotifyUnlockInformation(Packet):
""" """
......
...@@ -151,7 +151,7 @@ class MasterNotificationsHandlerTests(MasterHandlerTests): ...@@ -151,7 +151,7 @@ class MasterNotificationsHandlerTests(MasterHandlerTests):
oid1: tid, oid1: tid,
oid2: tid, oid2: tid,
} }
self.handler.invalidateObjects(conn, [oid1], tid) self.handler.invalidateObjects(conn, tid, [oid1])
self.assertFalse(oid1 in self.app.mq_cache) self.assertFalse(oid1 in self.app.mq_cache)
self.assertTrue(oid2 in self.app.mq_cache) self.assertTrue(oid2 in self.app.mq_cache)
invalidation_calls = self.db.mockGetNamedCalls('invalidate') invalidation_calls = self.db.mockGetNamedCalls('invalidate')
......
...@@ -96,7 +96,8 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -96,7 +96,8 @@ 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.askFinishTransaction, conn, oid_list, new_tid) self.checkProtocolErrorRaised(service.askFinishTransaction, conn,
new_tid, oid_list)
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)
...@@ -116,7 +117,7 @@ class MasterClientHandlerTests(NeoTestBase): ...@@ -116,7 +117,7 @@ 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.nm.getByUUID(storage_uuid).setConnection(storage_conn) self.app.nm.getByUUID(storage_uuid).setConnection(storage_conn)
service.askFinishTransaction(conn, oid_list, tid) service.askFinishTransaction(conn, tid, oid_list)
self.checkAskLockInformation(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]
......
...@@ -278,9 +278,9 @@ class ProtocolTests(NeoTestBase): ...@@ -278,9 +278,9 @@ class ProtocolTests(NeoTestBase):
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.AskFinishTransaction(oid_list, tid) p = Packets.AskFinishTransaction(tid, oid_list)
p_oid_list, ptid = p.decode() p_tid, p_oid_list = p.decode()
self.assertEqual(ptid, tid) self.assertEqual(p_tid, tid)
self.assertEqual(p_oid_list, oid_list) self.assertEqual(p_oid_list, oid_list)
def test_37_answerTransactionFinished(self): def test_37_answerTransactionFinished(self):
...@@ -308,9 +308,9 @@ class ProtocolTests(NeoTestBase): ...@@ -308,9 +308,9 @@ class ProtocolTests(NeoTestBase):
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.InvalidateObjects(oid_list, tid) p = Packets.InvalidateObjects(tid, oid_list)
p_oid_list, ptid = p.decode() p_tid, p_oid_list = p.decode()
self.assertEqual(ptid, tid) self.assertEqual(p_tid, tid)
self.assertEqual(p_oid_list, oid_list) self.assertEqual(p_oid_list, oid_list)
def test_41_notifyUnlockInformation(self): def test_41_notifyUnlockInformation(self):
......
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