cctools
batch_job.h File Reference

Represents a single batch job. More...

#include "list.h"
#include "jx.h"
#include "rmsummary.h"

Go to the source code of this file.

Data Structures

struct  batch_job
 Internal description of a single batch job submitted to a queue. More...
 

Functions

struct batch_jobbatch_job_create (struct batch_queue *queue)
 Create a batch_job struct.
 
void batch_job_delete (struct batch_job *t)
 Delete a batch_job struct.
 
struct batch_filebatch_job_add_input_file (struct batch_job *task, const char *outer_name, const char *inner_name)
 Add file to input list of batch_job Creates a new batch_file from outer_name and inner_name.
 
struct batch_filebatch_job_add_output_file (struct batch_job *task, const char *outer_name, const char *inner_name)
 Add file to output list of batch_job Creates a new batch_file from outer_name and inner_name.
 
void batch_job_set_command (struct batch_job *t, const char *command)
 Set the command of the batch_job.
 
void batch_job_set_command_spec (struct batch_job *t, struct jx *command)
 Set the batch task's command to the given JX command spec.
 
void batch_job_wrap_command (struct batch_job *t, const char *command)
 Wrap the existing command with a template string.
 
void batch_job_set_resources (struct batch_job *t, const struct rmsummary *resources)
 Set the resources needed for task.
 
void batch_job_set_envlist (struct batch_job *t, struct jx *envlist)
 Set the envlist for this task.
 
void batch_job_set_info (struct batch_job *t, struct batch_job_info *info)
 Set the batch_job_info of this task.
 
char * batch_job_generate_id (struct batch_job *t)
 Generate a sha1 hash based on the specified task.
 

Detailed Description

Represents a single batch job.

A batch_job describes a single batch job to be submitted to a batch queue using batch_queue_submit. This structure should not be manipulated manually, but created with batch_job_create and then elaborated with batch_job_set_command batch_job_add_input_file , batch_job_add_output_file and similar methods. This level of details permits the underlying system to appropriately manage the data used by each job. Once submitted to a queue, the batch_job object may be deleted.

Function Documentation

◆ batch_job_create()

struct batch_job * batch_job_create ( struct batch_queue queue)

Create a batch_job struct.

Parameters
queueThe queue this task is associated with/assigned to.
Returns
A batch_job struct in newly alloced space.

◆ batch_job_delete()

void batch_job_delete ( struct batch_job t)

Delete a batch_job struct.

This frees the command, deletes the files and lists, deletes the resources, and deletes envlist.

Parameters
tThe batch_job struct to be freed.

◆ batch_job_add_input_file()

struct batch_file * batch_job_add_input_file ( struct batch_job task,
const char *  outer_name,
const char *  inner_name 
)

Add file to input list of batch_job Creates a new batch_file from outer_name and inner_name.

This newly created file is add to input_files. For clarifications on outer_name, inner_name, and their uses see batch_file.

Parameters
taskThe batch_job this file is being added to.
outer_nameThe name of the file at submission/host site.
inner_nameThe name of the file at execution site.
Returns
A pointer to the newly allocated batch_file struct.

◆ batch_job_add_output_file()

struct batch_file * batch_job_add_output_file ( struct batch_job task,
const char *  outer_name,
const char *  inner_name 
)

Add file to output list of batch_job Creates a new batch_file from outer_name and inner_name.

This newly created file is add to output_files. For clarifications on outer_name, inner_name, and their uses see batch_file.

Parameters
taskThe batch_job this file is being added to.
outer_nameThe name of the file at submission/host site.
inner_nameThe name of the file at execution site.
Returns
A pointer to the newly allocated batch_file struct.

◆ batch_job_set_command()

void batch_job_set_command ( struct batch_job t,
const char *  command 
)

Set the command of the batch_job.

Frees previous command and xxstrdups new command.

Parameters
tThe batch_job to be updated.
commandThe new command to use.

◆ batch_job_set_command_spec()

void batch_job_set_command_spec ( struct batch_job t,
struct jx command 
)

Set the batch task's command to the given JX command spec.

The JX command spec is first expanded, and replaces the batch task's previous command.

Parameters
tThe batch_job to be updated.
commandThe spec to use.

◆ batch_job_wrap_command()

void batch_job_wrap_command ( struct batch_job t,
const char *  command 
)

Wrap the existing command with a template string.

This uses string_wrap_command to wrap command, see stringtools.h for details. This function allocates a new string with the result and free the previous command. Does not free passed command. Will use wrapper interface in future.

Parameters
tThe batch_job whose command is being wrapped.
commandThe command template that will wrap existing command.

◆ batch_job_set_resources()

void batch_job_set_resources ( struct batch_job t,
const struct rmsummary resources 
)

Set the resources needed for task.

This function will make a copy of full copy of resources using rmsummary_copy().

Parameters
tThe batch_job requiring specified resources.
resourcesA rmsummary specifying required resources.

◆ batch_job_set_envlist()

void batch_job_set_envlist ( struct batch_job t,
struct jx envlist 
)

Set the envlist for this task.

This function will make a copy using jx_copy of envlist.

Parameters
tThe batch_job using this environment.
envlistThe jx_object specifying the environment.

◆ batch_job_set_info()

void batch_job_set_info ( struct batch_job t,
struct batch_job_info info 
)

Set the batch_job_info of this task.

Performs simple copy into already allocated memory.

Parameters
tThe batch_job that was completed.
infoThe batch_job_info of the completed task.

◆ batch_job_generate_id()

char * batch_job_generate_id ( struct batch_job t)

Generate a sha1 hash based on the specified task.

Includes Command, Input files contents, Output files names Future improvement should include the Environment

Parameters
tThe batch_job whose checksum will be generated.
Returns
Allocated string of the hash, user should free.