Commit 0a9f2548 authored by Aurel's avatar Aurel

handle administrator node


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@532 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 9d941fb5
...@@ -192,20 +192,21 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -192,20 +192,21 @@ class ServiceEventHandler(MasterEventHandler):
# This node has a different UUID. # This node has a different UUID.
if node.getState() == RUNNING_STATE: if node.getState() == RUNNING_STATE:
# If it is still running, reject this node. # If it is still running, reject this node.
raise protocol.ProtocolError('invalid server address') raise protocol.ProtocolError('invalid uuid')
# Otherwise, forget the old one. else:
node.setState(DOWN_STATE) # Otherwise, forget the old one.
logging.debug('broadcasting node information') node.setState(DOWN_STATE)
app.broadcastNodeInformation(node) logging.debug('broadcasting node information')
app.nm.remove(node) app.broadcastNodeInformation(node)
old_node = node app.nm.remove(node)
node = copy(node) old_node = node
# And insert a new one. node = copy(node)
node.setUUID(uuid) # And insert a new one.
node.setState(RUNNING_STATE) node.setUUID(uuid)
logging.debug('broadcasting node information') node.setState(RUNNING_STATE)
app.broadcastNodeInformation(node) logging.debug('broadcasting node information')
app.nm.add(node) app.broadcastNodeInformation(node)
app.nm.add(node)
else: else:
# I know this node by the UUID. # I know this node by the UUID.
try: try:
...@@ -235,10 +236,11 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -235,10 +236,11 @@ class ServiceEventHandler(MasterEventHandler):
# it is working again. # it is working again.
if node.getState() == BROKEN_STATE: if node.getState() == BROKEN_STATE:
raise protocol.BrokenNodeDisallowedError raise protocol.BrokenNodeDisallowedError
node.setUUID(uuid) else:
node.setState(RUNNING_STATE) node.setUUID(uuid)
logging.debug('broadcasting node information') node.setState(RUNNING_STATE)
app.broadcastNodeInformation(node) logging.info('broadcasting node information as running')
app.broadcastNodeInformation(node)
conn.setUUID(uuid) conn.setUUID(uuid)
...@@ -299,6 +301,10 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -299,6 +301,10 @@ class ServiceEventHandler(MasterEventHandler):
@identification_required @identification_required
def handleNotifyNodeInformation(self, conn, packet, node_list): def handleNotifyNodeInformation(self, conn, packet, node_list):
app = self.app app = self.app
conn_node = app.nm.getNodeByUUID(uuid)
if conn_node is None:
raise RuntimeError('I do not know the uuid %r' % dump(uuid))
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
if node_type in (CLIENT_NODE_TYPE, ADMIN_NODE_TYPE): if node_type in (CLIENT_NODE_TYPE, ADMIN_NODE_TYPE):
# No interest. # No interest.
...@@ -342,10 +348,17 @@ class ServiceEventHandler(MasterEventHandler): ...@@ -342,10 +348,17 @@ class ServiceEventHandler(MasterEventHandler):
# Something wrong happened possibly. Cut the connection to # Something wrong happened possibly. Cut the connection to
# this node, if any, and notify the information to others. # this node, if any, and notify the information to others.
# XXX this can be very slow. # XXX this can be very slow.
for c in app.em.getConnectionList():
if c.getUUID() == uuid:
c.close()
node.setState(state) node.setState(state)
if conn_node.getNodeType() == ADMIN_NODE_TYPE:
# reply to it
ip, port = node.getServer()
node_list = [(node.getNodeType(), ip, port, node.getUUID(), node.getState()),]
conn.answer(protocol.notifyNodeInformation(node_list), packet)
else:
for c in app.em.getConnectionList():
if c.getUUID() == uuid:
c.close()
logging.debug('broadcasting node information') logging.debug('broadcasting node information')
app.broadcastNodeInformation(node) app.broadcastNodeInformation(node)
......
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