Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

batch_job.h File Reference


Detailed Description

Batch job submission.

This module implements batch job submission to multiple systems, including Condor, SGE, Work Queue, and local Unix processes. This simplifies the construction of parallel abstractions that need a simple form of parallel process execution.

#include <time.h>

Go to the source code of this file.

Data Structures

struct  batch_job_info
 Describes a batch job when it has completed. More...

Typedefs

typedef int batch_job_id_t
 An integer type indicating a unique batch job number.

Enumerations

enum  batch_queue_type_t {
  BATCH_QUEUE_TYPE_UNKNOWN = -1,
  BATCH_QUEUE_TYPE_UNIX,
  BATCH_QUEUE_TYPE_CONDOR,
  BATCH_QUEUE_TYPE_SGE,
  BATCH_QUEUE_TYPE_WORK_QUEUE
}
 Indicates which type of batch submission to use. More...

Functions

batch_queue * batch_queue_create (batch_queue_type_t type)
 Create a new batch queue.
batch_job_id_t batch_job_submit_simple (struct batch_queue *q, const char *cmdline, const char *input_files, const char *output_files)
 Submit a simple batch job.
batch_job_id_t batch_job_submit (struct batch_queue *q, const char *cmd, const char *args, const char *infile, const char *outfile, const char *errfile, const char *extra_input_files, const char *extra_output_files)
 Submit a batch job.
batch_job_id_t batch_job_wait (struct batch_queue *q, struct batch_job_info *info)
 Wait for any batch job to complete.
batch_job_id_t batch_job_wait_timeout (struct batch_queue *q, struct batch_job_info *info, time_t stoptime)
 Wait for any batch job to complete, with a timeout.
int batch_job_remove (struct batch_queue *q, batch_job_id_t jobid)
 Remove a batch job.
batch_queue_type_t batch_queue_type_from_string (const char *str)
 Converts a string into a batch queue type.
const char * batch_queue_type_to_string (batch_queue_type_t t)
 Converts a batch queue type to a string.
void batch_queue_set_logfile (struct batch_queue *q, const char *logfile)
 Set the log file used by the batch queue.
void batch_queue_set_options (struct batch_queue *q, const char *options)
 Add extra options to pass to the underlying batch system.
void batch_queue_delete (struct batch_queue *q)
 Delete a batch queue.


Typedef Documentation

typedef int batch_job_id_t
 

An integer type indicating a unique batch job number.


Enumeration Type Documentation

enum batch_queue_type_t
 

Indicates which type of batch submission to use.

Enumeration values:
BATCH_QUEUE_TYPE_UNKNOWN  An invalid batch queue type.
BATCH_QUEUE_TYPE_UNIX  Batch jobs will run as local Unix processes.
BATCH_QUEUE_TYPE_CONDOR  Batch jobs will be sent to Condor pool.
BATCH_QUEUE_TYPE_SGE  Batch jobs will be sent to Sun Grid Engine.
BATCH_QUEUE_TYPE_WORK_QUEUE  Batch jobs will be send to the Work Queue.


Function Documentation

struct batch_queue* batch_queue_create batch_queue_type_t  type  ) 
 

Create a new batch queue.

Parameters:
type The type of the queue.
Returns:
A new batch queue object on success, null on failure.

batch_job_id_t batch_job_submit_simple struct batch_queue *  q,
const char *  cmdline,
const char *  input_files,
const char *  output_files
 

Submit a simple batch job.

Parameters:
q The queue to submit to.
cmdline The command line to execute. This line will be interpreted by the shell, so it may include output redirection, multiple commands, pipes, and so forth.
input_files A comma separated list of all input files that will be required by the job. Null pointer is equivalent to empty string. This must also include the executable and any dependent programs.
output_files A comma separated list of all output files to retrieve from the job. Null pointer is equivalent to empty string.
Returns:
On success, returns a unique identifier for the batch job. On failure, returns a negative number.

