module documentation

Module implementing the job queue handling.

Function CheckDrainFlag Check if the queue is marked to be drained.
Function FormatJobID Convert a job ID to int format.
Function GetArchiveDirectory Returns the archive directory for a job.
Function InitAndVerifyQueue Open and lock job queue.
Function ParseJobId Parses a job ID and converts it to integer.
Function ReadSerial Read the serial file.
Function ReadVersion Read the queue version.
Function SetDrainFlag Sets the drain flag for the queue.
Function _ReadNumericFile Reads a file containing a number.
def CheckDrainFlag():

Check if the queue is marked to be drained.

This currently uses the queue drain file, which makes it a per-node flag. In the future this can be moved to the config file.

Returns
booleanTrue if the job queue is marked drained
def FormatJobID(job_id):

Convert a job ID to int format.

Currently this just is a no-op that performs some checks, but if we want to change the job id format this will abstract this change.

Parameters
job_id:int or longthe numeric job id
Returns
intthe formatted job id
def GetArchiveDirectory(job_id):

Returns the archive directory for a job.

Parameters
job_id:strJob identifier
Returns
strDirectory name
def InitAndVerifyQueue(must_lock):

Open and lock job queue.

If necessary, the queue is automatically initialized.

Parameters
must_lock:boolWhether an exclusive lock must be held.
Returns
utils.FileLockLock object for the queue. This can be used to change the locking mode.
def ParseJobId(job_id):

Parses a job ID and converts it to integer.

def ReadSerial():

Read the serial file.

The queue should be locked while this function is called.

def ReadVersion():

Read the queue version.

The queue should be locked while this function is called.

def SetDrainFlag(drain_flag):

Sets the drain flag for the queue.

Parameters
drain_flag:booleanWhether to set or unset the drain flag
Unknown Field: attention
This function should only called the current holder of the queue lock
def _ReadNumericFile(file_name):

Reads a file containing a number.

Returns
None or intNone if file is not found, otherwise number