[Neo-report] r2126 gregory - in /trunk/neo: master/ master/handlers/ tests/master/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jun 4 10:39:36 CEST 2010


Author: gregory
Date: Fri Jun  4 10:39:35 2010
New Revision: 2126

Log:
Don't send client informations to client nodes.

Modified:
    trunk/neo/master/app.py
    trunk/neo/master/handlers/client.py
    trunk/neo/tests/master/testClientHandler.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 10:39:35 2010
@@ -299,11 +299,13 @@
         " Outdate cell of non-working nodes and broadcast changes """
         self.broadcastPartitionChanges(self.pt.outdate())
 
-    def sendNodesInformations(self, conn):
+    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 not n.isAdmin():
+            if selector(n):
                 node_list.append(n.asTuple())
                 # Split the packet if too huge.
                 if len(node_list) == 10000:

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 10:39:35 2010
@@ -37,6 +37,12 @@
         node.setState(NodeStates.DOWN)
         app.broadcastNodesInformation([node])
         app.nm.remove(node)
+
+    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)
+        conn.answer(Packets.AnswerNodeInformation())
 
     def abortTransaction(self, conn, tid):
         if tid in self.app.tm:

Modified: trunk/neo/tests/master/testClientHandler.py
==============================================================================
--- trunk/neo/tests/master/testClientHandler.py [iso-8859-1] (original)
+++ trunk/neo/tests/master/testClientHandler.py [iso-8859-1] Fri Jun  4 10:39:35 2010
@@ -144,6 +144,18 @@
         service.abortTransaction(conn, tid)
         self.assertFalse(self.app.tm.hasPending())
 
+    def test_askNodeInformations(self):
+        # check that only informations about master and storages nodes are
+        # send to a client
+        self.app.nm.createClient()
+        conn = self.getFakeConnection()
+        self.service.askNodeInformation(conn)
+        calls = conn.mockGetNamedCalls('notify')
+        self.assertEqual(len(calls), 1)
+        packet = calls[0].getParam(0)
+        (node_list, ) = packet.decode()
+        self.assertEqual(len(node_list), 2)
+
     def __testWithMethod(self, method, state):
         # give a client uuid which have unfinished transactions
         client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT,





More information about the Neo-report mailing list