(self, instance)
Pops `batch_morlist_size` items from the mor objects queue and run asynchronously
        the _process_mor_objects_queue_async method to fill the Mor cache.
Pops `batch_morlist_size` items from the mor objects queue and run asynchronously
        the _process_mor_objects_queue_async method to fill the Mor cache.
Pops batch_morlist_size items from the mor objects queue and run asynchronously the _process_mor_objects_queue_async method to fill the Mor cache .
def _process_mor_objects_queue(self, instance):
        """
        Pops `batch_morlist_size` items from the mor objects queue and run asynchronously
        the _process_mor_objects_queue_async method to fill the Mor cache.
        """
        i_key = self._instance_key(instance)
        self.mor_cache.init_instance(i_key)

        if not self.mor_objects_queue.contains(i_key):
            self.log.debug("Objects queue is not initialized yet for instance %s, skipping processing", i_key)
            return

        # Simply move the realtime mors from the queue to the cache
        for resource_type in RESOURCE_TYPE_METRICS_REALTIME:
            while self.mor_objects_queue.size(i_key, resource_type):
                mor = self.mor_objects_queue.pop(i_key, resource_type)
                if self._is_main_instance(instance):
                    mor_name = str(mor['mor'])
                    mor['interval'] = REAL_TIME_INTERVAL
                    self.mor_cache.set_mor(i_key, mor_name, mor)

        # Move the mors with historical metrics from the queue to the cache and also fetch their list of metrics.
        for resource_type in RESOURCE_TYPE_METRICS_HISTORICAL:
            # Batch size can prevent querying large payloads at once if the environment is too large
            # If batch size is set to 0, process everything at once
            batch_size = self.batch_morlist_size or self.mor_objects_queue.size(i_key, resource_type)
            while self.mor_objects_queue.size(i_key, resource_type):
                hist_mors = []
                for _ in range(batch_size):
                    mor = self.mor_objects_queue.pop(i_key, resource_type)
                    if mor is None:
                        self.log.debug("No more objects of type '%s' left in the queue", ensure_unicode(resource_type))
                        break

                    mor_name = str(mor['mor'])
                    self.mor_cache.set_mor(i_key, mor_name, mor)

                    hist_mors.append(mor)

                # We will actually schedule jobs for non realtime resources only.
                if self._should_collect_historical(instance):
                    self.pool.apply_async(self._process_mor_objects_queue_async, args=(instance, hist_mors))
def _process_mor_objects_queue ( self , instance ) : i_key = self . _instance_key ( instance ) self . mor_cache . init_instance ( i_key ) if not self . mor_objects_queue . contains ( i_key ) : self . log . debug ( "Objects queue is not initialized yet for instance %s, skipping processing" , i_key ) return # Simply move the realtime mors from the queue to the cache for resource_type in RESOURCE_TYPE_METRICS_REALTIME : while self . mor_objects_queue . size ( i_key , resource_type ) : mor = self . mor_objects_queue . pop ( i_key , resource_type ) if self . _is_main_instance ( instance ) : mor_name = str ( mor [ 'mor' ] ) mor [ 'interval' ] = REAL_TIME_INTERVAL self . mor_cache . set_mor ( i_key , mor_name , mor ) # Move the mors with historical metrics from the queue to the cache and also fetch their list of metrics. for resource_type in RESOURCE_TYPE_METRICS_HISTORICAL : # Batch size can prevent querying large payloads at once if the environment is too large # If batch size is set to 0, process everything at once batch_size = self . batch_morlist_size or self . mor_objects_queue . size ( i_key , resource_type ) while self . mor_objects_queue . size ( i_key , resource_type ) : hist_mors = [ ] for _ in range ( batch_size ) : mor = self . mor_objects_queue . pop ( i_key , resource_type ) if mor is None : self . log . debug ( "No more objects of type '%s' left in the queue" , ensure_unicode ( resource_type ) ) break mor_name = str ( mor [ 'mor' ] ) self . mor_cache . set_mor ( i_key , mor_name , mor ) hist_mors . append ( mor ) # We will actually schedule jobs for non realtime resources only. if self . _should_collect_historical ( instance ) : self . pool . apply_async ( self . _process_mor_objects_queue_async , args = ( instance , hist_mors ) )