cctools
batch_job_internal.h
1 #ifndef BATCH_JOB_INTERNAL_H_
2 #define BATCH_JOB_INTERNAL_H_
3 
4 #include <sys/stat.h>
5 
6 #include <limits.h>
7 #include <stdlib.h>
8 
9 #include "batch_job.h"
10 #include "copy_stream.h"
11 #include "create_dir.h"
12 #include "delete_dir.h"
13 #include "hash_table.h"
14 #include "itable.h"
15 
16 #define BATCH_JOB_LINE_MAX 8192
17 
19  batch_queue_type_t type;
20  char typestr[128];
21 
22  int (*create) (struct batch_queue *Q);
23  int (*free) (struct batch_queue *Q);
24  int (*port) (struct batch_queue *Q);
25  void (*option_update) (struct batch_queue *Q, const char *what, const char *value); /* called when an option is changed */
26 
27  struct {
28  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);
29  batch_job_id_t (*submit_simple) (struct batch_queue *Q, const char *command, const char *inputs, const char *outputs);
30  batch_job_id_t (*wait) (struct batch_queue *Q, struct batch_job_info *info, time_t stoptime);
31  int (*remove) (struct batch_queue *Q, batch_job_id_t id);
32  } job;
33 
34  struct {
35  int (*chdir) (struct batch_queue *q, const char *path);
36  int (*getcwd) (struct batch_queue *q, char *buf, size_t size);
37  int (*mkdir) (struct batch_queue *q, const char *path, mode_t mode, int recursive);
38  int (*putfile) (struct batch_queue *q, const char *lpath, const char *rpath);
39  int (*stat) (struct batch_queue *q, const char *path, struct stat *buf);
40  int (*unlink) (struct batch_queue *q, const char *path);
41  } fs;
42 };
43 
44 struct batch_queue {
45  batch_queue_type_t type;
46 
47  char logfile[PATH_MAX];
48  struct hash_table *options;
49  struct itable *job_table;
50  struct itable *output_table;
51  void *data; /* module user data */
52  const struct batch_queue_module *module;
53 };
54 
55 #define batch_queue_stub_create(name) static int batch_queue_##name##_create (struct batch_queue *Q) { return 0; }
56 #define batch_queue_stub_free(name) static int batch_queue_##name##_free (struct batch_queue *Q) { return 0; }
57 #define batch_queue_stub_port(name) static int batch_queue_##name##_port (struct batch_queue *Q) { return 0; }
58 #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; }
59 
60 #define batch_fs_stub_chdir(name) static int batch_fs_##name##_chdir (struct batch_queue *Q, const char *path) { return chdir(path); }
61 #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; }
62 #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); }
63 #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); }
64 #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); }
65 #define batch_fs_stub_unlink(name) static int batch_fs_##name##_unlink (struct batch_queue *Q, const char *path) { return delete_dir(path); }
66 
67 #endif
68 
69 /* vim: set noexpandtab tabstop=4: */
Definition: batch_job_internal.h:18
Batch job submission.
int64_t batch_job_id_t
An integer type indicating a unique batch job number.
Definition: batch_job.h:25
Create a new directory recursively.
batch_queue_type_t
Indicates which type of batch submission to use.
Definition: batch_job.h:31
See unlink_recursive.h instead.
Definition: batch_job_internal.h:44
A general purpose hash table.
Describes a batch job when it has completed.
Definition: batch_job.h:47
An integer-indexed hash table.