Ejemplo n.º 1
0
 def test_ACK_COMMAND_DISCONNECT_MASTER(self):
     reply_to_conductor.register_player(112, self.__connection, conductor.exchange, Constants.CONDUCTOR_ROUTING_KEY)
     reply_to_conductor.register_player(115, self.__connection, conductor.exchange, Constants.CONDUCTOR_ROUTING_KEY)
     reply_to_conductor.acknowledgement_master_disconnected(112, self.__connection, conductor.exchange, Constants.CONDUCTOR_ROUTING_KEY)
     time.sleep(2)
     player_tracker = PlayerTracker()
     self.assertTrue(player_tracker.is_replication_stopped(112))
     self.assertFalse(player_tracker.is_replication_stopped(115))
Ejemplo n.º 2
0
 def test_ACK_COMMAND_DISCONNECT_MASTER(self):
     reply_to_conductor.register_player(112, self.__connection,
                                        conductor.exchange,
                                        Constants.CONDUCTOR_ROUTING_KEY)
     reply_to_conductor.register_player(115, self.__connection,
                                        conductor.exchange,
                                        Constants.CONDUCTOR_ROUTING_KEY)
     reply_to_conductor.acknowledgement_master_disconnected(
         112, self.__connection, conductor.exchange,
         Constants.CONDUCTOR_ROUTING_KEY)
     time.sleep(2)
     player_tracker = PlayerTracker()
     self.assertTrue(player_tracker.is_replication_stopped(112))
     self.assertFalse(player_tracker.is_replication_stopped(115))
 def test_acknowledgement_master_disconnected(self):
     message, exchange, routing_key = acknowledgement_master_disconnected(111, self.__conn, self.__exchange, self.__routing_key)
     body = json.loads(message['body'])
     self.assertEqual(Constants.ACK_COMMAND_STOP_REPLICATION, body[Constants.MESSAGE_ACK_COMMAND])
     self.assertEqual(111, body[Constants.MESSAGE_NODE_ID])
     self.assertEqual(self.__exchange.name, exchange)
     self.assertEqual(self.__routing_key, routing_key)
Ejemplo n.º 4
0
 def disconnect_master(self):
     '''
     insert iptable rules to block master to access slave database
     '''
     rtn = False
     with IptablesController() as iptables:
         iptables.block_pgsql_OUTPUT()
         blocked = IptablesChecker().check_block_output(self.master_hostname)
         if blocked:
             reply_to_conductor.acknowledgement_master_disconnected(self.node_id, self.connection,
                                                                    self.exchange, self.routing_key)
             rtn = True
             logger.debug("Block master database ( {master} )".format(master=self.master_hostname))
             admin_logger.debug("{name} at {hostname} with node id {node_id} blocked master database ( {master}).".
                                format(name=self.__class__.__name__, hostname=self.hostname,
                                       node_id=self.node_id, master=self.master_hostname))
         else:
             logger.error("Failed to block master( {master} )".format(master=self.master_hostname))
             admin_logger.error("{name} at {hostname} with node id {node_id} failed to block master database ( {master} ).".
                                format(name=self.__class__.__name__, hostname=self.hostname,
                                       node_id=self.node_id, master=self.master_hostname))
     return rtn
 def disconnect_master(self):
     reply_to_conductor.acknowledgement_master_disconnected(self.node_id, self.connection, self.exchange, self.routing_key)