cctools
work_queue_catalog.h
1 /*
2 Copyright (C) 2012- The University of Notre Dame
3 This software is distributed under the GNU General Public License.
4 See the file COPYING for details.
5 */
6 
7 #ifndef WORK_QUEUE_CATALOG_H
8 #define WORK_QUEUE_CATALOG_H
9 
10 #include "work_queue.h"
11 #include "work_queue_protocol.h"
12 
13 #include "catalog_query.h"
14 #include "catalog_server.h"
15 #include "datagram.h"
16 #include "domain_name_cache.h"
17 #include "nvpair.h"
18 #include "username.h"
19 #include "link.h"
20 #include "hash_cache.h"
21 #include "list.h"
22 #include "xxmalloc.h"
23 #include "debug.h"
24 #include "stringtools.h"
25 #include "domain_name_cache.h"
26 #include "timestamp.h"
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <time.h>
31 #include <unistd.h>
32 #include <string.h>
33 #include <fcntl.h>
34 #include <errno.h>
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 
38 #define WORK_QUEUE_CATALOG_UPDATE_INTERVAL 60
39 #define WORK_QUEUE_CATALOG_LIFETIME 300
40 
41 #define WORK_QUEUE_NAME_MAX 256
42 #define WORK_QUEUE_PROTOCOL_BLANK_FIELD "-"
43 #define WORK_QUEUE_PROTOCOL_FIELD_MAX 256
44 
46  char addr[LINK_ADDRESS_MAX];
47  int port;
48  char proj[WORK_QUEUE_NAME_MAX];
49  timestamp_t start_time;
50  int priority;
51  int capacity;
52  int tasks_waiting;
53  int tasks_running;
54  int tasks_complete;
55  int total_tasks_dispatched;
56  int workers_init;
57  int workers_ready;
58  int workers_busy;
59  int workers;
60  char *workers_by_pool;
61  char owner[USERNAME_MAX];
62  int default_max_workers_from_pool;
63  int workers_need;
64  int workers_from_this_pool;
65  int target_workers_from_pool;
66 };
67 
69  char addr[LINK_ADDRESS_MAX];
70  char name[WORK_QUEUE_POOL_NAME_MAX];
71  char *decision;
72  char owner[USERNAME_MAX];
73 };
74 
75 struct pool_info {
76  char name[WORK_QUEUE_POOL_NAME_MAX];
77  unsigned int count;
78 };
79 
80 void debug_print_masters(struct list *ml);
81 
82 int parse_catalog_server_description(char *server_string, char **host, int *port);
83 
84 struct work_queue_pool *parse_work_queue_pool_nvpair(struct nvpair *nv);
85 
86 void free_work_queue_pool(struct work_queue_pool *p);
87 
88 int workers_by_item(const char *workers_by_item, const char *item_name);
89 
90 struct work_queue_master *parse_work_queue_master_nvpair(struct nvpair *nv);
91 
92 struct work_queue_master *duplicate_work_queue_master(struct work_queue_master *master);
93 
94 void free_work_queue_master(struct work_queue_master *m);
95 
96 void free_work_queue_master_list(struct list *ml);
97 
98 struct list *get_masters_from_catalog(const char *catalog_host, int catalog_port, struct list *regex_list);
99 
100 int advertise_master_to_catalog(const char *catalog_host, int catalog_port, const char *project_name, struct work_queue_stats *s, const char *workers_summary, int now);
101 
102 int get_pool_decisions_from_catalog(const char *catalog_host, int catalog_port, const char *proj, struct list *decisions);
103 
104 int advertise_pool_decision_to_catalog(const char *catalog_host, int catalog_port, const char *pool_name, const char *decision);
105 #endif