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 *inputs, const char *outputs, struct nvpair *env_list );
29  batch_job_id_t (*wait) (struct batch_queue *Q, struct batch_job_info *info, time_t stoptime);
30  int (*remove) (struct batch_queue *Q, batch_job_id_t id);
31  } job;
32 
33  struct {
34  int (*chdir) (struct batch_queue *q, const char *path);
35  int (*getcwd) (struct batch_queue *q, char *buf, size_t size);
36  int (*mkdir) (struct batch_queue *q, const char *path, mode_t mode, int recursive);
37  int (*putfile) (struct batch_queue *q, const char *lpath, const char *rpath);
38  int (*stat) (struct batch_queue *q, const char *path, struct stat *buf);
39  int (*unlink) (struct batch_queue *q, const char *path);
40  } fs;
41 };
42 
43 struct batch_queue {
44  batch_queue_type_t type;
45 
46  char logfile[PATH_MAX];
47  struct hash_table *options;
48  struct itable *job_table;
49  struct itable *output_table;
50  void *data; /* module user data */
51  const struct batch_queue_module *module;
52 };
53 
54 #define batch_queue_stub_create(name) static int batch_queue_##name##_create (struct batch_queue *Q) { return 0; }
55 #define batch_queue_stub_free(name) static int batch_queue_##name##_free (struct batch_queue *Q) { return 0; }
56 #define batch_queue_stub_port(name) static int batch_queue_##name##_port (struct batch_queue *Q) { return 0; }
57 #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; }
58 
59 #define batch_fs_stub_chdir(name) static int batch_fs_##name##_chdir (struct batch_queue *Q, const char *path) { return chdir(path); }
60 #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; }
61 #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); }
62 #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); }
63 #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); }
64 #define batch_fs_stub_unlink(name) static int batch_fs_##name##_unlink (struct batch_queue *Q, const char *path) { return delete_dir(path); }
65 
66 #endif
67 
68 /* 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:27
Create a new directory recursively.
batch_queue_type_t
Indicates which type of batch submission to use.
Definition: batch_job.h:33
See unlink_recursive.h instead.
Definition: nvpair_private.h:15
Definition: batch_job_internal.h:43
A general purpose hash table.
Describes a batch job when it has completed.
Definition: batch_job.h:47
An integer-indexed hash table.