Commit 08f200bb authored by Grégory Wisniewski's avatar Grégory Wisniewski

getNodeByUUID always return None on invalid UUID, even if one was inserted by

mistake. Add an helper method on the event manager to retreive a connection from
an UUID.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@661 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 86056d54
...@@ -169,6 +169,17 @@ class EpollEventManager(object): ...@@ -169,6 +169,17 @@ class EpollEventManager(object):
def getConnectionList(self): def getConnectionList(self):
return self.connection_dict.values() return self.connection_dict.values()
def getConnectionByUUID(self, uuid):
""" Return the connection associated to the UUID, None if the UUID is
None, invalid or not found"""
# FIXME: We may optimize this by using use a dict on UUIDs
if uuid in (None, protocol.INVALID_UUID):
return None
for conn in self.connection_dict.values():
if conn.getUUID() == uuid:
return conn
return None
def register(self, conn): def register(self, conn):
fd = conn.getDescriptor() fd = conn.getDescriptor()
self.connection_dict[fd] = conn self.connection_dict[fd] = conn
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
from time import time from time import time
import logging import logging
from neo import protocol
from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \ from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, \
BROKEN_STATE, PENDING_STATE, MASTER_NODE_TYPE, STORAGE_NODE_TYPE, \ BROKEN_STATE, PENDING_STATE, MASTER_NODE_TYPE, STORAGE_NODE_TYPE, \
CLIENT_NODE_TYPE, VALID_NODE_STATE_LIST, ADMIN_NODE_TYPE CLIENT_NODE_TYPE, VALID_NODE_STATE_LIST, ADMIN_NODE_TYPE
...@@ -161,6 +162,8 @@ class NodeManager(object): ...@@ -161,6 +162,8 @@ class NodeManager(object):
return self.server_dict.get(server) return self.server_dict.get(server)
def getNodeByUUID(self, uuid): def getNodeByUUID(self, uuid):
if uuid in (None, protocol.INVALID_UUID):
return None
return self.uuid_dict.get(uuid) return self.uuid_dict.get(uuid)
def clear(self, filter=None): def clear(self, 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