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

« back to all changes in this revision

Viewing changes to source/clients/qmon/qmon_cq.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
#include <stdlib.h>
 
33
#include <ctype.h>
 
34
#include <float.h>
 
35
#include <math.h>
 
36
 
 
37
#include <Xm/ToggleB.h>
 
38
#include <Xmt/Xmt.h>
 
39
#include <Xmt/Create.h>
 
40
#include <Xmt/Layout.h>
 
41
#include <Xmt/Chooser.h>
 
42
#include <Xmt/Dialog.h>
 
43
#include <Xmt/Dialogs.h>
 
44
#include <Xmt/MsgLine.h>
 
45
#include <Xmt/InputField.h>
 
46
#include <Xmt/Procedures.h>
 
47
 
 
48
#include "ListTree.h"
 
49
#include "Matrix.h"
 
50
#include "Tab.h"
 
51
 
 
52
#include "qmon_rmon.h"
 
53
#include "qmon_cull.h"
 
54
#include "qmon_util.h"
 
55
#include "qmon_init.h"
 
56
#include "qmon_timer.h"
 
57
#include "qmon_comm.h"
 
58
#include "qmon_browser.h"
 
59
#include "qmon_cq.h"
 
60
#include "qmon_qaction.h"
 
61
#include "qmon_appres.h"
 
62
#include "sgeee.h"
 
63
#include "qmon_message.h"
 
64
#include "qmon_widgets.h"
 
65
#include "qmon_manop.h"
 
66
#include "qmon_project.h"
 
67
#include "qmon_ticket.h"
 
68
#include "qmon_qcustom.h"
 
69
#include "qmon_globals.h"
 
70
#include "sge_all_listsL.h"
 
71
#include "sge_dstring.h"
 
72
#include "sge_string.h"
 
73
#include "sge_support.h"
 
74
#include "sge_answer.h"
 
75
#include "sge_cqueue.h"
 
76
#include "sge_cqueue_qstat.h"
 
77
#include "sge_cqueue_qconf.h"
 
78
#include "sge_select_queue.h"
 
79
#include "sge_qinstance.h"
 
80
#include "sge_qinstance_state.h"
 
81
#include "sge_qinstance_type.h"
 
82
#include "load_correction.h"
 
83
#include "sge_parse_num_par.h"
 
84
#include "sge_complex_schedd.h"
 
85
#include "qstat_printing.h"
 
86
#include "sge_centry.h"
 
87
#include "sge_qstat.h"
 
88
 
 
89
#include "gdi/sge_gdi_ctx.h"
 
90
#include "gdi/sge_gdi.h"
 
91
 
 
92
extern sge_gdi_ctx_class_t *ctx;
 
93
 
 
94
 
 
95
static Widget qmon_cq = 0;
 
96
static Widget cq_cqfolder = 0;
 
97
static Widget cq_customize = 0;
 
98
static Widget cq_tree = 0;
 
99
static Widget cq_message = 0;
 
100
static Widget cluster_queue_settings = 0;
 
101
static Widget qinstance_settings = 0;
 
102
static Widget cq_add = 0;
 
103
static Widget cq_clone = 0;
 
104
static Widget cq_mod = 0;
 
105
static Widget cq_delete = 0;
 
106
static Widget cq_load = 0;
 
107
static Widget cq_suspend = 0;
 
108
static Widget cq_resume = 0;
 
109
static Widget cq_disable = 0;
 
110
static Widget cq_enable = 0;
 
111
static Widget cq_reschedule = 0;
 
112
static Widget cq_sick = 0;
 
113
static Widget cq_clear_error = 0;
 
114
static Widget cq_force = 0;
 
115
static Widget cq_explain_states = 0;
 
116
static Widget cq_explain = 0;
 
117
 
 
118
static Boolean dirty = False;
 
119
static Widget current_matrix = 0;
 
120
 
 
121
#define QI_SORTING
 
122
 
 
123
#ifdef QI_SORTING
 
124
/*
 
125
** use this descriptor only here
 
126
*/
 
127
enum {
 
128
   QI_queue,
 
129
   QI_qtype,
 
130
   QI_used_total,
 
131
   QI_load_avg,
 
132
   QI_arch,
 
133
   QI_states
 
134
};
 
135
 
 
136
static lDescr qi_descr[] = {
 
137
   { QI_queue, lStringT, NULL },
 
138
   { QI_qtype, lStringT, NULL },
 
139
   { QI_used_total, lStringT, NULL },
 
140
   { QI_load_avg, lStringT, NULL },
 
141
   { QI_arch, lStringT, NULL },
 
142
   { QI_states, lStringT, NULL },
 
143
   { NoName, lEndT, NULL}};
 
144
 
 
145
enum {
 
146
   SORT_ASCENDING = 0,
 
147
   SORT_DESCENDING = 1
 
148
};   
 
149
static int qi_field_sort_by = QI_queue;
 
150
static int qi_field_sort_direction = SORT_ASCENDING;
 
151
#endif
 
152
 
 
153
 
 
154
/*-------------------------------------------------------------------------*/
 
155
static Widget qhost_settings = 0;
 
156
static void qmonCQUpdateQhostMatrix(void);
 
157
 
 
158
static void qmonCQPopdown(Widget w, XtPointer cld, XtPointer cad);
 
159
static Widget qmonCQCreate(Widget shell);
 
160
static void qmonQinstanceHandleEnterLeave(Widget w, XtPointer cld, XEvent *ev, Boolean *ctd);
 
161
static void qmonCQHandleEnterLeave(Widget w, XtPointer cld, XEvent *ev, Boolean *ctd);
 
162
static void qmonQinstanceShowBrowserInfo(dstring *info, lListElem *qep);
 
163
static String qmonCQShowBrowserInfo(lListElem *qep);
 
164
static void qmonCQDelete(Widget matrix, XtPointer cld, XtPointer cad);
 
165
static void qmonCQChangeState(Widget w, XtPointer cld, XtPointer cad);
 
166
static void qmonCQFolderChange(Widget w, XtPointer cld, XtPointer cad);
 
167
static void qmonCQUpdateCQMatrix(void);
 
168
static void qmonCQUpdateQIMatrix(void);
 
169
static void qmonCQModify(Widget w, XtPointer cld, XtPointer cad);
 
170
static void qmonQinstanceSetLoad(Widget matrix, const char *qiname);
 
171
static void qmonQinstanceShowLoad(Widget w, XtPointer cld, XtPointer cad);
 
172
static void qmonCQSick(Widget w, XtPointer cld, XtPointer cad);
 
173
static void qmonQinstanceExplain(Widget w, XtPointer cld, XtPointer cad);
 
174
#ifdef QI_SORTING
 
175
static void qmonQinstanceSort(Widget w, XtPointer cld, XtPointer cad);
 
176
#endif
 
177
 
 
178
static void qmonQinstanceShowBrowserExplain(
 
179
dstring *info,
 
180
lListElem *q,
 
181
lList *centry_list,
 
182
lList *exechost_list,
 
183
u_long32 explain_bits);
 
184
/* static void qmonCQSetValues(ListTreeItem *item); */
 
185
 
 
186
#if 0
 
187
static void qmonCQHighlight(Widget w, XtPointer cld, XtPointer cad);
 
188
static void qmonCQMenu(Widget w, XtPointer cld, XtPointer cad);
 
189
static void qmonCQActivate(Widget w, XtPointer cld, XtPointer cad);
 
190
static void qmonCQFindNode(Widget w, XtPointer cld, XtPointer cad);
 
191
static void qmonCQFindNextNode(Widget w, XtPointer cld, XtPointer cad);
 
192
static ListTreeItem* CullToTree(Widget tree, ListTreeItem *parent, lList *shac);
 
193
static void qmonCQUpdateTree(void);
 
194
#endif
 
195
 
 
196
#if 0
 
197
static ListTreeItem* cq_add_aulng(Widget tree, ListTreeItem *parent, 
 
198
                           lListElem *elem, int field_nm, 
 
199
                           StringConst attribute_name);
 
200
static ListTreeItem* cq_add_abool(Widget tree, ListTreeItem *parent, 
 
201
                           lListElem *elem, int field_nm, 
 
202
                           StringConst attribute_name);
 
203
static ListTreeItem* cq_add_amem(Widget tree, ListTreeItem *parent, 
 
204
                           lListElem *elem, int field_nm, 
 
205
                           StringConst attribute_name);
 
206
static ListTreeItem* cq_add_atime(Widget tree, ListTreeItem *parent, 
 
207
                           lListElem *elem, int field_nm, 
 
208
                           StringConst attribute_name);
 
209
static ListTreeItem* cq_add_ainter(Widget tree, ListTreeItem *parent, 
 
210
                           lListElem *elem, int field_nm, 
 
211
                           StringConst attribute_name);
 
212
static ListTreeItem* cq_add_astr(Widget tree, ListTreeItem *parent, 
 
213
                           lListElem *elem, int field_nm, 
 
214
                           StringConst attribute_name);
 
215
static ListTreeItem* cq_add_astrlist(Widget tree, ListTreeItem *parent, 
 
216
                           lListElem *elem, int field_nm, 
 
217
                           StringConst attribute_name);
 
218
static ListTreeItem* cq_add_ausrlist(Widget tree, ListTreeItem *parent, 
 
219
                           lListElem *elem, int field_nm, 
 
220
                           StringConst attribute_name);
 
221
static ListTreeItem* cq_add_aprjlist(Widget tree, ListTreeItem *parent, 
 
222
                           lListElem *elem, int field_nm, 
 
223
                           StringConst attribute_name);
 
224
static ListTreeItem* cq_add_acelist(Widget tree, ListTreeItem *parent, 
 
225
                           lListElem *elem, int field_nm, 
 
226
                           StringConst attribute_name);
 
227
static ListTreeItem* cq_add_asolist(Widget tree, ListTreeItem *parent, 
 
228
                           lListElem *elem, int field_nm, 
 
229
                           StringConst attribute_name);
 
230
static ListTreeItem* cq_add_aqtlist(Widget tree, ListTreeItem *parent, 
 
231
                           lListElem *elem, int field_nm, 
 
232
                           StringConst attribute_name);
 
233
#endif
 
234
 
 
235
static void qmonCQStartUpdate(Widget w, XtPointer cld, XtPointer cad);
 
236
static void qmonCQStopUpdate(Widget w, XtPointer cld, XtPointer cad);
 
237
 
 
238
 
 
239
 
 
240
/*-------------------------------------------------------------------------*/
 
241
/* P U B L I C                                                             */
 
242
/*-------------------------------------------------------------------------*/
 
243
void qmonCQPopup(Widget w, XtPointer cld, XtPointer cad)
 
244
{
 
245
   Widget shell;
 
246
 
 
247
   DENTER(GUI_LAYER, "qmonCQPopup");
 
248
 
 
249
   /*
 
250
   ** reset dirty flag
 
251
   */
 
252
   dirty = False;
 
253
 
 
254
   /* set busy cursor */
 
255
   XmtDisplayBusyCursor(w);
 
256
 
 
257
   if (!qmon_cq) {
 
258
      shell = XmtGetTopLevelShell(w);
 
259
      qmon_cq = qmonCQCreate(shell);
 
260
      XmtAddDeleteCallback(shell, XmDO_NOTHING, 
 
261
                              qmonCQPopdown, NULL);
 
262
   } 
 
263
   
 
264
   /*
 
265
   ** show qhost_settings folder only if showHostTab == true
 
266
   ** this can be set in ~/Qmon file or changed in Q to default to true
 
267
   */
 
268
   if (!SHOW_HOST_TAB) {
 
269
      XmTabDeleteFolder(cq_cqfolder, XtParent(qhost_settings));
 
270
   }
 
271
   
 
272
   /*
 
273
   ** fill the displayed dialogues
 
274
   */
 
275
   qmonQCUReadPreferences();
 
276
   qmonCQUpdate(qmon_cq, NULL, NULL);
 
277
   XmTabSetTabWidget(cq_cqfolder, current_matrix, True);
 
278
 
 
279
   xmui_manage(qmon_cq);
 
280
 
 
281
   /* set default cursor */
 
282
   XmtDisplayDefaultCursor(w);
 
283
 
 
284
   DEXIT;
 
285
}
 
286
 
 
287
 
 
288
/*-------------------------------------------------------------------------*/
 
289
/* P R I V A T E                                                           */
 
290
/*-------------------------------------------------------------------------*/
 
291
static void qmonCQPopdown(Widget w, XtPointer cld, XtPointer cad)
 
292
{
 
293
 
 
294
   DENTER(GUI_LAYER, "qmonCQPopdown");
 
295
 
 
296
   XtUnmanageChild(qmon_cq);
 
297
 
 
298
   DEXIT;
 
299
}
 
300
 
 
301
/*-------------------------------------------------------------------------*/
 
302
static Widget qmonCQCreate(
 
303
Widget parent 
 
304
) {
 
305
   Widget cq_layout, cq_close, cq_update, cq_main_link, 
 
306
          cq_tickets;
 
307
 
 
308
   DENTER(GUI_LAYER, "qmonCQCreate");
 
309
 
 
310
   cq_layout = XmtBuildQueryDialog( parent, "qmon_cq",
 
311
                           NULL, 0,
 
312
                           "cq_close", &cq_close,
 
313
                           "cq_force", &cq_force,
 
314
                           "cq_update", &cq_update,
 
315
                           "cq_add", &cq_add,
 
316
                           "cq_clone", &cq_clone,
 
317
                           "cq_mod", &cq_mod,
 
318
                           "cq_delete", &cq_delete,
 
319
                           "cq_suspend", &cq_suspend,
 
320
                           "cq_resume", &cq_resume,
 
321
                           "cq_disable", &cq_disable,
 
322
                           "cq_enable", &cq_enable,
 
323
                           "cq_reschedule", &cq_reschedule,
 
324
                           "cq_clear_error", &cq_clear_error,
 
325
                           "cq_load", &cq_load,
 
326
                           "cq_sick", &cq_sick,
 
327
                           "cq_tree", &cq_tree,
 
328
                           "cq_customize", &cq_customize,
 
329
                           "cq_tickets", &cq_tickets,
 
330
                           "cq_main_link", &cq_main_link,
 
331
                           "cq_message", &cq_message,
 
332
                           "cluster_queue_settings", &cluster_queue_settings,
 
333
                           "qinstance_settings", &qinstance_settings,
 
334
                           "qhost_settings", &qhost_settings,
 
335
                           "cq_cqfolder", &cq_cqfolder,
 
336
                           "cq_explain", &cq_explain,
 
337
                           "cq_explain_states", &cq_explain_states,
 
338
                           NULL);
 
339
   
 
340
   current_matrix = cluster_queue_settings;
 
341
 
 
342
   if (SHOW_HOST_TAB && AUTOMATIC_UPDATE_HOST_TAB) {
 
343
      /* start the needed timers and the corresponding update routines */
 
344
      XtAddCallback(XtParent(cq_layout), XmNpopupCallback,
 
345
          qmonCQStartUpdate, NULL);
 
346
      XtAddCallback(XtParent(cq_layout), XmNpopdownCallback,
 
347
          qmonCQStopUpdate, NULL);
 
348
   }    
 
349
 
 
350
   /*
 
351
   ** callbacks
 
352
   */
 
353
   XtAddCallback(cq_main_link, XmNactivateCallback, 
 
354
                     qmonMainControlRaise, NULL);
 
355
   XtAddCallback(cq_close, XmNactivateCallback, 
 
356
                     qmonCQPopdown, NULL);
 
357
   XtAddCallback(cq_update, XmNactivateCallback, 
 
358
                     qmonCQUpdate, NULL);
 
359
   XtAddCallback(cq_tickets, XmNactivateCallback, 
 
360
                     qmonPopupTicketOverview, NULL);
 
361
 
 
362
#if 0
 
363
   XtAddCallback(cq_tree, XtNactivateCallback, 
 
364
                     qmonCQActivate, NULL);
 
365
   XtAddCallback(cq_tree, XtNhighlightCallback, 
 
366
                     qmonCQHighlight, NULL);
 
367
   XtAddCallback(cq_tree, XtNmenuCallback, 
 
368
                     qmonCQMenu, NULL);
 
369
#endif                     
 
370
 
 
371
   XtAddCallback(cq_add, XmNactivateCallback, 
 
372
                     qmonQCPopup, NULL);
 
373
   XtAddCallback(cq_clone, XmNactivateCallback, 
 
374
                     qmonCQModify, (XtPointer)QC_CLONE);
 
375
   XtAddCallback(cq_mod, XmNactivateCallback, 
 
376
                     qmonCQModify, (XtPointer)QC_MODIFY);
 
377
   XtAddCallback(cq_delete, XmNactivateCallback, 
 
378
                     qmonCQDelete, NULL);
 
379
 
 
380
   XtAddCallback(cq_suspend, XmNactivateCallback, 
 
381
                     qmonCQChangeState, (XtPointer)QI_DO_SUSPEND);
 
382
   XtAddCallback(cq_resume, XmNactivateCallback, 
 
383
                     qmonCQChangeState, (XtPointer)QI_DO_UNSUSPEND);
 
384
   XtAddCallback(cq_disable, XmNactivateCallback, 
 
385
                     qmonCQChangeState, (XtPointer)QI_DO_DISABLE);
 
386
   XtAddCallback(cq_enable, XmNactivateCallback, 
 
387
                     qmonCQChangeState, (XtPointer)QI_DO_ENABLE);
 
388
   XtAddCallback(cq_reschedule, XmNactivateCallback, 
 
389
                     qmonCQChangeState, (XtPointer)QI_DO_RESCHEDULE);
 
390
   XtAddCallback(cq_clear_error, XmNactivateCallback, 
 
391
                     qmonCQChangeState, (XtPointer)QI_DO_CLEARERROR);
 
392
   XtAddCallback(cq_load, XmNactivateCallback, 
 
393
                     qmonQinstanceShowLoad, NULL);
 
394
   XtAddCallback(cq_sick, XmNactivateCallback, 
 
395
                     qmonCQSick, NULL);
 
396
   XtAddCallback(cq_explain, XmNactivateCallback, 
 
397
                     qmonQinstanceExplain, NULL);
 
398
 
 
399
 
 
400
 
 
401
   XtAddCallback(cq_cqfolder, XmNvalueChangedCallback, 
 
402
                     qmonCQFolderChange, NULL);
 
403
 
 
404
   XtAddCallback(qinstance_settings, XmNdefaultActionCallback, 
 
405
                     qmonQinstanceShowLoad, NULL);
 
406
#ifdef QI_SORTING                     
 
407
   XtAddCallback(qinstance_settings, XmNlabelActivateCallback, 
 
408
                     qmonQinstanceSort, NULL);
 
409
#endif
 
410
 
 
411
   XtAddCallback(cq_customize, XmNactivateCallback, 
 
412
                     qmonPopupQCU, NULL); 
 
413
 
 
414
   XtAddEventHandler(qinstance_settings, PointerMotionMask, 
 
415
                     False, qmonQinstanceHandleEnterLeave,
 
416
                     NULL); 
 
417
   XtAddEventHandler(cluster_queue_settings, PointerMotionMask, 
 
418
                     False, qmonCQHandleEnterLeave,
 
419
                     NULL); 
 
420
 
 
421
 
 
422
   XtAddEventHandler(XtParent(cq_layout), StructureNotifyMask, False, 
 
423
                        SetMinShellSize, NULL);
 
424
 
 
425
 
 
426
   /*
 
427
   ** register callback procedures
 
428
   */
 
429
   XmtRegisterCallbackProcedure("DeleteClusterQueue", qmonCQDelete, XtRWidget);
 
430
 
 
431
   XtSetSensitive(cq_load, False);
 
432
   XtSetSensitive(cq_explain_states, False);
 
433
   XtSetSensitive(cq_explain, False);
 
434
 
 
435
   DEXIT;
 
436
   return cq_layout;
 
437
}
 
