Commit e31442dc authored by Grégory Wisniewski's avatar Grégory Wisniewski

Don't send client informations to client nodes.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2126 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7d984ac8
......@@ -299,11 +299,13 @@ class Application(object):
" 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:
......
......@@ -38,6 +38,12 @@ class ClientServiceHandler(MasterHandler):
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:
self.app.tm.remove(tid)
......
......@@ -144,6 +144,18 @@ class MasterClientHandlerTests(NeoTestBase):
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,
......
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