Commit 80eb719e authored by Vincent Pelletier's avatar Vincent Pelletier

Switch several master handler to singletons.

parent ff076765
...@@ -104,6 +104,12 @@ class Application(object): ...@@ -104,6 +104,12 @@ class Application(object):
self.backup_app = BackupApplication(self, upstream_cluster, self.backup_app = BackupApplication(self, upstream_cluster,
*config.getUpstreamMasters()) *config.getUpstreamMasters())
self.administration_handler = administration.AdministrationHandler(
self)
self.secondary_master_handler = secondary.SecondaryMasterHandler(self)
self.client_service_handler = client.ClientServiceHandler(self)
self.storage_service_handler = storage.StorageServiceHandler(self)
registerLiveDebugger(on_log=self.log) registerLiveDebugger(on_log=self.log)
def close(self): def close(self):
...@@ -388,10 +394,10 @@ class Application(object): ...@@ -388,10 +394,10 @@ class Application(object):
return return
# select the storage handler # select the storage handler
client_handler = client.ClientServiceHandler(self) client_handler = self.client_service_handler
if state in (ClusterStates.RUNNING, ClusterStates.STARTING_BACKUP, if state in (ClusterStates.RUNNING, ClusterStates.STARTING_BACKUP,
ClusterStates.BACKINGUP, ClusterStates.STOPPING_BACKUP): ClusterStates.BACKINGUP, ClusterStates.STOPPING_BACKUP):
storage_handler = storage.StorageServiceHandler(self) storage_handler = self.storage_service_handler
elif self._current_manager is not None: elif self._current_manager is not None:
storage_handler = self._current_manager.getHandler() storage_handler = self._current_manager.getHandler()
else: else:
...@@ -468,7 +474,7 @@ class Application(object): ...@@ -468,7 +474,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
return state, storage.StorageServiceHandler(self) return state, self.storage_service_handler
def identifyNode(self, node_type, uuid, node): def identifyNode(self, node_type, uuid, node):
...@@ -477,12 +483,12 @@ class Application(object): ...@@ -477,12 +483,12 @@ class Application(object):
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(self) handler = self.administration_handler
human_readable_node_type = 'n admin ' human_readable_node_type = 'n admin '
elif node_type == NodeTypes.MASTER: elif node_type == NodeTypes.MASTER:
# 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(self) handler = self.secondary_master_handler
human_readable_node_type = ' master ' human_readable_node_type = ' master '
elif node_type == NodeTypes.CLIENT: elif node_type == NodeTypes.CLIENT:
# refuse any client before running # refuse any client before running
...@@ -490,7 +496,7 @@ class Application(object): ...@@ -490,7 +496,7 @@ class Application(object):
logging.info('Reject a connection from a client') logging.info('Reject a connection from a client')
raise NotReadyError raise NotReadyError
node_ctor = self.nm.createClient node_ctor = self.nm.createClient
handler = client.ClientServiceHandler(self) handler = self.client_service_handler
human_readable_node_type = ' client ' human_readable_node_type = ' client '
elif node_type == NodeTypes.STORAGE: elif node_type == NodeTypes.STORAGE:
node_ctor = self.nm.createStorage node_ctor = self.nm.createStorage
......
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