438
 
 
439
 
 
440
 
 
441
/*-------------------------------------------------------------------------*/
 
442
void qmonCQUpdate( Widget w, XtPointer cld, XtPointer cad) 
 
443
{
 
444
   DENTER(GUI_LAYER, "qmonCQUpdate");
 
445
 
 
446
   if (!qmon_cq) {
 
447
      DEXIT;
 
448
      return;
 
449
   }
 
450
 
 
451
   XmtDisplayBusyCursor(w);
 
452
   if (current_matrix == cluster_queue_settings) {
 
453
      qmonCQUpdateCQMatrix();
 
454
   } else if (current_matrix == qinstance_settings) {
 
455
      qmonCQUpdateQIMatrix();
 
456
   } else if (current_matrix == qhost_settings) {
 
457
      qmonCQUpdateQhostMatrix();
 
458
   }   
 
459
      
 
460
/*    qmonCQUpdateTree(); */
 
461
 
 
462
   XmtDisplayDefaultCursor(w);
 
463
 
 
464
   DEXIT;
 
465
}
 
466
 
 
467
#if 0
 
468
static char search_for[256] = "";
 
469
static ListTreeMultiReturnStruct *matches;
 
470
 
 
471
/*-------------------------------------------------------------------------*/
 
472
static void qmonCQFindNode(Widget w, XtPointer cld, XtPointer cad)
 
473
{
 
474
   Widget tree = (Widget)cld;
 
475
   ListTreeItem *item = NULL;
 
476
   char name[256];
 
477
   Boolean status;
 
478
 
 
479
   DENTER(GUI_LAYER, "qmonCQFindNode");
 
480
 
 
481
   /*
 
482
   ** create new_node
 
483
   */
 
484
   strcpy(name, "");
 
485
   status = XmtAskForString(w, "xmtAskForString", "@{Enter item name}", name, 256, NULL);
 
486
 
 
487
   if (status && name[0] != '\0') {
 
488
      item = ListTreeFindChildName(tree, ListTreeFirstItem(tree), name);
 
489
      if (!item) {
 
490
         DEXIT;
 
491
         return;
 
492
      }   
 
493
      strncpy(search_for, name, 256);
 
494
      matches = NULL;
 
495
      /*
 
496
      ** Highlight the new_node
 
497
      */
 
498
      ListTreeOpenNode(tree, item);
 
499
      ListTreeMakeItemVisible(tree, item);
 
500
      ListTreeHighlightItem(tree, item, True);
 
501
   }
 
502
   else {
 
503
      strcpy(search_for, "");
 
504
   }   
 
505
 
 
506
   DEXIT;
 
507
}
 
508
 
 
509
/*-------------------------------------------------------------------------*/
 
510
static void qmonCQFindNextNode(Widget w, XtPointer cld, XtPointer cad)
 
511
{
 
512
   Widget tree = (Widget)cld;
 
513
   static int count = 0;
 
514
   ListTreeItem *current;
 
515
   int first = 0;
 
516
 
 
517
   DENTER(GUI_LAYER, "qmonCQFindNode");
 
518
 
 
519
   if (!matches && strcmp(search_for, "")) {
 
520
      first = 1;
 
521
      count = 0;
 
522
      matches = ListTreeBuildSearchList(tree, ListTreeFirstItem(tree),search_for, 1);
 
523
      /*
 
524
      {
 
525
         int i;
 
526
         for (i=0; i<matches->count; i++) 
 
527
            printf("matches->items[%d]->text: %s\n", i, matches->items[i]->text);
 
528
      }
 
529
      */
 
530
   }
 
531
 
 
532
   /*
 
533
   ** Highlight the new_node
 
534
   */
 
535
   if (matches && matches->count > 1 && count < matches->count) {
 
536
      if (first) {
 
537
         first = 0;
 
538
         count++;
 
539
      }
 
540
      current = matches->items[count];
 
541
      DPRINTF(("current->text: %s, current->count = %d\n", current->text, current->count));
 
542
      /*
 
543
      ** open branch and highlight item
 
544
      */
 
545
      ListTreeOpenNode(tree, current);
 
546
      ListTreeMakeItemVisible(tree, current);
 
547
      ListTreeHighlightItem(tree, current, True);
 
548
 
 
549
      count++;
 
550
      if (count == matches->count)
 
551
         count = 0;
 
552
   }
 
553
 
 
554
   DEXIT;
 
555
}
 
556
 
 
557
/*-------------------------------------------------------------------------*/
 
558
static void qmonCQHighlight(Widget w, XtPointer cld, XtPointer cad)
 
559
{
 
560
   ListTreeMultiReturnStruct *ret = (ListTreeMultiReturnStruct*)cad;
 
561
   ListTreeItem *item;
 
562
   int i;
 
563
 
 
564
   DENTER(GUI_LAYER, "qmonCQHighlight");
 
565
 
 
566
   if (rmon_mlgetl(&RMON_DEBUG_ON, GUI_LAYER) & INFOPRINT) {
 
567
      printf("HIGHLIGHT: count=%d\n",ret->count);
 
568
      for (i=0; i<ret->count; i++) {
 
569
        item=ret->items[i];
 
570
        printf("%s",item->text);
 
571
        while (item->parent) {
 
572
          item=item->parent;
 
573
          printf("<--%s",item->text);
 
574
        }
 
575
        printf("\n");
 
576
      }
 
577
   }
 
578
 
 
579
   if (ret && ret->count > 0) {
 
580
      item = ret->items[0];
 
581
/*       qmonCQSetValues(item); */
 
582
   }
 
583
 
 
584
   DEXIT;
 
585
}
 
586
 
 
587
/*-------------------------------------------------------------------------*/
 
588
static void qmonCQMenu(Widget w, XtPointer cld, XtPointer cad)
 
589
{
 
590
   ListTreeItemReturnStruct *ret = (ListTreeItemReturnStruct *)cad;
 
591
   char name[BUFSIZ];
 
592
 
 
593
   DENTER(GUI_LAYER, "qmonCQMenu");
 
594
 
 
595
   if (rmon_mlgetl(&RMON_DEBUG_ON, GUI_LAYER) & INFOPRINT) {
 
596
      printf ("MENU: item=%s\n", ret->item->text);
 
597
   }
 
598
 
 
599
   /*
 
600
   ** set the values in the item for the node popup
 
601
   */
 
602
   strcpy(name, ret->item->text);
 
603
 
 
604
   printf("Menu Item: %s\n", name); 
 
605
 
 
606
   DEXIT;
 
607
}
 
608
 
 
609
/*-------------------------------------------------------------------------*/
 
610
static void qmonCQActivate(Widget w, XtPointer cld, XtPointer cad)
 
611
{
 
612
   ListTreeActivateStruct *ret = (ListTreeActivateStruct*)cad;
 
613
   int count;
 
614
 
 
615
   DENTER(GUI_LAYER, "qmonCQActivate");
 
616
 
 
617
   if (rmon_mlgetl(&RMON_DEBUG_ON, GUI_LAYER) & INFOPRINT) {
 
618
      printf("ACTIVATE: item=%s count=%d\n",ret->item->text,ret->count);
 
619
      count=0;
 
620
      while (count<ret->count) {
 
621
         printf(" path: %s\n",ret->path[count]->text);
 
622
         count++;
 
623
      }
 
624
   }
 
625
}
 
626
 
 
627
 
 
628
 
 
629
/*-------------------------------------------------------------------------*/
 
630
static ListTreeItem* CullToTree(
 
631
Widget tree,
 
632
ListTreeItem *parent,
 
633
lList *cql 
 
634
) {
 
635
   lListElem *ep = NULL;
 
636
   lListElem *ep2 = NULL;
 
637
   ListTreeItem *cq_node = NULL;
 
638
   ListTreeItem *cq_hostnode = NULL;
 
639
#if 0   
 
640
   ListTreeItem *cq_attributes = NULL;
 
641
   ListTreeItem *cq_attributes_gen = NULL;
 
642
   ListTreeItem *cq_attributes_em = NULL;
 
643
   ListTreeItem *cq_attributes_ckpt = NULL;
 
644
   ListTreeItem *cq_attributes_pe = NULL;
 
645
   ListTreeItem *cq_attributes_lst = NULL;
 
646
   ListTreeItem *cq_attributes_hlim = NULL;
 
647
   ListTreeItem *cq_attributes_slim = NULL;
 
648
   ListTreeItem *cq_attributes_cplx = NULL;
 
649
   ListTreeItem *cq_attributes_acl = NULL;
 
650
   ListTreeItem *cq_attributes_prj = NULL;
 
651
#endif   
 
652
   ListTreeItem *cq_qinstances = NULL;
 
653
   ListTreeItem *ret = NULL;
 
654
   StringConst cq_name = NULL;
 
655
 
 
656
   DENTER(GUI_LAYER, "CullToTree");
 
657
 
 
658
   for_each(ep, cql) {
 
659
      /*
 
660
      ** create new node
 
661
      ** 
 
662
      */
 
663
      cq_name = lGetString(ep, CQ_name) ? lGetString(ep, CQ_name) : "-NA-";
 
664
      cq_node = ListTreeAddBranch(tree, parent, (char*) cq_name);
 
665
      
 
666
      /*
 
667
      ** CQ_hostlist
 
668
      */
 
669
      cq_hostnode = ListTreeAddBranch(tree, cq_node, (char*)"Hostlist");
 
670
      for_each(ep2, lGetList(ep, CQ_hostlist)) { 
 
671
         ListTreeAddLeaf(tree, cq_hostnode, (char*)lGetHost(ep2,HR_name));
 
672
      }   
 
673
 
 
674
      /*
 
675
      ** CQ_qinstances
 
676
      ** FIXME
 
677
      */
 
678
      cq_qinstances = ListTreeAddBranch(tree, cq_node, (char*) "Queue Instances");
 
679
      for_each(ep2, lGetList(ep, CQ_qinstances)) { 
 
680
         ListTreeAddLeaf(tree, cq_qinstances, (char*)lGetString(ep2,QU_full_name));
 
681
      }   
 
682
 
 
683
      
 
684
#if 0      
 
685
      /*
 
686
      ** Attributes pseudo nodes
 
687
      */
 
688
      cq_attributes = ListTreeAddBranch(tree, cq_node, (char*) "Attributes");
 
689
      cq_attributes_gen = ListTreeAddBranch(tree, cq_attributes, (char*) "General");
 
690
      cq_attributes_em = ListTreeAddBranch(tree, cq_attributes, (char*) "Execution Method");
 
691
      cq_attributes_ckpt = ListTreeAddBranch(tree, cq_attributes, (char*) "Checkpointing");
 
692
      cq_attributes_pe = ListTreeAddBranch(tree, cq_attributes, (char*) "Parallel Environment");
 
693
      cq_attributes_lst = ListTreeAddBranch(tree, cq_attributes, (char*) "Load/Suspend Thresholds");
 
694
      cq_attributes_hlim = ListTreeAddBranch(tree, cq_attributes, (char*) "Hard Limits");
 
695
      cq_attributes_slim = ListTreeAddBranch(tree, cq_attributes, (char*) "Soft Limits");
 
696
      cq_attributes_cplx = ListTreeAddBranch(tree, cq_attributes, (char*) "Complexes");
 
697
      cq_attributes_acl = ListTreeAddBranch(tree, cq_attributes, (char*) "Access");
 
698
      cq_attributes_prj = ListTreeAddBranch(tree, cq_attributes, (char*) "Project Access");
 
699
      
 
700
      
 
701
      /*--------- general config --------------------------------------------*/
 
702
      
 
703
      cq_add_aqtlist(tree, cq_attributes_gen, ep, CQ_qtype, "CQ_qtype"); 
 
704
 
 
705
      cq_add_aulng(tree, cq_attributes_gen, ep, CQ_seq_no, "Sequence Number");
 
706
 
 
707
      cq_add_aulng(tree, cq_attributes_gen, ep, CQ_job_slots, "Job Slots"); 
 
708
 
 
709
      cq_add_abool(tree, cq_attributes_gen, ep, CQ_rerun, "Rerun Jobs"); 
 
710
 
 
711
      cq_add_astr(tree, cq_attributes_gen, ep, CQ_shell_start_mode, "CQ_shell_start_mode"); 
 
712
 
 
713
      cq_add_ainter(tree, cq_attributes_gen, ep, CQ_notify, "CQ_notify"); 
 
714
 
 
715
      cq_add_astr(tree, cq_attributes_gen, ep, CQ_tmpdir, "CQ_tmpdir"); 
 
716
 
 
717
      cq_add_astr(tree, cq_attributes_gen, ep, CQ_shell, "CQ_shell"); 
 
718
 
 
719
      cq_add_astr(tree, cq_attributes_gen, ep, CQ_calendar, "CQ_calendar"); 
 
720
 
 
721
      cq_add_astr(tree, cq_attributes_gen, ep, CQ_priority, "CQ_priority"); 
 
722
 
 
723
      cq_add_astr(tree, cq_attributes_gen, ep, CQ_processors, "CQ_processors"); 
 
724
 
 
725
      cq_add_astr(tree, cq_attributes_gen, ep, CQ_initial_state, "CQ_initial_state"); 
 
726
      /*--------- hard limits --------------------------------------------*/
 
727
      cq_add_atime(tree, cq_attributes_hlim, ep, CQ_h_rt, "Wallclock Time (sec)"); 
 
728
      cq_add_atime(tree, cq_attributes_hlim, ep, CQ_h_cpu, "CPU Time (sec)"); 
 
729
      cq_add_amem(tree, cq_attributes_hlim, ep, CQ_h_fsize, "File Size (Byte)"); 
 
730
      cq_add_amem(tree, cq_attributes_hlim, ep, CQ_h_data, "Data Size (Byte)"); 
 
731
      cq_add_amem(tree, cq_attributes_hlim, ep, CQ_h_stack, "Stack Size (Byte)"); 
 
732
      cq_add_amem(tree, cq_attributes_hlim, ep, CQ_h_core, "Corefile Size (Byte)"); 
 
733
      cq_add_amem(tree, cq_attributes_hlim, ep, CQ_h_rss, "Resident Set Size (Byte)"); 
 
734
      cq_add_amem(tree, cq_attributes_hlim, ep, CQ_h_vmem, "Virtual Memory (Byte)"); 
 
735
 
 
736
      /*--------- soft limits --------------------------------------------*/
 
737
      cq_add_atime(tree, cq_attributes_slim, ep, CQ_s_rt, "Wallclock Time (sec)"); 
 
738
      cq_add_atime(tree, cq_attributes_slim, ep, CQ_s_cpu, "CPU Time (sec)"); 
 
739
      cq_add_amem(tree, cq_attributes_slim, ep, CQ_s_fsize, "File Size (Byte)"); 
 
740
      cq_add_amem(tree, cq_attributes_slim, ep, CQ_s_data, "Data Size (Byte)"); 
 
741
      cq_add_amem(tree, cq_attributes_slim, ep, CQ_s_stack, "Stack Size (Byte)"); 
 
742
      cq_add_amem(tree, cq_attributes_slim, ep, CQ_s_core, "Corefile Size (Byte)"); 
 
743
      cq_add_amem(tree, cq_attributes_slim, ep, CQ_s_rss, "Resident Set Size (Byte)"); 
 
744
      cq_add_amem(tree, cq_attributes_slim, ep, CQ_s_vmem, "Virtual Memory (Byte)"); 
 
745
 
 
746
      /*--------- ckpt --------------------------------------------*/
 
747
      cq_add_ainter(tree, cq_attributes_ckpt, ep, CQ_min_cpu_interval, "Min CPU Interval"); 
 
748
 
 
749
      cq_add_astrlist(tree, cq_attributes_ckpt, ep, CQ_ckpt_list, "CQ_ckpt_list"); 
 
750
      
 
751
      /*--------- execution method ------------------------------------------*/
 
752
      cq_add_astr(tree, cq_attributes_em, ep, CQ_prolog, "CQ_prolog"); 
 
753
 
 
754
      cq_add_astr(tree, cq_attributes_em, ep, CQ_epilog, "CQ_epilog"); 
 
755
 
 
756
      cq_add_astr(tree, cq_attributes_em, ep, CQ_starter_method, "CQ_starter_method"); 
 
757
 
 
758
      cq_add_astr(tree, cq_attributes_em, ep, CQ_suspend_method, "CQ_suspend_method"); 
 
759
 
 
760
      cq_add_astr(tree, cq_attributes_em, ep, CQ_resume_method, "CQ_resume_method"); 
 
761
      cq_add_astr(tree, cq_attributes_em, ep, CQ_terminate_method, "CQ_terminate_method"); 
 
762
 
 
763
 
 
764
      /*--------- pe  ------------------------------------------*/
 
765
      cq_add_astrlist(tree, cq_attributes_pe, ep, CQ_pe_list, "Parallel Environment"); 
 
766
 
 
767
      /*--------- Owners  ------------------------------------------*/
 
768
      cq_add_ausrlist(tree, cq_attributes, ep, CQ_owner_list, "Owners"); 
 
769
 
 
770
      /*--------- Access -------------------------------------------*/
 
771
      cq_add_ausrlist(tree, cq_attributes_acl, ep, CQ_acl, "CQ_acl"); 
 
772
 
 
773
      cq_add_ausrlist(tree, cq_attributes_acl, ep, CQ_xacl, "CQ_xacl"); 
 
774
 
 
775
      /*--------- Projects -------------------------------------------*/
 
776
      cq_add_aprjlist(tree, cq_attributes_prj, ep, CQ_projects, "CQ_projects"); 
 
777
 
 
778
      cq_add_aprjlist(tree, cq_attributes_prj, ep, CQ_xprojects, "CQ_xprojects"); 
 
779
 
 
780
      /*--------- Load/Suspend Thresholds ---------------------------------*/
 
781
      cq_add_acelist(tree, cq_attributes_lst, ep, CQ_load_thresholds, "CQ_load_thresholds"); 
 
782
 
 
783
      cq_add_acelist(tree, cq_attributes_lst, ep, CQ_suspend_thresholds, "CQ_suspend_thresholds"); 
 
784
 
 
785
      cq_add_aulng(tree, cq_attributes_lst, ep, CQ_nsuspend, "Jobs suspended per interval"); 
 
786
 
 
787
      cq_add_ainter(tree, cq_attributes_lst, ep, CQ_suspend_interval, "Suspend Interval"); 
 
788
      
 
789
 
 
790
      /*--------- Consumables ---------------------------------*/
 
791
      cq_add_acelist(tree, cq_attributes, ep, CQ_consumable_config_list, "CQ_consumable_config_list"); 
 
792
 
 
793
      /*--------- Subordinates ---------------------------------*/
 
794
      cq_add_asolist(tree, cq_attributes, ep, CQ_subordinate_list, "CQ_subordinate_list"); 
 
795
 
 
796
#endif
 
797
 
 
798
   }
 
799
 
 
800
   ret = ListTreeFirstItem(tree);
 
801
 
 
802
 
 
803
   DEXIT;
 
804
   return ret; 
 
805
}
 
