~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/clients/qrstat/qrstat_report_handler.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 * 
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 * 
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 * 
 
9
 * 
 
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
 
16
 * 
 
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.
 
23
 * 
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 * 
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 * 
 
28
 *   All Rights Reserved.
 
29
 * 
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
 
 
33
#include <string.h>
 
34
 
 
35
#include "basis_types.h"
 
36
#include "sge.h"
 
37
#include "sgermon.h"
 
38
#include "sge_strL.h"
 
39
#include "sge_ulongL.h"
 
40
 
 
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"
 
52
 
 
53
#include "qrstat_report_handler.h"
 
54
 
 
55
#include "msg_common.h"
 
56
 
 
57
bool
 
58
qrstat_print(lList **answer_list, qrstat_report_handler_t *handler, qrstat_env_t *qrstat_env) {
 
59
   bool ret = true;
 
60
 
 
61
   DENTER(TOP_LAYER, "qrstat_print");
 
62
 
 
63
   {
 
64
      lListElem *ar = NULL;
 
65
 
 
66
      handler->report_start(handler, answer_list);
 
67
      if (qrstat_env->is_summary == false &&
 
68
          lGetNumberOfElem(qrstat_env->ar_list) == 0) {
 
69
 
 
70
          ret = false;
 
71
 
 
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);
 
76
          }
 
77
          handler->report_newline(handler, answer_list);
 
78
      } else {
 
79
         for_each(ar, qrstat_env->ar_list) {
 
80
 
 
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));
 
91
 
 
92
            if (qrstat_env->is_explain || handler->show_summary == false) {
 
93
               lListElem *qinstance;
 
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);
 
99
                  }
 
100
               }
 
101
            }
 
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));
 
107
 
 
108
               if (lGetList(ar, AR_resource_list) != NULL) {
 
109
                  lListElem *resource = NULL;
 
110
 
 
111
                  handler->report_start_resource_list(handler, answer_list);            
 
112
                  for_each(resource, lGetList(ar, AR_resource_list)) {
 
113
                     dstring string_value = DSTRING_INIT;
 
114
 
 
115
                     if (lGetString(resource, CE_stringval)) {
 
116
                        sge_dstring_append(&string_value, lGetString(resource, CE_stringval));
 
117
                     } else {
 
118
                        sge_dstring_sprintf(&string_value, "%f", lGetDouble(resource, CE_doubleval));
 
119
                     }
 
120
 
 
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);
 
125
                  }
 
126
                  handler->report_finish_resource_list(handler, answer_list);
 
127
               }
 
128
               
 
129
               if (lGetUlong(ar, AR_error_handling) != 0) {
 
130
                  handler->report_ar_node_boolean(handler, answer_list, "error_handling", true);
 
131
               }
 
132
               
 
133
               if (lGetList(ar, AR_granted_slots) != NULL) {
 
134
                  lListElem *resource = NULL;
 
135
 
 
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));
 
141
                  }
 
142
                  handler->report_finish_granted_slots_list(handler, answer_list);
 
143
               }
 
144
               if (lGetString(ar, AR_pe) != NULL) {
 
145
                  dstring pe_range_string = DSTRING_INIT;
 
146
 
 
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);
 
154
               }
 
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);
 
162
               }
 
163
 
 
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));
 
167
               }
 
168
 
 
169
               if (lGetUlong(ar, AR_mail_options) != 0) {
 
170
                  dstring mailopt = DSTRING_INIT;
 
171
 
 
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));
 
175
 
 
176
                  sge_dstring_free(&mailopt);
 
177
               }
 
178
 
 
179
               if (lGetList(ar, AR_mail_list) != NULL) {
 
180
                  lListElem *mail = NULL;
 
181
 
 
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),
 
188
                                                    host?host:"NONE");
 
189
                  }
 
190
                  handler->report_finish_mail_list(handler, answer_list);
 
191
               }
 
192
               if (lGetList(ar, AR_acl_list) != NULL) {
 
193
                  lListElem *acl = NULL;
 
194
 
 
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));
 
199
                  }
 
200
                  handler->report_finish_acl_list(handler, answer_list);
 
201
               }
 
202
               if (lGetList(ar, AR_xacl_list) != NULL) {
 
203
                  lListElem *xacl = NULL;
 
204
 
 
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));
 
209
                  }
 
210
                  handler->report_finish_xacl_list(handler, answer_list);
 
211
               }
 
212
            }
 
213
            handler->report_finish_ar(handler, answer_list);
 
214
         }
 
215
      }
 
216
 
 
217
      handler->report_finish(handler, answer_list);
 
218
   }
 
219
   DRETURN(ret);
 
220
}
 
221