Commit d62476dd authored by Vincent Pelletier's avatar Vincent Pelletier

Make setDown() consistent with update() with a down node.

parent 8ae3f0ea
...@@ -58,10 +58,14 @@ class Node(object): ...@@ -58,10 +58,14 @@ class Node(object):
def setState(self, new_state): def setState(self, new_state):
if self._state == new_state: if self._state == new_state:
return return
if new_state == NodeStates.DOWN:
self._manager.remove(self)
self._state = new_state
else:
old_state = self._state old_state = self._state
self._state = new_state self._state = new_state
self._last_state_change = time()
self._manager._updateState(self, old_state) self._manager._updateState(self, old_state)
self._last_state_change = time()
def setAddress(self, address): def setAddress(self, address):
if self._address == address: if self._address == address:
...@@ -268,6 +272,7 @@ class NodeManager(object): ...@@ -268,6 +272,7 @@ class NodeManager(object):
if node in self._node_set: if node in self._node_set:
neo.lib.logging.warning('adding a known node %r, ignoring', node) neo.lib.logging.warning('adding a known node %r, ignoring', node)
return return
assert not node.isDown(), node
self._node_set.add(node) self._node_set.add(node)
self._updateAddress(node, None) self._updateAddress(node, None)
self._updateUUID(node, None) self._updateUUID(node, None)
...@@ -334,6 +339,7 @@ class NodeManager(object): ...@@ -334,6 +339,7 @@ class NodeManager(object):
set_dict.setdefault(new_key, set()).add(node) set_dict.setdefault(new_key, set()).add(node)
def _updateState(self, node, old_state): def _updateState(self, node, old_state):
assert not node.isDown(), node
self.__updateSet(self._state_dict, old_state, node.getState(), node) self.__updateSet(self._state_dict, old_state, node.getState(), node)
def getList(self, node_filter=None): def getList(self, node_filter=None):
......
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