Commit de2dfaa0 authored by Aurel's avatar Aurel

make sure to have a connection to the node before changing it state

only send START_OPERATION message is master is in RUNNING state


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@705 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 3cd85a3d
...@@ -20,7 +20,7 @@ import logging ...@@ -20,7 +20,7 @@ import logging
from neo import protocol from neo import protocol
from neo.master.handler import MasterEventHandler from neo.master.handler import MasterEventHandler
from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \ from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \
STORAGE_NODE_TYPE, HIDDEN_STATE, PENDING_STATE STORAGE_NODE_TYPE, HIDDEN_STATE, PENDING_STATE, RUNNING
from neo.util import dump from neo.util import dump
class AdministrationEventHandler(MasterEventHandler): class AdministrationEventHandler(MasterEventHandler):
...@@ -86,18 +86,30 @@ class AdministrationEventHandler(MasterEventHandler): ...@@ -86,18 +86,30 @@ class AdministrationEventHandler(MasterEventHandler):
p = protocol.noError('node state changed') p = protocol.noError('node state changed')
conn.answer(p, packet) conn.answer(p, packet)
# forward information to all nodes # Change node state
if node.getState() != state: if node.getState() != state:
# first make sure to have a connection to the node
node_conn = None
conn_found = False
for node_conn in app.em.getConnectionList():
if node_conn.getUUID() == node.getUUID():
conn_found = True
break
if conn_found is False:
# no connection to the node
p = protocol.protocolError('no connection to the node')
conn.notify(p)
return
node.setState(state) node.setState(state)
p = protocol.noError('state changed') p = protocol.noError('state changed')
conn.answer(p, packet) conn.answer(p, packet)
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
# If this is a storage node, ask it to start. # If this is a storage node, ask it to start.
if node.getNodeType() == STORAGE_NODE_TYPE and state == RUNNING_STATE: if node.getNodeType() == STORAGE_NODE_TYPE and state == RUNNING_STATE \
for sn_conn in app.em.getConnectionList(): and self.app.cluster_state == RUNNING:
if sn_conn.getUUID() == node.getUUID():
logging.info("asking sn to start operation") logging.info("asking sn to start operation")
sn_conn.notify(protocol.startOperation()) node_conn.notify(protocol.startOperation())
# modify the partition table if required # modify the partition table if required
if modify_partition_table and node.getNodeType() == STORAGE_NODE_TYPE: if modify_partition_table and node.getNodeType() == STORAGE_NODE_TYPE:
......
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