806
 
 
807
/*-------------------------------------------------------------------------*/
 
808
static void qmonCQUpdateTree(void)
 
809
{
 
810
   Widget tree = cq_tree;
 
811
   lList *cluster_queue_tree = NULL;
 
812
   ListTreeItem *old_root = NULL;
 
813
   ListTreeItem *root_node = NULL;
 
814
   lList *alp = NULL;
 
815
 
 
816
   DENTER(GUI_LAYER, "qmonCQUpdateTree");
 
817
 
 
818
   /*
 
819
   ** set and get several lists
 
820
   */
 
821
   qmonMirrorMultiAnswer(CQUEUE_T,  &alp);
 
822
   if (alp) {
 
823
      qmonMessageBox(AppShell, alp, 0);
 
824
      lFreeList(&alp);
 
825
      DEXIT;
 
826
      return;
 
827
   }
 
828
 
 
829
   cluster_queue_tree = qmonMirrorList(SGE_CQUEUE_LIST);
 
830
 
 
831
   ListTreeRefreshOff(tree);
 
832
   /*
 
833
   ** unchain the old tree, what about the old user_data struct ????
 
834
   */
 
835
   old_root = ListTreeFirstItem(tree);
 
836
   ListTreeUnchainItem(tree, old_root);
 
837
      
 
838
   root_node = ListTreeAddBranch(tree, NULL, "/");
 
839
   CullToTree(tree, root_node, cluster_queue_tree);
 
840
 
 
841
   /*
 
842
   ** open the new tree according to old tree or to
 
843
   ** a defined level
 
844
   */
 
845
   if (old_root) {
 
846
      ListTreeOpenLikeTree(tree, root_node, old_root);
 
847
      ListTreeDelete(tree, old_root);
 
848
   }
 
849
   else
 
850
      ListTreeOpenToLevel(tree, NULL, 1);
 
851
   
 
852
/*    ListTreeHighlightItem(tree, root_node, True); */
 
853
   ListTreeRefreshOn(tree);
 
854
/*    ListTreeMakeItemVisible(tree, root_node); */
 
855
 
 
856
   DEXIT;
 
857
}
 
858
 
 
859
#endif
 
860
 
 
861
#if 0
 
862
/*-------------------------------------------------------------------------*/
 
863
static ListTreeItem* cq_add_aulng(Widget tree, ListTreeItem *parent, 
 
864
                           lListElem *elem, int field_nm, 
 
865
                           StringConst attribute_name)
 
866
{
 
867
   lListElem *ep;
 
868
   ListTreeItem *item;
 
869
   
 
870
   DENTER(GUI_LAYER, "cq_add_aulng");
 
871
 
 
872
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
873
   for_each(ep, lGetList(elem, field_nm)) {
 
874
      char *hostref = (char*) lGetHost(ep, AULNG_href);
 
875
      u_long32 u = lGetUlong(ep, AULNG_value);
 
876
      dstring ds = DSTRING_INIT;
 
877
      sge_dstring_sprintf(&ds, "%s " sge_u32, hostref, u);
 
878
      ListTreeAddLeaf(tree, item, ds.s);
 
879
      sge_dstring_free(&ds);
 
880
   }   
 
881
   DEXIT;
 
882
   return item;
 
883
}   
 
884
 
 
885
/*-------------------------------------------------------------------------*/
 
886
static ListTreeItem* cq_add_abool(Widget tree, ListTreeItem *parent, 
 
887
                           lListElem *elem, int field_nm, 
 
888
                           StringConst attribute_name)
 
889
{
 
890
   lListElem *ep;
 
891
   ListTreeItem *item;
 
892
   
 
893
   DENTER(GUI_LAYER, "cq_add_abool");
 
894
 
 
895
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
896
   for_each(ep, lGetList(elem, field_nm)) {
 
897
      char *hostref = (char*) lGetHost(ep, ABOOL_href);
 
898
      Bool b = lGetBool(ep, ABOOL_value);
 
899
      dstring ds = DSTRING_INIT;
 
900
      sge_dstring_sprintf(&ds, "%s %s", hostref, b ? "true" : "false");
 
901
      ListTreeAddLeaf(tree, item, ds.s);
 
902
      sge_dstring_free(&ds);
 
903
   }   
 
904
   DEXIT;
 
905
   return item;
 
906
}   
 
907
 
 
908
/*-------------------------------------------------------------------------*/
 
909
static ListTreeItem* cq_add_amem(Widget tree, ListTreeItem *parent, 
 
910
                           lListElem *elem, int field_nm, 
 
911
                           StringConst attribute_name)
 
912
{
 
913
   lListElem *ep;
 
914
   ListTreeItem *item;
 
915
   
 
916
   DENTER(GUI_LAYER, "cq_add_amem");
 
917
 
 
918
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
919
   for_each(ep, lGetList(elem, field_nm)) {
 
920
      char *hostref = (char*) lGetHost(ep, AMEM_href);
 
921
      char *value = (char*)lGetString(ep, AMEM_value);
 
922
      dstring ds = DSTRING_INIT;
 
923
      sge_dstring_sprintf(&ds, "%s %s", hostref, value ? value : "-NA-");
 
924
      ListTreeAddLeaf(tree, item, ds.s);
 
925
      sge_dstring_free(&ds);
 
926
   }   
 
927
   DEXIT;
 
928
   return item;
 
929
}   
 
930
 
 
931
/*-------------------------------------------------------------------------*/
 
932
static ListTreeItem* cq_add_atime(Widget tree, ListTreeItem *parent, 
 
933
                           lListElem *elem, int field_nm, 
 
934
                           StringConst attribute_name)
 
935
{
 
936
   lListElem *ep;
 
937
   ListTreeItem *item;
 
938
   
 
939
   DENTER(GUI_LAYER, "cq_add_atime");
 
940
 
 
941
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
942
   for_each(ep, lGetList(elem, field_nm)) {
 
943
      char *hostref = (char*) lGetHost(ep, ATIME_href);
 
944
      char *value = (char*)lGetString(ep, ATIME_value);
 
945
      dstring ds = DSTRING_INIT;
 
946
      sge_dstring_sprintf(&ds, "%s %s", hostref, value ? value : "-NA-");
 
947
      ListTreeAddLeaf(tree, item, ds.s);
 
948
      sge_dstring_free(&ds);
 
949
   }   
 
950
   DEXIT;
 
951
   return item;
 
952
}   
 
953
 
 
954
/*-------------------------------------------------------------------------*/
 
955
static ListTreeItem* cq_add_ainter(Widget tree, ListTreeItem *parent, 
 
956
                           lListElem *elem, int field_nm, 
 
957
                           StringConst attribute_name)
 
958
{
 
959
   lListElem *ep;
 
960
   ListTreeItem *item;
 
961
   
 
962
   DENTER(GUI_LAYER, "cq_add_ainter");
 
963
 
 
964
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
965
   for_each(ep, lGetList(elem, field_nm)) {
 
966
      char *hostref = (char*) lGetHost(ep, AINTER_href);
 
967
      char *value = (char*)lGetString(ep, AINTER_value);
 
968
      dstring ds = DSTRING_INIT;
 
969
      sge_dstring_sprintf(&ds, "%s %s", hostref, value ? value : "-NA-");
 
970
      ListTreeAddLeaf(tree, item, ds.s);
 
971
      sge_dstring_free(&ds);
 
972
   }   
 
973
   DEXIT;
 
974
   return item;
 
975
}   
 
976
 
 
977
/*-------------------------------------------------------------------------*/
 
978
static ListTreeItem* cq_add_astr(Widget tree, ListTreeItem *parent, 
 
979
                           lListElem *elem, int field_nm, 
 
980
                           StringConst attribute_name)
 
981
{
 
982
   lListElem *ep;
 
983
   ListTreeItem *item;
 
984
   
 
985
   DENTER(GUI_LAYER, "cq_add_astr");
 
986
 
 
987
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
988
   for_each(ep, lGetList(elem, field_nm)) {
 
989
      char *hostref = (char*) lGetHost(ep, ASTR_href);
 
990
      char *value = (char*)lGetString(ep, ASTR_value);
 
991
      dstring ds = DSTRING_INIT;
 
992
      sge_dstring_sprintf(&ds, "%s %s", hostref, value ? value : "-NA-");
 
993
      ListTreeAddLeaf(tree, item, ds.s);
 
994
      sge_dstring_free(&ds);
 
995
   }   
 
996
   DEXIT;
 
997
   return item;
 
998
}   
 
999
 
 
1000
/*-------------------------------------------------------------------------*/
 
1001
static ListTreeItem* cq_add_astrlist(Widget tree, ListTreeItem *parent, 
 
1002
                           lListElem *elem, int field_nm, 
 
1003
                           StringConst attribute_name)
 
1004
{
 
1005
   lListElem *ep;
 
1006
   ListTreeItem *item;
 
1007
   
 
1008
   DENTER(GUI_LAYER, "cq_add_astrlist");
 
1009
 
 
1010
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
1011
   for_each(ep, lGetList(elem, field_nm)) {
 
1012
      ListTreeItem *sublist;
 
1013
      lListElem *ep2;
 
1014
      char *hostref = (char*) lGetHost(ep, ASTRLIST_href);
 
1015
      lList *value = lGetList(ep, ASTRLIST_value);
 
1016
      sublist = ListTreeAddBranch(tree, item, hostref);
 
1017
      for_each(ep2, value) { 
 
1018
         char *name = (char*) lGetString(ep2, ST_name);
 
1019
         ListTreeAddLeaf(tree, sublist, name ? name : "-NA-");
 
1020
      }   
 
1021
   }   
 
1022
   DEXIT;
 
1023
   return item;
 
1024
}   
 
1025
 
 
1026
/*-------------------------------------------------------------------------*/
 
1027
static ListTreeItem* cq_add_ausrlist(Widget tree, ListTreeItem *parent, 
 
1028
                           lListElem *elem, int field_nm, 
 
1029
                           StringConst attribute_name)
 
1030
{
 
1031
   lListElem *ep;
 
1032
   ListTreeItem *item;
 
1033
   
 
1034
   DENTER(GUI_LAYER, "cq_add_ausrlist");
 
1035
 
 
1036
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
1037
   for_each(ep, lGetList(elem, field_nm)) {
 
1038
      ListTreeItem *sublist;
 
1039
      lListElem *ep2;
 
1040
      char *hostref = (char*) lGetHost(ep, AUSRLIST_href);
 
1041
      lList *value = lGetList(ep, AUSRLIST_value);
 
1042
      sublist = ListTreeAddBranch(tree, item, hostref);
 
1043
      for_each(ep2, value) { 
 
1044
         char *name = (char*) lGetString(ep2, US_name);
 
1045
         ListTreeAddLeaf(tree, sublist, name ? name : "-NA-");
 
1046
      }   
 
1047
   }   
 
1048
   DEXIT;
 
1049
   return item;
 
1050
}   
 
1051
 
 
1052
/*-------------------------------------------------------------------------*/
 
1053
static ListTreeItem* cq_add_aprjlist(Widget tree, ListTreeItem *parent, 
 
1054
                           lListElem *elem, int field_nm, 
 
1055
                           StringConst attribute_name)
 
