Commit 1742c007 authored by Aurel's avatar Aurel

add handler for notify node information message so that they can be

ignored if we are stopping all storage and master nodes


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@676 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 1b261542
......@@ -18,6 +18,7 @@
import logging
from neo import protocol
from neo.master.service import ServiceEventHandler
from neo.protocol import BOOTING
class ShutdownEventHandler(ServiceEventHandler):
"""This class deals with events for a shutting down phase."""
......@@ -39,3 +40,78 @@ class ShutdownEventHandler(ServiceEventHandler):
logging.error('reject any new demand for new tid')
raise protocol.ProtocolError('cluster is shutting down')
@decorators.identification_required
def handleNotifyNodeInformation(self, conn, packet, node_list):
app = self.app
uuid = conn.getUUID()
conn_node = app.nm.getNodeByUUID(uuid)
if conn_node is None:
raise RuntimeError('I do not know the uuid %r' % dump(uuid))
if app.cluster_state == STOPPING and len(app.finishing_transaction_dict) == 0:
# do not care about these messages as we are shutting down all nodes
return
for node_type, ip_address, port, uuid, state in node_list:
if node_type in (CLIENT_NODE_TYPE, ADMIN_NODE_TYPE):
# No interest.
continue
if uuid == INVALID_UUID:
# No interest.
continue
if app.uuid == uuid:
# This looks like me...
if state == RUNNING_STATE:
# Yes, I know it.
continue
else:
# What?! What happened to me?
raise RuntimeError, 'I was told that I am bad'
addr = (ip_address, port)
node = app.nm.getNodeByUUID(uuid)
if node is None:
node = app.nm.getNodeByServer(addr)
if node is None:
# I really don't know such a node. What is this?
continue
else:
if node.getServer() != addr:
# This is different from what I know.
continue
if node.getState() == state:
# No change. Don't care.
continue
if state == node.getState():
# No problem.
continue
node.setState(state)
# Something wrong happened possibly. Cut the connection to
# this node, if any, and notify the information to others.
# XXX this can be very slow.
# XXX does this need to be closed in all cases ?
for c in app.em.getConnectionList():
if c.getUUID() == uuid:
c.close()
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node)
if node.getNodeType() == STORAGE_NODE_TYPE:
if state in (DOWN_STATE, BROKEN_STATE):
# XXX still required to change here ??? who can send
# this kind of message with these status except admin node
cell_list = app.pt.dropNode(node)
if len(cell_list) != 0:
ptid = app.pt.setNextID()
app.broadcastPartitionChanges(ptid, cell_list)
elif state == TEMPORARILY_DOWN_STATE:
cell_list = app.pt.outdate()
if len(cell_list) != 0:
ptid = app.pt.setNextID()
app.broadcastPartitionChanges(ptid, cell_list)
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