00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BATCH_JOB_H
00009 #define BATCH_JOB_H
00010
00011 #include <sys/stat.h>
00012
00013 #include <inttypes.h>
00014 #include <stdint.h>
00015 #include <time.h>
00016
00017 #include "nvpair.h"
00018
00027 typedef int64_t batch_job_id_t;
00028 #define PRIbjid PRId64
00029 #define SCNbjid SCNd64
00030
00032
00033 typedef enum {
00034 BATCH_QUEUE_TYPE_LOCAL,
00035 BATCH_QUEUE_TYPE_CONDOR,
00036 BATCH_QUEUE_TYPE_SGE,
00037 BATCH_QUEUE_TYPE_MOAB,
00038 BATCH_QUEUE_TYPE_TORQUE,
00039 BATCH_QUEUE_TYPE_CLUSTER,
00040 BATCH_QUEUE_TYPE_WORK_QUEUE,
00041 BATCH_QUEUE_TYPE_HADOOP,
00042 BATCH_QUEUE_TYPE_CHIRP,
00043 BATCH_QUEUE_TYPE_UNKNOWN = -1
00044 } batch_queue_type_t;
00045
00047 struct batch_job_info {
00048 time_t submitted;
00049 time_t started;
00050 time_t finished;
00051 int exited_normally;
00052 int exit_code;
00053 int exit_signal;
00054 };
00055
00060 struct batch_queue *batch_queue_create(batch_queue_type_t type);
00061
00070 batch_job_id_t batch_job_submit(struct batch_queue *q, const char *cmdline, const char *input_files, const char *output_files, struct nvpair *envlist );
00071
00080 batch_job_id_t batch_job_wait(struct batch_queue *q, struct batch_job_info *info);
00081
00092 batch_job_id_t batch_job_wait_timeout(struct batch_queue *q, struct batch_job_info *info, time_t stoptime);
00093
00101 int batch_job_remove(struct batch_queue *q, batch_job_id_t jobid);
00102
00103 int batch_fs_chdir (struct batch_queue *q, const char *path);
00104 int batch_fs_getcwd (struct batch_queue *q, char *buf, size_t size);
00105 int batch_fs_mkdir (struct batch_queue *q, const char *path, mode_t mode, int recursive);
00106 int batch_fs_putfile (struct batch_queue *q, const char *lpath, const char *rpath);
00107 int batch_fs_stat (struct batch_queue *q, const char *path, struct stat *buf);
00108 int batch_fs_unlink (struct batch_queue *q, const char *path);
00109
00114 batch_queue_type_t batch_queue_type_from_string(const char *str);
00115
00120 const char *batch_queue_type_to_string(batch_queue_type_t t);
00121
00128 void batch_queue_set_logfile(struct batch_queue *q, const char *logfile);
00129
00142 void batch_queue_set_option(struct batch_queue *q, const char *what, const char *value);
00143
00151 const char *batch_queue_get_option(struct batch_queue *q, const char *what);
00152
00158 batch_queue_type_t batch_queue_get_type(struct batch_queue *q);
00159
00167 void batch_queue_delete(struct batch_queue *q);
00168
00173 const char *batch_queue_type_string();
00174
00179 int batch_queue_port(struct batch_queue *q);
00180
00181 #endif