Commit 36f2c2f7 authored by Aurel's avatar Aurel

try to retrieve node by uuid and address before updating their data


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@578 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7f5695cb
...@@ -117,9 +117,22 @@ class StorageEventHandler(EventHandler): ...@@ -117,9 +117,22 @@ class StorageEventHandler(EventHandler):
for node_type, ip_address, port, uuid, state in node_list: for node_type, ip_address, port, uuid, state in node_list:
addr = (ip_address, port) addr = (ip_address, port)
# Try to retrieve it from nm
n = None
if uuid != INVALID_UUID:
n = app.nm.getNodeByUUID(uuid)
if n is None:
n = app.nm.getNodeByServer(addr)
if n is not None and uuid != INVALID_UUID:
# node only exists by address, remove it
app.nm.remove(n)
n = None
elif n.getServer() != addr:
# same uuid but different address, remove it
app.nm.remove(n)
n = None
if node_type == MASTER_NODE_TYPE: if node_type == MASTER_NODE_TYPE:
n = app.nm.getNodeByServer(addr)
if n is None: if n is None:
n = MasterNode(server = addr) n = MasterNode(server = addr)
app.nm.add(n) app.nm.add(n)
...@@ -148,12 +161,15 @@ class StorageEventHandler(EventHandler): ...@@ -148,12 +161,15 @@ class StorageEventHandler(EventHandler):
# I know I'm running # I know I'm running
continue continue
n = app.nm.getNodeByUUID(uuid)
if n is None: if n is None:
# try by address
n = app.nm.getNodeByServer(addr)
if n is not None:
# remove the node
app.nm.remode(n)
n = StorageNode(server = addr, uuid = uuid) n = StorageNode(server = addr, uuid = uuid)
app.nm.add(n) app.nm.add(n)
else:
n.setServer(addr)
n.setState(state) n.setState(state)
elif node_type == CLIENT_NODE_TYPE: elif node_type == CLIENT_NODE_TYPE:
...@@ -162,15 +178,11 @@ class StorageEventHandler(EventHandler): ...@@ -162,15 +178,11 @@ class StorageEventHandler(EventHandler):
continue continue
if state == RUNNING_STATE: if state == RUNNING_STATE:
n = app.nm.getNodeByUUID(uuid)
if n is None: if n is None:
logging.debug('adding client node %s', dump(uuid))
n = ClientNode(uuid = uuid) n = ClientNode(uuid = uuid)
app.nm.add(n) app.nm.add(n)
assert app.nm.getNodeByUUID(uuid) is n
else: else:
self.dealWithClientFailure(uuid) self.dealWithClientFailure(uuid)
n = app.nm.getNodeByUUID(uuid)
if n is not None: if n is not None:
logging.debug('removing client node %s', dump(uuid)) logging.debug('removing client node %s', dump(uuid))
app.nm.remove(n) app.nm.remove(n)
......
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