/*___INFO__MARK_BEGIN__*/ /************************************************************************* * * The Contents of this file are made available subject to the terms of * the Sun Industry Standards Source License Version 1.2 * * Sun Microsystems Inc., March, 2001 * * * Sun Industry Standards Source License Version 1.2 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.2 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2001 by Sun Microsystems, Inc. * * All Rights Reserved. * ************************************************************************/ /*___INFO__MARK_END__*/ #include #include #include #include #include #include #include #include #include #include "qmon_rmon.h" #include "qmon_cull.h" #include "qmon_qcustom.h" #include "qmon_cq.h" #include "qmon_util.h" #include "qmon_request.h" #include "qmon_comm.h" #include "sge_sched.h" #include "sge_all_listsL.h" #include "IconList.h" #include "qmon_preferences.h" #include "qmon_message.h" #include "sge_bitfield.h" #include "sge_qinstance_state.h" #include "uti/sge_string.h" /*-------------------------------------------------------------------------*/ /* Prototypes */ static void okCB(Widget w, XtPointer cld, XtPointer cad); static void cancelCB(Widget w, XtPointer cld, XtPointer cad); static void saveCB(Widget w, XtPointer cld, XtPointer cad); static void qmonCreateQCU(Widget parent, XtPointer cld); static void qmonResFilterSet(Widget w, XtPointer cld, XtPointer cad); static void qmonResFilterClear(Widget w, XtPointer cld, XtPointer cad); static void qmonResFilterEditResource(Widget w, XtPointer cld, XtPointer cad); static void qmonResFilterRemoveResource(Widget w, XtPointer cld, XtPointer cad); static void qmonPEFilterSet(Widget w, XtPointer cld, XtPointer cad); static void qmonPEAdd(Widget w, XtPointer cld, XtPointer cad); static void qmonPERemove(Widget w, XtPointer cld, XtPointer cad); static void qmonUserFilterSet(Widget w, XtPointer cld, XtPointer cad); static void qmonQFilterSet(Widget w, XtPointer cld, XtPointer cad); static void qmonQStateFilterSet(Widget w, XtPointer cld, XtPointer cad); static void qmonQCUAddEntryToList(Widget w, XtPointer cld, XtPointer cad); /* ** this list restricts the selected qs, queues displayed */ static lList *queue_filter_resources = NULL; static lList *queue_filter_pe = NULL; static lList *queue_filter_user = NULL; static lList *queue_filter_q = NULL; static char queue_filter_state[20]; static Widget qcu = 0; static Widget r_filter_ar = 0; static Widget r_filter_sr = 0; static Widget pe_filter_ap = 0; static Widget pe_filter_sp = 0; static Widget misc_filter_user_sp = 0; static Widget misc_filter_user = 0; static Widget misc_filter_q_sp = 0; static Widget misc_filter_q = 0; static Widget misc_filter_state = 0; /*-------------------------------------------------------------------------*/ void qmonPopupQCU(Widget w, XtPointer cld, XtPointer cad) { lList *alp = NULL; DENTER(TOP_LAYER, "qmonPopupQCU"); qmonMirrorMultiAnswer(PE_T | CENTRY_T, &alp); if (alp) { qmonMessageBox(w, alp, 0); lFreeList(&alp); DEXIT; return; } if (!qcu) qmonCreateQCU(w, NULL); /* ** preset qfilter resources */ qmonResFilterSet(qcu, NULL, NULL); qmonPEFilterSet(qcu, NULL, NULL); qmonUserFilterSet(qcu, NULL, NULL); qmonQFilterSet(qcu, NULL, NULL); qmonQStateFilterSet(qcu, NULL, NULL); xmui_manage(qcu); DEXIT; } /*-------------------------------------------------------------------------*/ void qmonQCUReadPreferences(void) { static bool preferences_set = false; DENTER(GUI_LAYER, "qmonQCUReadPreferences"); if (!preferences_set) { const char *qfs; queue_filter_resources = lCopyList("", lGetList(qmonGetPreferences(), PREF_queue_filter_resources)); queue_filter_pe = lCopyList("", lGetList(qmonGetPreferences(), PREF_queue_filter_pe)); queue_filter_user = lCopyList("", lGetList(qmonGetPreferences(), PREF_queue_filter_user)); queue_filter_q = lCopyList("", lGetList(qmonGetPreferences(), PREF_queue_filter_q)); qfs = lGetString(qmonGetPreferences(), PREF_queue_filter_state); strcpy(queue_filter_state, qfs ? qfs: ""); preferences_set = true; } DEXIT; } /*-------------------------------------------------------------------------*/ lList *qmonGetQCUResourceList(void) { return queue_filter_resources; } /*-------------------------------------------------------------------------*/ lList *qmonGetQCUQrefList(void) { return queue_filter_q; } /*-------------------------------------------------------------------------*/ lList *qmonGetQCUUserRefList(void) { return queue_filter_user; } /*-------------------------------------------------------------------------*/ lList *qmonGetQCUPERefList(void) { return queue_filter_pe; } /*-------------------------------------------------------------------------*/ u_long32 qmonGetQCUQueueState(void) { u_long32 filter = 0xFFFFFFFF; u_long32 state = qinstance_state_from_string(queue_filter_state, NULL, filter); return state; } /*-------------------------------------------------------------------------*/ static void okCB(Widget w, XtPointer cld, XtPointer cad) { static char state_string[] = "acdosuACDES"; char *qp; int i; int state; lList *lp; DENTER(GUI_LAYER, "okCB"); /* ** pe filter */ lp = XmStringToCull(pe_filter_sp, ST_Type, ST_name, ALL_ITEMS); lFreeList(&queue_filter_pe); queue_filter_pe = lp; /* ** user filter */ lp = XmStringToCull(misc_filter_user_sp, ST_Type, ST_name, ALL_ITEMS); lFreeList(&queue_filter_user); queue_filter_user = lp; /* ** q wildcard filter */ lp = XmStringToCull(misc_filter_q_sp, QR_Type, QR_name, ALL_ITEMS); lFreeList(&queue_filter_q); queue_filter_q = lp; for (i=0; ielement->string[0]); } else { for_each (fill_in_request, queue_filter_resources) { name = lGetString(fill_in_request, CE_name); value = lGetString(fill_in_request, CE_stringval); if (cbs->element->string[0] && name && !strcmp(cbs->element->string[0], name) && cbs->element->string[2] && value && !strcmp(cbs->element->string[2], value) ) { found = True; break; } } if (!found) { fill_in_request = NULL; } } if (!fill_in_request) { lFreeList(&arl); DRETURN_VOID; } type = lGetUlong(fill_in_request, CE_valtype); strval = lGetString(fill_in_request, CE_stringval); sge_strlcpy(stringval, strval, CL_MAXHOSTLEN); status = qmonRequestInput(w, type, cbs->element->string[0], stringval, sizeof(stringval)); /* ** put the value in the CE_Type elem */ if (status) { lSetString(fill_in_request, CE_stringval, stringval); /* put it in the request list if necessary */ if (!how) { if (!queue_filter_resources) { queue_filter_resources = lCreateList("queue_filter_resources", CE_Type); } if (!lGetElemStr(queue_filter_resources, CE_name, cbs->element->string[0])) lAppendElem(queue_filter_resources, lCopyElem(fill_in_request)); } qmonRequestDraw(r_filter_sr, queue_filter_resources, 1); } lFreeList(&arl); DRETURN_VOID; } /*-------------------------------------------------------------------------*/ static void qmonResFilterRemoveResource(Widget w, XtPointer cld, XtPointer cad) { XmIconListCallbackStruct *cbs = (XmIconListCallbackStruct*) cad; lListElem *dep = NULL; Boolean found = False; StringConst name, value; DENTER(GUI_LAYER, "qmonResFilterRemoveResource"); if (queue_filter_resources) { for_each (dep, queue_filter_resources) { name = lGetString(dep, CE_name); value = lGetString(dep, CE_stringval); if (cbs->element->string[0] && name && !strcmp(cbs->element->string[0], name) && cbs->element->string[2] && value && !strcmp(cbs->element->string[2], value) ) { found = True; break; } } if (found) { lRemoveElem(queue_filter_resources, &dep); if (lGetNumberOfElem(queue_filter_resources) == 0) { lFreeList(&queue_filter_resources); } qmonRequestDraw(r_filter_sr, queue_filter_resources, 1); } } DEXIT; } /*-------------------------------------------------------------------------*/ static void qmonPEFilterSet(Widget w, XtPointer cld, XtPointer cad) { lList *apl = NULL; DENTER(GUI_LAYER, "qmonPEFilterSet"); apl = qmonMirrorList(SGE_PE_LIST); UpdateXmListFromCull(pe_filter_ap, XmFONTLIST_DEFAULT_TAG, apl, PE_name); UpdateXmListFromCull(pe_filter_sp, XmFONTLIST_DEFAULT_TAG, queue_filter_pe, ST_name); DEXIT; } /*-------------------------------------------------------------------------*/ static void qmonPEAdd(Widget w, XtPointer cld, XtPointer cad) { XmString *selectedItems; Cardinal selectedItemCount, i; String text; DENTER(GUI_LAYER, "qmonPEAdd"); XtVaGetValues( pe_filter_ap, XmNselectedItems, &selectedItems, XmNselectedItemCount, &selectedItemCount, NULL); if (selectedItemCount) { XmtLayoutDisableLayout(qcu); for (i=0; i