1056
{
 
1057
   lListElem *ep;
 
1058
   ListTreeItem *item;
 
1059
   
 
1060
   DENTER(GUI_LAYER, "cq_add_aprjlist");
 
1061
 
 
1062
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
1063
   for_each(ep, lGetList(elem, field_nm)) {
 
1064
      ListTreeItem *sublist;
 
1065
      lListElem *ep2;
 
1066
      char *hostref = (char*) lGetHost(ep, APRJLIST_href);
 
1067
      lList *value = lGetList(ep, APRJLIST_value);
 
1068
      sublist = ListTreeAddBranch(tree, item, hostref);
 
1069
      for_each(ep2, value) { 
 
1070
         char *name = (char*) lGetString(ep2, PR_name);
 
1071
         ListTreeAddLeaf(tree, sublist, name ? name : "-NA-");
 
1072
      }   
 
1073
   }   
 
1074
   DEXIT;
 
1075
   return item;
 
1076
}   
 
1077
 
 
1078
/*-------------------------------------------------------------------------*/
 
1079
static ListTreeItem* cq_add_aqtlist(Widget tree, ListTreeItem *parent, 
 
1080
                           lListElem *elem, int field_nm, 
 
1081
                           StringConst attribute_name)
 
1082
{
 
1083
   lListElem *ep;
 
1084
   ListTreeItem *item;
 
1085
   
 
1086
   DENTER(GUI_LAYER, "cq_add_aqtlist");
 
1087
 
 
1088
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
1089
#if 0   
 
1090
   for_each(ep, lGetList(elem, field_nm)) {
 
1091
      ListTreeItem *sublist;
 
1092
      char *hostref = (char*) lGetHost(ep, AQTLIST_href);
 
1093
      u_long32 u = lGetUlong(ep, AQTLIST_value);
 
1094
      sublist = ListTreeAddBranch(tree, item, hostref);
 
1095
      for_each(ep2, value) { 
 
1096
         char *name = lGetString(ep2, UP_name);
 
1097
         ListTreeAddLeaf(tree, sublist, name ? name : "-NA-");
 
1098
      }   
 
1099
   }   
 
1100
#endif   
 
1101
   DEXIT;
 
1102
   return item;
 
1103
}   
 
1104
 
 
1105
/*-------------------------------------------------------------------------*/
 
1106
static ListTreeItem* cq_add_acelist(Widget tree, ListTreeItem *parent, 
 
1107
                           lListElem *elem, int field_nm, 
 
1108
                           StringConst attribute_name)
 
1109
{
 
1110
   lListElem *ep;
 
1111
   ListTreeItem *item;
 
1112
   
 
1113
   DENTER(GUI_LAYER, "cq_add_acelist");
 
1114
 
 
1115
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
1116
#if 0   
 
1117
   for_each(ep, lGetList(elem, field_nm)) {
 
1118
      ListTreeItem *sublist;
 
1119
      char *hostref = (char*) lGetHost(ep, AQTLIST_href);
 
1120
      u_long32 u = lGetUlong(ep, AQTLIST_value);
 
1121
      sublist = ListTreeAddBranch(tree, item, hostref);
 
1122
      for_each(ep2, value) { 
 
1123
         char *name = lGetString(ep2, UP_name);
 
1124
         ListTreeAddLeaf(tree, sublist, name ? name : "-NA-");
 
1125
      }   
 
1126
   }   
 
1127
#endif   
 
1128
   DEXIT;
 
1129
   return item;
 
1130
}   
 
1131
 
 
1132
/*-------------------------------------------------------------------------*/
 
1133
static ListTreeItem* cq_add_asolist(Widget tree, ListTreeItem *parent, 
 
1134
                           lListElem *elem, int field_nm, 
 
1135
                           StringConst attribute_name)
 
1136
{
 
1137
   lListElem *ep;
 
1138
   lListElem *ep2;
 
1139
   ListTreeItem *item;
 
1140
   
 
1141
   DENTER(GUI_LAYER, "cq_add_asolist");
 
1142
 
 
1143
   item = ListTreeAddBranch(tree, parent, (char*)attribute_name);
 
1144
   for_each(ep, lGetList(elem, field_nm)) {
 
1145
      ListTreeItem *sublist;
 
1146
      char *hostref = (char*) lGetHost(ep, AQTLIST_href);
 
1147
      u_long32 u = lGetUlong(ep, AQTLIST_value);
 
1148
      sublist = ListTreeAddBranch(tree, item, hostref);
 
1149
      for_each(ep2, value) { 
 
1150
         char *name = lGetString(ep2, PR_name);
 
1151
         ListTreeAddLeaf(tree, sublist, name ? name : "-NA-");
 
1152
      }   
 
1153
   }   
 
1154
   
 
1155
   DEXIT;
 
1156
   return item;
 
1157
}   
 
1158
#endif
 
1159
 
 
1160
/*-------------------------------------------------------------------------*/
 
1161
static void qmonQinstanceHandleEnterLeave(
 
1162
Widget w,
 
1163
XtPointer cld,
 
1164
XEvent *ev,
 
1165
Boolean *ctd 
 
1166
) {
 
1167
   /*
 
1168
   int root_x, root_y, pos_x, pos_y;
 
1169
   Window root, child;
 
1170
   unsigned int keys_buttons;
 
1171
   */
 
1172
   char line[BUFSIZ];
 
1173
   static int prev_row = -1;
 
1174
   int row, col;
 
1175
   String str;
 
1176
   DENTER(GUI_LAYER, "qmonQinstanceHandleEnterLeave");
 
1177
   
 
1178
   switch (ev->type) {
 
1179
      case MotionNotify:
 
1180
         if (qmonBrowserObjectEnabled(BROWSE_QUEUE)) {
 
1181
            /* 
 
1182
            ** XQueryPointer(XtDisplay(w), XtWindow(w), 
 
1183
            **            &root, &child, &root_x, &root_y,
 
1184
            **            &pos_x, &pos_y, &keys_buttons);
 
1185
            */
 
1186
            if (XbaeMatrixGetEventRowColumn(w, ev, &row, &col)) {
 
1187
               if ( row != prev_row ) {
 
1188
                  prev_row = row;
 
1189
                  /* locate the quue */
 
1190
                  str = XbaeMatrixGetCell(w, row, 0);
 
1191
                  if (str && *str != '\0') {
 
1192
                     lListElem *qp;
 
1193
                     dstring queue_info = DSTRING_INIT;
 
1194
                     qp = cqueue_list_locate_qinstance(
 
1195
                                 qmonMirrorList(SGE_CQUEUE_LIST), str);
 
1196
                     if (qp) {
 
1197
                        sprintf(line, "+++++++++++++++++++++++++++++++++++++++++++\n");  
 
1198
                        qmonBrowserShow(line);
 
1199
                        qmonQinstanceShowBrowserInfo(&queue_info, qp);      
 
1200
                        qmonBrowserShow(sge_dstring_get_string(&queue_info));
 
1201
                        qmonBrowserShow(line);
 
1202
                     }
 
1203
                     sge_dstring_free(&queue_info);
 
1204
                  }
 
1205
               }
 
1206
            }
 
1207
         }
 
1208
         break;
 
1209
   }
 
1210
   DEXIT;
 
1211
}
 
1212
 
 
1213
/*-------------------------------------------------------------------------*/
 
1214
static void qmonQinstanceShowBrowserInfo(
 
1215
dstring *info,
 
1216
lListElem *qep 
 
1217
) {
 
1218
 
 
1219
   lListElem *ep;
 
1220
   const char *str, *str2;
 
1221
   int i;
 
1222
 
 
1223
   DENTER(GUI_LAYER, "qmonQinstanceShowBrowserInfo");
 
1224
 
 
1225
/*    sge_dstring_sprintf(info, "%-30.30s%s\n", "Queue:", lGetString(qep, QU_full_name)); */
 
1226
   /* qname */
 
1227
   sge_dstring_sprintf(info, "%-30.30s%s\n", "qname:", lGetString(qep, QU_qname));
 
1228
 
 
1229
   /* hostname */
 
1230
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "hostname:", 
 
1231
                           lGetHost(qep, QU_qhostname));
 
1232
   /* seq_no */
 
1233
   sge_dstring_sprintf_append(info, "%-30.30s%d\n", "seq_no:", 
 
1234
                           (int)lGetUlong(qep, QU_seq_no));
 
1235
   /* Load Thresholds */
 
1236
   sge_dstring_sprintf_append(info, "%-30.30s", "Load Thresholds:");
 
1237
   for_each(ep, lGetList(qep, QU_load_thresholds)) {
 
1238
      str = lGetString(ep, CE_name);
 
1239
      str2 = lGetString(ep, CE_stringval);
 
1240
      sge_dstring_sprintf_append(info, "%s=%s ", str?str:"", str2?str2:"");
 
1241
   }
 
1242
   sge_dstring_sprintf_append(info, "\n"); 
 
1243
   /* Suspend Thresholds */
 
1244
   sge_dstring_sprintf_append(info, "%-30.30s", "Suspend Thresholds:");
 
1245
   for_each(ep, lGetList(qep, QU_suspend_thresholds)) {
 
1246
      str = lGetString(ep, CE_name);
 
1247
      str2 = lGetString(ep, CE_stringval);
 
1248
      sge_dstring_sprintf_append(info, "%s=%s ", str?str:"", str2?str2:"");
 
1249
   }
 
1250
   sge_dstring_sprintf_append(info, "\n"); 
 
1251
   /* nsuspend */
 
1252
   sge_dstring_sprintf_append(info, "%-30.30s%d\n", "nsuspend:", 
 
1253
                           (int)lGetUlong(qep, QU_nsuspend));
 
1254
   /* suspend_interval */
 
1255
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "suspend_interval:", 
 
1256
                           lGetString(qep, QU_suspend_interval));
 
1257
   /* priority */
 
1258
   str = lGetString(qep, QU_priority);
 
1259
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "priority:", str?str:"");
 
1260
 
 
1261
   /* min_cpu_interval */
 
1262
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "min_cpu_interval:", 
 
1263
                           lGetString(qep, QU_min_cpu_interval));
 
1264
 
 
1265
   /* processors */
 
1266
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "processors:", 
 
1267
                           lGetString(qep, QU_processors));
 
1268
 
 
1269
   /* qtype */
 
1270
   {
 
1271
      dstring type_buffer = DSTRING_INIT;
 
1272
 
 
1273
      qinstance_print_qtype_to_dstring(qep, &type_buffer, false);
 
1274
      sge_dstring_sprintf_append(info, "%-30.30s%s\n", "qype:", 
 
1275
              sge_dstring_get_string(&type_buffer));
 
1276
      sge_dstring_free(&type_buffer);
 
1277
   }
 
1278
   /* ckpt_list */
 
1279
   sge_dstring_sprintf_append(info, "%-30.30s", "ckpt_list:");
 
1280
   for_each(ep, lGetList(qep, QU_ckpt_list)) {
 
1281
      str = lGetString(ep, ST_name);
 
1282
      sge_dstring_sprintf_append(info, "%s ", str);
 
1283
   }
 
1284
   sge_dstring_sprintf_append(info, "\n"); 
 
1285
   /* pe_list */
 
1286
   sge_dstring_sprintf_append(info, "%-30.30s", "pe_list:");
 
1287
   for_each(ep, lGetList(qep, QU_pe_list)) {
 
1288
      str = lGetString(ep, ST_name);
 
1289
      sge_dstring_sprintf_append(info, "%s ", str);
 
1290
   }
 
1291
   sge_dstring_sprintf_append(info, "\n"); 
 
1292
   /* rerun */
 
1293
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "rerun:", 
 
1294
                     lGetBool(qep, QU_rerun) ? "True" : "False");
 
1295
   /* slots */
 
1296
   sge_dstring_sprintf_append(info, "%-30.30s%d\n", "slots:", 
 
1297
                     (int)lGetUlong(qep, QU_job_slots));
 
1298
   /* slots used */
 
1299
   sge_dstring_sprintf_append(info, "%-30.30s%d\n", "slots used:", 
 
1300
                                 qinstance_slots_used(qep));
 
1301
   /* shell */
 
1302
   str = lGetString(qep, QU_shell);
 
1303
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "shell:", str ? str : ""); 
 
1304
   
 
1305
   /* prolog */
 
1306
   str = lGetString(qep, QU_prolog);
 
1307
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "prolog:", str ? str : ""); 
 
1308
   /* epilog */
 
1309
   str = lGetString(qep, QU_epilog);
 
1310
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "epilog:", str ? str : ""); 
 
1311
   /* shell_start_mode */
 
1312
   str = lGetString(qep, QU_shell_start_mode);
 
1313
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "shell_start_mode:", str ? str : ""); 
 
1314
   
 
1315
   /* starter_method */
 
1316
   str = lGetString(qep, QU_starter_method);
 
1317
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "starter_method:", str ? str : ""); 
 
1318
   
 
1319
   /* suspend_method */
 
1320
   str = lGetString(qep, QU_suspend_method);
 
1321
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "suspend_method:", str ? str : ""); 
 
1322
   
 
1323
   /* resume_method */
 
1324
   str = lGetString(qep, QU_resume_method);
 
1325
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "resume_method:", str ? str : ""); 
 
1326
   
 
1327
   /* terminate_method */
 
1328
   str = lGetString(qep, QU_terminate_method);
 
1329
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "terminate_method:", str ? str : ""); 
 
1330
   
 
1331
   /* notify */
 
1332
   str = lGetString(qep, QU_notify);
 
1333
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Notify Job Interval:",  str ? str : ""); 
 
1334
 
 
1335
   /* tmpdir */
 
1336
   str = lGetString(qep, QU_tmpdir);
 
1337
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "tmpdir:", str ? str : ""); 
 
1338
   /* user_lists */
 
1339
   sge_dstring_sprintf_append(info, "%-30.30s", "Access List:");
 
1340
   for_each(ep, lGetList(qep, QU_acl)) {
 
1341
      sge_dstring_sprintf_append(info, "%s ", lGetString(ep, US_name));
 
1342
   }
 
1343
   sge_dstring_sprintf_append(info, "\n"); 
 
1344
   /* xuser_lists */
 
1345
   sge_dstring_sprintf_append(info, "%-30.30s", "No Access List:");
 
1346
   for_each(ep, lGetList(qep, QU_xacl)) {
 
1347
      sge_dstring_sprintf_append(info, "%s ", lGetString(ep, US_name));
 
1348
   }
 
1349
   sge_dstring_sprintf_append(info, "\n"); 
 
1350
   /* subordinate_list */
 
1351
   sge_dstring_sprintf_append(info, "%-30.30s", "Subordinates:");
 
1352
   for_each(ep, lGetList(qep, QU_subordinate_list)) {
 
1353
      str = lGetString(ep, SO_name);
 
1354
      i = (int) lGetUlong(ep, SO_threshold);
 
1355
      sge_dstring_sprintf_append(info, "%s=%d ", str?str:"", i);
 
1356
   }
 
1357
   sge_dstring_sprintf_append(info, "\n"); 
 
1358
   /* Complex Values */
 
1359
   sge_dstring_sprintf_append(info, "%-30.30s", "Complex Values:");
 
1360
   for_each(ep, lGetList(qep, QU_consumable_config_list)) {
 
1361
      str = lGetString(ep, CE_name);
 
1362
      str2 = lGetString(ep, CE_stringval);
 
1363
      sge_dstring_sprintf_append(info, "%s=%s ", str?str:"", str2?str2:"");
 
1364
   }
 
1365
   sge_dstring_sprintf_append(info, "\n"); 
 
1366
 
 
1367
   /* projects */
 
1368
   sge_dstring_sprintf_append(info, "%-30.30s", "Project List:");
 
1369
   for_each(ep, lGetList(qep, QU_projects)) {
 
1370
      sge_dstring_sprintf_append(info, "%s ", lGetString(ep, PR_name));
 
1371
   }
 
1372
   sge_dstring_sprintf_append(info, "\n"); 
 
1373
   /* xprojects */
 
1374
   sge_dstring_sprintf_append(info, "%-30.30s", "XProject List:");
 
1375
   for_each(ep, lGetList(qep, QU_xprojects)) {
 
1376
      sge_dstring_sprintf_append(info, "%s ", lGetString(ep, PR_name));
 
1377
   }
 
1378
   sge_dstring_sprintf_append(info, "\n"); 
 
1379
 
 
1380
   /* calendar */
 
1381
   str = lGetString(qep, QU_calendar);
 
1382
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "calendar:", str ? str : ""); 
 
1383
   
 
1384
   /* initial state */
 
