3
/*___INFO__MARK_BEGIN__*/
4
/*************************************************************************
6
* The Contents of this file are made available subject to the terms of
7
* the Sun Industry Standards Source License Version 1.2
9
* Sun Microsystems Inc., March, 2001
12
* Sun Industry Standards Source License Version 1.2
13
* =================================================
14
* The contents of this file are subject to the Sun Industry Standards
15
* Source License Version 1.2 (the "License"); You may not use this file
16
* except in compliance with the License. You may obtain a copy of the
17
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
19
* Software provided under this License is provided on an "AS IS" basis,
20
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
21
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
22
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
23
* See the License for the specific provisions governing your rights and
24
* obligations concerning the Software.
26
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
28
* Copyright: 2001 by Sun Microsystems, Inc.
30
* All Rights Reserved.
32
************************************************************************/
33
/*___INFO__MARK_END__*/
39
#include "sge_gdi_ctx.h"
41
typedef struct qstat_env_str qstat_env_t;
43
struct qstat_env_str {
44
sge_gdi_ctx_class_t *ctx;
46
/* Input parameters */
47
lList *resource_list; /* -l resource_request */
48
lList *qresource_list; /* -F qresource_request */
49
lList* queueref_list; /* -q queue_list */
50
lList* peref_list; /* -pe pe_list */
51
lList* user_list; /* -u user_list - selects jobs */
52
lList* queue_user_list; /* -U user_list - selects queues */
53
u_long32 full_listing; /* -ext */
54
u_long32 qselect_mode; /* called as qselect */
55
u_long32 group_opt; /* -g */
56
u_long32 queue_state; /* -qs */
57
u_long32 explain_bits; /* -explain */
58
u_long32 job_info; /* -j */
75
int (*shut_me_down)(void);
76
u_long32 global_showjobs;
77
u_long32 global_showqueues;
80
** number of slots to be printed in slots column when 0 i
81
** is passed the number of requested slots printed
85
/* length of the longest queue name */
86
int longest_queue_length;
89
lEnumeration *what_JB_Type;
90
lEnumeration *what_JAT_Type_template;
91
lEnumeration *what_JAT_Type_list;
96
typedef struct qselect_handler_str qselect_handler_t;
98
struct qselect_handler_str {
101
int (*report_started)(qselect_handler_t *thiz, lList** alpp);
102
int (*report_finished)(qselect_handler_t *thiz, lList** alpp);
103
int (*report_queue)(qselect_handler_t *thiz, const char* qname, lList** alpp);
104
int (*destroy)(qselect_handler_t *thiz, lList** alpp);
107
int qselect(qstat_env_t* qstat_env, qselect_handler_t *handler, lList **alpp);
109
/* ------------- Cluster Queue Summary -------------------------------------- */
112
typedef struct cqueue_summary_str cqueue_summary_t;
114
struct cqueue_summary_str {
116
bool is_load_available;
120
u_long32 temp_disabled;
122
u_long32 manual_intervention;
123
u_long32 suspend_manual;
124
u_long32 suspend_threshold;
125
u_long32 suspend_on_subordinate;
126
u_long32 suspend_calendar;
127
u_long32 unknown, load_alarm;
128
u_long32 disabled_manual;
129
u_long32 disabled_calendar;
131
u_long32 orphaned, error;
134
typedef struct cqueue_summary_handler_str cqueue_summary_handler_t;
136
struct cqueue_summary_handler_str {
138
qstat_env_t *qstat_env;
140
int (*report_started)(cqueue_summary_handler_t *thiz, lList **alpp);
141
int (*report_finished)(cqueue_summary_handler_t *thiz, lList **alpp);
143
int (*report_cqueue)(cqueue_summary_handler_t *thiz, const char* cqname, cqueue_summary_t *summary, lList **alpp);
145
int (*destroy)(cqueue_summary_handler_t *thiz);
148
int qstat_cqueue_summary(qstat_env_t* qstat_env, cqueue_summary_handler_t *handler, lList **alpp);
150
/* ---------------- QStat queue/job handling ---------------------------------*/
152
typedef struct queue_summary_str queue_summary_t;
154
struct queue_summary_str {
156
const char* queue_type;
165
const char* load_avg_str;
167
bool has_load_value_from_object;
172
typedef struct job_summary_str job_summary_t;
174
struct job_summary_str {
188
const char* department;
192
time_t stop_initiate_time;
203
u_long override_tickets;
204
bool is_queue_assigned;
221
JOB_ADDITIONAL_INFO_ERROR = 0,
225
} job_additional_info_t;
227
typedef struct task_summary_str task_summary_t;
229
struct task_summary_str {
239
bool has_exit_status;
240
u_long32 exit_status;
243
typedef struct job_handler_str job_handler_t;
245
struct job_handler_str {
248
qstat_env_t *qstat_env;
250
int(*report_job)(job_handler_t* handler, u_long32 jid, job_summary_t *summary, lList **alpp);
252
int (*report_sub_tasks_started)(job_handler_t* handler, lList **alpp);
253
int (*report_sub_task)(job_handler_t* handler, task_summary_t *summary, lList **alpp);
254
int (*report_sub_tasks_finished)(job_handler_t* handler, lList **alpp);
256
int (*report_additional_info)(job_handler_t *handler, job_additional_info_t name, const char* value, lList **alpp);
258
int (*report_requested_pe)(job_handler_t *handler, const char* pe_name, const char* pe_range, lList **alpp);
259
int (*report_granted_pe)(job_handler_t *handler, const char* pe_name, int pe_slots, lList **alpp);
261
int (*report_request)(job_handler_t* handler, const char* name, const char* value, lList **alpp);
263
int (*report_hard_resources_started)(job_handler_t* handler, lList **alpp);
264
int (*report_hard_resource)(job_handler_t *handler, const char* name, const char* value, double uc, lList **alpp);
265
int (*report_hard_resources_finished)(job_handler_t* handler, lList **alpp);
267
int (*report_soft_resources_started)(job_handler_t* handler, lList **alpp);
268
/* RH TODO: the soft resource/request has no contribution => remove the parameter uc */
269
int (*report_soft_resource)(job_handler_t *handler, const char* name, const char* value, double uc, lList **alpp);
270
int (*report_soft_resources_finished)(job_handler_t* handler, lList **alpp);
272
int (*report_hard_requested_queues_started)(job_handler_t *handler, lList **alpp);
273
int (*report_hard_requested_queue)(job_handler_t *handler, const char* name, lList **alpp);
274
int (*report_hard_requested_queues_finished)(job_handler_t *handler, lList **alpp);
276
int (*report_soft_requested_queues_started)(job_handler_t *handler, lList **alpp);
277
int (*report_soft_requested_queue)(job_handler_t *handler, const char* name, lList **alpp);
278
int (*report_soft_requested_queues_finished)(job_handler_t *handler, lList **alpp);
280
int (*report_master_hard_requested_queues_started)(job_handler_t* handler, lList **alpp);
281
int (*report_master_hard_requested_queue)(job_handler_t* handler, const char* name, lList **alpp);
282
int (*report_master_hard_requested_queues_finished)(job_handler_t* handler, lList **alpp);
284
int (*report_predecessors_requested_started)(job_handler_t* handler, lList **alpp);
285
int (*report_predecessor_requested)(job_handler_t* handler, const char* name, lList **alpp);
286
int (*report_predecessors_requested_finished)(job_handler_t* handler, lList **alpp);
288
int (*report_predecessors_started)(job_handler_t* handler, lList **alpp);
289
int (*report_predecessor)(job_handler_t* handler, u_long32 jid, lList **alpp);
290
int (*report_predecessors_finished)(job_handler_t* handler, lList **alpp);
292
int (*report_ad_predecessors_requested_started)(job_handler_t* handler, lList **alpp);
293
int (*report_ad_predecessor_requested)(job_handler_t* handler, const char* name, lList **alpp);
294
int (*report_ad_predecessors_requested_finished)(job_handler_t* handler, lList **alpp);
296
int (*report_ad_predecessors_started)(job_handler_t* handler, lList **alpp);
297
int (*report_ad_predecessor)(job_handler_t* handler, u_long32 jid, lList **alpp);
298
int (*report_ad_predecessors_finished)(job_handler_t* handler, lList **alpp);
300
int (*report_job_finished)(job_handler_t* handler, u_long32 jid, lList **alpp);
305
typedef struct qstat_handler_str qstat_handler_t;
307
struct qstat_handler_str {
309
qstat_env_t *qstat_env;
311
int (*report_started)(qstat_handler_t* handler, lList** alpp);
312
int (*report_finished)(qstat_handler_t* hanlder, lList** alpp);
314
int (*report_queue_started)(qstat_handler_t *handler, const char* qname, lList **alpp);
315
int (*report_queue_summary)(qstat_handler_t *handler, const char* qname, queue_summary_t *summary, lList **alpp);
316
int (*report_queue_load_alarm)(qstat_handler_t* handler, const char* qname, const char* reason, lList **alpp);
317
int (*report_queue_suspend_alarm)(qstat_handler_t* handler, const char* qname, const char* reason, lList **alpp);
318
int (*report_queue_message)(qstat_handler_t* handler, const char* qname, const char *message, lList **alpp);
320
int (*report_queue_resource)(qstat_handler_t* handler, const char* dom, const char* name, const char* value, lList **alpp);
322
job_handler_t job_handler;
324
int (*report_queue_jobs_started)(qstat_handler_t *handler, const char* qname, lList **alpp);
325
int (*report_queue_jobs_finished)(qstat_handler_t *handler, const char* qname, lList **alpp);
327
int (*report_queue_finished)(qstat_handler_t* handler, const char* qname, lList **alpp);
329
int (*report_pending_jobs_started)(qstat_handler_t *handler, lList **alpp);
330
int (*report_pending_jobs_finished)(qstat_handler_t *handler, lList **alpp);
331
int (*report_finished_jobs_started)(qstat_handler_t *handler, lList **alpp);
332
int (*report_finished_jobs_finished)(qstat_handler_t *handler, lList **alpp);
333
int (*report_error_jobs_started)(qstat_handler_t *handler, lList **alpp);
334
int (*report_error_jobs_finished)(qstat_handler_t *handler, lList **alpp);
335
int (*report_zombie_jobs_started)(qstat_handler_t *handler, lList **alpp);
336
int (*report_zombie_jobs_finished)(qstat_handler_t *handler, lList **alpp);
339
int (*destroy)(qstat_handler_t* handler);
344
int qstat_no_group(qstat_env_t* qstat_env, qstat_handler_t* handler, lList **alpp);
347
void qstat_env_destroy(qstat_env_t *qstat_env);
349
const char* sge_get_dominant_stringval(lListElem *rep, u_long32 *dominant_p, dstring *resource_string_p);
351
int filter_queues(lList **filtered_queue_list,
355
lList *exechost_list,
359
lList *resource_list,
360
lList *queueref_list,
362
lList *queue_user_list,
363
u_long32 queue_states,
366
lCondition *qstat_get_JB_Type_selection(lList *user_list, u_long32 show);
367
lEnumeration *qstat_get_JB_Type_filter(qstat_env_t* qstat_env);
368
void qstat_filter_add_core_attributes(qstat_env_t* qstat_env);
369
void qstat_filter_add_ext_attributes(qstat_env_t* qstat_env);
370
void qstat_filter_add_pri_attributes(qstat_env_t* qstat_env);
371
void qstat_filter_add_urg_attributes(qstat_env_t* qstat_env);
372
void qstat_filter_add_l_attributes(qstat_env_t* qstat_env);
373
void qstat_filter_add_q_attributes(qstat_env_t* qstat_env);
374
void qstat_filter_add_pe_attributes(qstat_env_t* qstat_env);
375
void qstat_filter_add_r_attributes(qstat_env_t *qstat_env);
376
void qstat_filter_add_xml_attributes(qstat_env_t *qstat_env);
377
void qstat_filter_add_t_attributes(qstat_env_t *qstat_env);
378
void qstat_filter_add_U_attributes(qstat_env_t *qstat_env);
380
int build_job_state_filter(qstat_env_t *qstat_env, const char* job_state, lList **alpp);