Commit 2b77af21 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Create handler instance at selection.

To allow latter give an instance instead of a class.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1589 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 3739fbae
...@@ -738,7 +738,7 @@ class Application(object): ...@@ -738,7 +738,7 @@ class Application(object):
if uuid is None: if uuid is None:
logging.info('reject empty storage node') logging.info('reject empty storage node')
raise protocol.NotReadyError raise protocol.NotReadyError
handler = recovery.RecoveryHandler handler = recovery.RecoveryHandler(self)
elif self.cluster_state == ClusterStates.VERIFYING: elif self.cluster_state == ClusterStates.VERIFYING:
if uuid is None or node is None: if uuid is None or node is None:
# if node is unknown, it has been forget when the current # if node is unknown, it has been forget when the current
...@@ -752,7 +752,7 @@ class Application(object): ...@@ -752,7 +752,7 @@ class Application(object):
if uuid is None or node is None: if uuid is None or node is None:
# same as for verification # same as for verification
state = NodeStates.PENDING state = NodeStates.PENDING
handler = storage.StorageServiceHandler handler = storage.StorageServiceHandler(self)
elif self.cluster_state == ClusterStates.STOPPING: elif self.cluster_state == ClusterStates.STOPPING:
raise protocol.NotReadyError raise protocol.NotReadyError
else: else:
...@@ -762,12 +762,12 @@ class Application(object): ...@@ -762,12 +762,12 @@ class Application(object):
def identifyNode(self, node_type, uuid, node): def identifyNode(self, node_type, uuid, node):
state = NodeStates.RUNNING state = NodeStates.RUNNING
handler = identification.IdentificationHandler handler = identification.IdentificationHandler(self)
if node_type == NodeTypes.ADMIN: if node_type == NodeTypes.ADMIN:
# always accept admin nodes # always accept admin nodes
node_ctor = self.nm.createAdmin node_ctor = self.nm.createAdmin
handler = administration.AdministrationHandler handler = administration.AdministrationHandler(self)
logging.info('Accept an admin %s' % (dump(uuid), )) logging.info('Accept an admin %s' % (dump(uuid), ))
elif node_type == NodeTypes.MASTER: elif node_type == NodeTypes.MASTER:
if node is None: if node is None:
...@@ -775,7 +775,7 @@ class Application(object): ...@@ -775,7 +775,7 @@ class Application(object):
raise protocol.ProtocolError('Reject an unknown master node') raise protocol.ProtocolError('Reject an unknown master node')
# always put other master in waiting state # always put other master in waiting state
node_ctor = self.nm.createMaster node_ctor = self.nm.createMaster
handler = secondary.SecondaryMasterHandler handler = secondary.SecondaryMasterHandler(self)
logging.info('Accept a master %s' % (dump(uuid), )) logging.info('Accept a master %s' % (dump(uuid), ))
elif node_type == NodeTypes.CLIENT: elif node_type == NodeTypes.CLIENT:
# refuse any client before running # refuse any client before running
...@@ -783,13 +783,11 @@ class Application(object): ...@@ -783,13 +783,11 @@ class Application(object):
logging.info('Reject a connection from a client') logging.info('Reject a connection from a client')
raise protocol.NotReadyError raise protocol.NotReadyError
node_ctor = self.nm.createClient node_ctor = self.nm.createClient
handler = client.ClientServiceHandler handler = client.ClientServiceHandler(self)
logging.info('Accept a client %s' % (dump(uuid), )) logging.info('Accept a client %s' % (dump(uuid), ))
elif node_type == NodeTypes.STORAGE: elif node_type == NodeTypes.STORAGE:
node_ctor = self.nm.createStorage node_ctor = self.nm.createStorage
(uuid, state, handler) = self.identifyStorageNode(uuid, node) (uuid, state, handler) = self.identifyStorageNode(uuid, node)
logging.info('Accept a storage %s (%s)' % (dump(uuid), state)) logging.info('Accept a storage %s (%s)' % (dump(uuid), state))
# create a handler instance
handler = handler(self)
return (uuid, node, state, handler, node_ctor) return (uuid, node, state, handler, node_ctor)
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