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