batch_job_id_t batch_job_submit struct batch_queue *  q,
const char *  cmd,
const char *  args,
const char *  infile,
const char *  outfile,
const char *  errfile,
const char *  extra_input_files,
const char *  extra_output_files
 

Submit a batch job.

Parameters:
q The queue to submit to.
cmd The command to execute.
args The command line arguments.
infile The standard input file.
outfile The standard output file.
errfile The standard error file.
extra_input_files A comma separated list of extra input files that will be required by the job. Null pointer is equivalent to empty string.
extra_output_files A comma separated list of extra output files to retrieve from the job. Null pointer is equivalent to empty string.
Returns:
On success, returns a unique positive jobid. Zero or a negative number indicates a failure to submit this job.

batch_job_id_t batch_job_wait struct batch_queue *  q,
struct batch_job_info info
 

Wait for any batch job to complete.

Blocks until a batch job completes.

Parameters:
q The queue to wait on.
info Pointer to a batch_job_info structure that will be filled in with the details of the completed job.
Returns:
If greater than zero, indicates the jobid of the completed job. If equal to zero, there were no more jobs to wait for. If less than zero, the operation was interrupted by a system event, but may be tried again.

batch_job_id_t batch_job_wait_timeout struct batch_queue *  q,
struct batch_job_info info,
time_t  stoptime
 

Wait for any batch job to complete, with a timeout.

Blocks until a batch job completes or the current time exceeds stoptime.

Parameters:
q The queue to wait on.
info Pointer to a batch_job_info structure that will be filled in with the details of the completed job.
stoptime An absolute time at which to stop waiting. If less than or equal to the current time, then this function will check for a complete job but will not block.
Returns:
If greater than zero, indicates the jobid of the completed job. If equal to zero, there were no more jobs to wait for. If less than zero, the operation timed out or was interrupted by a system event, but may be tried again.

int batch_job_remove struct batch_queue *  q,
batch_job_id_t  jobid
 

Remove a batch job.

This call will start the removal process. You must still call batch_job_wait to wait for the removal to complete.

Parameters:
q The queue to remove from.
jobid The job to be removed.
Returns:
Greater than zero if the job exists and was removed, zero otherwise.

batch_queue_type_t batch_queue_type_from_string const char *  str  ) 
 

Converts a string into a batch queue type.

Parameters:
str A string indicating the work queue type, which may be "unix", "condor", "sge", or "wq".
Returns:
The batch queue type corresponding to the string, or BATCH_QUEUE_TYPE_UNKNOWN if the string is invalid.

const char* batch_queue_type_to_string batch_queue_type_t  t  ) 
 

Converts a batch queue type to a string.

Parameters:
t A batch_queue_type_t.
Returns:
A string corresponding to the batch queue type.

void batch_queue_set_logfile struct batch_queue *  q,
const char *  logfile
 

Set the log file used by the batch queue.

This is an optional call that will only affect batch queue types that use an internal logfile; currently only Condor.

Parameters:
q The batch queue to adjust.
logfile Name of the logfile to use.

void batch_queue_set_options struct batch_queue *  q,
const char *  options
 

Add extra options to pass to the underlying batch system.

This call specifies additional options to be passed to the batch system each time a job is submitted. It may be called once to apply to all subsequent jobs, or it may be called before each submission. If the queue type is BATCH_QUEUE_TYPE_CONDOR, the options must be valid submit file properties like requirements = (Memory>100). If the batch queue type is BATCH_QUEUE_TYPE_SGE, the extra text will be added as options to the qsub command. This call has no effect on other queue types.

Parameters:
q The batch queue to adjust.
options The options to pass to the batch system.

void batch_queue_delete struct batch_queue *  q  ) 
 

Delete a batch queue.

Note that this function just destroys the internal data structures, it does not abort running jobs. To properly clean up running jobs, you must call batch_job_wait until it returns zero, or call batch_job_remove on all runnings jobs.

Parameters:
q The queue to delete.


Generated on Thu Jul 23 09:26:51 2009 for cctools by  doxygen 1.3.9.1