1385
   str = lGetString(qep, QU_initial_state);
 
1386
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "initial state:", str ? str : ""); 
 
1387
   /* limits*/
 
1388
   str = lGetString(qep, QU_s_rt);
 
1389
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft Real Time:", str ? str : ""); 
 
1390
   str = lGetString(qep, QU_h_rt);
 
1391
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard Real Time:", str ? str : ""); 
 
1392
   str = lGetString(qep, QU_s_cpu);
 
1393
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft Cpu:", str ? str : ""); 
 
1394
   str = lGetString(qep, QU_h_cpu);
 
1395
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard Cpu:", str ? str : "");
 
1396
   str = lGetString(qep, QU_s_fsize);
 
1397
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft File Size:", str ? str : "");
 
1398
   str = lGetString(qep, QU_h_fsize);
 
1399
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard File Size:", str ? str : "");
 
1400
   str = lGetString(qep, QU_s_data);
 
1401
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft Data Size:", str ? str : "");
 
1402
   str = lGetString(qep, QU_h_data);
 
1403
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard Data Size:", str ? str : "");
 
1404
   str = lGetString(qep, QU_s_stack);
 
1405
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft Stack Size:", str ? str : "");
 
1406
   str = lGetString(qep, QU_h_stack);
 
1407
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard Stack Size:", str ? str : "");
 
1408
   str = lGetString(qep, QU_s_core);
 
1409
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft Core Size:", str ? str : "");
 
1410
   str = lGetString(qep, QU_h_core);
 
1411
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard Core Size:", str ? str : "");
 
1412
   str = lGetString(qep, QU_s_rss);
 
1413
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft Resident Set Size:", str ? str : "");
 
1414
   str = lGetString(qep, QU_h_rss);
 
1415
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard Resident Set Size:", str ? str : "");
 
1416
   str = lGetString(qep, QU_s_vmem);
 
1417
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Soft Virtual Memory: Size", str ? str : "");
 
1418
   str = lGetString(qep, QU_h_vmem);
 
1419
   sge_dstring_sprintf_append(info, "%-30.30s%s\n", "Hard Virtual Memory Size:", str ? str : "");
 
1420
 
 
1421
   DEXIT;
 
1422
}
 
1423
 
 
1424
/*-------------------------------------------------------------------------*/
 
1425
static void qmonQinstanceExplain(Widget w, XtPointer cld, XtPointer cad)
 
1426
{
 
1427
   int rows, i;
 
1428
   char *str;
 
1429
   u_long32 explain_bits = QI_DEFAULT;
 
1430
   int state = 0;
 
1431
   Widget explain_w;
 
1432
   Widget matrix = current_matrix;
 
1433
   lListElem *qp = NULL;
 
1434
   lList *alp = NULL;
 
1435
   int nr_selected_rows = 0;
 
1436
 
 
1437
   DENTER(GUI_LAYER, "qmonQinstanceExplain");
 
1438
 
 
1439
   /* 
 
1440
   ** loop over selected entries and build id list
 
1441
   */
 
1442
   rows = XbaeMatrixNumRows(matrix);
 
1443
   /*
 
1444
   ** number of selected rows
 
1445
   */
 
1446
   nr_selected_rows = XbaeMatrixGetNumSelected(matrix)/XbaeMatrixNumColumns(matrix);
 
1447
   
 
1448
   if (nr_selected_rows > 0) {
 
1449
      char line[BUFSIZ];
 
1450
      sprintf(line, "+++++++++++++++++++++++++++++++++++++++++++\n");  
 
1451
 
 
1452
      qmonMirrorMultiAnswer(CQUEUE_T | EXECHOST_T | CENTRY_T,  &alp);
 
1453
      if (alp) {
 
1454
         qmonMessageBox(w, alp, 0);
 
1455
         lFreeList(&alp);
 
1456
         DEXIT;
 
1457
         return;
 
1458
      }
 
1459
      /*
 
1460
      ** cld contains the action we need, check if a force is involved
 
1461
      */
 
1462
      explain_w = XmtNameToWidget(w, "*cq_explain_states"); 
 
1463
      state = XmtChooserGetState(explain_w);
 
1464
 
 
1465
      if (ISSET(state,(1<<0))) {
 
1466
         explain_bits |= QI_AMBIGUOUS;
 
1467
      }   
 
1468
      if (ISSET(state,(1<<1))) {
 
1469
         explain_bits |= QI_ALARM;
 
1470
      }   
 
1471
      if (ISSET(state,(1<<2))) {
 
1472
         explain_bits |= QI_SUSPEND_ALARM;
 
1473
      }   
 
1474
      if (ISSET(state,(1<<3))) {
 
1475
         explain_bits |= QI_ERROR;
 
1476
      }   
 
1477
   
 
1478
      if (explain_bits != QI_DEFAULT) {
 
1479
         /*
 
1480
         ** open browser window
 
1481
         */
 
1482
         qmonBrowserOpen(w, NULL, NULL);
 
1483
 
 
1484
         for (i=0; i<rows; i++) {
 
1485
            /* is this row selected */ 
 
1486
            if (XbaeMatrixIsRowSelected(matrix, i)) {
 
1487
               str = XbaeMatrixGetCell(matrix, i, 0);
 
1488
               if ( str && *str != '\0' ) { 
 
1489
                  dstring queue_info = DSTRING_INIT;
 
1490
                  DPRINTF(("CQ/QI to explain: %s\n", str));
 
1491
                  qp = cqueue_list_locate_qinstance(
 
1492
                                 qmonMirrorList(SGE_CQUEUE_LIST), str);
 
1493
                  if (qp) {
 
1494
                     qmonQinstanceShowBrowserExplain(&queue_info, qp,
 
1495
                                             qmonMirrorList(SGE_CENTRY_LIST),
 
1496
                                             qmonMirrorList(SGE_EXECHOST_LIST),
 
1497
                                             explain_bits);
 
1498
                     qmonBrowserShow(sge_dstring_get_string(&queue_info));
 
1499
                     qmonBrowserShow(line);
 
1500
                  }
 
1501
                  sge_dstring_free(&queue_info);
 
1502
               }
 
1503
            }
 
1504
         }
 
1505
      }
 
1506
   } else { 
 
1507
      qmonMessageShow(w, True, "@{Select at least one queue instance!}");
 
1508
   }
 
1509
 
 
1510
   DEXIT;
 
1511
}   
 
1512
 
 
1513
 
 
1514
/*-------------------------------------------------------------------------*/
 
1515
static void qmonQinstanceShowBrowserExplain( dstring *info, lListElem *q,
 
1516
lList *centry_list, lList *exechost_list, u_long32 explain_bits) 
 
1517
{
 
1518
 
 
1519
   char *load_avg_str;
 
1520
   char load_alarm_reason[MAX_STRING_SIZE];
 
1521
   char suspend_alarm_reason[MAX_STRING_SIZE];
 
1522
   bool is_load_value;
 
1523
   bool has_value_from_object; 
 
1524
   double load_avg;
 
1525
   u_long32 interval;
 
1526
 
 
1527
   DENTER(GUI_LAYER, "qmonQinstanceShowBrowserExplain");
 
1528
 
 
1529
   if (explain_bits == QI_DEFAULT) {
 
1530
      DEXIT;
 
1531
      return;
 
1532
   }
 
1533
 
 
1534
   *load_alarm_reason = 0;
 
1535
   *suspend_alarm_reason = 0;
 
1536
 
 
1537
   if (!(load_avg_str=getenv("SGE_LOAD_AVG")) || !strlen(load_avg_str))
 
1538
         load_avg_str = LOAD_ATTR_LOAD_AVG;
 
1539
 
 
1540
   /* compute the load and check for alarm states */
 
1541
   is_load_value = sge_get_double_qattr(&load_avg, load_avg_str, q, exechost_list, centry_list, &has_value_from_object);
 
1542
   if (sge_load_alarm(NULL, q, lGetList(q, QU_load_thresholds), exechost_list, centry_list, NULL, true)) {
 
1543
      qinstance_state_set_alarm(q, true);
 
1544
      sge_load_alarm_reason(q, lGetList(q, QU_load_thresholds), exechost_list, 
 
1545
                            centry_list, load_alarm_reason, 
 
1546
                            MAX_STRING_SIZE - 1, "load");
 
1547
   }
 
1548
   parse_ulong_val(NULL, &interval, TYPE_TIM,
 
1549
                   lGetString(q, QU_suspend_interval), NULL, 0);
 
1550
   if (lGetUlong(q, QU_nsuspend) != 0 &&
 
1551
       interval != 0 &&
 
1552
       sge_load_alarm(NULL, q, lGetList(q, QU_suspend_thresholds), exechost_list, centry_list, NULL, false)) {
 
1553
      qinstance_state_set_suspend_alarm(q, true);
 
1554
      sge_load_alarm_reason(q, lGetList(q, QU_suspend_thresholds), 
 
1555
                            exechost_list, centry_list, suspend_alarm_reason, 
 
1556
                            MAX_STRING_SIZE - 1, "suspend");
 
1557
   }
 
1558
 
 
1559
   sge_dstring_sprintf(info, "Queue: %s\n", lGetString(q, QU_full_name));
 
1560
   if ((explain_bits & QI_ALARM) > 0) {
 
1561
      if(*load_alarm_reason) {
 
1562
         sge_dstring_sprintf_append(info, load_alarm_reason); 
 
1563
      }
 
1564
   }
 
1565
   if ((explain_bits & QI_SUSPEND_ALARM) > 0) {
 
1566
      if(*suspend_alarm_reason) {
 
1567
         sge_dstring_sprintf_append(info, suspend_alarm_reason); 
 
1568
      }
 
1569
   }
 
1570
   if (explain_bits != QI_DEFAULT) {
 
1571
      lList *qim_list = lGetList(q, QU_message_list);
 
1572
      lListElem *qim = NULL;
 
1573
 
 
1574
      for_each(qim, qim_list) {
 
1575
         u_long32 type = lGetUlong(qim, QIM_type);
 
1576
 
 
1577
         if ((explain_bits & QI_AMBIGUOUS) == type || 
 
1578
             (explain_bits & QI_ERROR) == type) {
 
1579
            const char *message = lGetString(qim, QIM_message);
 
1580
 
 
1581
            sge_dstring_sprintf_append(info, "\t"); 
 
1582
            sge_dstring_sprintf_append(info, message); 
 
1583
         }
 
1584
      }
 
1585
   }
 
1586
 
 
1587
   DEXIT;
 
1588
}
 
1589
 
 
1590
/*-------------------------------------------------------------------------*/
 
1591
static void qmonCQHandleEnterLeave(
 
1592
Widget w,
 
1593
XtPointer cld,
 
1594
XEvent *ev,
 
1595
Boolean *ctd 
 
1596
) {
 
1597
   /*
 
1598
   int root_x, root_y, pos_x, pos_y;
 
1599
   Window root, child;
 
1600
   unsigned int keys_buttons;
 
1601
   */
 
1602
   static char line[] = "+++++++++++++++++++++++++++++++++++++++++++\n";
 
1603
   static int prev_row = -1;
 
1604
   int row, col;
 
1605
   String str;
 
1606
   lListElem *qp;
 
1607
   String queue_info;
 
1608
   
 
1609
   DENTER(GUI_LAYER, "qmonCQHandleEnterLeave");
 
1610
   
 
1611
   switch (ev->type) {
 
1612
      case MotionNotify:
 
1613
         if (qmonBrowserObjectEnabled(BROWSE_QUEUE)) {
 
1614
            /* 
 
1615
            ** XQueryPointer(XtDisplay(w), XtWindow(w), 
 
1616
            **            &root, &child, &root_x, &root_y,
 
1617
            **            &pos_x, &pos_y, &keys_buttons);
 
1618
            */
 
1619
            if (XbaeMatrixGetEventRowColumn(w, ev, &row, &col)) {
 
1620
               if ( row != prev_row ) {
 
1621
                  prev_row = row;
 
1622
                  /* locate the quue */
 
1623
                  str = XbaeMatrixGetCell(w, row, 0);
 
1624
                  if (str && *str != '\0') {
 
1625
                     qp = cqueue_list_locate(qmonMirrorList(SGE_CQUEUE_LIST), str);
 
1626
                     if (qp) {
 
1627
                        queue_info = qmonCQShowBrowserInfo(qp);      
 
1628
                        qmonBrowserShow(queue_info);
 
1629
                        qmonBrowserShow(line);
 
1630
                     }
 
1631
                  }
 
1632
               }
 
1633
            }
 
1634
         }
 
1635
         break;
 
1636
   }
 
1637
   DEXIT;
 
1638
}
 
1639
/*-------------------------------------------------------------------------*/
 
1640
static String qmonCQShowBrowserInfo(
 
1641
lListElem *qep 
 
1642
) {
 
1643
 
 
1644
   static char info[60000];
 
1645
#define WIDTH  "%s%-30.30s"
 
1646
 
 
1647
   DENTER(GUI_LAYER, "qmonCQShowBrowserInfo");
 
1648
 
 
1649
   sprintf(info, WIDTH"%s\n", "\n","Cluster Queue:", lGetString(qep, CQ_name));
 
1650
 
 
1651
   sprintf(info, "%s\n", info); 
 
1652
 
 
1653
   DPRINTF(("info is %d long\n", strlen(info)));
 
1654
   
 
1655
#undef WIDTH
 
1656
   DEXIT;
 
1657
   return info;
 
1658
}
 
1659
 
 
1660
/*-------------------------------------------------------------------------*/
 
1661
static void qmonCQModify(Widget w, XtPointer cld, XtPointer cad)
 
1662
{
 
1663
   int rows = 0;
 
1664
   int nr_selected_rows;
 
1665
   int i;
 
1666
   char *str = NULL;
 
1667
   lList *alp = NULL;
 
1668
   Widget matrix = cluster_queue_settings;
 
1669
   int mode = (int) cld;
 
1670
   tQCAction qc_action = {QC_ADD, NULL};
 
1671
   
 
1672
   DENTER(GUI_LAYER, "qmonCQModify");
 
1673
 
 
1674
   /* 
 
1675
   ** loop over selected entries and delete them
 
1676
   */
 
1677
   rows = XbaeMatrixNumRows(matrix);
 
1678
   /*
 
1679
   ** number of selected rows
 
1680
   */
 
1681
   nr_selected_rows = XbaeMatrixGetNumSelected(matrix)/XbaeMatrixNumColumns(matrix);
 
1682
   
 
1683
   if (nr_selected_rows == 1) {
 
1684
      for (i=0; i<rows; i++) {
 
1685
         /* is this row selected */ 
 
1686
         if (XbaeMatrixIsRowSelected(matrix, i)) {
 
1687
            str = XbaeMatrixGetCell(cluster_queue_settings, i, 0);
 
1688
            if ( str && *str != '\0' ) { 
 
1689
               DPRINTF(("CQ to modify: %s\n", str));
 
1690
               qc_action.action = mode;
 
1691
               qc_action.qname = str;
 
1692
               qmonQCPopup(matrix, (XtPointer)(&qc_action), NULL); 
 
1693
            }
 
1694
         }
 
1695
      }
 
1696
      qmonMessageBox(w, alp, 0);
 
1697
      lFreeList(&alp);
 
1698
      /*
 
1699
      ** update the matrix
 
1700
      */
 
1701
      qmonCQUpdateCQMatrix();
 
1702
   } else {
 
1703
      if (nr_selected_rows > 1) {
 
1704
         qmonMessageShow(w, True, "@{Select only one queue !}");
 
1705
      } else {
 
1706
         qmonMessageShow(w, True, "@{Select one queue !}");
 
1707
      }
 
1708
   }
 
1709
 
 
1710
 
 
1711
   DEXIT;
 
1712
}
 
1713
 
 
1714
 
 
1715
/*-------------------------------------------------------------------------*/
 
1716
static void qmonCQDelete(Widget w, XtPointer cld, XtPointer cad) 
 
