Commit e497e98e authored by Yoshinori Okuji's avatar Yoshinori Okuji

Accept Notify Node Information from ClientConnection as well, because it might...

Accept Notify Node Information from ClientConnection as well, because it might be to a primary master node.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@135 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 1ff2f9fe
......@@ -248,34 +248,31 @@ class ElectionEventHandler(MasterEventHandler):
raise ElectionFailure, 'reelection requested'
def handleNotifyNodeInformation(self, conn, packet, node_list):
if isinstance(conn, ClientConnection):
uuid = conn.getUUID()
if uuid is None:
self.handleUnexpectedPacket(conn, packet)
else:
uuid = conn.getUUID()
if uuid is None:
self.handleUnexpectedPacket(conn, packet)
return
return
app = self.app
for node_type, ip_address, port, uuid, state in node_list:
if node_type != MASTER_NODE_TYPE:
# No interest.
continue
# Register new master nodes.
addr = (ip_address, port)
if app.server == addr:
# This is self.
continue
else:
n = app.nm.getNodeByServer(addr)
if n is None:
n = MasterNode(server = addr)
app.nm.add(n)
app.unconnected_master_node_set.add(addr)
app = self.app
for node_type, ip_address, port, uuid, state in node_list:
if node_type != MASTER_NODE_TYPE:
# No interest.
continue
if uuid != INVALID_UUID:
# If I don't know the UUID yet, believe what the peer
# told me at the moment.
if n.getUUID() is None:
n.setUUID(uuid)
# Register new master nodes.
addr = (ip_address, port)
if app.server == addr:
# This is self.
continue
else:
n = app.nm.getNodeByServer(addr)
if n is None:
n = MasterNode(server = addr)
app.nm.add(n)
app.unconnected_master_node_set.add(addr)
if uuid != INVALID_UUID:
# If I don't know the UUID yet, believe what the peer
# told me at the moment.
if n.getUUID() is None:
n.setUUID(uuid)
......@@ -46,6 +46,7 @@ class ServiceEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid)
if node.getState() == RUNNING_STATE:
node.setState(TEMPORARILY_DOWN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
if isinstance(node, ClientNode):
# If this node is a client, just forget it.
......@@ -63,6 +64,7 @@ class ServiceEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid)
if node.getState() == RUNNING_STATE:
node.setState(TEMPORARILY_DOWN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
if isinstance(node, ClientNode):
# If this node is a client, just forget it.
......@@ -80,6 +82,7 @@ class ServiceEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid)
if node.getState() != BROKEN_STATE:
node.setState(BROKEN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
if isinstance(node, ClientNode):
# If this node is a client, just forget it.
......@@ -129,6 +132,7 @@ class ServiceEventHandler(MasterEventHandler):
else:
node = StorageNode(server = addr, uuid = uuid)
app.nm.add(node)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
else:
# Otherwise, I know it only by the server address or the same server
......@@ -146,6 +150,7 @@ class ServiceEventHandler(MasterEventHandler):
node.setUUID(uuid)
if node.getState() != RUNNING_STATE:
node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
else:
# This node has a different UUID.
......@@ -158,10 +163,12 @@ class ServiceEventHandler(MasterEventHandler):
else:
# Otherwise, forget the old one.
node.setState(BROKEN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
# And insert a new one.
node.setUUID(uuid)
node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
else:
# I know this node by the UUID.
......@@ -176,10 +183,12 @@ class ServiceEventHandler(MasterEventHandler):
else:
# Otherwise, forget the old one.
node.setState(BROKEN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
# And insert a new one.
node.setServer(addr)
node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
else:
# If this node is broken, reject it. Otherwise, assume that it is
......@@ -193,6 +202,7 @@ class ServiceEventHandler(MasterEventHandler):
else:
node.setUUID(uuid)
node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
conn.setUUID(uuid)
......@@ -229,6 +239,8 @@ class ServiceEventHandler(MasterEventHandler):
conn.addPacket(p)
# Send the information.
logging.debug('sending notify node information to %s:%d',
*(conn.getAddress()))
node_list = []
for n in app.nm.getNodeList():
try:
......@@ -331,6 +343,7 @@ class ServiceEventHandler(MasterEventHandler):
if c.getUUID() == uuid:
c.close()
node.setState(state)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
if isinstance(node, StorageNode) and state in (DOWN_STATE, BROKEN_STATE):
......
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