[Neo-report] r2130 gregory - in /trunk/neo/master: ./ handlers/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jun 4 15:45:03 CEST 2010


Author: gregory
Date: Fri Jun  4 15:45:03 2010
New Revision: 2130

Log:
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)

Modified:
    trunk/neo/master/app.py
    trunk/neo/master/handlers/__init__.py
    trunk/neo/master/handlers/client.py

Modified: trunk/neo/master/app.py
==============================================================================
--- trunk/neo/master/app.py [iso-8859-1] (original)
+++ trunk/neo/master/app.py [iso-8859-1] Fri Jun  4 15:45:03 2010
@@ -298,21 +298,6 @@
     def outdateAndBroadcastPartition(self):
         " 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))

Modified: trunk/neo/master/handlers/__init__.py
==============================================================================
--- trunk/neo/master/handlers/__init__.py [iso-8859-1] (original)
+++ trunk/neo/master/handlers/__init__.py [iso-8859-1] Fri Jun  4 15:45:03 2010
@@ -59,7 +59,12 @@
         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):

Modified: trunk/neo/master/handlers/client.py
==============================================================================
--- trunk/neo/master/handlers/client.py [iso-8859-1] (original)
+++ trunk/neo/master/handlers/client.py [iso-8859-1] Fri Jun  4 15:45:03 2010
@@ -40,8 +40,11 @@
 
     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):





More information about the Neo-report mailing list