1717
{
 
1718
   int i;
 
1719
   int rows;
 
1720
   lList *alp = NULL;
 
1721
   const char *str;
 
1722
   Boolean status, answer = False;
 
1723
   Widget matrix = cluster_queue_settings;
 
1724
 
 
1725
   DENTER(GUI_LAYER, "qmonCQDelete");
 
1726
 
 
1727
/*    force = XmToggleButtonGetState(force_toggle); */
 
1728
 
 
1729
   /* 
 
1730
   ** loop over selected entries and delete them
 
1731
   */
 
1732
   rows = XbaeMatrixNumRows(matrix);
 
1733
   if (XbaeMatrixGetNumSelected(matrix) > 0) {
 
1734
      status = XmtAskForBoolean(w, "xmtBooleanDialog", 
 
1735
                     "@{queue.askdel.Do you really want to\ndelete the selected queues ?}", 
 
1736
                     "@{Delete}", "@{Cancel}", NULL, XmtNoButton, XmDIALOG_WARNING, 
 
1737
                     False, &answer, NULL);
 
1738
         
 
1739
      if (answer) { 
 
1740
         for (i=0; i<rows; i++) {
 
1741
            /* is this row selected */ 
 
1742
            if (XbaeMatrixIsRowSelected(matrix, i)) {
 
1743
               str = XbaeMatrixGetCell(cluster_queue_settings, i, 0);
 
1744
               if ( str && *str != '\0' ) { 
 
1745
                  DPRINTF(("CQ to delete: %s\n", str));
 
1746
                  cqueue_delete(ctx, &alp, str);
 
1747
               }
 
1748
            }
 
1749
         }
 
1750
      }
 
1751
      qmonMessageBox(w, alp, 0);
 
1752
      lFreeList(&alp);
 
1753
      /*
 
1754
      ** update the matrix
 
1755
      */
 
1756
      XbaeMatrixDeselectAll(cluster_queue_settings);
 
1757
      qmonCQUpdateCQMatrix();
 
1758
/*       qmonCQUpdateTree(); */
 
1759
   }
 
1760
 
 
1761
 
 
1762
   DEXIT;
 
1763
}
 
1764
 
 
1765
/*-------------------------------------------------------------------------*/
 
1766
static void qmonCQChangeState(Widget w, XtPointer cld, XtPointer cad)
 
1767
{
 
1768
   int rows;
 
1769
   const char *str;
 
1770
   int i;
 
1771
   lList *ql = NULL;
 
1772
   lList *alp = NULL;
 
1773
   int force = 0;
 
1774
   long action = (long) cld;
 
1775
   Widget force_toggle;
 
1776
   Widget matrix = current_matrix;
 
1777
   
 
1778
   DENTER(GUI_LAYER, "qmonCQChangeState");
 
1779
 
 
1780
   /* 
 
1781
   ** loop over selected entries and build id list
 
1782
   */
 
1783
   rows = XbaeMatrixNumRows(matrix);
 
1784
   if (XbaeMatrixGetNumSelected(matrix) > 0) {
 
1785
      /*
 
1786
      ** cld contains the action we need, check if a force is involved
 
1787
      */
 
1788
      force_toggle = XmtNameToWidget(w, "*cq_force"); 
 
1789
      force = XmToggleButtonGetState(force_toggle);
 
1790
   
 
1791
      for (i=0; i<rows; i++) {
 
1792
         /* is this row selected */ 
 
1793
         if (XbaeMatrixIsRowSelected(matrix, i)) {
 
1794
            str = XbaeMatrixGetCell(matrix, i, 0);
 
1795
            if ( str && *str != '\0' ) { 
 
1796
               DPRINTF(("CQ/QI to change: %s\n", str));
 
1797
               lAddElemStr(&ql, ST_name, str, ST_Type);
 
1798
            }
 
1799
         }
 
1800
      }
 
1801
      if (ql) {
 
1802
         alp = qmonChangeStateList(SGE_CQUEUE_LIST, ql, force, action); 
 
1803
      
 
1804
         qmonMessageBox(w, alp, 0);
 
1805
         /*
 
1806
         ** update the matrix
 
1807
         */
 
1808
         if (current_matrix == cluster_queue_settings) {
 
1809
            qmonCQUpdateCQMatrix();
 
1810
         } else {   
 
1811
            qmonCQUpdateQIMatrix();
 
1812
         }   
 
1813
         lFreeList(&ql);
 
1814
         lFreeList(&alp);
 
1815
      }
 
1816
   }
 
1817
 
 
1818
   DEXIT;
 
1819
}
 
1820
 
 
1821
/*-------------------------------------------------------------------------*/
 
1822
static void qmonCQFolderChange(Widget w, XtPointer cld, XtPointer cad)
 
1823
{
 
1824
   XmTabCallbackStruct *cbs = (XmTabCallbackStruct*)cad;
 
1825
   
 
1826
   DENTER(GUI_LAYER, "qmonCQFolderChange");
 
1827
 
 
1828
   DPRINTF(("%s\n", XtName(cbs->tab_child)));
 
1829
 
 
1830
   if (!strcmp(XtName(cbs->tab_child), "clusterqueue_layout")) {
 
1831
      current_matrix = cluster_queue_settings;
 
1832
      qmonCQUpdateCQMatrix();
 
1833
 
 
1834
      XtSetSensitive(cq_add, True);
 
1835
      XtSetSensitive(cq_clone, True);
 
1836
      XtSetSensitive(cq_mod, True);
 
1837
      XtSetSensitive(cq_delete, True);
 
1838
      XtSetSensitive(cq_sick, True);
 
1839
      XtSetSensitive(cq_force, True);
 
1840
      XtSetSensitive(cq_suspend, True);
 
1841
      XtSetSensitive(cq_resume, True);
 
1842
      XtSetSensitive(cq_disable, True);
 
1843
      XtSetSensitive(cq_enable, True);
 
1844
      XtSetSensitive(cq_clear_error, True);
 
1845
      XtSetSensitive(cq_reschedule, True);
 
1846
      XtSetSensitive(cq_load, False);
 
1847
      XtSetSensitive(cq_explain_states, False);
 
1848
      XtSetSensitive(cq_explain, False);
 
1849
   } else if (!strcmp(XtName(cbs->tab_child), "qhost_layout")) {
 
1850
      current_matrix = qhost_settings;
 
1851
      qmonCQUpdateQhostMatrix();
 
1852
 
 
1853
      XtSetSensitive(cq_add, False);
 
1854
      XtSetSensitive(cq_clone, False);
 
1855
      XtSetSensitive(cq_mod, False);
 
1856
      XtSetSensitive(cq_delete, False);
 
1857
      XtSetSensitive(cq_sick, False);
 
1858
      XtSetSensitive(cq_force, False);
 
1859
      XtSetSensitive(cq_suspend, False);
 
1860
      XtSetSensitive(cq_resume, False);
 
1861
      XtSetSensitive(cq_disable, False);
 
1862
      XtSetSensitive(cq_enable, False);
 
1863
      XtSetSensitive(cq_reschedule, False);
 
1864
      XtSetSensitive(cq_clear_error, False);
 
1865
      XtSetSensitive(cq_load, False);
 
1866
      XtSetSensitive(cq_explain_states, False);
 
1867
      XtSetSensitive(cq_explain, False);
 
1868
   } else {
 
1869
      current_matrix = qinstance_settings;
 
1870
      qmonCQUpdateQIMatrix();
 
1871
 
 
1872
      XtSetSensitive(cq_add, False);
 
1873
      XtSetSensitive(cq_clone, False);
 
1874
      XtSetSensitive(cq_mod, False);
 
1875
      XtSetSensitive(cq_delete, False);
 
1876
      XtSetSensitive(cq_sick, False);
 
1877
      XtSetSensitive(cq_force, True);
 
1878
      XtSetSensitive(cq_suspend, True);
 
1879
      XtSetSensitive(cq_resume, True);
 
1880
      XtSetSensitive(cq_disable, True);
 
1881
      XtSetSensitive(cq_enable, True);
 
1882
      XtSetSensitive(cq_reschedule, True);
 
1883
      XtSetSensitive(cq_clear_error, True);
 
1884
      XtSetSensitive(cq_load, True);
 
1885
      XtSetSensitive(cq_explain_states, True);
 
1886
      XtSetSensitive(cq_explain, True);
 
1887
   }   
 
1888
 
 
1889
   DEXIT;
 
1890
}
 
1891
 
 
1892
/*-------------------------------------------------------------------------*/
 
1893
static void qmonCQUpdateCQMatrix(void)
 
1894
{
 
1895
   lList *alp = NULL;
 
1896
   lList *ehl = NULL;
 
1897
   lList *cl = NULL;
 
1898
   lList *acl = NULL;
 
1899
   lList *prjl = NULL;
 
1900
   lList *ql = NULL;
 
1901
   lList *fql = NULL;
 
1902
   lList *ul = NULL;
 
1903
   lList *rl = NULL;
 
1904
   lList *prl = NULL;
 
1905
   lList *pel = NULL;
 
1906
   lList *qrl = NULL;
 
1907
   lList *hgl = NULL;
 
1908
   lListElem *cq = NULL;
 
1909
   int row;
 
1910
   int num_rows;
 
1911
   int num_fql;
 
1912
   char buf[BUFSIZ];
 
1913
   u_long32 qstate = U_LONG32_MAX; 
 
1914
 
 
1915
   DENTER(GUI_LAYER, "qmonCQUpdateCQMatrix");
 
1916
 
 
1917
   qmonMirrorMultiAnswer(CQUEUE_T | EXECHOST_T | CENTRY_T | USERSET_T | PE_T |HGROUP_T,  &alp);
 
1918
   if (alp) {
 
1919
      qmonMessageBox(cluster_queue_settings, alp, 0);
 
1920
      lFreeList(&alp);
 
1921
      DEXIT;
 
1922
      return;
 
1923
   }
 
1924
 
 
1925
   rl = qmonGetQCUResourceList();
 
1926
   qrl = qmonGetQCUQrefList();
 
1927
   ul = qmonGetQCUUserRefList();
 
1928
   prl = qmonGetQCUPERefList();
 
1929
   qstate = qmonGetQCUQueueState();
 
1930
 
 
1931
   /*
 
1932
   ** set the customize button label
 
1933
   */
 
1934
   if (rl || qrl || ul || prl || qstate != U_LONG32_MAX) {
 
1935
      setButtonLabel(cq_customize, "@{Customize +}");
 
1936
   } else {   
 
1937
      setButtonLabel(cq_customize, "@{Customize}");
 
1938
   }   
 
1939
   
 
1940
   ehl = qmonMirrorList(SGE_EXECHOST_LIST);
 
1941
   cl = qmonMirrorList(SGE_CENTRY_LIST);
 
1942
   ql = qmonMirrorList(SGE_CQUEUE_LIST);
 
1943
   acl = qmonMirrorList(SGE_USERSET_LIST);
 
1944
   prjl = qmonMirrorList(SGE_PROJECT_LIST);
 
1945
   pel = qmonMirrorList(SGE_PE_LIST);
 
1946
   hgl = qmonMirrorList(SGE_HGROUP_LIST);
 
1947
 
 
1948
   /*
 
1949
   ** match filter criteria
 
1950
   */
 
1951
   filter_queues(&fql, ql, cl, hgl, ehl, acl, prjl, pel, rl, qrl, prl, ul, qstate, NULL);
 
1952
 
 
1953
   /*
 
1954
   ** sort according to sorting criteria
 
1955
   */
 
1956
   lPSortList(fql, "%I+ ", CQ_name);
 
1957
 
 
1958
   /*
 
1959
   ** Cluster Queue Pane
 
1960
   */
 
1961
   XtVaSetValues(cluster_queue_settings, XmNcells, NULL, NULL);
 
1962
 
 
1963
   num_rows = XbaeMatrixNumRows(cluster_queue_settings);
 
1964
   num_fql = lGetNumberOfElem(fql);
 
1965
   if (num_fql > num_rows) {
 
1966
      XbaeMatrixAddRows(cluster_queue_settings, num_rows, NULL, NULL, NULL, 
 
1967
                           num_fql - num_rows);
 
1968
   }   
 
1969
 
 
1970
   row = 0;
 
1971
/*    TODO                                            */    
 
1972
/*    is correct_capacities needed here ???           */    
 
1973
/*    correct_capacities(ehl, cl); */
 
1974
   for_each (cq, fql) {
 
1975
      double load = 0.0;
 
1976
      u_long32 used, resv, total;
 
1977
      u_long32 temp_disabled, available, manual_intervention;
 
1978
      u_long32 suspend_manual, suspend_threshold, suspend_on_subordinate;
 
1979
      u_long32 suspend_calendar, unknown, load_alarm;
 
1980
      u_long32 disabled_manual, disabled_calendar, ambiguous;
 
1981
      u_long32 orphaned, error;
 
1982
      bool is_load_available;
 
1983
 
 
1984
      cqueue_calculate_summary(cq, ehl, cl, 
 
1985
                            &load, &is_load_available, &used, &resv, &total,
 
1986
                            &suspend_manual, &suspend_threshold,
 
1987
                            &suspend_on_subordinate, &suspend_calendar,
 
1988
                            &unknown, &load_alarm, &disabled_manual,
 
1989
                            &disabled_calendar, &ambiguous, &orphaned,
 
1990
                            &error, &available, &temp_disabled,
 
1991
                            &manual_intervention);
 
1992
 
 
1993
      XbaeMatrixSetCell(cluster_queue_settings, row, 0, (char*)lGetString(cq, CQ_name));
 
1994
      if (is_load_available) {
 
1995
         sprintf(buf, "%7.2f ", load);
 
1996
      } else {
 
1997
         sprintf(buf, "%7s ", "-NA-");
 
1998
      }
 
1999
      XbaeMatrixSetCell(cluster_queue_settings, row, 1, buf);
 
2000
      sprintf(buf, "%6d ", (int)used);
 
2001
      XbaeMatrixSetCell(cluster_queue_settings, row, 2, buf);
 
2002
      sprintf(buf, "%6d ", (int)resv);
 
2003
      XbaeMatrixSetCell(cluster_queue_settings, row, 3, buf);
 
2004
      sprintf(buf, "%6d ", (int)available);
 
2005
      XbaeMatrixSetCell(cluster_queue_settings, row, 4, buf);
 
2006
      sprintf(buf, "%6d ", (int)total);
 
2007
      XbaeMatrixSetCell(cluster_queue_settings, row, 5, buf);
 
2008
      sprintf(buf, "%6d ", (int)temp_disabled);
 
2009
      XbaeMatrixSetCell(cluster_queue_settings, row, 6, buf);
 
2010
      sprintf(buf, "%6d ", (int)manual_intervention);
 
2011
      XbaeMatrixSetCell(cluster_queue_settings, row, 7, buf);
 
2012
      sprintf(buf, "%5d ", (int)suspend_manual);
 
2013
      XbaeMatrixSetCell(cluster_queue_settings, row, 8, buf);
 
2014
      sprintf(buf, "%5d ", (int)suspend_threshold);
 
2015
      XbaeMatrixSetCell(cluster_queue_settings, row, 9, buf);
 
2016
      sprintf(buf, "%5d ", (int)suspend_on_subordinate);
 
2017
      XbaeMatrixSetCell(cluster_queue_settings, row, 10, buf);
 
2018
      sprintf(buf, "%5d ", (int)suspend_calendar);
 
2019
      XbaeMatrixSetCell(cluster_queue_settings, row, 11, buf);
 
2020
      sprintf(buf, "%5d ", (int)unknown);
 
2021
      XbaeMatrixSetCell(cluster_queue_settings, row, 12, buf);
 
2022
      sprintf(buf, "%5d ", (int)load_alarm);
 
2023
      XbaeMatrixSetCell(cluster_queue_settings, row, 13, buf);
 
2024
      sprintf(buf, "%5d ", (int)disabled_manual);
 
2025
      XbaeMatrixSetCell(cluster_queue_settings, row, 14, buf);
 
2026
      sprintf(buf, "%5d ", (int)disabled_calendar);
 
2027
      XbaeMatrixSetCell(cluster_queue_settings, row, 15, buf);
 
2028
      sprintf(buf, "%5d ", (int)ambiguous);
 
2029
      XbaeMatrixSetCell(cluster_queue_settings, row, 16, buf);
 
2030
      sprintf(buf, "%5d ", (int)orphaned);
 
2031
      XbaeMatrixSetCell(cluster_queue_settings, row, 17, buf);
 
2032
      sprintf(buf, "%5d ", (int)error);
 
2033
      XbaeMatrixSetCell(cluster_queue_settings, row, 18, buf);
 
2034
   
 
2035
      row++;
 
2036
   }   
 
2037
 
 
2038
   lFreeList(&fql);
 
2039
}
 
2040
 
 
2041
/*-------------------------------------------------------------------------*/
 
2042
static void qmonCQUpdateQIMatrix(void)
 
