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,9 +248,6 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -248,9 +248,6 @@ class ElectionEventHandler(MasterEventHandler):
raise ElectionFailure, 'reelection requested' raise ElectionFailure, 'reelection requested'
def handleNotifyNodeInformation(self, conn, packet, node_list): def handleNotifyNodeInformation(self, conn, packet, node_list):
if isinstance(conn, ClientConnection):
self.handleUnexpectedPacket(conn, packet)
else:
uuid = conn.getUUID() uuid = conn.getUUID()
if uuid is None: if uuid is None:
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
......
...@@ -46,6 +46,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -46,6 +46,7 @@ class ServiceEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid) node = app.nm.getNodeByUUID(uuid)
if node.getState() == RUNNING_STATE: if node.getState() == RUNNING_STATE:
node.setState(TEMPORARILY_DOWN_STATE) node.setState(TEMPORARILY_DOWN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
if isinstance(node, ClientNode): if isinstance(node, ClientNode):
# If this node is a client, just forget it. # If this node is a client, just forget it.
...@@ -63,6 +64,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -63,6 +64,7 @@ class ServiceEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid) node = app.nm.getNodeByUUID(uuid)
if node.getState() == RUNNING_STATE: if node.getState() == RUNNING_STATE:
node.setState(TEMPORARILY_DOWN_STATE) node.setState(TEMPORARILY_DOWN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
if isinstance(node, ClientNode): if isinstance(node, ClientNode):
# If this node is a client, just forget it. # If this node is a client, just forget it.
...@@ -80,6 +82,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -80,6 +82,7 @@ class ServiceEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid) node = app.nm.getNodeByUUID(uuid)
if node.getState() != BROKEN_STATE: if node.getState() != BROKEN_STATE:
node.setState(BROKEN_STATE) node.setState(BROKEN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
if isinstance(node, ClientNode): if isinstance(node, ClientNode):
# If this node is a client, just forget it. # If this node is a client, just forget it.
...@@ -129,6 +132,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -129,6 +132,7 @@ class ServiceEventHandler(MasterEventHandler):
else: else:
node = StorageNode(server = addr, uuid = uuid) node = StorageNode(server = addr, uuid = uuid)
app.nm.add(node) app.nm.add(node)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
else: else:
# Otherwise, I know it only by the server address or the same server # Otherwise, I know it only by the server address or the same server
...@@ -146,6 +150,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -146,6 +150,7 @@ class ServiceEventHandler(MasterEventHandler):
node.setUUID(uuid) node.setUUID(uuid)
if node.getState() != RUNNING_STATE: if node.getState() != RUNNING_STATE:
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
else: else:
# This node has a different UUID. # This node has a different UUID.
...@@ -158,10 +163,12 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -158,10 +163,12 @@ class ServiceEventHandler(MasterEventHandler):
else: else:
# Otherwise, forget the old one. # Otherwise, forget the old one.
node.setState(BROKEN_STATE) node.setState(BROKEN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
# And insert a new one. # And insert a new one.
node.setUUID(uuid) node.setUUID(uuid)
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
else: else:
# I know this node by the UUID. # I know this node by the UUID.
...@@ -176,10 +183,12 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -176,10 +183,12 @@ class ServiceEventHandler(MasterEventHandler):
else: else:
# Otherwise, forget the old one. # Otherwise, forget the old one.
node.setState(BROKEN_STATE) node.setState(BROKEN_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
# And insert a new one. # And insert a new one.
node.setServer(addr) node.setServer(addr)
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
else: else:
# If this node is broken, reject it. Otherwise, assume that it is # If this node is broken, reject it. Otherwise, assume that it is
...@@ -193,6 +202,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -193,6 +202,7 @@ class ServiceEventHandler(MasterEventHandler):
else: else:
node.setUUID(uuid) node.setUUID(uuid)
node.setState(RUNNING_STATE) node.setState(RUNNING_STATE)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
conn.setUUID(uuid) conn.setUUID(uuid)
...@@ -229,6 +239,8 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -229,6 +239,8 @@ class ServiceEventHandler(MasterEventHandler):
conn.addPacket(p) conn.addPacket(p)
# Send the information. # Send the information.
logging.debug('sending notify node information to %s:%d',
*(conn.getAddress()))
node_list = [] node_list = []
for n in app.nm.getNodeList(): for n in app.nm.getNodeList():
try: try:
...@@ -331,6 +343,7 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -331,6 +343,7 @@ class ServiceEventHandler(MasterEventHandler):
if c.getUUID() == uuid: if c.getUUID() == uuid:
c.close() c.close()
node.setState(state) node.setState(state)
logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
if isinstance(node, StorageNode) and state in (DOWN_STATE, BROKEN_STATE): 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