Exemplo n.º 1
0
 def _configure_pipeline_listeners(self):
     self.pipeline_listeners = []
     ev_pipes = []
     if cfg.CONF.notification.store_events:
         ev_pipes = self.event_pipeline_manager.pipelines
     pipelines = self.pipeline_manager.pipelines + ev_pipes
     transport = messaging.get_transport()
     partitioned = self.partition_coordinator.extract_my_subset(
         self.group_id,
         range(cfg.CONF.notification.pipeline_processing_queues))
     for pipe_set in partitioned:
         for pipe in pipelines:
             LOG.debug('Pipeline endpoint: %s from set: %s', pipe.name,
                       pipe_set)
             pipe_endpoint = (pipeline.EventPipelineEndpoint
                              if isinstance(pipe, pipeline.EventPipeline)
                              else pipeline.SamplePipelineEndpoint)
             listener = messaging.get_notification_listener(
                 transport,
                 [oslo_messaging.Target(
                     topic='%s-%s-%s' % (self.NOTIFICATION_IPC,
                                         pipe.name, pipe_set))],
                 [pipe_endpoint(self.ctxt, pipe)])
             listener.start()
             self.pipeline_listeners.append(listener)
Exemplo n.º 2
0
    def start(self):
        """Bind the UDP socket and handle incoming data."""
        # ensure dispatcher is configured before starting other services
        dispatcher_managers = dispatcher.load_dispatcher_manager()
        (self.meter_manager, self.event_manager) = dispatcher_managers
        self.rpc_server = None
        self.sample_listener = None
        self.event_listener = None
        super(CollectorService, self).start()

        if cfg.CONF.collector.udp_address:
            self.tg.add_thread(self.start_udp)

        transport = messaging.get_transport(optional=True)
        if transport:
            if cfg.CONF.collector.enable_rpc:
                LOG.warning('RPC collector is deprecated in favour of queues. '
                            'Please switch to notifier publisher.')
                self.rpc_server = messaging.get_rpc_server(
                    transport, cfg.CONF.publisher_rpc.metering_topic, self)

            if list(self.meter_manager):
                sample_target = oslo_messaging.Target(
                    topic=cfg.CONF.publisher_notifier.metering_topic)
                self.sample_listener = messaging.get_notification_listener(
                    transport, [sample_target],
                    [SampleEndpoint(self.meter_manager)],
                    allow_requeue=(cfg.CONF.collector.
                                   requeue_sample_on_dispatcher_error))
                self.sample_listener.start()

            if cfg.CONF.notification.store_events and list(self.event_manager):
                event_target = oslo_messaging.Target(
                    topic=cfg.CONF.publisher_notifier.event_topic)
                self.event_listener = messaging.get_notification_listener(
                    transport, [event_target],
                    [EventEndpoint(self.event_manager)],
                    allow_requeue=(cfg.CONF.collector.
                                   requeue_event_on_dispatcher_error))
                self.event_listener.start()

            if cfg.CONF.collector.enable_rpc:
                self.rpc_server.start()

            if not cfg.CONF.collector.udp_address:
                # Add a dummy thread to have wait() working
                self.tg.add_timer(604800, lambda: None)
Exemplo n.º 3
0
    def start(self):
        """Bind the UDP socket and handle incoming data."""
        # ensure dispatcher is configured before starting other services
        self.dispatcher_manager = dispatcher.load_dispatcher_manager()
        self.rpc_server = None
        self.sample_listener = None
        self.event_listener = None
        super(CollectorService, self).start()

        if cfg.CONF.collector.udp_address:
            self.tg.add_thread(self.start_udp)

        transport = messaging.get_transport(optional=True)
        if transport:
            if cfg.CONF.collector.enable_rpc:
                LOG.warning('RPC collector is deprecated in favour of queues. '
                            'Please switch to notifier publisher.')
                self.rpc_server = messaging.get_rpc_server(
                    transport, cfg.CONF.publisher_rpc.metering_topic, self)

            sample_target = oslo_messaging.Target(
                topic=cfg.CONF.publisher_notifier.metering_topic)
            self.sample_listener = messaging.get_notification_listener(
                transport, [sample_target],
                [SampleEndpoint(self.dispatcher_manager)],
                allow_requeue=(
                    cfg.CONF.collector.requeue_sample_on_dispatcher_error))

            if cfg.CONF.notification.store_events:
                event_target = oslo_messaging.Target(
                    topic=cfg.CONF.publisher_notifier.event_topic)
                self.event_listener = messaging.get_notification_listener(
                    transport, [event_target],
                    [EventEndpoint(self.dispatcher_manager)],
                    allow_requeue=(
                        cfg.CONF.collector.requeue_event_on_dispatcher_error))
                self.event_listener.start()

            if cfg.CONF.collector.enable_rpc:
                self.rpc_server.start()
            self.sample_listener.start()

            if not cfg.CONF.collector.udp_address:
                # Add a dummy thread to have wait() working
                self.tg.add_timer(604800, lambda: None)