2043
{
 
2044
   lList *alp = NULL;
 
2045
   lList *ehl = NULL;
 
2046
   lList *cl = NULL;
 
2047
   lList *acl = NULL;
 
2048
   lList *ql = NULL;
 
2049
   lList *fql = NULL;
 
2050
   lList *ul = NULL;
 
2051
   lList *rl = NULL;
 
2052
   lList *prl = NULL;
 
2053
   lList *pel = NULL;
 
2054
   lList *qrl = NULL;
 
2055
   lList *hgl = NULL;
 
2056
   lList *prjl = NULL;
 
2057
   lListElem *cq = NULL;
 
2058
   int row;
 
2059
   int num_rows;
 
2060
   char buf[BUFSIZ];
 
2061
   u_long32 qstate = U_LONG32_MAX; 
 
2062
 
 
2063
#ifdef QI_SORTING
 
2064
   lListElem *qip = NULL;
 
2065
   lList *qil = NULL;
 
2066
   int qil_num = 0;
 
2067
#endif   
 
2068
 
 
2069
   DENTER(GUI_LAYER, "qmonCQUpdateQIMatrix");
 
2070
 
 
2071
   qmonMirrorMultiAnswer(CQUEUE_T | EXECHOST_T | CENTRY_T | USERSET_T | PE_T |HGROUP_T,  &alp);
 
2072
   if (alp) {
 
2073
      qmonMessageBox(cluster_queue_settings, alp, 0);
 
2074
      lFreeList(&alp);
 
2075
      DEXIT;
 
2076
      return;
 
2077
   }
 
2078
 
 
2079
   rl = qmonGetQCUResourceList();
 
2080
   qrl = qmonGetQCUQrefList();
 
2081
   ul = qmonGetQCUUserRefList();
 
2082
   prl = qmonGetQCUPERefList();
 
2083
   qstate = qmonGetQCUQueueState();
 
2084
   
 
2085
   /*
 
2086
   ** set the customize button label
 
2087
   */
 
2088
   if (rl || qrl || ul || prl || qstate != U_LONG32_MAX) {
 
2089
      setButtonLabel(cq_customize, "@{Customize +}");
 
2090
   } else {   
 
2091
      setButtonLabel(cq_customize, "@{Customize}");
 
2092
   }   
 
2093
   
 
2094
   ehl = qmonMirrorList(SGE_EXECHOST_LIST);
 
2095
   cl = qmonMirrorList(SGE_CENTRY_LIST);
 
2096
   ql = qmonMirrorList(SGE_CQUEUE_LIST);
 
2097
   acl = qmonMirrorList(SGE_USERSET_LIST);
 
2098
   prjl = qmonMirrorList(SGE_PROJECT_LIST);
 
2099
   pel = qmonMirrorList(SGE_PE_LIST);
 
2100
   hgl = qmonMirrorList(SGE_HGROUP_LIST);
 
2101
 
 
2102
   /*
 
2103
   ** match filter criteria
 
2104
   */
 
2105
   filter_queues(&fql, ql, cl, hgl, ehl, acl, prjl, pel, rl, qrl, prl, ul, qstate, NULL);
 
2106
 
 
2107
   /*
 
2108
   ** sort according to sorting criteria
 
2109
   */
 
2110
   lPSortList(fql, "%I+", CQ_name);
 
2111
 
 
2112
   /*
 
2113
   ** Cluster Queue Instances Pane
 
2114
   */
 
2115
   XtVaSetValues(qinstance_settings, XmNcells, NULL, NULL);
 
2116
 
 
2117
   row=0;
 
2118
   for_each(cq, fql) {
 
2119
      lList *ql = NULL;
 
2120
      lListElem *qp;
 
2121
      char to_print[80];
 
2122
      char arch_string[80];
 
2123
      double load_avg;
 
2124
      char *load_avg_str = NULL;
 
2125
      char load_alarm_reason[MAX_STRING_SIZE];
 
2126
      char suspend_alarm_reason[MAX_STRING_SIZE];
 
2127
      bool is_load_value;
 
2128
      bool has_value_from_object; 
 
2129
      u_long32 interval;
 
2130
 
 
2131
      if (!(load_avg_str=getenv("SGE_LOAD_AVG")) || !strlen(load_avg_str))
 
2132
         load_avg_str = LOAD_ATTR_LOAD_AVG;
 
2133
 
 
2134
      ql = lCopyList("copy", lGetList(cq, CQ_qinstances));
 
2135
      lPSortList(ql, "%I+", QU_full_name);
 
2136
      for_each(qp, ql) {
 
2137
         if ((lGetUlong(qp, QU_tag) & TAG_SHOW_IT)!=0) {
 
2138
#ifndef QI_SORTING
 
2139
            num_rows = XbaeMatrixNumRows(qinstance_settings);
 
2140
            if (row >= num_rows) {
 
2141
               XbaeMatrixAddRows(qinstance_settings, num_rows, 
 
2142
                                    NULL, NULL, NULL, 1);
 
2143
            }   
 
2144
#endif
 
2145
            /* compute the load and check for alarm states */
 
2146
            is_load_value = sge_get_double_qattr(&load_avg, load_avg_str, qp, ehl, cl, 
 
2147
                                                   &has_value_from_object);
 
2148
            if (sge_load_alarm(NULL, qp, lGetList(qp, QU_load_thresholds), ehl, cl, NULL, true)) {
 
2149
               qinstance_state_set_alarm(qp, true);
 
2150
               sge_load_alarm_reason(qp, lGetList(qp, QU_load_thresholds), ehl, 
 
2151
                               cl, load_alarm_reason, MAX_STRING_SIZE - 1, "load");
 
2152
            }
 
2153
            parse_ulong_val(NULL, &interval, TYPE_TIM,
 
2154
                            lGetString(qp, QU_suspend_interval), NULL, 0);
 
2155
            if (lGetUlong(qp, QU_nsuspend) != 0 &&
 
2156
                interval != 0 &&
 
2157
                sge_load_alarm(NULL, qp, lGetList(qp, QU_suspend_thresholds), ehl, cl, NULL, false)) {
 
2158
               qinstance_state_set_suspend_alarm(qp, true);
 
2159
               sge_load_alarm_reason(qp, lGetList(qp, QU_suspend_thresholds), 
 
2160
                               ehl, cl, suspend_alarm_reason, 
 
2161
                               MAX_STRING_SIZE - 1, "suspend");
 
2162
            }
 
2163
 
 
2164
#ifndef QI_SORTING
 
2165
            /* full qname */
 
2166
            XbaeMatrixSetCell(qinstance_settings, row, 0, 
 
2167
                              (char*)lGetString(qp, QU_full_name));
 
2168
#else
 
2169
            qip = lAddElemStr(&qil, QI_queue, lGetString(qp, QU_full_name), qi_descr);
 
2170
#endif
 
2171
            /* qtype */
 
2172
            {
 
2173
               dstring type_string = DSTRING_INIT;
 
2174
 
 
2175
               qinstance_print_qtype_to_dstring(qp, &type_string, true);
 
2176
#ifndef QI_SORTING
 
2177
               XbaeMatrixSetCell(qinstance_settings, row, 1, 
 
2178
                                 (char*) sge_dstring_get_string(&type_string));
 
2179
#else
 
2180
               lSetString(qip, QI_qtype, sge_dstring_get_string(&type_string));
 
2181
#endif
 
2182
               sge_dstring_free(&type_string);
 
2183
            }
 
2184
            /* number of used/free slots */
 
2185
            sprintf(to_print, "%d/%d/%d ", qinstance_slots_reserved_now(qp), qinstance_slots_used(qp),
 
2186
                     (int)lGetUlong(qp, QU_job_slots));
 
2187
            sprintf(buf, "%-9.9s ", to_print);   
 
2188
#ifndef QI_SORTING
 
2189
            XbaeMatrixSetCell(qinstance_settings, row, 2, buf);
 
2190
#else
 
2191
            lSetString(qip, QI_used_total, buf);
 
2192
#endif
 
2193
 
 
2194
            /* load avg */
 
2195
            if (!is_load_value) {
 
2196
               if (has_value_from_object) {
 
2197
                  sprintf(to_print, "%2.2f ", load_avg);
 
2198
               } else {
 
2199
                  sprintf(to_print, "---  ");
 
2200
               }
 
2201
            } else {
 
2202
               sprintf(to_print, "-NA- ");
 
2203
            }
 
2204
#ifndef QI_SORTING
 
2205
            XbaeMatrixSetCell(qinstance_settings, row, 3, to_print);
 
2206
#else
 
2207
            lSetString(qip, QI_load_avg, to_print);
 
2208
#endif
 
2209
      
 
2210
            /* arch */
 
2211
            if (!sge_get_string_qattr(arch_string, sizeof(arch_string)-1, 
 
2212
                                      LOAD_ATTR_ARCH, qp, ehl, cl)) {
 
2213
#ifndef QI_SORTING
 
2214
               XbaeMatrixSetCell(qinstance_settings, row, 4, arch_string);
 
2215
#else               
 
2216
               lSetString(qip, QI_arch, arch_string);
 
2217
#endif
 
2218
            } else {
 
2219
#ifndef QI_SORTING
 
2220
               XbaeMatrixSetCell(qinstance_settings, row, 4, "-NA-");
 
2221
#else
 
2222
               lSetString(qip, QI_arch, "-NA-");
 
2223
#endif
 
2224
            }
 
2225
            {
 
2226
               dstring state_string = DSTRING_INIT;
 
2227
 
 
2228
               qinstance_state_append_to_dstring(qp, &state_string);
 
2229
#ifndef QI_SORTING
 
2230
               XbaeMatrixSetCell(qinstance_settings, row, 5,
 
2231
                                 (char *)sge_dstring_get_string(&state_string));
 
2232
#else
 
2233
               lSetString(qip, QI_states, sge_dstring_get_string(&state_string));
 
2234
#endif
 
2235
               sge_dstring_free(&state_string);
 
2236
            }
 
2237
#ifndef QI_SORTING
 
2238
            row++;
 
2239
#endif            
 
2240
         }
 
2241
      }   
 
2242
      lFreeList(&ql);
 
2243
   }   
 
2244
 
 
2245
   lFreeList(&fql);
 
2246
 
 
2247
#ifdef QI_SORTING
 
2248
   /*
 
2249
   ** sort qinstances according to the criteria in qi_field_sort_by
 
2250
   */
 
2251
   if (qi_field_sort_by == QI_queue && qi_field_sort_direction == SORT_ASCENDING) {
 
2252
      lPSortList(qil, "%I+", QI_queue);
 
2253
   } else if (qi_field_sort_by == QI_queue && qi_field_sort_direction == SORT_DESCENDING) {
 
2254
      lPSortList(qil, "%I-", QI_queue);
 
2255
   } else if (qi_field_sort_direction == SORT_ASCENDING) {
 
2256
      lPSortList(qil, "%I+ %I+", qi_field_sort_by, QI_queue);
 
2257
   } else {
 
2258
      lPSortList(qil, "%I- %I+", qi_field_sort_by, QI_queue);
 
2259
   }
 
2260
 
 
2261
   if ((qil_num = lGetNumberOfElem(qil)) > 0) {
 
2262
      num_rows = XbaeMatrixNumRows(qinstance_settings);
 
2263
      if (qil_num >= num_rows) {
 
2264
         XbaeMatrixAddRows(qinstance_settings, num_rows, 
 
2265
                              NULL, NULL, NULL, qil_num - num_rows);
 
2266
      }   
 
2267
   }   
 
2268
 
 
2269
   row = 0;
 
2270
   for_each(qip, qil) {
 
2271
      XbaeMatrixSetCell(qinstance_settings, row, 0, (char*)lGetString(qip, QI_queue));
 
2272
      XbaeMatrixSetCell(qinstance_settings, row, 1, (char*)lGetString(qip, QI_qtype));
 
2273
      XbaeMatrixSetCell(qinstance_settings, row, 2, (char*)lGetString(qip, QI_used_total));
 
2274
      XbaeMatrixSetCell(qinstance_settings, row, 3, (char*)lGetString(qip, QI_load_avg));
 
2275
      XbaeMatrixSetCell(qinstance_settings, row, 4, (char*)lGetString(qip, QI_arch));
 
2276
      XbaeMatrixSetCell(qinstance_settings, row, 5, (char*)lGetString(qip, QI_states));
 
2277
      row++;
 
2278
   }
 
2279
 
 
2280
   lFreeList(&qil);
 
2281
#endif
 
2282
 
 
2283
   DEXIT;
 
2284
}
 
2285
 
 
2286
static int reformatDoubleValue(
 
2287
                               char *result,
 
2288
                               char *format,
 
2289
const char *oldmem
 
2290
                               ) {
 
2291
  char c;
 
2292
  double dval;
 
2293
  int ret = 1;
 
2294
 
 
2295
  DENTER(TOP_LAYER, "reformatDoubleValue");
 
2296
 
 
2297
  if (parse_ulong_val(&dval, NULL, TYPE_MEM, oldmem, NULL, 0)) {
 
2298
    if (dval==DBL_MAX) {
 
2299
      strcpy(result, "infinity");
 
2300
    } else {
 
2301
      c = '\0';
 
2302
 
 
2303
      if (fabs(dval) >= 1024*1024*1024) {
 
2304
        dval /= 1024*1024*1024;
 
2305
        c = 'G';
 
2306
      } else if (fabs(dval) >= 1024*1024) {
 
2307
        dval /= 1024*1024;
 
2308
        c = 'M';
 
2309
      } else if (fabs(dval) >= 1024) {
 
2310
        dval /= 1024;
 
2311
        c = 'K';
 
2312
      }
 
2313
      sprintf(result, format, dval, c);
 
2314
    }
 
2315
  }
 
2316
  else {
 
2317
    strcpy(result, "?E");
 
2318
    ret = 0;
 
2319
  }
 
2320
  DEXIT;
 
2321
  return ret;
 
2322
}
 
2323
 
 
2324
 
 
2325
/*-------------------------------------------------------------------------*/
 
2326
static void qmonCQUpdateQhostMatrix(void)
 
