cctools
work_queue_process.h
1 #ifndef WORK_QUEUE_PROCESS_H
2 #define WORK_QUEUE_PROCESS_H
3 
4 #include "work_queue.h"
5 #include "timestamp.h"
6 #include "path_disk_size_info.h"
7 
8 #include <unistd.h>
9 #include <sys/types.h>
10 #include <sys/resource.h>
11 
12 #define NONE 0
13 #define DOCKER 1
14 #define DOCKER_PRESERVE 2
15 #define UMBRELLA 3
16 
17 #define MAX_BUFFER_SIZE 4096
18 
19 /*
20 work_queue_process is a running instance of a work_queue_task.
21 This object is private to the work_queue_worker.
22 */
23 
25  pid_t pid;
26  int task_status; // Any of WORK_QUEUE_RESULT_*
27  int exit_status; // Exit code, or signal number to task process.
28 
29  struct rusage rusage;
30  timestamp_t execution_start;
31  timestamp_t execution_end;
32 
33  char *sandbox;
34  char *tmpdir; // TMPDIR per task, expected to be a subdir of sandbox.
35  char *output_file_name;
36  int output_fd;
37 
38  struct work_queue_task *task;
39 
40  /* expected disk usage by the process. If no cache is used, it is the same as in task. */
41  int64_t disk;
42  /* 1 if the task sandbox was mounted on a loop device. 0 otherwise. */
43  int loop_mount;
44 
45  /* disk size and number of files found in the process sandbox. */
46  int64_t sandbox_size;
47  int64_t sandbox_file_count;
48 
49  /* state between complete disk measurements. */
50  struct path_disk_size_info *disk_measurement_state;
51 
52  char container_id[MAX_BUFFER_SIZE];
53 };
54 
55 struct work_queue_process * work_queue_process_create( struct work_queue_task *task, int disk_allocation );
56 pid_t work_queue_process_execute( struct work_queue_process *p, int container_mode, ... );
57 // lunching process with container, arg_3 can be either img_name or container_name, depending on container_mode
58 void work_queue_process_kill( struct work_queue_process *p );
59 void work_queue_process_delete( struct work_queue_process *p );
60 void work_queue_process_compute_disk_needed( struct work_queue_process *p );
61 
62 int work_queue_process_measure_disk(struct work_queue_process *p, int max_time_on_measurement);
63 
64 #endif
A task description.
Definition: work_queue.h:103
A master-worker library.
Portable routines for high resolution timing.
UINT64_T timestamp_t
A type to hold the current time, in microseconds since January 1st, 1970.
Definition: timestamp.h:20
Definition: path_disk_size_info.h:13
Query disk space on the given directory.
Definition: work_queue_process.h:24