batch_job_internal.h
00001 #ifndef BATCH_JOB_INTERNAL_H_
00002 #define BATCH_JOB_INTERNAL_H_
00003
00004 #include <sys/stat.h>
00005
00006 #include <limits.h>
00007 #include <stdlib.h>
00008
00009 #include "batch_job.h"
00010 #include "copy_stream.h"
00011 #include "create_dir.h"
00012 #include "delete_dir.h"
00013 #include "hash_table.h"
00014 #include "itable.h"
00015
00016 #define BATCH_JOB_LINE_MAX 8192
00017
00018 struct batch_queue_module {
00019 batch_queue_type_t type;
00020 char typestr[128];
00021
00022 int (*create) (struct batch_queue *Q);
00023 int (*free) (struct batch_queue *Q);
00024 int (*port) (struct batch_queue *Q);
00025 void (*option_update) (struct batch_queue *Q, const char *what, const char *value);
00026
00027 struct {
00028 batch_job_id_t (*submit) (struct batch_queue *Q, const char *command, const char *arguments, const char *infile, const char *outfile, const char *errfile, const char *inputs, const char *outputs);
00029 batch_job_id_t (*submit_simple) (struct batch_queue *Q, const char *command, const char *inputs, const char *outputs);
00030 batch_job_id_t (*wait) (struct batch_queue *Q, struct batch_job_info *info, time_t stoptime);
00031 int (*remove) (struct batch_queue *Q, batch_job_id_t id);
00032 } job;
00033
00034 struct {
00035 int (*chdir) (struct batch_queue *q, const char *path);
00036 int (*getcwd) (struct batch_queue *q, char *buf, size_t size);
00037 int (*mkdir) (struct batch_queue *q, const char *path, mode_t mode, int recursive);
00038 int (*putfile) (struct batch_queue *q, const char *lpath, const char *rpath);
00039 int (*stat) (struct batch_queue *q, const char *path, struct stat *buf);
00040 int (*unlink) (struct batch_queue *q, const char *path);
00041 } fs;
00042 };
00043
00044 struct batch_queue {
00045 batch_queue_type_t type;
00046
00047 char logfile[PATH_MAX];
00048 struct hash_table *options;
00049 struct itable *job_table;
00050 struct itable *output_table;
00051 void *data;
00052 const struct batch_queue_module *module;
00053 };
00054
00055 #define batch_queue_stub_create(name) static int batch_queue_##name##_create (struct batch_queue *Q) { return 0; }
00056 #define batch_queue_stub_free(name) static int batch_queue_##name##_free (struct batch_queue *Q) { return 0; }
00057 #define batch_queue_stub_port(name) static int batch_queue_##name##_port (struct batch_queue *Q) { return 0; }
00058 #define batch_queue_stub_option_update(name) static void batch_queue_##name##_option_update (struct batch_queue *Q, const char *what, const char *value) { return; }
00059
00060 #define batch_fs_stub_chdir(name) static int batch_fs_##name##_chdir (struct batch_queue *Q, const char *path) { return chdir(path); }
00061 #define batch_fs_stub_getcwd(name) static int batch_fs_##name##_getcwd (struct batch_queue *Q, char *buf, size_t size) { getcwd(buf, size); return 0; }
00062 #define batch_fs_stub_mkdir(name) static int batch_fs_##name##_mkdir (struct batch_queue *Q, const char *path, mode_t mode, int recursive) { if (recursive) return create_dir(path, mode); else return mkdir(path, mode); }
00063 #define batch_fs_stub_putfile(name) static int batch_fs_##name##_putfile (struct batch_queue *Q, const char *lpath, const char *rpath) { return copy_file_to_file(lpath, rpath); }
00064 #define batch_fs_stub_stat(name) static int batch_fs_##name##_stat (struct batch_queue *Q, const char *path, struct stat *buf) { return stat(path, buf); }
00065 #define batch_fs_stub_unlink(name) static int batch_fs_##name##_unlink (struct batch_queue *Q, const char *path) { return delete_dir(path); }
00066
00067 #endif
00068
00069