2327
{
 
2328
   lList *alp = NULL;
 
2329
   lList *ehl = NULL;
 
2330
   lList *cl = NULL;
 
2331
   lListElem *eh = NULL;
 
2332
   lListElem *lep = NULL;
 
2333
   int row;
 
2334
   int num_rows;
 
2335
 
 
2336
   DENTER(GUI_LAYER, "qmonCQUpdateQhostMatrix");
 
2337
 
 
2338
   if (!qmon_cq) {
 
2339
     DEXIT;
 
2340
     return;
 
2341
   }
 
2342
 
 
2343
   qmonMirrorMultiAnswer(EXECHOST_T | CENTRY_T, &alp);
 
2344
   if (alp) {
 
2345
      qmonMessageBox(qhost_settings, alp, 0);
 
2346
      lFreeList(&alp);
 
2347
      DEXIT;
 
2348
      return;
 
2349
   }
 
2350
 
 
2351
   ehl = qmonMirrorList(SGE_EXECHOST_LIST);
 
2352
   cl = qmonMirrorList(SGE_CENTRY_LIST);
 
2353
   /*
 
2354
   lWriteListTo(ehl, stdout);
 
2355
   lWriteListTo(cl, stdout);
 
2356
   */
 
2357
   lPSortList(ehl, "%I+", EH_name);
 
2358
   
 
2359
   XtVaSetValues(qhost_settings, XmNcells, NULL, NULL);
 
2360
   
 
2361
   row=0;
 
2362
   for_each(eh, ehl) {
 
2363
     char buffer[80];
 
2364
     char *s;
 
2365
     dstring rs = DSTRING_INIT;
 
2366
     u_long32 dominant = 0;
 
2367
     int column =0, i=0;
 
2368
     char *fields[] = {LOAD_ATTR_MEM_USED, LOAD_ATTR_MEM_TOTAL, 
 
2369
                       LOAD_ATTR_SWAP_USED, LOAD_ATTR_SWAP_TOTAL,
 
2370
                       LOAD_ATTR_VIRTUAL_USED, LOAD_ATTR_VIRTUAL_TOTAL};
 
2371
     
 
2372
     num_rows = XbaeMatrixNumRows(qhost_settings);
 
2373
     if (row >= num_rows) {
 
2374
       XbaeMatrixAddRows(qhost_settings, num_rows, 
 
2375
                         NULL, NULL, NULL, 1);
 
2376
     }
 
2377
     
 
2378
     if(!strcmp(lGetHost(eh, EH_name), SGE_TEMPLATE_NAME) || !strcmp(lGetHost(eh, EH_name), SGE_GLOBAL_NAME)) {
 
2379
       continue;
 
2380
     }
 
2381
     strcpy(buffer, (char *)lGetHost(eh, EH_name));
 
2382
     if (bootstrap_get_ignore_fqdn() && (s = strchr(buffer, '.')))
 
2383
       *s = '\0';
 
2384
      
 
2385
     XbaeMatrixSetCell(qhost_settings, row, column++, buffer);
 
2386
 
 
2387
     lep=get_attribute_by_name(NULL, eh, NULL, LOAD_ATTR_ARCH, cl, DISPATCH_TIME_NOW, 0);
 
2388
     if (lep) {
 
2389
       sge_strlcpy(buffer, sge_get_dominant_stringval(lep, &dominant, &rs),
 
2390
                   sizeof(buffer));
 
2391
       sge_dstring_clear(&rs);
 
2392
       lFreeElem(&lep);
 
2393
     }
 
2394
     else
 
2395
       strcpy(buffer, "-");
 
2396
     
 
2397
     XbaeMatrixSetCell(qhost_settings, row, column++, buffer);
 
2398
 
 
2399
     lep=get_attribute_by_name(NULL, eh, NULL, LOAD_ATTR_NUM_PROC, cl, DISPATCH_TIME_NOW, 0);
 
2400
     if (lep) {
 
2401
       sge_strlcpy(buffer, sge_get_dominant_stringval(lep, &dominant, &rs),
 
2402
                   sizeof(buffer));
 
2403
       sge_dstring_clear(&rs);
 
2404
       lFreeElem(&lep);
 
2405
     }
 
2406
     else
 
2407
       strcpy(buffer, "-");
 
2408
     XbaeMatrixSetCell(qhost_settings, row, column++, buffer);
 
2409
 
 
2410
     lep=get_attribute_by_name(NULL, eh, NULL, LOAD_ATTR_LOAD_AVG, cl, DISPATCH_TIME_NOW, 0);
 
2411
     if (lep) {
 
2412
       reformatDoubleValue(buffer, "%.2f%c", sge_get_dominant_stringval(lep, &dominant, &rs));
 
2413
       sge_dstring_clear(&rs);
 
2414
       lFreeElem(&lep);
 
2415
     }
 
2416
     else
 
2417
       strcpy(buffer, "-");
 
2418
       
 
2419
     XbaeMatrixSetCell(qhost_settings, row, column++, buffer);
 
2420
 
 
2421
     lep=get_attribute_by_name(NULL, eh, NULL, LOAD_ATTR_NP_LOAD_AVG, cl, DISPATCH_TIME_NOW, 0);
 
2422
     if (lep) {
 
2423
       /* lWriteElemTo(lep, stdout); */
 
2424
       sprintf(buffer, "%.1f%%", 100 * lGetDouble(lep, CE_pj_doubleval));
 
2425
       sge_dstring_clear(&rs);
 
2426
       lFreeElem(&lep);
 
2427
     }
 
2428
     else
 
2429
       strcpy(buffer, "-");
 
2430
       
 
2431
     XbaeMatrixSetCell(qhost_settings, row, column++, buffer);
 
2432
 
 
2433
     for (i = 0; i < 6 ; i++) {
 
2434
       lep=get_attribute_by_name(NULL, eh, NULL, fields[i], cl, DISPATCH_TIME_NOW, 0);
 
2435
       if (lep) {
 
2436
         reformatDoubleValue(buffer, "%.1f%c", sge_get_dominant_stringval(lep, &dominant, &rs));
 
2437
         sge_dstring_clear(&rs);
 
2438
         lFreeElem(&lep);
 
2439
       }
 
2440
       else
 
2441
         strcpy(buffer, "-");
 
2442
       
 
2443
       XbaeMatrixSetCell(qhost_settings, row, column++, buffer);
 
2444
     }
 
2445
     row++;
 
2446
   }
 
2447
   /* shrink back excess rows */
 
2448
   num_rows = XbaeMatrixNumRows(qhost_settings);
 
2449
   row = MAX(row, 30);
 
2450
   if (num_rows > row) {
 
2451
     XbaeMatrixDeleteRows(qhost_settings, row, num_rows - row);
 
2452
   }
 
2453
 
 
2454
   DEXIT;
 
2455
}
 
2456
 
 
2457
/*-------------------------------------------------------------------------*/
 
2458
static void qmonCQStartUpdate(Widget w, XtPointer cld, XtPointer cad)
 
2459
{
 
2460
  DENTER(GUI_LAYER, "qmonCQStartUpdate");
 
2461
 
 
2462
  qmonTimerAddUpdateProc(EXECHOST_T, "qmonCQUpdateQhostMatrix", qmonCQUpdateQhostMatrix);
 
2463
  qmonStartTimer(EXECHOST_T);
 
2464
 
 
2465
  DEXIT;
 
2466
}
 
2467
 
 
2468
/*-------------------------------------------------------------------------*/
 
2469
static void qmonCQStopUpdate(Widget w, XtPointer cld, XtPointer cad)
 
2470
{
 
2471
  DENTER(GUI_LAYER, "qmonCQStopUpdate");
 
2472
 
 
2473
  qmonStopTimer(EXECHOST_T);
 
2474
  qmonTimerRmUpdateProc(EXECHOST_T, "qmonCQUpdateQhostMatrix");
 
2475
 
 
2476
  DEXIT;
 
2477
}
 
2478
 
 
2479
/*-------------------------------------------------------------------------*/
 
2480
static void qmonQinstanceShowLoad(Widget w, XtPointer cld, XtPointer cad) 
 
2481
{
 
2482
   static Widget lmon=0;
 
2483
   static Widget lmon_matrix=0;
 
2484
   Widget matrix = qinstance_settings;
 
2485
   const char *qiname = NULL;
 
2486
   int rows, nr_selected_rows, i;
 
2487
   
 
2488
   DENTER(GUI_LAYER, "qmonQinstanceShowLoad");
 
2489
 
 
2490
   rows = XbaeMatrixNumRows(matrix);
 
2491
   /*
 
2492
   ** number of selected rows
 
2493
   */
 
2494
   nr_selected_rows = XbaeMatrixGetNumSelected(matrix)/XbaeMatrixNumColumns(matrix);
 
2495
   
 
2496
   if (nr_selected_rows == 1) {
 
2497
      for (i=0; i<rows; i++) {
 
2498
         /* is this row selected */ 
 
2499
         if (XbaeMatrixIsRowSelected(matrix, i)) {
 
2500
            qiname = XbaeMatrixGetCell(matrix, i, 0);
 
2501
            break;
 
2502
         }
 
2503
      }
 
2504
      if (qiname && qiname[0] != '\0') {
 
2505
         if (!lmon)
 
2506
            lmon = XmtBuildQueryDialog(matrix, "lmon_shell", 
 
2507
                                             NULL, 0,
 
2508
                                             "lmon_matrix", &lmon_matrix,
 
2509
                                             NULL);
 
2510
 
 
2511
/*          qmonCQUpdate(w, NULL, NULL); */
 
2512
         XtManageChild(lmon);
 
2513
         qmonQinstanceSetLoad(lmon_matrix, qiname);
 
2514
 
 
2515
         XtAddEventHandler(XtParent(lmon), StructureNotifyMask, False, 
 
2516
                              SetMinShellSize, (XtPointer) SHELL_WIDTH);
 
2517
         XtAddEventHandler(XtParent(lmon), StructureNotifyMask, False, 
 
2518
                              SetMaxShellSize, (XtPointer) SHELL_WIDTH);
 
2519
      }
 
2520
   } else {
 
2521
      if (nr_selected_rows > 1) {
 
2522
         qmonMessageShow(w, True, "@{Select only one queue instance !}");
 
2523
      } else {
 
2524
         qmonMessageShow(w, True, "@{To show the load select one queue instance!}");
 
2525
      }
 
2526
   }
 
2527
 
 
2528
   DEXIT;
 
2529
}
 
2530
 
 
2531
/*-------------------------------------------------------------------------*/
 
2532
static void qmonQinstanceSetLoad(Widget matrix, const char *qiname) 
 
2533
{
 
2534
   static char info[10000];
 
2535
   lListElem *ep;
 
2536
   lListElem *qep;
 
2537
   lList *ncl = NULL;
 
2538
   lList *ehl = NULL;
 
2539
   lList *cl = NULL; 
 
2540
   lList *ql = NULL; 
 
2541
   StringConst new_row[3];
 
2542
   int rows;
 
2543
   float fval;
 
2544
   XmString xstr;
 
2545
 
 
2546
   DENTER(GUI_LAYER, "qmonQueueSetLoad");
 
2547
 
 
2548
   ehl = qmonMirrorList(SGE_EXECHOST_LIST);
 
2549
   cl = qmonMirrorList(SGE_CENTRY_LIST);
 
2550
   ql = qmonMirrorList(SGE_CQUEUE_LIST);
 
2551
 
 
2552
   qep = cqueue_list_locate_qinstance(ql, qiname);
 
2553
/*    TODO                                            */    
 
2554
/*    is correct_capacities needed here ???           */    
 
2555
/*    correct_capacities(ehl, cl);                    */
 
2556
   queue_complexes2scheduler(&ncl, qep, ehl, cl);
 
2557
 
 
2558
   sprintf(info, "%s %s", XmtLocalize(matrix, "Attributes for queue", "Attributes for queue"), lGetString(qep, QU_qname));
 
2559
 
 
2560
   xstr = XmtCreateXmString(info);
 
2561
   XtVaSetValues(XtParent(matrix), XmNdialogTitle, xstr, NULL);
 
2562
   XmStringFree(xstr);
 
2563
 
 
2564
   rows = XbaeMatrixNumRows(matrix);
 
2565
   XbaeMatrixDeleteRows(matrix, 0, rows);
 
2566
 
 
2567
   rows = 0;
 
2568
   for_each_rev (ep, ncl) {
 
2569
      int n;
 
2570
      u_long32 type;
 
2571
      char unit;
 
2572
      StringConst name;
 
2573
      StringConst slot_limit;
 
2574
      StringConst job_limit;
 
2575
      if (!(name = lGetString(ep, CE_name))) 
 
2576
         continue;
 
2577
      /* don't view value entry from complex */
 
2578
      slot_limit = (lGetUlong(ep, CE_dominant)&DOMINANT_TYPE_VALUE)?
 
2579
                        NULL:lGetString(ep, CE_stringval);
 
2580
      type = lGetUlong(ep, CE_valtype);
 
2581
      if (slot_limit && (type == TYPE_MEM || type == TYPE_DOUBLE) &&
 
2582
         (n=sscanf(slot_limit, "%f%c", &fval, &unit))>=1) {
 
2583
         sprintf(info, "%8.3f%c", fval, (n>1) ? unit : '\0');
 
2584
         lSetString(ep, CE_stringval, info);
 
2585
         slot_limit = lGetString(ep, CE_stringval);
 
2586
      }
 
2587
      if (slot_limit)
 
2588
         while (*slot_limit && isspace(*slot_limit))
 
2589
            slot_limit++;
 
2590
 
 
2591
      job_limit = lGetString(ep, CE_pj_stringval);
 
2592
      type = lGetUlong(ep, CE_valtype);
 
2593
      if (job_limit && (type == TYPE_MEM || type == TYPE_DOUBLE) &&
 
2594
         (n = sscanf(job_limit, "%f%c", &fval, &unit))>=1) {
 
2595
         sprintf(info, "%8.3f%c", fval, (n>1) ? unit : '\0');
 
2596
         lSetString(ep, CE_pj_stringval, info);
 
2597
         job_limit = lGetString(ep, CE_pj_stringval);
 
2598
      }
 
2599
 
 
2600
      if (job_limit)
 
2601
         while (*job_limit && isspace(*job_limit))
 
2602
            job_limit++;
 
2603
 
 
2604
      new_row[0] = name; 
 
2605
      new_row[1] = slot_limit ? slot_limit : "";
 
2606
      new_row[2] = job_limit ? job_limit : ""; 
 
2607
      /* FIX_CONST_GUI */
 
2608
      XbaeMatrixAddRows(matrix, 0, (String*) new_row, NULL, NULL, 1); 
 
2609
 
 
2610
      rows++;
 
2611
   }
 
2612
 
 
2613
   lFreeList(&ncl);
 
2614
   
 
2615
   DEXIT;
 
2616
}
 
2617
 
 
2618
/*-------------------------------------------------------------------------*/
 
2619
static void qmonCQSick(Widget w, XtPointer cld, XtPointer cad) 
 
2620
{
 
2621
   int i;
 
2622
   int rows;
 
2623
   lList *alp = NULL;
 
2624
   const char *str;
 
2625
   lList *hgl = NULL;
 
2626
   lListElem *qp = NULL;
 
2627
   Widget matrix = cluster_queue_settings;
 
2628
   int nr_selected_rows = 0;
 
2629
 
 
2630
   DENTER(GUI_LAYER, "qmonCQSick");
 
2631
 
 
2632
   rows = XbaeMatrixNumRows(matrix);
 
2633
   /*
 
2634
   ** number of selected rows
 
2635
   */
 
2636
   nr_selected_rows = XbaeMatrixGetNumSelected(matrix)/XbaeMatrixNumColumns(matrix);
 
2637
   
 
2638
   if (nr_selected_rows > 0) {
 
2639
      dstring ds = DSTRING_INIT;
 
2640
      qmonBrowserOpen(w, NULL, NULL);
 
2641
 
 
2642
      qmonMirrorMultiAnswer(CQUEUE_T | HGROUP_T,  &alp);
 
2643
      if (alp) {
 
2644
         qmonMessageBox(cluster_queue_settings, alp, 0);
 
2645
         lFreeList(&alp);
 
2646
         DEXIT;
 
2647
         return;
 
2648
      }
 
2649
 
 
2650
      hgl = qmonMirrorList(SGE_HGROUP_LIST);
 
2651
      for (i=0; i<rows; i++) {
 
2652
         /* is this row selected */ 
 
2653
         if (XbaeMatrixIsRowSelected(matrix, i)) {
 
2654
            str = XbaeMatrixGetCell(cluster_queue_settings, i, 0);
 
2655
            if ( str && *str != '\0' ) { 
 
2656
               qp = cqueue_list_locate(qmonMirrorList(SGE_CQUEUE_LIST), str);
 
2657
               cqueue_sick(qp, &alp, hgl, &ds);
 
2658
            }
 
2659
         }
 
2660
      }
 
2661
      if (sge_dstring_get_string(&ds)) 
 
2662
         qmonBrowserShow(sge_dstring_get_string(&ds));
 
2663
      sge_dstring_free(&ds);
 
2664
      qmonMessageBox(w, alp, 0);
 
2665
      lFreeList(&alp);
 
2666
   } else { 
 
2667
      qmonMessageShow(w, True, "@{Select at least one queue !}");
 
2668
   }
 
2669
 
 
2670
   DEXIT;
 
2671
}
 
2672
 
 
2673
 
 
2674
#ifdef QI_SORTING
 
2675
/*-------------------------------------------------------------------------*/
 
2676
static void qmonQinstanceSort(
 
2677
Widget w,
 
2678
XtPointer cld,
 
2679
XtPointer cad  
 
2680
) {
 
2681
   XbaeMatrixLabelActivateCallbackStruct *cbs = 
 
2682
            (XbaeMatrixLabelActivateCallbackStruct *) cad;
 
2683
   int column_nm[] = {
 
2684
      QI_queue,
 
2685
      QI_qtype,
 
2686
      QI_used_total,
 
2687
      QI_load_avg,
 
2688
      QI_arch,
 
2689
      QI_states,
 
2690
   };
 
2691
 
 
2692
   DENTER(GUI_LAYER, "qmonQinstanceSort");
 
2693
 
 
2694
   DPRINTF(("QISort = cbs->column = %d\n", cbs->column));
 
2695
   
 
2696
   /* not coping beyond 6th column */
 
2697
   if (cbs->column > 5) {
 
2698
      DEXIT;
 
2699
      return;
 
2700
   }
 
2701
   /* 
 
2702
   ** Here is what we are going to do for sorting:
 
2703
   ** if the user clicks on a column, we'll sort ascending,
 
2704
   ** doing a 2nd time toggles to decending; except
 
2705
   ** we always toggle on the job number the first time
 
2706
   ** it is selected from a different column, since it is
 
2707
   ** always a secondary sort key and if it is selected
 
2708
   ** the user most likely wants a toggle.
 
2709
   */
 
2710
      
 
2711
   if (column_nm[cbs->column] == qi_field_sort_by) {
 
2712
      /* toggling sort order */
 
2713
      if (qi_field_sort_direction == SORT_ASCENDING) {
 
2714
         qi_field_sort_direction = SORT_DESCENDING;     
 
2715
      } else {
 
2716
         qi_field_sort_direction = SORT_ASCENDING;     
 
2717
      }
 
2718
   } else {
 
2719
      qi_field_sort_by = column_nm[cbs->column];
 
2720
      qi_field_sort_direction = SORT_ASCENDING;
 
2721
   }
 
2722
 
 
2723
   qmonCQUpdateQIMatrix();
 
2724
    
 
2725
   DEXIT;
 
2726
}
 
2727
#endif
 
2728
 
 
2729