Commit 764b9815 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Factorise cell_list length checking before broadcast changes.

Now the broadcastPartitionChanges() method check itself the cell_list content.
- If empty, it does nothing.
- If not empty, it generate itself the next PTID and broadcast the changes.

Remove the related XXX.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1447 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f20e2962
......@@ -292,10 +292,12 @@ class Application(object):
elif not node.isAdmin():
raise RuntimeError('unknown node type')
def broadcastPartitionChanges(self, ptid, cell_list):
def broadcastPartitionChanges(self, cell_list):
"""Broadcast a Notify Partition Changes packet."""
# XXX: don't send if cell_list is empty, to have an unique check
logging.debug('broadcastPartitionChanges')
if not cell_list:
return
ptid = self.pt.setNextID()
self.pt.log()
for c in self.em.getConnectionList():
n = self.nm.getByUUID(c.getUUID())
......@@ -315,9 +317,7 @@ class Application(object):
def outdateAndBroadcastPartition(self):
" Outdate cell of non-working nodes and broadcast changes """
cell_list = self.pt.outdate()
if cell_list:
self.broadcastPartitionChanges(self.pt.setNextID(), cell_list)
self.broadcastPartitionChanges(self.pt.outdate())
def sendPartitionTable(self, conn):
""" Send the partition table through the given connection """
......@@ -535,8 +535,7 @@ class Application(object):
cell_list.extend(self.pt.tweak())
# If anything changed, send the changes.
if cell_list:
self.broadcastPartitionChanges(self.pt.setNextID(), cell_list)
self.broadcastPartitionChanges(cell_list)
def provideService(self):
"""
......
......@@ -83,9 +83,7 @@ class AdministrationHandler(MasterHandler):
else:
# outdate node in partition table
cell_list = app.pt.outdate()
if len(cell_list) != 0:
ptid = app.pt.setNextID()
app.broadcastPartitionChanges(ptid, cell_list)
app.broadcastPartitionChanges(cell_list)
# /!\ send the node information *after* the partition table change
node.setState(state)
......@@ -127,6 +125,6 @@ class AdministrationHandler(MasterHandler):
s_conn.notify(Packets.NotifyLastOID(app.loid))
s_conn.notify(Packets.StartOperation())
# broadcast the new partition table
app.broadcastPartitionChanges(app.pt.setNextID(), cell_list)
app.broadcastPartitionChanges(cell_list)
p = protocol.noError('node added')
conn.answer(p, packet.getId())
......@@ -136,8 +136,6 @@ class StorageServiceHandler(BaseServiceHandler):
CellStates.DISCARDED))
break
if new_cell_list:
ptid = app.pt.setNextID()
app.broadcastPartitionChanges(ptid, new_cell_list)
app.broadcastPartitionChanges(new_cell_list)
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