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):
# Call finish on master
oid_list = self.local_var.data_dict.keys()
p = Packets.AskFinishTransaction(oid_list, tid)
p = Packets.AskFinishTransaction(tid, oid_list)
self._askPrimary(p)
if not self.isTransactionFinished():
......
......@@ -115,7 +115,7 @@ class PrimaryNotificationsHandler(BaseHandler):
def stopOperation(self, conn):
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._cache_lock_acquire()
try:
......
......@@ -211,7 +211,7 @@ class EventHandler(object):
def answerNewOIDs(self, conn, num_oids):
raise UnexpectedPacketError
def askFinishTransaction(self, conn, oid_list, tid):
def askFinishTransaction(self, conn, tid, oid_list):
raise UnexpectedPacketError
def answerTransactionFinished(self, conn, tid):
......@@ -223,7 +223,7 @@ class EventHandler(object):
def answerInformationLocked(self, conn, tid):
raise UnexpectedPacketError
def invalidateObjects(self, conn, oid_list, tid):
def invalidateObjects(self, conn, tid, oid_list):
raise UnexpectedPacketError
def notifyUnlockInformation(self, conn, tid):
......
......@@ -53,7 +53,7 @@ class ClientServiceHandler(MasterHandler):
oid_list = self.app.getNewOIDList(num_oids)
conn.answer(Packets.AnswerNewOIDs(oid_list))
def askFinishTransaction(self, conn, oid_list, tid):
def askFinishTransaction(self, conn, tid, oid_list):
app = self.app
# If the given transaction ID is later than the last TID, the peer
# is crazy.
......
......@@ -71,7 +71,7 @@ class StorageServiceHandler(BaseServiceHandler):
# - Invalidate Objects to the other client nodes
nm = app.nm
transaction_node = t.getNode()
invalidate_objects = Packets.InvalidateObjects(t.getOIDList(), tid)
invalidate_objects = Packets.InvalidateObjects(tid, t.getOIDList())
answer_transaction_finished = Packets.AnswerTransactionFinished(tid)
for client_node in nm.getClientList(only_identified=True):
c = client_node.getConnection()
......
......@@ -750,7 +750,7 @@ class AskFinishTransaction(Packet):
_list_entry_format = '8s'
_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.extend(oid_list)
return ''.join(body)
......@@ -766,7 +766,7 @@ class AskFinishTransaction(Packet):
oid = unpack(list_entry_format, body[offset:next_offset])[0]
offset = next_offset
oid_list.append(oid)
return (oid_list, tid)
return (tid, oid_list)
class AnswerTransactionFinished(Packet):
"""
......@@ -809,7 +809,7 @@ class InvalidateObjects(Packet):
_list_entry_format = '8s'
_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.extend(oid_list)
return ''.join(body)
......@@ -825,7 +825,7 @@ class InvalidateObjects(Packet):
oid = unpack(list_entry_format, body[offset:next_offset])[0]
offset = next_offset
oid_list.append(oid)
return (oid_list, tid)
return (tid, oid_list)
class NotifyUnlockInformation(Packet):
"""
......
......@@ -151,7 +151,7 @@ class MasterNotificationsHandlerTests(MasterHandlerTests):
oid1: tid,
oid2: tid,
}
self.handler.invalidateObjects(conn, [oid1], tid)
self.handler.invalidateObjects(conn, tid, [oid1])
self.assertFalse(oid1 in self.app.mq_cache)
self.assertTrue(oid2 in self.app.mq_cache)
invalidation_calls = self.db.mockGetNamedCalls('invalidate')
......
......@@ -96,7 +96,8 @@ class MasterClientHandlerTests(NeoTestBase):
oid_list = []
upper, lower = unpack('!LL', self.app.tm.getLastTID())
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)
self.app.nm.remove(old_node)
self.app.pt.dropNode(old_node)
......@@ -116,7 +117,7 @@ class MasterClientHandlerTests(NeoTestBase):
tid = self.app.tm.getLastTID()
conn = self.getFakeConnection(client_uuid, self.client_address)
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.assertEquals(len(self.app.tm.getPendingList()), 1)
apptid = self.app.tm.getPendingList()[0]
......
......@@ -278,9 +278,9 @@ class ProtocolTests(NeoTestBase):
oid4 = self.getNextTID()
tid = self.getNextTID()
oid_list = [oid1, oid2, oid3, oid4]
p = Packets.AskFinishTransaction(oid_list, tid)
p_oid_list, ptid = p.decode()
self.assertEqual(ptid, tid)
p = Packets.AskFinishTransaction(tid, oid_list)
p_tid, p_oid_list = p.decode()
self.assertEqual(p_tid, tid)
self.assertEqual(p_oid_list, oid_list)
def test_37_answerTransactionFinished(self):
......@@ -308,9 +308,9 @@ class ProtocolTests(NeoTestBase):
oid4 = self.getNextTID()
tid = self.getNextTID()
oid_list = [oid1, oid2, oid3, oid4]
p = Packets.InvalidateObjects(oid_list, tid)
p_oid_list, ptid = p.decode()
self.assertEqual(ptid, tid)
p = Packets.InvalidateObjects(tid, oid_list)
p_tid, p_oid_list = p.decode()
self.assertEqual(p_tid, tid)
self.assertEqual(p_oid_list, oid_list)
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