Пример #1
0
    def started(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In started event.",
                              attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id

        # An existing wait_duration implies the patch had been started previously and is
        # being picked up again because it had expired, or was released.
        if patch_log.wait_duration is not None:
            patch_log.retry_count += 1
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_retry_count += 1
            queue_log.put()
        else:
            patch_log.calculate_wait_duration()
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_wait_durations.append(patch_log.wait_duration)
            queue_log.put()
Пример #2
0
    def started(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In started event.", attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id

        # An existing wait_duration implies the patch had been started previously and is
        # being picked up again because it had expired, or was released.
        if patch_log.wait_duration is not None:
            patch_log.retry_count += 1
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_retry_count += 1
            queue_log.put()
        else:
            patch_log.calculate_wait_duration()
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_wait_durations.append(patch_log.wait_duration)
            queue_log.put()
Пример #3
0
 def _get_queue_logs(self, queue_name, timestamp, view_range):
     queue_logs = []
     current_timestamp = timestamp - view_range
     while current_timestamp <= timestamp:
         queue_logs.append(QueueLog.get_at(queue_name, logging.queue_log_duration, current_timestamp))
         current_timestamp += logging.queue_log_duration
     return queue_logs
Пример #4
0
 def added(cls, attachment_id, queue_name):
     PatchLog.lookup(attachment_id, queue_name)
     queue_log = QueueLog.get_current(queue_name, queue_log_duration)
     patches_waiting = cls._get_patches_waiting(queue_name)
     if patches_waiting and queue_log.max_patches_waiting < patches_waiting:
         queue_log.max_patches_waiting = patches_waiting
         queue_log.put()
Пример #5
0
    def stopped(cls, attachment_id, queue_name, status_message, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In stopped event.",
                              attachment_id, queue_name, bot_id)
            return

        if patch_log.wait_duration is None:
            WarningLog.record("patchlog wait duration missing",
                              "In stopped event.", attachment_id, queue_name,
                              bot_id)
            return

        if not patch_log.finished:
            if bot_id:
                patch_log.bot_id = bot_id
            patch_log.finished = True
            patch_log.calculate_process_duration()
            patch_log.latest_message = status_message
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_process_durations.append(
                patch_log.process_duration)
            queue_log.put()
Пример #6
0
 def _get_queue_logs(self, queue_name, timestamp, view_range):
     queue_logs = []
     current_timestamp = timestamp - view_range
     while current_timestamp <= timestamp:
         queue_logs.append(
             QueueLog.get_at(queue_name, logging.queue_log_duration,
                             current_timestamp))
         current_timestamp += logging.queue_log_duration
     return queue_logs
Пример #7
0
    def retrying(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup(attachment_id, queue_name)
        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.retry_count += 1
        patch_log.put()

        queue_log = QueueLog.get_current(queue_name, queue_log_duration)
        queue_log.patch_retry_count += 1
        queue_log.put()
Пример #8
0
    def updated(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup(attachment_id, queue_name)
        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.status_update_count += 1
        patch_log.put()

        queue_log = QueueLog.get_current(queue_name, queue_log_duration)
        queue_log.status_update_count += 1
        queue_log.put()
Пример #9
0
    def started(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup(attachment_id, queue_name)
        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.calculate_wait_duration()
        patch_log.put()

        queue_log = QueueLog.get_current(queue_name, queue_log_duration)
        queue_log.patch_wait_durations.append(patch_log.wait_duration)
        queue_log.put()
Пример #10
0
    def stopped(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup(attachment_id, queue_name)
        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.finished = True
        patch_log.calculate_process_duration()
        patch_log.put()

        if patch_log.process_duration:
            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_process_durations.append(patch_log.process_duration)
            queue_log.put()
Пример #11
0
    def updated(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In updated event.", attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.status_update_count += 1
        patch_log.put()

        queue_log = QueueLog.get_current(queue_name, queue_log_duration)
        queue_log.status_update_count += 1
        queue_log.put()
    def updated(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In updated event.", attachment_id, queue_name, bot_id)
            return

        if bot_id:
            patch_log.bot_id = bot_id
        patch_log.status_update_count += 1
        patch_log.put()

        queue_log = QueueLog.get_current(queue_name, queue_log_duration)
        queue_log.status_update_count += 1
        queue_log.put()
    def stopped(cls, attachment_id, queue_name, bot_id=None):
        patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name)
        if not patch_log:
            WarningLog.record("patchlog missing", "In stopped event.", attachment_id, queue_name, bot_id)
            return

        if not patch_log.wait_duration:
            WarningLog.record("patchlog wait duration missing", "In stopped event.", attachment_id, queue_name, bot_id)
            return

        if not patch_log.finished:
            if bot_id:
                patch_log.bot_id = bot_id
            patch_log.finished = True
            patch_log.calculate_process_duration()
            patch_log.put()

            queue_log = QueueLog.get_current(queue_name, queue_log_duration)
            queue_log.patch_process_durations.append(patch_log.process_duration)
            queue_log.put()
Пример #14
0
 def added(cls, attachment_id, queue_name):
     PatchLog.lookup(attachment_id, queue_name)
     queue_log = QueueLog.get_current(queue_name, queue_log_duration)
     if queue_log.update_max_patches_waiting():
         queue_log.put()
Пример #15
0
 def get(self):
     for queue_name in all_queue_names:
         queue_log = QueueLog.get_current(queue_name, queue_log_duration)
         if queue_log.update_max_patches_waiting():
             queue_log.put()
     self.response.out.write("Done!")
Пример #16
0
 def record_activity(cls, queue_name, bot_id):
     queue_log = QueueLog.get_current(queue_name, queue_log_duration)
     if queue_log and bot_id not in queue_log.bot_ids_seen:
         queue_log.bot_ids_seen.append(bot_id)
         queue_log.put()
Пример #17
0
 def record_activity(cls, queue_name, bot_id):
     queue_log = QueueLog.get_current(queue_name, queue_log_duration)
     if queue_log and bot_id not in queue_log.bot_ids_seen:
         queue_log.bot_ids_seen.append(bot_id)
         queue_log.put()
Пример #18
0
 def added(cls, attachment_id, queue_name):
     PatchLog.lookup(attachment_id, queue_name)
     queue_log = QueueLog.get_current(queue_name, queue_log_duration)
     if queue_log.update_max_patches_waiting():
         queue_log.put()