Commit 97e9b77c authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rework sendNodeInformations() method.

- Drop it from app
- Don't split packets as 10000 entries is beyond NEO expectations.
- Iterate over used nodes only (instead of filtering)

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2130 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 5d5a06c6
......@@ -299,21 +299,6 @@ class Application(object):
" Outdate cell of non-working nodes and broadcast changes """
self.broadcastPartitionChanges(self.pt.outdate())
def sendNodesInformations(self, conn, selector=None):
""" Send informations on all nodes through the given connection """
if selector is None:
selector = lambda node: not node.isAdmin()
node_list = []
for n in self.nm.getList():
if selector(n):
node_list.append(n.asTuple())
# Split the packet if too huge.
if len(node_list) == 10000:
conn.notify(Packets.NotifyNodeInformation(node_list))
del node_list[:]
if node_list:
conn.notify(Packets.NotifyNodeInformation(node_list))
def broadcastLastOID(self, oid):
logging.debug('Broadcast last OID to storages : %s' % dump(oid))
packet = Packets.NotifyLastOID(oid)
......
......@@ -59,7 +59,12 @@ class MasterHandler(EventHandler):
conn.answer(Packets.AnswerClusterState(state))
def askNodeInformation(self, conn):
self.app.sendNodesInformations(conn)
nm = self.app.nm
node_list = []
node_list.extend(n.asTuple() for n in nm.getMasterList())
node_list.extend(n.asTuple() for n in nm.getClientList())
node_list.extend(n.asTuple() for n in nm.getStorageList())
conn.notify(Packets.NotifyNodeInformation(node_list))
conn.answer(Packets.AnswerNodeInformation())
def askPartitionTable(self, conn):
......
......@@ -40,8 +40,11 @@ class ClientServiceHandler(MasterHandler):
def askNodeInformation(self, conn):
# send informations about master and storages only
selector = lambda node: node.isMaster() or node.isStorage()
self.app.sendNodesInformations(conn, selector=selector)
nm = self.app.nm
node_list = []
node_list.extend(n.asTuple() for n in nm.getMasterList())
node_list.extend(n.asTuple() for n in nm.getStorageList())
conn.notify(Packets.NotifyNodeInformation(node_list))
conn.answer(Packets.AnswerNodeInformation())
def abortTransaction(self, conn, 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