work_queue.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2008- The University of Notre Dame
00003 This software is distributed under the GNU General Public License.
00004 See the file COPYING for details.
00005 */
00006 
00007 #ifndef WORK_QUEUE_H
00008 #define WORK_QUEUE_H
00009 
00020 #include "timestamp.h"
00021 
00022 #define WORK_QUEUE_DEFAULT_PORT 9123  
00023 #define WORK_QUEUE_RANDOM_PORT  0    
00024 #define WORK_QUEUE_WAITFORTASK  -1    
00026 #define WORK_QUEUE_SCHEDULE_UNSET 0
00027 #define WORK_QUEUE_SCHEDULE_FCFS         1 
00028 #define WORK_QUEUE_SCHEDULE_FILES        2 
00029 #define WORK_QUEUE_SCHEDULE_TIME         3 
00030 #define WORK_QUEUE_SCHEDULE_RAND         4 
00032 #define WORK_QUEUE_TASK_ORDER_FIFO 0  
00033 #define WORK_QUEUE_TASK_ORDER_LIFO 1  
00035 #define WORK_QUEUE_INPUT  0     
00036 #define WORK_QUEUE_OUTPUT 1     
00038 #define WORK_QUEUE_NOCACHE 0    
00039 #define WORK_QUEUE_CACHE 1      
00040 #define WORK_QUEUE_SYMLINK 2    /* Create a symlink to the file rather than copying it, if possible. */
00041 #define WORK_QUEUE_PREEXIST 4   /* If the filename already exists on the host, use it in place. */
00042 #define WORK_QUEUE_THIRDGET 8   /* Access the file on the client from a shared filesystem */
00043 #define WORK_QUEUE_THIRDPUT 8   /* Access the file on the client from a shared filesystem (included for readability) */
00044 
00045 #define WORK_QUEUE_MASTER_MODE_STANDALONE 0 
00046 #define WORK_QUEUE_MASTER_MODE_CATALOG 1    
00048 extern double wq_option_fast_abort_multiplier; 
00049 extern int wq_option_scheduler; 
00053 struct work_queue_task {
00054         char *tag;                      
00055         char *command_line;             
00056         int worker_selection_algorithm;           
00057         char *output;                   
00058         struct list *input_files;       
00059         struct list *output_files;      
00060         int taskid;                     
00061         int return_status;              
00062         int result;                     
00063         char *host;                     
00065         timestamp_t time_task_submit;   
00066         timestamp_t time_task_finish;   
00067         timestamp_t time_app_delay;      
00068         timestamp_t time_send_input_start;      
00069         timestamp_t time_send_input_finish;     
00070         timestamp_t time_execute_cmd_start;                 
00071         timestamp_t time_execute_cmd_finish;            
00072         timestamp_t time_receive_output_start;  
00073         timestamp_t time_receive_output_finish; 
00075         INT64_T total_bytes_transferred;
00076         timestamp_t total_transfer_time;    
00077         timestamp_t cmd_execution_time;    
00078 };
00079 
00082 struct work_queue_stats {
00083         int port;
00084         int priority;
00085         int workers_init;               
00086         int workers_ready;              
00087         int workers_busy;               
00088         int workers_cancelling; 
00089         int tasks_running;              
00090         int tasks_waiting;              
00091         int tasks_complete;             
00092         int total_tasks_dispatched;     
00093         int total_tasks_complete;       
00094         int total_workers_joined;       
00095         int total_workers_removed;      
00096         INT64_T total_bytes_sent;       
00097         INT64_T total_bytes_received;   
00098         timestamp_t start_time;         
00099         timestamp_t total_send_time;    
00100         timestamp_t total_receive_time; 
00101         double efficiency;
00102         double idle_percentage;
00103         int capacity;
00104         int avg_capacity;
00105         int total_workers_connected;
00106 };
00107 
00111 
00118 struct work_queue_task *work_queue_task_create(const char *full_command);
00119 
00131 void work_queue_task_specify_file(struct work_queue_task *t, const char *local_name, const char *remote_name, int type, int flags);
00132 
00142 void work_queue_task_specify_buffer(struct work_queue_task *t, const char *data, int length, const char *remote_name, int flags);
00143 
00144 /* Add a file created or handled by an arbitrary command to a task (eg: wget, ftp, chirp_get|put).
00145 @param t A task object.
00146 @param remote_name The name of the file at the execution site.
00147 @param cmd The command to run on the remote node to retrieve or store the file.
00148 @param type Must be one of the following values:
00149 - @ref WORK_QUEUE_INPUT to indicate an input file to be consumed by the task
00150 - @ref WORK_QUEUE_OUTPUT to indicate an output file to be produced by the task
00151 @param flags    May be zero to indicate no special handling or any of the following or'd together:
00152 - @ref WORK_QUEUE_CACHE indicates that the file should be cached for later tasks. (recommended)
00153 - @ref WORK_QUEUE_NOCACHE indicates that the file should not be cached for later tasks.
00154 */
00155 void work_queue_task_specify_file_command(struct work_queue_task *t, const char *remote_name, const char *cmd, int type, int flags);
00156 
00163 void work_queue_task_specify_tag(struct work_queue_task *t, const char *tag);
00164 
00174 void work_queue_task_specify_algorithm(struct work_queue_task *t, int algo );
00175 
00180 void work_queue_task_delete(struct work_queue_task *t);
00181 
00183 
00187 
00204 struct work_queue *work_queue_create(int port);
00205 
00214 int work_queue_submit(struct work_queue *q, struct work_queue_task *t);
00215 
00230 struct work_queue_task *work_queue_wait(struct work_queue *q, int timeout);
00231 
00243 int work_queue_hungry(struct work_queue *q);
00244 
00252 int work_queue_empty(struct work_queue *q);
00253 
00260 int work_queue_port(struct work_queue *q);
00261 
00266 const char *work_queue_name(struct work_queue *q);
00267 
00272 void work_queue_get_stats(struct work_queue *q, struct work_queue_stats *s);
00273 
00280 char * work_queue_get_worker_summary( struct work_queue *q );
00281 
00287 int work_queue_activate_fast_abort(struct work_queue *q, double multiplier);
00288 
00300 void work_queue_specify_algorithm(struct work_queue *q, int algo);
00301 
00311 void work_queue_specify_task_order(struct work_queue *q, int order);
00312 
00317 void work_queue_specify_name(struct work_queue *q, const char *name);
00318 
00323 void work_queue_specify_priority(struct work_queue *q, int priority);
00324 
00331 void work_queue_specify_master_mode(struct work_queue *q, int mode);
00332 
00338 struct work_queue_task *work_queue_cancel_by_taskid(struct work_queue *q, int id);
00339 
00345 struct work_queue_task *work_queue_cancel_by_tasktag(struct work_queue *q, const char *tag);
00346 
00351 int work_queue_shut_down_workers(struct work_queue *q, int n);
00352 
00357 void work_queue_delete(struct work_queue *q);
00358 
00360 
00364 
00372 void work_queue_task_specify_input_buf(struct work_queue_task *t, const char *buf, int length, const char *rname);
00373 
00380 void work_queue_task_specify_input_file(struct work_queue_task *t, const char *fname, const char *rname);
00381 
00388 void work_queue_task_specify_input_file_do_not_cache(struct work_queue_task *t, const char *fname, const char *rname);
00389 
00396 void work_queue_task_specify_output_file(struct work_queue_task *t, const char *rname, const char *fname);
00397 
00404 void work_queue_task_specify_output_file_do_not_cache(struct work_queue_task *t, const char *rname, const char *fname);
00405 
00407 
00408 
00409 #endif

Generated on Mon Jun 11 03:16:07 2012 for cctools by  doxygen 1.4.7