Revision 58b22b6e lib/jqueue.py
b/lib/jqueue.py | ||
---|---|---|
49 | 49 |
|
50 | 50 |
|
51 | 51 |
JOBQUEUE_THREADS = 25 |
52 |
JOBS_PER_ARCHIVE_DIRECTORY = 10000 |
|
52 | 53 |
|
53 | 54 |
|
54 | 55 |
class CancelJob(Exception): |
... | ... | |
714 | 715 |
@param new: the new name of the file |
715 | 716 |
|
716 | 717 |
""" |
717 |
os.rename(old, new)
|
|
718 |
utils.RenameFile(old, new, mkdir=True)
|
|
718 | 719 |
|
719 | 720 |
names, addrs = self._GetNodeIp() |
720 | 721 |
result = rpc.RpcRunner.call_jobqueue_rename(names, addrs, old, new) |
... | ... | |
741 | 742 |
|
742 | 743 |
return str(job_id) |
743 | 744 |
|
745 |
@classmethod |
|
746 |
def _GetArchiveDirectory(cls, job_id): |
|
747 |
"""Returns the archive directory for a job. |
|
748 |
|
|
749 |
@type job_id: str |
|
750 |
@param job_id: Job identifier |
|
751 |
@rtype: str |
|
752 |
@return: Directory name |
|
753 |
|
|
754 |
""" |
|
755 |
return str(int(job_id) / JOBS_PER_ARCHIVE_DIRECTORY) |
|
756 |
|
|
744 | 757 |
def _NewSerialUnlocked(self): |
745 | 758 |
"""Generates a new job identifier. |
746 | 759 |
|
... | ... | |
774 | 787 |
""" |
775 | 788 |
return os.path.join(constants.QUEUE_DIR, "job-%s" % job_id) |
776 | 789 |
|
777 |
@staticmethod
|
|
778 |
def _GetArchivedJobPath(job_id): |
|
790 |
@classmethod
|
|
791 |
def _GetArchivedJobPath(cls, job_id):
|
|
779 | 792 |
"""Returns the archived job file for a give job id. |
780 | 793 |
|
781 | 794 |
@type job_id: str |
... | ... | |
784 | 797 |
@return: the path to the archived job file |
785 | 798 |
|
786 | 799 |
""" |
787 |
return os.path.join(constants.JOB_QUEUE_ARCHIVE_DIR, "job-%s" % job_id) |
|
800 |
path = "%s/job-%s" % (cls._GetArchiveDirectory(job_id), job_id) |
|
801 |
return os.path.join(constants.JOB_QUEUE_ARCHIVE_DIR, path) |
|
788 | 802 |
|
789 | 803 |
@classmethod |
790 | 804 |
def _ExtractJobID(cls, name): |
Also available in: Unified diff