Exemplo n.º 4
0
    def start(self):
        super(NotificationService, self).start()
        # FIXME(sileht): endpoint use notification_topics option
        # and it should not because this is oslo.messaging option
        # not a ceilometer, until we have a something to get
        # the notification_topics in an other way
        # we must create a transport to ensure the option have
        # beeen registered by oslo.messaging
        transport = messaging.get_transport()
        messaging.get_notifier(transport, '')

        self.pipeline_manager = pipeline.setup_pipeline()

        self.notification_manager = self._get_notifications_manager(
            self.pipeline_manager)
        if not list(self.notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints = [event_endpoint.EventsNotificationEndpoint()]

        targets = []
        for ext in self.notification_manager:
            handler = ext.obj
            LOG.debug(
                _('Event types from %(name)s: %(type)s'
                  ' (ack_on_error=%(error)s)') % {
                      'name': ext.name,
                      'type': ', '.join(handler.event_types),
                      'error': ack_on_error
                  })
            # NOTE(gordc): this could be a set check but oslo.messaging issue
            # https://bugs.launchpad.net/oslo.messaging/+bug/1398511
            # This ensures we don't create multiple duplicate consumers.
            for new_tar in handler.get_targets(cfg.CONF):
                if new_tar not in targets:
                    targets.append(new_tar)
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        self.listeners = []
        for url in urls:
            transport = messaging.get_transport(url)
            listener = messaging.get_notification_listener(
                transport, targets, endpoints)
            listener.start()
            self.listeners.append(listener)

        # Add a dummy thread to have wait() working
        self.tg.add_timer(604800, lambda: None)
Exemplo n.º 5
0
    def start(self):
        super(NotificationService, self).start()
        # FIXME(sileht): endpoint use notification_topics option
        # and it should not because this is oslo.messaging option
        # not a ceilometer, until we have a something to get
        # the notification_topics in an other way
        # we must create a transport to ensure the option have
        # beeen registered by oslo.messaging
        transport = messaging.get_transport()
        messaging.get_notifier(transport, '')

        self.pipeline_manager = pipeline.setup_pipeline()

        self.notification_manager = self._get_notifications_manager(
            self.pipeline_manager)
        if not list(self.notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints = [event_endpoint.EventsNotificationEndpoint()]

        targets = []
        for ext in self.notification_manager:
            handler = ext.obj
            LOG.debug(_('Event types from %(name)s: %(type)s'
                        ' (ack_on_error=%(error)s)') %
                      {'name': ext.name,
                       'type': ', '.join(handler.event_types),
                       'error': ack_on_error})
            # NOTE(gordc): this could be a set check but oslo.messaging issue
            # https://bugs.launchpad.net/oslo.messaging/+bug/1398511
            # This ensures we don't create multiple duplicate consumers.
            for new_tar in handler.get_targets(cfg.CONF):
                if new_tar not in targets:
                    targets.append(new_tar)
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        self.listeners = []
        for url in urls:
            transport = messaging.get_transport(url)
            listener = messaging.get_notification_listener(
                transport, targets, endpoints)
            listener.start()
            self.listeners.append(listener)

        # Add a dummy thread to have wait() working
        self.tg.add_timer(604800, lambda: None)
Exemplo n.º 6
0
    def start(self):
        """Bind the UDP socket and handle incoming data."""
        # ensure dispatcher is configured before starting other services
        dispatcher_managers = dispatcher.load_dispatcher_manager()
        (self.meter_manager, self.event_manager) = dispatcher_managers
        self.sample_listener = None
        self.event_listener = None
        super(CollectorService, self).start()

        if cfg.CONF.collector.udp_address:
            self.tg.add_thread(self.start_udp)

        transport = messaging.get_transport(optional=True)
        if transport:
            if list(self.meter_manager):
                sample_target = oslo_messaging.Target(
                    topic=cfg.CONF.publisher_notifier.metering_topic)
                self.sample_listener = messaging.get_notification_listener(
                    transport, [sample_target],
                    [SampleEndpoint(self.meter_manager)],
                    allow_requeue=(
                        cfg.CONF.collector.requeue_sample_on_dispatcher_error))
                self.sample_listener.start()

            if cfg.CONF.notification.store_events and list(self.event_manager):
                event_target = oslo_messaging.Target(
                    topic=cfg.CONF.publisher_notifier.event_topic)
                self.event_listener = messaging.get_notification_listener(
                    transport, [event_target],
                    [EventEndpoint(self.event_manager)],
                    allow_requeue=(
                        cfg.CONF.collector.requeue_event_on_dispatcher_error))
                self.event_listener.start()

            if not cfg.CONF.collector.udp_address:
                # Add a dummy thread to have wait() working
                self.tg.add_timer(604800, lambda: None)
Exemplo n.º 7
0
    def _configure_pipeline_listeners(self, reuse_listeners=False):
        with self.coord_lock:
            ev_pipes = []
            if cfg.CONF.notification.store_events:
                ev_pipes = self.event_pipeline_manager.pipelines
            pipelines = self.pipeline_manager.pipelines + ev_pipes
            transport = messaging.get_transport()
            partitioned = self.partition_coordinator.extract_my_subset(
                self.group_id,
                range(cfg.CONF.notification.pipeline_processing_queues))

            queue_set = {}
            for pipe_set, pipe in itertools.product(partitioned, pipelines):
                queue_set['%s-%s-%s' %
                          (self.NOTIFICATION_IPC, pipe.name, pipe_set)] = pipe

            if reuse_listeners:
                topics = queue_set.keys()
                kill_list = []
                for listener in self.pipeline_listeners:
                    if listener.dispatcher.targets[0].topic in topics:
                        queue_set.pop(listener.dispatcher.targets[0].topic)
                    else:
                        kill_list.append(listener)
                for listener in kill_list:
                    utils.kill_listeners([listener])
                    self.pipeline_listeners.remove(listener)
            else:
                utils.kill_listeners(self.pipeline_listeners)
                self.pipeline_listeners = []

            for topic, pipe in queue_set.items():
                LOG.debug('Pipeline endpoint: %s from set: %s', pipe.name,
                          pipe_set)
                pipe_endpoint = (pipeline.EventPipelineEndpoint
                                 if isinstance(pipe, pipeline.EventPipeline)
                                 else pipeline.SamplePipelineEndpoint)
                listener = messaging.get_notification_listener(
                    transport,
                    [oslo_messaging.Target(topic=topic)],
                    [pipe_endpoint(self.ctxt, pipe)])
                listener.start()
                self.pipeline_listeners.append(listener)
Exemplo n.º 8
0
    def _configure_main_queue_listeners(self, pipe_manager,
                                        event_pipe_manager):
        notification_manager = self._get_notifications_manager(pipe_manager)
        if not list(notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints.append(
                event_endpoint.EventsNotificationEndpoint(event_pipe_manager))

        targets = []
        for ext in notification_manager:
            handler = ext.obj
            if (cfg.CONF.notification.disable_non_metric_meters
                    and isinstance(handler, base.NonMetricNotificationBase)):
                continue
            LOG.debug(
                _('Event types from %(name)s: %(type)s'
                  ' (ack_on_error=%(error)s)') % {
                      'name': ext.name,
                      'type': ', '.join(handler.event_types),
                      'error': ack_on_error
                  })
            # NOTE(gordc): this could be a set check but oslo_messaging issue
            # https://bugs.launchpad.net/oslo.messaging/+bug/1398511
            # This ensures we don't create multiple duplicate consumers.
            for new_tar in handler.get_targets(cfg.CONF):
                if new_tar not in targets:
                    targets.append(new_tar)
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        for url in urls:
            transport = messaging.get_transport(url)
            listener = messaging.get_notification_listener(
                transport, targets, endpoints)
            listener.start()
            self.listeners.append(listener)
Exemplo n.º 9
0
    def _configure_pipeline_listeners(self, reuse_listeners=False):
        with self.coord_lock:
            ev_pipes = []
            if cfg.CONF.notification.store_events:
                ev_pipes = self.event_pipeline_manager.pipelines
            pipelines = self.pipeline_manager.pipelines + ev_pipes
            transport = messaging.get_transport()
            partitioned = self.partition_coordinator.extract_my_subset(
                self.group_id,
                range(cfg.CONF.notification.pipeline_processing_queues))

            queue_set = {}
            for pipe_set, pipe in itertools.product(partitioned, pipelines):
                queue_set['%s-%s-%s' %
                          (self.NOTIFICATION_IPC, pipe.name, pipe_set)] = pipe

            if reuse_listeners:
                topics = queue_set.keys()
                kill_list = []
                for listener in self.pipeline_listeners:
                    if listener.dispatcher.targets[0].topic in topics:
                        queue_set.pop(listener.dispatcher.targets[0].topic)
                    else:
                        kill_list.append(listener)
                for listener in kill_list:
                    utils.kill_listeners([listener])
                    self.pipeline_listeners.remove(listener)
            else:
                utils.kill_listeners(self.pipeline_listeners)
                self.pipeline_listeners = []

            for topic, pipe in queue_set.items():
                LOG.debug('Pipeline endpoint: %s from set: %s', pipe.name,
                          pipe_set)
                pipe_endpoint = (pipeline.EventPipelineEndpoint if isinstance(
                    pipe, pipeline.EventPipeline) else
                                 pipeline.SamplePipelineEndpoint)
                listener = messaging.get_notification_listener(
                    transport, [oslo_messaging.Target(topic=topic)],
                    [pipe_endpoint(self.ctxt, pipe)])
                listener.start()
                self.pipeline_listeners.append(listener)
Exemplo n.º 10
0
 def _configure_pipeline_listeners(self):
     self.pipeline_listeners = []
     ev_pipes = []
     if cfg.CONF.notification.store_events:
         ev_pipes = self.event_pipeline_manager.pipelines
     partitioned = self.partition_coordinator.extract_my_subset(
         self.group_id, self.pipeline_manager.pipelines + ev_pipes)
     transport = messaging.get_transport()
     for pipe in partitioned:
         LOG.debug(_('Pipeline endpoint: %s'), pipe.name)
         pipe_endpoint = (pipeline.EventPipelineEndpoint if isinstance(
             pipe, pipeline.EventPipeline) else
                          pipeline.SamplePipelineEndpoint)
         listener = messaging.get_notification_listener(
             transport, [
                 oslo_messaging.Target(topic='%s-%s' %
                                       (self.NOTIFICATION_IPC, pipe.name))
             ], [pipe_endpoint(self.ctxt, pipe)])
         listener.start()
         self.pipeline_listeners.append(listener)
Exemplo n.º 11
0
    def _configure_main_queue_listeners(self, pipe_manager,
                                        event_pipe_manager):
        notification_manager = self._get_notifications_manager(pipe_manager)
        if not list(notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints.append(
                event_endpoint.EventsNotificationEndpoint(event_pipe_manager))

        targets = []
        for ext in notification_manager:
            handler = ext.obj
            if (cfg.CONF.notification.disable_non_metric_meters and
                    isinstance(handler, base.NonMetricNotificationBase)):
                continue
            LOG.debug(_('Event types from %(name)s: %(type)s'
                        ' (ack_on_error=%(error)s)') %
                      {'name': ext.name,
                       'type': ', '.join(handler.event_types),
                       'error': ack_on_error})
            # NOTE(gordc): this could be a set check but oslo_messaging issue
            # https://bugs.launchpad.net/oslo.messaging/+bug/1398511
            # This ensures we don't create multiple duplicate consumers.
            for new_tar in handler.get_targets(cfg.CONF):
                if new_tar not in targets:
                    targets.append(new_tar)
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        for url in urls:
            transport = messaging.get_transport(url)
            listener = messaging.get_notification_listener(
                transport, targets, endpoints)
            listener.start()
            self.listeners.append(listener)
Exemplo n.º 12
0
    def start(self):
        super(NotificationService, self).start()
        self.pipeline_manager = pipeline.setup_pipeline()

        self.notification_manager = self._get_notifications_manager(
            self.pipeline_manager)
        if not list(self.notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints = [event_endpoint.EventsNotificationEndpoint()]

        targets = []
        for ext in self.notification_manager:
            handler = ext.obj
            LOG.debug(
                _('Event types from %(name)s: %(type)s'
                  ' (ack_on_error=%(error)s)') % {
                      'name': ext.name,
                      'type': ', '.join(handler.event_types),
                      'error': ack_on_error
                  })
            targets.extend(handler.get_targets(cfg.CONF))
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        self.listeners = []
        for url in urls:
            listener = messaging.get_notification_listener(
                targets, endpoints, url)
            listener.start()
            self.listeners.append(listener)

        # Add a dummy thread to have wait() working
        self.tg.add_timer(604800, lambda: None)
Exemplo n.º 13
0
    def start(self):
        super(NotificationService, self).start()
        self.pipeline_manager = pipeline.setup_pipeline()

        self.notification_manager = self._get_notifications_manager(
            self.pipeline_manager)
        if not list(self.notification_manager):
            LOG.warning(_('Failed to load any notification handlers for %s'),
                        self.NOTIFICATION_NAMESPACE)

        ack_on_error = cfg.CONF.notification.ack_on_event_error

        endpoints = []
        if cfg.CONF.notification.store_events:
            endpoints = [event_endpoint.EventsNotificationEndpoint()]

        targets = []
        for ext in self.notification_manager:
            handler = ext.obj
            LOG.debug(_('Event types from %(name)s: %(type)s'
                        ' (ack_on_error=%(error)s)') %
                      {'name': ext.name,
                       'type': ', '.join(handler.event_types),
                       'error': ack_on_error})
            targets.extend(handler.get_targets(cfg.CONF))
            endpoints.append(handler)

        urls = cfg.CONF.notification.messaging_urls or [None]
        self.listeners = []
        for url in urls:
            listener = messaging.get_notification_listener(targets,
                                                           endpoints,
                                                           url)
            listener.start()
            self.listeners.append(listener)

        # Add a dummy thread to have wait() working
        self.tg.add_timer(604800, lambda: None)