1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
35
#include "basis_types.h"
39
#include "sge_ulongL.h"
41
#include "sgeobj/sge_answer.h"
42
#include "sgeobj/sge_advance_reservation.h"
43
#include "sgeobj/sge_centry.h"
44
#include "sgeobj/sge_job.h"
45
#include "sgeobj/sge_range.h"
46
#include "sgeobj/sge_mailrec.h"
47
#include "sgeobj/sge_userset.h"
48
#include "sgeobj/sge_qinstance.h"
49
#include "sgeobj/sge_qref.h"
50
#include "sgeobj/sge_mesobj.h"
51
#include "sgeobj/cull_parse_util.h"
53
#include "qrstat_report_handler.h"
55
#include "msg_common.h"
58
qrstat_print(lList **answer_list, qrstat_report_handler_t *handler, qrstat_env_t *qrstat_env) {
61
DENTER(TOP_LAYER, "qrstat_print");
66
handler->report_start(handler, answer_list);
67
if (qrstat_env->is_summary == false &&
68
lGetNumberOfElem(qrstat_env->ar_list) == 0) {
72
for_each(ar, qrstat_env->ar_id_list) {
73
handler->report_start_unknown_ar(handler, qrstat_env, answer_list);
74
handler->report_ar_node_ulong_unknown(handler, qrstat_env, answer_list, "id", lGetUlong(ar, ULNG));
75
handler->report_finish_unknown_ar(handler, answer_list);
77
handler->report_newline(handler, answer_list);
79
for_each(ar, qrstat_env->ar_list) {
81
handler->report_start_ar(handler, qrstat_env, answer_list);
82
handler->report_ar_node_ulong(handler, qrstat_env, answer_list, "id", lGetUlong(ar, AR_id));
83
handler->report_ar_node_string(handler, answer_list, "name", lGetString(ar, AR_name));
84
handler->report_ar_node_string(handler, answer_list, "owner", lGetString(ar, AR_owner));
85
handler->report_ar_node_state(handler, answer_list, "state", lGetUlong(ar, AR_state));
86
handler->report_ar_node_time(handler, answer_list, "start_time",
87
((time_t)lGetUlong(ar, AR_start_time)));
88
handler->report_ar_node_time(handler, answer_list, "end_time",
89
((time_t)lGetUlong(ar, AR_end_time)));
90
handler->report_ar_node_duration(handler, answer_list, "duration", lGetUlong(ar, AR_duration));
92
if (qrstat_env->is_explain || handler->show_summary == false) {
94
for_each(qinstance, lGetList(ar, AR_reserved_queues)) {
95
lListElem *qim = NULL;
96
for_each(qim, lGetList(qinstance, QU_message_list)) {
97
const char *message = lGetString(qim, QIM_message);
98
handler->report_ar_node_string(handler, answer_list, "message", message);
102
if (handler->show_summary == false) {
103
handler->report_ar_node_time(handler, answer_list, "submission_time",
104
((time_t)lGetUlong(ar, AR_submission_time)));
105
handler->report_ar_node_string(handler, answer_list, "group", lGetString(ar, AR_group));
106
handler->report_ar_node_string(handler, answer_list, "account", lGetString(ar, AR_account));
108
if (lGetList(ar, AR_resource_list) != NULL) {
109
lListElem *resource = NULL;
111
handler->report_start_resource_list(handler, answer_list);
112
for_each(resource, lGetList(ar, AR_resource_list)) {
113
dstring string_value = DSTRING_INIT;
115
if (lGetString(resource, CE_stringval)) {
116
sge_dstring_append(&string_value, lGetString(resource, CE_stringval));
118
sge_dstring_sprintf(&string_value, "%f", lGetDouble(resource, CE_doubleval));
121
handler->report_resource_list_node(handler, answer_list,
122
lGetString(resource, CE_name),
123
sge_dstring_get_string(&string_value));
124
sge_dstring_free(&string_value);
126
handler->report_finish_resource_list(handler, answer_list);
129
if (lGetUlong(ar, AR_error_handling) != 0) {
130
handler->report_ar_node_boolean(handler, answer_list, "error_handling", true);
133
if (lGetList(ar, AR_granted_slots) != NULL) {
134
lListElem *resource = NULL;
136
handler->report_start_granted_slots_list(handler, answer_list);
137
for_each(resource, lGetList(ar, AR_granted_slots)) {
138
handler->report_granted_slots_list_node(handler, answer_list,
139
lGetString(resource, JG_qname),
140
lGetUlong(resource, JG_slots));
142
handler->report_finish_granted_slots_list(handler, answer_list);
144
if (lGetString(ar, AR_pe) != NULL) {
145
dstring pe_range_string = DSTRING_INIT;
147
range_list_print_to_string(lGetList(ar, AR_pe_range), &pe_range_string, true, false, false);
148
handler->report_start_granted_parallel_environment(handler, answer_list);
149
handler->report_granted_parallel_environment_node(handler, answer_list,
150
lGetString(ar, AR_pe),
151
sge_dstring_get_string(&pe_range_string));
152
handler->report_finish_granted_parallel_environment(handler, answer_list);
153
sge_dstring_free(&pe_range_string);
155
if (lGetList(ar, AR_master_queue_list) != NULL) {
156
char tmp_buffer[MAX_STRING_SIZE];
157
int fields[] = {QR_name, 0 };
158
const char *delis[] = {" ", ",", ""};
159
uni_print_list(NULL, tmp_buffer, sizeof(tmp_buffer), lGetList(ar, AR_master_queue_list),
160
fields, delis, FLG_NO_DELIS_STRINGS);
161
handler->report_ar_node_string(handler, answer_list, "master hard queue_list", tmp_buffer);
164
if (lGetString(ar, AR_checkpoint_name) != NULL) {
165
handler->report_ar_node_string(handler, answer_list, "checkpoint_name",
166
lGetString(ar, AR_checkpoint_name));
169
if (lGetUlong(ar, AR_mail_options) != 0) {
170
dstring mailopt = DSTRING_INIT;
172
sge_dstring_append_mailopt(&mailopt, lGetUlong(ar, AR_mail_options));
173
handler->report_ar_node_string(handler, answer_list, "mail_options",
174
sge_dstring_get_string(&mailopt));
176
sge_dstring_free(&mailopt);
179
if (lGetList(ar, AR_mail_list) != NULL) {
180
lListElem *mail = NULL;
182
handler->report_start_mail_list(handler, answer_list);
183
for_each(mail, lGetList(ar, AR_mail_list)) {
184
const char *host=NULL;
185
host=lGetHost(mail, MR_host);
186
handler->report_mail_list_node(handler, answer_list,
187
lGetString(mail, MR_user),
190
handler->report_finish_mail_list(handler, answer_list);
192
if (lGetList(ar, AR_acl_list) != NULL) {
193
lListElem *acl = NULL;
195
handler->report_start_acl_list(handler, answer_list);
196
for_each(acl, lGetList(ar, AR_acl_list)) {
197
handler->report_acl_list_node(handler, answer_list,
198
lGetString(acl, ARA_name));
200
handler->report_finish_acl_list(handler, answer_list);
202
if (lGetList(ar, AR_xacl_list) != NULL) {
203
lListElem *xacl = NULL;
205
handler->report_start_xacl_list(handler, answer_list);
206
for_each(xacl, lGetList(ar, AR_xacl_list)) {
207
handler->report_xacl_list_node(handler, answer_list,
208
lGetString(xacl, ARA_name));
210
handler->report_finish_xacl_list(handler, answer_list);
213
handler->report_finish_ar(handler, answer_list);
217
handler->report_finish(handler, answer_list);