Exemplo n.º 1
0
 def start_server(self):
     '''
         launch the true starting sequence for the server
     '''
     self._set_logger()
     if self._is_server_started():
         print('\nServer alrady started. If not, remove the lock (if you are running the test, this message is normal)')
         logging.error('Server alrady started. If not, remove the lock')
         return 1
     else:
         self._lock_instance()
         logging.info('Starting server')
         cluster_adapter = ClusterAdapter.get_instance()
         cluster_adapter.start()
         service_manager = ServiceManager.get_instance()
         service_manager.create_all_service(True)
         self._external_control = ExternalControl(self)
         self._external_control.start()
         logging.info('Server started')
         if self._is_testing:
             pass
         else :
             # waiting for the stop order
             self._stop_event.wait()
             self.stop_server()
     return 0
Exemplo n.º 2
0
	def main(self):
		self._room_handler = ServiceManager.get_instance().get_service(MY_ROOM_HANDLER)
		self._cluster = ClusterAdapter.get_instance()
		self._cluster.subscribe('say_socket_send', self.say_cluster_callback)
		logging.info('launching SaySocket service')
		self._shutdown_event.wait()
		self._shutdown_event.clear()
Exemplo n.º 3
0
	def test_subscribe_no_event(self):
		event = 'toto'
		def callback(self):
			self._test_callback = True
		cluster_adapter = ClusterAdapter.get_instance()
		cluster_adapter.subscribe(event, callback)
		
		self.assertEqual(cluster_adapter._subscribers.has_key(event), True)
		self.assertEqual(len(cluster_adapter._subscribers), 1)
		self.assertEqual(cluster_adapter._subscribers[event][0], callback)
Exemplo n.º 4
0
 def stop_server(self):
     '''
         stop server's sequence
     '''
     logging.info('Halting server requested')
     service_manager = ServiceManager.get_instance()
     service_manager.stop_service_manager()
     self._external_control.halt_external_control()
     self._external_control.join()
     cluster_adapter = ClusterAdapter.get_instance()
     cluster_adapter.disable()
     cluster_adapter.join()
     self._release_instace()
     logging.info('Halting server done')
Exemplo n.º 5
0
	def test_get_unique_instance(self):
		print('\ntest de l\'unicité du servicemanager')
		sm1 = ClusterAdapter.get_instance()
		sm2 = ClusterAdapter.get_instance()
		self.assertEqual(sm1, sm2)
Exemplo n.º 6
0
	def test_get_instance_simple(self):
		print('\ntest de la recuperation d\'une instance simple du servicemanager')
		self.assertIsInstance(ClusterAdapter.get_instance(), ClusterAdapter)
Exemplo n.º 7
0
	def tearDown(self):
		#apres chaque test on eteint le serveur
		cluster_adapter = ClusterAdapter.get_instance()
		cluster_adapter._stop_service = False
		cluster_adapter._subscribers = {}