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); /* called when an option is changed */
00026 
00027         struct {
00028                 batch_job_id_t (*submit) (struct batch_queue *Q, const char *command, const char *inputs, const char *outputs, struct nvpair *env_list );
00029                 batch_job_id_t (*wait) (struct batch_queue *Q, struct batch_job_info *info, time_t stoptime);
00030                 int (*remove) (struct batch_queue *Q, batch_job_id_t id);
00031         } job;
00032 
00033         struct {
00034                 int (*chdir) (struct batch_queue *q, const char *path);
00035                 int (*getcwd) (struct batch_queue *q, char *buf, size_t size);
00036                 int (*mkdir) (struct batch_queue *q, const char *path, mode_t mode, int recursive);
00037                 int (*putfile) (struct batch_queue *q, const char *lpath, const char *rpath);
00038                 int (*stat) (struct batch_queue *q, const char *path, struct stat *buf);
00039                 int (*unlink) (struct batch_queue *q, const char *path);
00040         } fs;
00041 };
00042 
00043 struct batch_queue {
00044         batch_queue_type_t type;
00045 
00046         char logfile[PATH_MAX];
00047         struct hash_table *options;
00048         struct itable *job_table;
00049         struct itable *output_table;
00050         void *data; /* module user data */
00051         const struct batch_queue_module *module;
00052 };
00053 
00054 #define batch_queue_stub_create(name)  static int batch_queue_##name##_create (struct batch_queue *Q) { return 0; }
00055 #define batch_queue_stub_free(name)  static int batch_queue_##name##_free (struct batch_queue *Q) { return 0; }
00056 #define batch_queue_stub_port(name)  static int batch_queue_##name##_port (struct batch_queue *Q) { return 0; }
00057 #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; }
00058 
00059 #define batch_fs_stub_chdir(name)  static int batch_fs_##name##_chdir (struct batch_queue *Q, const char *path) { return chdir(path); }
00060 #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; }
00061 #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); }
00062 #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); }
00063 #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); }
00064 #define batch_fs_stub_unlink(name)  static int batch_fs_##name##_unlink (struct batch_queue *Q, const char *path) { return delete_dir(path); }
00065 
00066 #endif
00067 
00068 /* vim: set noexpandtab tabstop=4: */

Generated on 17 Dec 2015 for cctools by  doxygen 1.6.1