예제 #1
0
    def __init__(self, host, virtual_host, port=61680,
                 realm='Apollo', username='******', password='******',
                 update_interval_s=5):
        """Construct a new ApolloMonitor that monitors the $virtual_host
           virtual-host on the Apollo server at $host:$port with credentials
           $username and $password.  Monitor for update events every
           $update_interval_s seconds (or, if seconds is None, not at all)."""
        # Prepare a URL opener
        self.auth = (username, password)
        self._url = ('http://%s:%d/broker/virtual-hosts/%s'
                     % (host, port, virtual_host))
        self._url_queues = self._url + '/queues.json'
        self._url_delete = self._url + '/queues/%s.json'
        self._s = Session()

        # Initialize the queue status dictionary
        self.queues = self._structure_queue_data(self._get_queue_data())
        for queue in self.queues.values():
            self.on_queue_init(queue)

        # Initialize the update wait event
        self.update_event = Event()
        self.update_event.clear()

        # Run updates in a loop
        if update_interval_s is not None:
            call_periodic(update_interval_s, self.do_update)
예제 #2
0
    def __init__(self,
                 host,
                 virtual_host,
                 port=61680,
                 realm='Apollo',
                 username='******',
                 password='******',
                 update_interval_s=5):
        """Construct a new ApolloMonitor that monitors the $virtual_host
           virtual-host on the Apollo server at $host:$port with credentials
           $username and $password.  Monitor for update events every
           $update_interval_s seconds (or, if seconds is None, not at all)."""
        # Prepare a URL opener
        self.auth = (username, password)
        self._url = ('http://%s:%d/broker/virtual-hosts/%s' %
                     (host, port, virtual_host))
        self._url_queues = self._url + '/queues.json'
        self._url_delete = self._url + '/queues/%s.json'
        self._s = Session()

        # Initialize the queue status dictionary
        self.queues = self._structure_queue_data(self._get_queue_data())
        for queue in self.queues.values():
            self.on_queue_init(queue)

        # Initialize the update wait event
        self.update_event = Event()
        self.update_event.clear()

        # Run updates in a loop
        if update_interval_s is not None:
            call_periodic(update_interval_s, self.do_update)
예제 #3
0
 def start_updating(self):
     if self.updater is None:
         self.updater = call_periodic(self.interval, self.do_update)
예제 #4
0
 def start_updating(self):
     if self.updater is None:
         self.updater = call_periodic(self.interval, self.do_update)