Commit 7df940fd authored by Vincent Pelletier's avatar Vincent Pelletier

Client nodes are not advertised via node state broadcast, so they must be...

Client nodes are not advertised via node state broadcast, so they must be created upon identification if they don't already exist.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@858 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7f11c557
......@@ -21,6 +21,7 @@ from neo.storage.handlers import BaseStorageHandler
from neo.protocol import BROKEN_STATE, STORAGE_NODE_TYPE, CLIENT_NODE_TYPE
from neo import protocol
from neo.util import dump
from neo.node import ClientNode
class IdentificationHandler(BaseStorageHandler):
""" Handler used for incoming connections during operation state """
......@@ -42,21 +43,24 @@ class IdentificationHandler(BaseStorageHandler):
raise protocol.NotReadyError
app = self.app
node = app.nm.getNodeByUUID(uuid)
if node is None:
logging.error('reject an unknown node %s', dump(uuid))
raise protocol.NotReadyError
# If this node is broken, reject it.
if node.getState() == BROKEN_STATE:
raise protocol.BrokenNodeDisallowedError
# choose the handler according to the node type
if node_type == protocol.CLIENT_NODE_TYPE:
from neo.storage.handlers.client import ClientOperationHandler
handler = ClientOperationHandler
if node is None:
node = ClientNode()
app.nm.add(node)
elif node_type == protocol.STORAGE_NODE_TYPE:
from neo.storage.handlers.storage import StorageOperationHandler
handler = StorageOperationHandler
else:
raise protocol.protocolError('reject non-client-or-storage node')
if node is None:
logging.error('reject an unknown node %s', dump(uuid))
raise protocol.NotReadyError
# If this node is broken, reject it.
if node.getState() == BROKEN_STATE:
raise protocol.BrokenNodeDisallowedError
# apply the handler and set up the connection
handler = handler(self.app)
conn.setHandler(handler)
......
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