Exemplo n.º 1
0
    def __init__(self):
        self.ports = []
        cep_port = HealthStatisticsPublisher.read_config(constants.CEP_RECEIVER_PORT)
        self.ports.append(cep_port)

        cep_ip = HealthStatisticsPublisher.read_config(constants.CEP_RECEIVER_IP)

        cartridgeagentutils.wait_until_ports_active(
            cep_ip,
            self.ports,
            int(Config.read_property("port.check.timeout", critical=False)))

        cep_active = cartridgeagentutils.check_ports_active(
            cep_ip,
            self.ports)

        if not cep_active:
            raise CEPPublisherException("CEP server not active. Health statistics publishing aborted.")

        cep_admin_username = HealthStatisticsPublisher.read_config(constants.CEP_SERVER_ADMIN_USERNAME)
        cep_admin_password = HealthStatisticsPublisher.read_config(constants.CEP_SERVER_ADMIN_PASSWORD)

        self.stream_definition = HealthStatisticsPublisher.create_stream_definition()
        HealthStatisticsPublisher.log.debug("Stream definition created: %r" % str(self.stream_definition))

        self.publisher = ThriftPublisher(
            cep_ip,
            cep_port,
            cep_admin_username,
            cep_admin_password,
            self.stream_definition)

        HealthStatisticsPublisher.log.debug("HealthStatisticsPublisher initialized")
Exemplo n.º 2
0
    def __init__(self):

        self.publishers = []
        cep_admin_username = HealthStatisticsPublisher.read_config(constants.CEP_SERVER_ADMIN_USERNAME)
        cep_admin_password = HealthStatisticsPublisher.read_config(constants.CEP_SERVER_ADMIN_PASSWORD)
        # 1.1.1.1:1883,2.2.2.2:1883
        cep_urls = HealthStatisticsPublisher.read_config(constants.CEP_RECEIVER_URLS)
        cep_urls = cep_urls.split(',')
        for cep_url in cep_urls:
            self.ports = []
            cep_ip = cep_url.split(':')[0]
            cep_port = cep_url.split(':')[1]
            self.ports.append(cep_port)
            cartridgeagentutils.wait_until_ports_active(
                cep_ip,
                self.ports,
                int(Config.read_property("port.check.timeout", critical=False)))

            cep_active = cartridgeagentutils.check_ports_active(
                cep_ip,
                self.ports)

            if not cep_active:
                raise CEPPublisherException("CEP server not active. Health statistics publishing aborted.")

            self.stream_definition = HealthStatisticsPublisher.create_stream_definition()
            HealthStatisticsPublisher.log.debug("Stream definition created: %r" % str(self.stream_definition))

            publisher = ThriftPublisher(
                cep_ip,
                cep_port,
                cep_admin_username,
                cep_admin_password,
                self.stream_definition)

            self.publishers.append(publisher)

            HealthStatisticsPublisher.log.debug("HealthStatisticsPublisher initialized. %r %r",
                                                cep_ip, cep_port)