cctools
batch_job.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3 Copyright (C) 2022 The University of Notre Dame
4 This software is distributed under the GNU General Public License.
5 See the file COPYING for details.
6 */
7 
8 #ifndef BATCH_JOB_H
9 #define BATCH_JOB_H
10 
11 #include <sys/stat.h>
12 
13 #include <inttypes.h>
14 #include <stdint.h>
15 #include <time.h>
16 
17 #include "jx.h"
18 #include "rmsummary.h"
19 
28 typedef int64_t batch_job_id_t;
29 #define PRIbjid PRId64
30 #define SCNbjid SCNd64
31 
33 /* Must be kept in sync with batch_job_subsystems. */
34 typedef enum {
57 
60  time_t submitted;
61  time_t started;
62  time_t finished;
63  time_t heartbeat;
65  int exit_code;
68  long log_pos;
69 };
70 
75 
79 void batch_job_info_delete(struct batch_job_info *info);
80 
86 
97 batch_job_id_t batch_job_submit(struct batch_queue *q, const char *cmdline, const char *input_files, const char *output_files, struct jx *envlist, const struct rmsummary *resources);
98 
110 
123 batch_job_id_t batch_job_wait_timeout(struct batch_queue *q, struct batch_job_info *info, time_t stoptime);
124 
132 int batch_job_remove(struct batch_queue *q, batch_job_id_t jobid);
133 
134 int batch_fs_chdir (struct batch_queue *q, const char *path);
135 int batch_fs_getcwd (struct batch_queue *q, char *buf, size_t size);
136 int batch_fs_mkdir (struct batch_queue *q, const char *path, mode_t mode, int recursive);
137 int batch_fs_putfile (struct batch_queue *q, const char *lpath, const char *rpath);
138 int batch_fs_rename (struct batch_queue *q, const char *lpath, const char *rpath);
139 int batch_fs_stat (struct batch_queue *q, const char *path, struct stat *buf);
140 int batch_fs_unlink (struct batch_queue *q, const char *path);
141 
147 
153 
160 void batch_queue_set_logfile(struct batch_queue *q, const char *logfile);
161 
174 void batch_queue_set_option(struct batch_queue *q, const char *what, const char *value);
175 
184 void batch_queue_set_feature(struct batch_queue *q, const char *what, const char *value);
185 
191 void batch_queue_set_int_option(struct batch_queue *q, const char *what, int value);
192 
200 const char *batch_queue_get_option(struct batch_queue *q, const char *what);
201 
207 int batch_queue_option_is_yes (struct batch_queue *q, const char *what);
208 
216 const char *batch_queue_supports_feature (struct batch_queue *q, const char *what);
217 
218 
225 
233 void batch_queue_delete(struct batch_queue *q);
234 
239 const char *batch_queue_type_string();
240 
245 int batch_queue_port(struct batch_queue *q);
246 
247 /* Hack: provide a backdoor to allow the MPI module to perform
248  some initial setup before the MPI batch queue is created.
249 */
250 void batch_job_mpi_setup( const char *debug_filename, int mpi_cores, int mpi_memory );
251 
252 #endif
BATCH_QUEUE_TYPE_MOAB
@ BATCH_QUEUE_TYPE_MOAB
Batch jobs will be sent to the Moab Workload Manager.
Definition: batch_job.h:41
BATCH_QUEUE_TYPE_MPI
@ BATCH_QUEUE_TYPE_MPI
Batch jobs distributed within an MPI program.
Definition: batch_job.h:53
batch_queue_type_to_string
const char * batch_queue_type_to_string(batch_queue_type_t t)
Converts a batch queue type to a string.
BATCH_QUEUE_TYPE_WORK_QUEUE
@ BATCH_QUEUE_TYPE_WORK_QUEUE
Batch jobs will be sent to the Work Queue.
Definition: batch_job.h:48
BATCH_QUEUE_TYPE_DRYRUN
@ BATCH_QUEUE_TYPE_DRYRUN
Batch jobs will not actually run.
Definition: batch_job.h:52
batch_job_remove
int batch_job_remove(struct batch_queue *q, batch_job_id_t jobid)
Remove a batch job.
BATCH_QUEUE_TYPE_LSF
@ BATCH_QUEUE_TYPE_LSF
Batch jobs will be sent to LSF.
Definition: batch_job.h:43
jx.h
BATCH_QUEUE_TYPE_LAMBDA
@ BATCH_QUEUE_TYPE_LAMBDA
Batch jobs will be executed by an Amazon Lambda function with S3 objects.
Definition: batch_job.h:38
BATCH_QUEUE_TYPE_LOCAL
@ BATCH_QUEUE_TYPE_LOCAL
Batch jobs will run as local processes.
Definition: batch_job.h:35
BATCH_QUEUE_TYPE_TORQUE
@ BATCH_QUEUE_TYPE_TORQUE
Batch jobs will be send to the Torque Scheduler.
Definition: batch_job.h:44
BATCH_QUEUE_TYPE_UNKNOWN
@ BATCH_QUEUE_TYPE_UNKNOWN
An invalid batch queue type.
Definition: batch_job.h:55
batch_job_info::heartbeat
time_t heartbeat
Time the job last wrote heartbeat.
Definition: batch_job.h:63
batch_queue_get_option
const char * batch_queue_get_option(struct batch_queue *q, const char *what)
Get batch queue options.
BATCH_QUEUE_TYPE_CHIRP
@ BATCH_QUEUE_TYPE_CHIRP
Batch jobs will be sent to Chirp.
Definition: batch_job.h:49
batch_queue
Definition: batch_job_internal.h:50
batch_queue_get_type
batch_queue_type_t batch_queue_get_type(struct batch_queue *q)
Get batch queue type.
batch_queue_delete
void batch_queue_delete(struct batch_queue *q)
Delete a batch queue.
BATCH_QUEUE_TYPE_BLUE_WATERS
@ BATCH_QUEUE_TYPE_BLUE_WATERS
Batch jobs will be send to the Torque Scheduler at Blue Waters.
Definition: batch_job.h:45
batch_job_wait
batch_job_id_t batch_job_wait(struct batch_queue *q, struct batch_job_info *info)
Wait for any batch job to complete.
BATCH_QUEUE_TYPE_K8S
@ BATCH_QUEUE_TYPE_K8S
Batch jobs will be sent to kubernetes.
Definition: batch_job.h:51
batch_queue_set_int_option
void batch_queue_set_int_option(struct batch_queue *q, const char *what, int value)
As batch_queue_set_option, but allowing an integer argument.
batch_job_info_create
struct batch_job_info * batch_job_info_create()
Create a new batch_job_info struct.
batch_queue_create
struct batch_queue * batch_queue_create(batch_queue_type_t type)
Create a new batch queue.
BATCH_QUEUE_TYPE_SLURM
@ BATCH_QUEUE_TYPE_SLURM
Batch jobs will be send to the SLURM Scheduler.
Definition: batch_job.h:46
batch_job_info::exit_signal
int exit_signal
The signal by which the job was killed, if it exited abnormally.
Definition: batch_job.h:66
batch_queue_type_from_string
batch_queue_type_t batch_queue_type_from_string(const char *str)
Converts a string into a batch queue type.
batch_job_info::started
time_t started
Time the job actually began executing.
Definition: batch_job.h:61
BATCH_QUEUE_TYPE_AMAZON_BATCH
@ BATCH_QUEUE_TYPE_AMAZON_BATCH
Batch jobs will be sent to Amazon Batch System.
Definition: batch_job.h:39
batch_job_info::submitted
time_t submitted
Time the job was submitted to the system.
Definition: batch_job.h:60
batch_job_info::exit_code
int exit_code
The result code of the job, if it exited normally.
Definition: batch_job.h:65
batch_queue_set_logfile
void batch_queue_set_logfile(struct batch_queue *q, const char *logfile)
Set the log file used by the batch queue.
batch_queue_type_t
batch_queue_type_t
Indicates which type of batch submission to use.
Definition: batch_job.h:34
rmsummary
Definition: rmsummary.h:26
batch_job_wait_timeout
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.
batch_job_info::finished
time_t finished
Time at which the job actually completed.
Definition: batch_job.h:62
batch_job_id_t
int64_t batch_job_id_t
An integer type indicating a unique batch job number.
Definition: batch_job.h:28
batch_job_info::log_pos
long log_pos
Last read position in the log file, for ftell and fseek.
Definition: batch_job.h:68
BATCH_QUEUE_TYPE_VINE
@ BATCH_QUEUE_TYPE_VINE
Batch jobs executed via TaskVine.
Definition: batch_job.h:54
BATCH_QUEUE_TYPE_PBS
@ BATCH_QUEUE_TYPE_PBS
Batch jobs will be send to the PBS Scheduler.
Definition: batch_job.h:42
batch_queue_port
int batch_queue_port(struct batch_queue *q)
Returns the port number of the batch queue.
batch_queue_type_string
const char * batch_queue_type_string()
Returns the list of queue types supported by this module.
batch_job_submit
batch_job_id_t batch_job_submit(struct batch_queue *q, const char *cmdline, const char *input_files, const char *output_files, struct jx *envlist, const struct rmsummary *resources)
Submit a batch job.
batch_job_info::exited_normally
int exited_normally
Non-zero if the job ran to completion, zero otherwise.
Definition: batch_job.h:64
BATCH_QUEUE_TYPE_CLUSTER
@ BATCH_QUEUE_TYPE_CLUSTER
Batch jobs will be sent to a user-defined cluster manager.
Definition: batch_job.h:47
BATCH_QUEUE_TYPE_AMAZON
@ BATCH_QUEUE_TYPE_AMAZON
Batch jobs will be sent spun up Amazon ec2 instances.
Definition: batch_job.h:37
batch_queue_set_feature
void batch_queue_set_feature(struct batch_queue *q, const char *what, const char *value)
Expresses support for feature in the underlying batch system.
batch_queue_option_is_yes
int batch_queue_option_is_yes(struct batch_queue *q, const char *what)
Check if option is set to yes.
batch_job_info
Describes a batch job when it has completed.
Definition: batch_job.h:59
BATCH_QUEUE_TYPE_MESOS
@ BATCH_QUEUE_TYPE_MESOS
Batch jobs will be sent to Mesos.
Definition: batch_job.h:50
jx
JX value representing any expression type.
Definition: jx.h:117
batch_job_info_delete
void batch_job_info_delete(struct batch_job_info *info)
Delete a batch_job_info struct.
batch_job_info::disk_allocation_exhausted
int disk_allocation_exhausted
Non-zero if the job filled its loop device allocation to capacity, zero otherwise.
Definition: batch_job.h:67
batch_queue_set_option
void batch_queue_set_option(struct batch_queue *q, const char *what, const char *value)
Add extra options to pass to the underlying batch system.
BATCH_QUEUE_TYPE_SGE
@ BATCH_QUEUE_TYPE_SGE
Batch jobs will be sent to Sun Grid Engine.
Definition: batch_job.h:40
batch_queue_supports_feature
const char * batch_queue_supports_feature(struct batch_queue *q, const char *what)
Get batch queue feature.
BATCH_QUEUE_TYPE_CONDOR
@ BATCH_QUEUE_TYPE_CONDOR
Batch jobs will be sent to Condor pool.
Definition: batch_job.h:36