The task of archiving jobs is now done by luxid.

Signed-off-by: Klaus Aehlig <[email protected]>
---
 lib/jqueue/__init__.py | 76 --------------------------------------------------
 1 file changed, 76 deletions(-)

diff --git a/lib/jqueue/__init__.py b/lib/jqueue/__init__.py
index 1f61d58..5897ab9 100644
--- a/lib/jqueue/__init__.py
+++ b/lib/jqueue/__init__.py
@@ -2338,82 +2338,6 @@ class JobQueue(object):
     self._UpdateQueueSizeUnlocked()
     return len(archive_jobs)
 
-  @locking.ssynchronized(_LOCK)
-  def ArchiveJob(self, job_id):
-    """Archives a job.
-
-    This is just a wrapper over L{_ArchiveJobsUnlocked}.
-
-    @type job_id: int
-    @param job_id: Job ID of job to be archived.
-    @rtype: bool
-    @return: Whether job was archived
-
-    """
-    logging.info("Archiving job %s", job_id)
-
-    job = self._LoadJobUnlocked(job_id)
-    if not job:
-      logging.debug("Job %s not found", job_id)
-      return False
-
-    return self._ArchiveJobsUnlocked([job]) == 1
-
-  @locking.ssynchronized(_LOCK)
-  def AutoArchiveJobs(self, age, timeout):
-    """Archives all jobs based on age.
-
-    The method will archive all jobs which are older than the age
-    parameter. For jobs that don't have an end timestamp, the start
-    timestamp will be considered. The special '-1' age will cause
-    archival of all jobs (that are not running or queued).
-
-    @type age: int
-    @param age: the minimum age in seconds
-
-    """
-    logging.info("Archiving jobs with age more than %s seconds", age)
-
-    now = time.time()
-    end_time = now + timeout
-    archived_count = 0
-    last_touched = 0
-
-    all_job_ids = self._GetJobIDsUnlocked()
-    pending = []
-    for idx, job_id in enumerate(all_job_ids):
-      last_touched = idx + 1
-
-      # Not optimal because jobs could be pending
-      # TODO: Measure average duration for job archival and take number of
-      # pending jobs into account.
-      if time.time() > end_time:
-        break
-
-      # Returns None if the job failed to load
-      job = self._LoadJobUnlocked(job_id)
-      if job:
-        if job.end_timestamp is None:
-          if job.start_timestamp is None:
-            job_age = job.received_timestamp
-          else:
-            job_age = job.start_timestamp
-        else:
-          job_age = job.end_timestamp
-
-        if age == -1 or now - job_age[0] > age:
-          pending.append(job)
-
-          # Archive 10 jobs at a time
-          if len(pending) >= 10:
-            archived_count += self._ArchiveJobsUnlocked(pending)
-            pending = []
-
-    if pending:
-      archived_count += self._ArchiveJobsUnlocked(pending)
-
-    return (archived_count, len(all_job_ids) - last_touched)
-
   def _Query(self, fields, qfilter):
     qobj = query.Query(query.JOB_FIELDS, fields, qfilter=qfilter,
                        namefield="id")
-- 
2.0.0.526.g5318336

Reply via email to