00001 #ifndef WORK_QUEUE_H
00002 #define WORK_QUEUE_H
00003
00014 #include "timestamp.h"
00015
00016 #define WORK_QUEUE_DEFAULT_PORT 9123
00017 #define WORK_QUEUE_LINE_MAX 1024
00018
00019 #define WAITFORTASK -1
00020
00021 #define WQ_RESULT_UNSET 0
00022 #define WQ_RESULT_INPUT_FAIL 1
00023 #define WQ_RESULT_FUNCTION_FAIL 2
00024 #define WQ_RESULT_OUTPUT_FAIL 3
00025
00026 #define WORK_QUEUE_CHOOSE_HOST_UNSET 0 // default setting for task.
00027 #define WORK_QUEUE_CHOOSE_HOST_BY_FCFS 1
00028 #define WORK_QUEUE_CHOOSE_HOST_BY_FILES 2
00029 #define WORK_QUEUE_CHOOSE_HOST_BY_TIME 3
00030 #define WORK_QUEUE_CHOOSE_HOST_MAX 3
00031 #define WORK_QUEUE_CHOOSE_HOST_DEFAULT 1 // default setting for queue.
00032
00033
00034 extern double wq_option_fast_abort_multiplier;
00035 extern int wq_option_worker_selection_algorithm;
00039 struct work_queue_task {
00040 char *tag;
00041 char *command_line;
00042 int worker_selection_algorithm;
00043 char *output;
00044 struct list * input_files;
00045 struct list * output_files;
00046 int taskid;
00047 int return_status;
00048 int result;
00049 char* host;
00050 timestamp_t submit_time;
00051 timestamp_t start_time;
00052 timestamp_t finish_time;
00053 INT64_T total_bytes_transfered;
00054 timestamp_t total_transfer_time;
00055 };
00056
00059 struct work_queue_stats {
00060 int workers_init;
00061 int workers_ready;
00062 int workers_busy;
00063 int tasks_running;
00064 int tasks_waiting;
00065 int tasks_complete;
00066 int total_tasks_dispatched;
00067 int total_tasks_complete;
00068 int total_workers_joined;
00069 int total_workers_removed;
00070 };
00071
00077 struct work_queue * work_queue_create( int port , time_t stoptime);
00078
00082 void work_queue_delete( struct work_queue *q );
00083
00088 void work_queue_get_stats( struct work_queue *q, struct work_queue_stats *s );
00089
00095 int work_queue_activate_fast_abort(struct work_queue* q, double multiplier);
00096
00102 struct work_queue_task * work_queue_wait( struct work_queue *q, int timeout );
00103
00108 void work_queue_submit( struct work_queue *q, struct work_queue_task *t );
00109
00113 void work_queue_task_delete( struct work_queue_task *t );
00114
00118 struct work_queue_task * work_queue_task_create( const char* full_command);
00119
00124 INT64_T work_queue_task_specify_tag( struct work_queue_task* t, const char* tag);
00125
00130 INT64_T work_queue_task_specify_algorithm( struct work_queue_task* t, int alg);
00131
00138 INT64_T work_queue_task_specify_input_buf( struct work_queue_task* t, const char* buf, int length, const char* rname);
00139
00145 INT64_T work_queue_task_specify_input_file( struct work_queue_task* t, const char* fname, const char* rname);
00146
00152 INT64_T work_queue_task_specify_output_file( struct work_queue_task* t, const char* rname, const char* fname);
00153
00157 int work_queue_hungry (struct work_queue* q);
00158
00162 int work_queue_empty (struct work_queue* q);
00163
00168 int work_queue_shut_down_workers (struct work_queue* q, int n);
00169
00174
00175
00180
00181
00182 #endif