Exemple #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")
    def __init__(self, logfile_paths):
        Thread.__init__(self)

        self.log = LogFactory().get_log(__name__)

        self.logfile_paths = logfile_paths
        self.publishers = {}
        self.ports = []
        self.ports.append(
            DataPublisherConfiguration.get_instance().monitoring_server_port)
        self.ports.append(DataPublisherConfiguration.get_instance().
                          monitoring_server_secure_port)

        self.log.debug("Checking if Monitoring server is active.")
        ports_active = cartridgeagentutils.wait_until_ports_active(
            DataPublisherConfiguration.get_instance().monitoring_server_ip,
            self.ports, int(Config.port_check_timeout))

        if not ports_active:
            self.log.debug("Monitoring server is not active")
            raise DataPublisherException(
                "Monitoring server not active, data publishing is aborted")

        self.log.debug(
            "Monitoring server is up and running. Log Publisher Manager started."
        )

        self.tenant_id = LogPublisherManager.get_valid_tenant_id(
            Config.tenant_id)
        self.alias = LogPublisherManager.get_alias(Config.cluster_id)
        self.date_time = LogPublisherManager.get_current_date()

        self.stream_definition = self.define_stream(self.tenant_id, self.alias,
                                                    self.date_time)
    def __init__(self, logfile_paths):
        Thread.__init__(self)

        self.log = LogFactory().get_log(__name__)
        self.setDaemon(True)
        self.logfile_paths = logfile_paths
        self.publishers = {}
        self.ports = []
        self.ports.append(DataPublisherConfiguration.get_instance().monitoring_server_port)
        self.ports.append(DataPublisherConfiguration.get_instance().monitoring_server_secure_port)

        self.log.debug("Checking if Monitoring server is active.")
        ports_active = cartridgeagentutils.wait_until_ports_active(
            DataPublisherConfiguration.get_instance().monitoring_server_ip,
            self.ports,
            int(Config.port_check_timeout))

        if not ports_active:
            self.log.debug("Monitoring server is not active")
            raise DataPublisherException("Monitoring server not active, data publishing is aborted")

        self.log.debug("Monitoring server is up and running. Log Publisher Manager started.")

        self.tenant_id = LogPublisherManager.get_valid_tenant_id(Config.tenant_id)
        self.alias = LogPublisherManager.get_alias(Config.cluster_id)
        self.date_time = LogPublisherManager.get_current_date()

        self.stream_definition = self.define_stream(self.tenant_id, self.alias)
        self.setName("LogPublisherManagerThread")
        self.log.debug("Created a LogPublisherManager thread")
Exemple #4
0
def publish_instance_activated_event():
    if not Config.activated:
        # Wait for all ports to be active
        listen_address = Config.listen_address
        configuration_ports = Config.ports
        ports_active = cartridgeagentutils.wait_until_ports_active(
            listen_address, configuration_ports, int(Config.port_check_timeout)
        )

        if ports_active:
            log.info("Publishing instance activated event...")
            service_name = Config.service_name
            cluster_id = Config.cluster_id
            member_id = Config.member_id
            instance_id = Config.instance_id
            cluster_instance_id = Config.cluster_instance_id
            network_partition_id = Config.network_partition_id
            partition_id = Config.partition_id

            instance_activated_event = InstanceActivatedEvent(
                service_name,
                cluster_id,
                cluster_instance_id,
                member_id,
                instance_id,
                network_partition_id,
                partition_id,
            )

            publisher = get_publisher(constants.INSTANCE_STATUS_TOPIC + constants.INSTANCE_ACTIVATED_EVENT)
            publisher.publish(instance_activated_event)
            log.info("Instance activated event published")

            health_stat_publishing_enabled = Config.read_property(constants.CEP_PUBLISHER_ENABLED, True)

            if health_stat_publishing_enabled:
                interval_default = 15  # seconds
                interval = Config.read_property("stats.notifier.interval", False)
                if interval is not None and len(interval) > 0:
                    try:
                        interval = int(interval)
                    except ValueError:
                        interval = interval_default
                else:
                    interval = interval_default
                health_stats_publisher = healthstats.HealthStatisticsPublisherManager(interval)
                log.info("Starting Health statistics publisher with interval %r" % interval)
                health_stats_publisher.start()
            else:
                log.warn("Statistics publisher is disabled")

            Config.activated = True
            log.info("Health statistics notifier started")
        else:
            log.error(
                "Ports activation timed out. Aborting publishing instance activated event [IPAddress] %s [Ports] %s"
                % (listen_address, configuration_ports)
            )
    else:
        log.warn("Instance already activated")
Exemple #5
0
def publish_instance_activated_event():
    if not Config.activated:
        # Wait for all ports to be active
        listen_address = Config.listen_address
        configuration_ports = Config.ports
        ports_active = cartridgeagentutils.wait_until_ports_active(
            listen_address, configuration_ports,
            int(Config.port_check_timeout))

        if ports_active:
            log.info("Publishing instance activated event...")
            service_name = Config.service_name
            cluster_id = Config.cluster_id
            member_id = Config.member_id
            instance_id = Config.instance_id
            cluster_instance_id = Config.cluster_instance_id
            network_partition_id = Config.network_partition_id
            partition_id = Config.partition_id

            instance_activated_event = InstanceActivatedEvent(
                service_name, cluster_id, cluster_instance_id, member_id,
                instance_id, network_partition_id, partition_id)

            publisher = get_publisher(constants.INSTANCE_STATUS_TOPIC +
                                      constants.INSTANCE_ACTIVATED_EVENT)
            publisher.publish(instance_activated_event)
            log.info("Instance activated event published")

            health_stat_publishing_enabled = Config.read_property(
                constants.CEP_PUBLISHER_ENABLED, True)

            if health_stat_publishing_enabled:
                interval_default = 15  # seconds
                interval = Config.read_property("stats.notifier.interval",
                                                False)
                if interval is not None and len(interval) > 0:
                    try:
                        interval = int(interval)
                    except ValueError:
                        interval = interval_default
                else:
                    interval = interval_default
                health_stats_publisher = healthstats.HealthStatisticsPublisherManager(
                    interval)
                log.info(
                    "Starting Health statistics publisher with interval %r" %
                    interval)
                health_stats_publisher.start()
            else:
                log.warn("Statistics publisher is disabled")

            Config.activated = True
            log.info("Health statistics notifier started")
        else:
            log.error(
                "Ports activation timed out. Aborting publishing instance activated event [IPAddress] %s [Ports] %s"
                % (listen_address, configuration_ports))
    else:
        log.warn("Instance already activated")
Exemple #6
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)