Commit 0ea22929 authored by Aurel's avatar Aurel

lock connection, and don't expect message when notifying node

information to primary master node


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@169 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent fc3c5e87
...@@ -84,15 +84,16 @@ class ClientEventHandler(EventHandler): ...@@ -84,15 +84,16 @@ class ClientEventHandler(EventHandler):
if isinstance(node, StorageNode): if isinstance(node, StorageNode):
# Notify primary master node that a storage node is temporarily down # Notify primary master node that a storage node is temporarily down
conn = app.master_conn conn = app.master_conn
msg_id = conn.getNextId() conn.lock()
p = Packet() try:
ip_address, port = node.getServer() p = Packet()
node_list = [(STORAGE_NODE_TYPE, ip_address, port, node.getUUID(), ip_address, port = node.getServer()
TEMPORARILY_DOWN_STATE),] node_list = [(STORAGE_NODE_TYPE, ip_address, port, node.getUUID(),
p.notifyNodeInformation(msg_id, node_list) TEMPORARILY_DOWN_STATE),]
conn.addPacket(p) p.notifyNodeInformation(msg_id, node_list)
conn.expectMessage(msg_id) conn.addPacket(p)
self.dispatcher.register(conn, msg_id, app.getQueue()) finally:
conn.unlock()
# Remove from pool connection # Remove from pool connection
app.cp.removeConnection(node) app.cp.removeConnection(node)
EventHandler.connectionClosed(self, conn) EventHandler.connectionClosed(self, conn)
...@@ -110,15 +111,16 @@ class ClientEventHandler(EventHandler): ...@@ -110,15 +111,16 @@ class ClientEventHandler(EventHandler):
if isinstance(node, StorageNode): if isinstance(node, StorageNode):
# Notify primary master node that a storage node is temporarily down # Notify primary master node that a storage node is temporarily down
conn = app.master_conn conn = app.master_conn
msg_id = conn.getNextId() conn.lock()
p = Packet() try:
ip_address, port = node.getServer() p = Packet()
node_list = [(STORAGE_NODE_TYPE, ip_address, port, node.getUUID(), ip_address, port = node.getServer()
TEMPORARILY_DOWN_STATE),] node_list = [(STORAGE_NODE_TYPE, ip_address, port, node.getUUID(),
p.notifyNodeInformation(msg_id, node_list) TEMPORARILY_DOWN_STATE),]
conn.addPacket(p) p.notifyNodeInformation(msg_id, node_list)
conn.expectMessage(msg_id) conn.addPacket(p)
self.dispatcher.register(conn, msg_id, app.getQueue()) finally:
conn.unlock()
# Remove from pool connection # Remove from pool connection
app.cp.removeConnection(node) app.cp.removeConnection(node)
EventHandler.timeoutExpired(self, conn) EventHandler.timeoutExpired(self, conn)
...@@ -136,15 +138,16 @@ class ClientEventHandler(EventHandler): ...@@ -136,15 +138,16 @@ class ClientEventHandler(EventHandler):
if isinstance(node, StorageNode): if isinstance(node, StorageNode):
# Notify primary master node that a storage node is broken # Notify primary master node that a storage node is broken
conn = app.master_conn conn = app.master_conn
msg_id = conn.getNextId() conn.lock()
p = Packet() try:
ip_address, port = node.getServer() p = Packet()
node_list = [(STORAGE_NODE_TYPE, ip_address, port, node.getUUID(), ip_address, port = node.getServer()
BROKEN_STATE),] node_list = [(STORAGE_NODE_TYPE, ip_address, port, node.getUUID(),
p.notifyNodeInformation(msg_id, node_list) BROKEN_STATE),]
conn.addPacket(p) p.notifyNodeInformation(msg_id, node_list)
conn.expectMessage(msg_id) conn.addPacket(p)
self.dispatcher.register(conn, msg_id, app.getQueue()) finally:
conn.unlock()
# Remove from pool connection # Remove from pool connection
app.cp.removeConnection(node) app.cp.removeConnection(node)
EventHandler.peerBroken(self, conn) EventHandler.peerBroken(self, conn)
......
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