PHP 7.4.33
Preview: result_queue.py Size: 1.99 KB
/usr/lib/fm-agent/library/result_queue.py

class ResultQueue(object):
    """If the aggregator can't be reached for some reason, we want
    to still keep calculating results and store them locally until we can reach the agg
    again."""

    # Variables for ResultQueue
    # QUEUE_MAX_RESULTS = 150000     # We put results in a queue if aggregator can't be reached.
    # QUEUE_BATCH_SIZE = 10000       # How many queue results we send back to the aggregator at once

    def __init__(self, queue_max_results=None, queue_batch_size=None):
        self.data = []
        self.queue_max_results = queue_max_results
        if self.queue_max_results is None:
            self.queue_max_results = 150000
        self.queue_batch_size = queue_batch_size
        if self.queue_batch_size is None:
            self.queue_batch_size = 10000

    def pop(self):
        # remove the oldest results first
        self.data.pop(0)

    # Pop only the most recent result
    def pop_latest(self):
        self.data.pop()

    def pop_results(self, chunk=None):
        if chunk is None:
            chunk = self.queue_batch_size
        # Pop and return 'chunk' of the newest items
        if len(self.data) <= chunk:
            result = self.data
            self.data = []

        else:
            x = len(self.data) - chunk
            result = self.data[x:]
            self.data = self.data[:x]

        return result

    def push(self, result):
        if len(self.data) == self.queue_max_results:
            self.pop()
        self.data.append(result)

    def update(self, results):
        if len(results) + len(self.data) <= self.queue_max_results:
            self.data.extend(results)
        else:
            # Make room so we stay under QUEUE_MAX_RESULTS
            free_space = self.queue_max_results - len(self.data)
            removal = len(results) - free_space
            self.data = self.data[removal:]
            self.data.extend(results)

    def isEmpty(self):
        return len(self.data) == 0

    def queueLength(self):
        return len(self.data)

Directory Contents

Dirs: 1 × Files: 23

Name Size Perms Modified Actions
- drwxr-xr-x 2025-06-19 05:08:01
Edit Download
107.89 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
110 B lrw-r--r-- 2025-06-18 20:44:50
Edit Download
9.19 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
14.82 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.17 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
807 B lrw-r--r-- 2025-06-18 20:44:50
Edit Download
3.54 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.12 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.99 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
16.17 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
2.97 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.96 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
4.25 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
3.62 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.34 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
5.32 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
11.69 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
872 B lrw-r--r-- 2025-06-18 20:44:50
Edit Download
874 B lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.99 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
3.23 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
1.48 KB lrw-r--r-- 2025-06-18 20:44:50
Edit Download
0 B lrw-r--r-- 2025-06-18 20:44:50
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).