Commit 7aa40c49 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Storage handlers use update() from node manager. Previous custom logic is kept

but should be removed later.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@936 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 709d69a5
...@@ -94,79 +94,22 @@ class BaseMasterHandler(BaseStorageHandler): ...@@ -94,79 +94,22 @@ class BaseMasterHandler(BaseStorageHandler):
def handleNotifyNodeInformation(self, conn, packet, node_list): def handleNotifyNodeInformation(self, conn, packet, node_list):
"""Store information on nodes, only if this is sent by a primary """Store information on nodes, only if this is sent by a primary
master node.""" master node."""
# XXX it might be better to implement this callback in each handler. self.app.nm.update(node_list)
uuid = conn.getUUID() # XXX: iterate over the list to keep previous logic for now, but
app = self.app # notification must not be used to change a node state
for node_type, addr, uuid, state in node_list: for node_type, addr, uuid, state in node_list:
# Try to retrieve it from nm if uuid == self.app.uuid:
n = None # This is me, do what the master tell me
if uuid is not None: logging.info("I was told I'm %s" %(state))
n = app.nm.getNodeByUUID(uuid) if state in (DOWN_STATE, TEMPORARILY_DOWN_STATE, BROKEN_STATE):
if n is None: conn.close()
n = app.nm.getNodeByServer(addr) self.app.shutdown()
if n is not None and uuid is not None: elif state == HIDDEN_STATE:
# node only exists by address, remove it raise OperationFailure
app.nm.remove(n) elif node_type == CLIENT_NODE_TYPE and state != RUNNING_STATE:
n = None # XXX: check why dealWithClientFailure is triggered with node
elif n.getServer() != addr: # notification and not only by client connection failure
# same uuid but different address, update it self.dealWithClientFailure(uuid)
n.setServer(addr)
if state == protocol.DOWN_STATE and n is not None:
# this node is consider as down, remove it
self.app.nm.remove(n)
continue
if node_type == MASTER_NODE_TYPE:
if n is None:
n = MasterNode(server = addr)
app.nm.add(n)
n.setState(state)
if uuid is not None:
if n.getUUID() is None:
n.setUUID(uuid)
elif node_type == STORAGE_NODE_TYPE:
if uuid is None:
# No interest.
continue
if uuid == self.app.uuid:
# This is me, do what the master tell me
logging.info("I was told I'm %s" %(state))
if state in (DOWN_STATE, TEMPORARILY_DOWN_STATE, BROKEN_STATE):
conn.close()
self.app.shutdown()
elif state == HIDDEN_STATE:
n = app.nm.getNodeByUUID(uuid)
if n is not None:
n.setState(state)
raise OperationFailure
if n is None:
n = StorageNode(server = addr, uuid = uuid)
app.nm.add(n)
n.setState(state)
elif node_type == CLIENT_NODE_TYPE:
if uuid is None:
# No interest.
continue
if state == RUNNING_STATE:
if n is None:
n = ClientNode(uuid = uuid)
app.nm.add(n)
else:
self.dealWithClientFailure(uuid)
if n is not None:
logging.debug('removing client node %s', dump(uuid))
app.nm.remove(n)
if n is not None:
logging.info("added %s %s" %(dump(n.getUUID()), n.getServer()))
class BaseClientAndStorageOperationHandler(BaseStorageHandler): class BaseClientAndStorageOperationHandler(BaseStorageHandler):
......
...@@ -39,25 +39,15 @@ class HiddenHandler(BaseMasterHandler): ...@@ -39,25 +39,15 @@ class HiddenHandler(BaseMasterHandler):
"""Store information on nodes, only if this is sent by a primary """Store information on nodes, only if this is sent by a primary
master node.""" master node."""
app = self.app app = self.app
self.app.nm.update(node_list)
# XXX: notification must not be used to change a node state
for node_type, addr, uuid, state in node_list: for node_type, addr, uuid, state in node_list:
if node_type == STORAGE_NODE_TYPE: if node_type == STORAGE_NODE_TYPE:
if uuid == None:
# No interest.
continue
if uuid == self.app.uuid: if uuid == self.app.uuid:
# This is me, do what the master tell me # This is me, do what the master tell me
if state in (DOWN_STATE, TEMPORARILY_DOWN_STATE, BROKEN_STATE): if state in (DOWN_STATE, TEMPORARILY_DOWN_STATE, BROKEN_STATE):
conn.close() conn.close()
self.app.shutdown() self.app.shutdown()
elif state == HIDDEN_STATE:
# I know I'm hidden
continue
else:
# I must be working again
n = app.nm.getNodeByUUID(uuid)
n.setState(state)
def handleRequestNodeIdentification(self, conn, packet, node_type, def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, address, name): uuid, address, name):
......
...@@ -29,7 +29,7 @@ class InitializationHandler(BaseMasterHandler): ...@@ -29,7 +29,7 @@ class InitializationHandler(BaseMasterHandler):
self.app.has_node_information = True self.app.has_node_information = True
def handleNotifyNodeInformation(self, conn, packet, node_list): def handleNotifyNodeInformation(self, conn, packet, node_list):
# FIXME: This message could be replaced by a SendNodeInformation to be # XXX: This message should be replaced by a SendNodeInformation to be
# consistent with SendPartitionTable. # consistent with SendPartitionTable.
BaseMasterHandler.handleNotifyNodeInformation(self, conn, packet, node_list) BaseMasterHandler.handleNotifyNodeInformation(self, conn, packet, node_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