bool test_lReduceDescr(void) { bool ret = true; lEnumeration *what1 = lWhat("%T(ALL)", TEST_Type); lEnumeration *what2 = lWhat("%T(NONE)", TEST_Type); lEnumeration *what3 = lWhat("%T(%I %I " "%I -> %T(%I %I -> %T(%I %I)) " "%I -> %T(NONE) " "%I -> %T(ALL))", TEST_Type, TEST_int, TEST_host, TEST_list, TEST1_Type, TEST1_int, TEST1_object, TEST1_Type, TEST1_int, TEST1_host, TEST_object, TEST1_Type, TEST_ref, TEST1_Type); lDescr *dst_descriptor1 = NULL; lDescr *dst_descriptor2 = NULL; lDescr *dst_descriptor3 = NULL; lReduceDescr(&dst_descriptor1, TEST_Type, what1); lReduceDescr(&dst_descriptor2, TEST_Type, what2); lReduceDescr(&dst_descriptor3, TEST_Type, what3); #if 0 fprintf(stderr, sge_u32"\n", lCountDescr(dst_descriptor1)); fprintf(stderr, sge_u32"\n", lCountDescr(dst_descriptor2)); fprintf(stderr, sge_u32"\n", lCountDescr(dst_descriptor3)); fprintf(stderr, sge_u32"\n", lCountWhat(what1, TEST_Type)); fprintf(stderr, sge_u32"\n", lCountWhat(what2, TEST_Type)); fprintf(stderr, sge_u32"\n", lCountWhat(what3, TEST_Type)); #endif ret &= (lCountDescr(dst_descriptor1) == 12); ret &= (12 == lCountWhat(what1, TEST_Type)); ret &= (lCountDescr(dst_descriptor2) == -1); ret &= (0 == lCountWhat(what2, TEST_Type)); ret &= (lCountDescr(dst_descriptor3) == 5); ret &= (5 == lCountWhat(what3, TEST_Type)); lFreeWhat(&what1); lFreeWhat(&what2); lFreeWhat(&what3); sge_free(&dst_descriptor1); sge_free(&dst_descriptor2); sge_free(&dst_descriptor3); return ret; }
lListElem *cuser_get_via_gdi(sge_gdi_ctx_class_t *ctx, lList **answer_list, const char *name) { lListElem *ret = NULL; DENTER(TOP_LAYER, "cuser_get_via_gdi"); if (name != NULL) { lList *gdi_answer_list = NULL; lEnumeration *what = NULL; lCondition *where = NULL; lList *cuser_list = NULL; what = lWhat("%T(ALL)", CU_Type); where = lWhere("%T(%I==%s)", CU_Type, CU_name, name); gdi_answer_list = ctx->gdi(ctx, SGE_USER_MAPPING_LIST, SGE_GDI_GET, &cuser_list, where, what); lFreeWhat(&what); lFreeWhere(&where); if (!answer_list_has_error(&gdi_answer_list)) { ret = lFirst(cuser_list); } else { answer_list_replace(answer_list, &gdi_answer_list); } } DRETURN(ret); }
/*-------------------------------------------------------------------------*/ static void qmonCalendarOk(Widget w, XtPointer cld, XtPointer cad) { lList *cal = NULL; lList *alp; lEnumeration *what; Boolean status = False; XmString xcalname = NULL; StringConst calname = NULL; DENTER(GUI_LAYER, "qmonCalendarOk"); /* ** get the contents of the dialog fields here, ** build the cull list and send gdi request ** decalnding on success of gdi request close the dialog or stay ocaln */ cal = lCreateElemList("CALENDAR_ADD", CAL_Type, 1); if (cal) { if (qmonCalendarGetAsk(lFirst(cal))) { calname = (StringConst)lGetString(lFirst(cal), CAL_name); /* ** gdi call */ what = lWhat("%T(ALL)", CAL_Type); if (add_mode) { alp = qmonAddList(SGE_CAL_LIST, qmonMirrorListRef(SGE_CAL_LIST), CAL_name, &cal, NULL, what); } else { alp = qmonModList(SGE_CAL_LIST, qmonMirrorListRef(SGE_CAL_LIST), CAL_name, &cal, NULL, what); } if (lFirst(alp) && lGetUlong(lFirst(alp), AN_status) == STATUS_OK) status = True; qmonMessageBox(w, alp, 0); if (status) { XtUnmanageChild(cal_ask_layout); updateCalendarList(); /* ** select the modified or added Calendar */ xcalname = XmtCreateXmString(calname); XmListSelectItem(cal_names, xcalname, True); XmStringFree(xcalname); } lFreeWhat(&what); lFreeList(&cal); lFreeList(&alp); } } DEXIT; }
bool test_lIntVector2What(void) { bool ret = true; lEnumeration *what1 = lWhat("%T(%I %I %I %I)", TEST_Type, TEST_int, TEST_list, TEST_object, TEST_ref); const int vector1[] = {TEST_int, TEST_list, TEST_object, TEST_ref, NoName}; lEnumeration *dst_what1 = NULL; dst_what1 = lIntVector2What(TEST_Type, vector1); ret &= (enumeration_compare(what1, dst_what1) == 0); lFreeWhat(&what1); lFreeWhat(&dst_what1); return ret; }
/*-------------------------------------------------------------------------*/ static void qmonSchedOk(Widget w, XtPointer cld, XtPointer cad) { lList *scl = NULL; lListElem *sep = NULL; lEnumeration *what = NULL; lList *alp = NULL; Boolean status = False; DENTER(GUI_LAYER, "qmonSchedOk"); /* ** get the contents of the dialog fields here, ** build the cull list and send gdi request */ qmonMirrorMultiAnswer(SC_T, &alp); if (alp) { qmonMessageBox(w, alp, 0); lFreeList(&alp); DEXIT; return; } scl = qmonMirrorList(SGE_SC_LIST); sep = lFirst(scl); if (qmonSchedGet(sep)) { if (rmon_mlgetl(&RMON_DEBUG_ON, GUI_LAYER) & INFOPRINT) { printf("___SCHEDULER_CONF________________________\n"); lWriteListTo(scl, stdout); printf("_______________________________________\n"); } /* ** gdi call */ what = lWhat("%T(ALL)", SC_Type); alp = qmonModList(SGE_SC_LIST, qmonMirrorListRef(SGE_SC_LIST), 0, &scl, NULL, what); if (lFirst(alp) && lGetUlong(lFirst(alp), AN_status) == STATUS_OK) status = True; qmonMessageBox(qmon_sconf, alp, 0); lFreeWhat(&what); lFreeList(&alp); } if (status) XtUnmanageChild(qmon_sconf); DEXIT; }
bool test_lCountWhat(void) { bool ret = true; lEnumeration *what1 = lWhat("%T(%I %I " "%I -> %T(%I %I -> %T(%I %I)) " "%I -> %T(NONE) " "%I -> %T(ALL))", TEST_Type, TEST_int, TEST_host, TEST_list, TEST1_Type, TEST1_int, TEST1_object, TEST1_Type, TEST1_int, TEST1_host, TEST_object, TEST1_Type, TEST_ref, TEST1_Type); lEnumeration *what2 = lWhat("%T(%I %I %I %I %I)", TEST_Type, TEST_int, TEST_list, TEST_object, TEST_ref); int elements = lCountWhat(what1, TEST_Type); ret &= (elements == 5); ret &= (elements == lCountWhat(what2, TEST_Type)); lFreeWhat(&what1); lFreeWhat(&what2); return ret; }
/****** gdi/request_internal/sge_gdi_task_free() ****************************** * NAME * sge_gdi_task_free() -- free a gdi task structure * * SYNOPSIS * static bool * sge_gdi_task_free(sge_gdi_task_class_t **task) * * FUNCTION * free all elements of the gdi task structure and the structure itself. * * INPUTS * sge_gdi_task_class_t **task - pointer to the task structure pointer * * RESULT * static bool - * true - success (always) * * NOTES * MT-NOTE: sge_gdi_task_free() is MT safe as long as the structure * passed to this function is not accessed by more than one * thread simultaniously. * * SEE ALSO * gdi/request_internal/sge_gdi_task_create() ******************************************************************************/ static bool sge_gdi_task_free(sge_gdi_task_class_t ** task) { bool ret = true; DENTER(TOP_LAYER, "sge_gdi_task_free"); if (task != NULL && *task != NULL) { lFreeList(&((*task)->data_list)); lFreeList(&((*task)->answer_list)); lFreeWhat(&((*task)->enumeration)); lFreeWhere(&((*task)->condition)); *task = (sge_gdi_task_class_t *) sge_free((char *) (*task)); } DRETURN(ret); }
bool test_lWhat_simple(void) { bool ret = true; lEnumeration *what = lWhat("%T(%I%I%I)", TEST_Type, TEST_int, TEST_host, TEST_object); int result[] = {1, 7, 0, 0, 2, 12, 1, 0, 11, 10, 10, 0, NoName, lEndT, 0, 0}; const int max = 4; int pos_what = 0; int pos_result = 0; ret &= test_lWhat_enumeration(what, result, &pos_what, &pos_result, max); lFreeWhat(&what); return ret; }
bool test_lWhat_NONE(void) { bool ret = true; lEnumeration *what = lWhat("%T(NONE)", TEST_Type); const int result[] = {-99, -99, -2}; const int max = 3; int i = 0; for (i = 0; i < max / 3 && ret; i++) { int j = i * 3; ret &= (what[i].nm == result[j] && what[i].mt == result[j + 1] && what[i].pos == result[j + 2]); } lFreeWhat(&what); return ret; }
/*-------------------------------------------------------------------------*/ static void qmonCalendarDelete(Widget w, XtPointer cld, XtPointer cad) { lList *lp = NULL; lList *alp = NULL; lEnumeration *what = NULL; Cardinal itemCount = 0; Boolean status, answer; DENTER(GUI_LAYER, "qmonCalendarDelete"); lp = XmStringToCull(cal_names, CAL_Type, CAL_name, SELECTED_ITEMS); if (lp) { status = XmtAskForBoolean(w, "xmtBooleanDialog", "@{calendar.askdel.Do you really want to delete the\nselected Calendar Configuration ?}", "@{Delete}", "@{Cancel}", NULL, XmtNoButton, XmDIALOG_WARNING, False, &answer, NULL); if (answer) { what = lWhat("%T(ALL)", CAL_Type); alp = qmonDelList(SGE_CAL_LIST, qmonMirrorListRef(SGE_CAL_LIST), CAL_name, &lp, NULL, what); qmonMessageBox(w, alp, 0); lFreeWhat(&what); lFreeList(&alp); updateCalendarList(); XtVaGetValues( cal_names, XmNitemCount, &itemCount, NULL); if (itemCount) { XmListSelectPos(cal_names, 1, True); } else { qmonCalendarFillConf(cal_names, NULL); } } lFreeList(&lp); } DEXIT; }
/*-------------------------------------------------------------------------*/ static void qmonUsersetDelete(Widget w, XtPointer cld, XtPointer cad) { lList *lp = NULL; lList *alp = NULL; Cardinal itemCount = 0; lEnumeration *what = NULL; Boolean answer; DENTER(GUI_LAYER, "qmonUsersetDelete"); lp = XmStringToCull(userset_names, US_Type, US_name, SELECTED_ITEMS); if (lp) { XmtAskForBoolean(w, "xmtBooleanDialog", "@{userset.askdel.Do you really want to delete\nthe selected userset lists ?}", "@{Delete}", "@{Cancel}", NULL, XmtNoButton, XmDIALOG_WARNING, False, &answer, NULL); if (answer) { what = lWhat("%T(ALL)", US_Type); alp = qmonDelList(SGE_US_LIST, qmonMirrorListRef(SGE_US_LIST), US_name, &lp, NULL, what); qmonMessageBox(w, alp, 0); lFreeWhat(&what); lFreeList(&lp); lFreeList(&alp); updateUsersetList(); XtVaGetValues( userset_names, XmNitemCount, &itemCount, NULL); if (itemCount) XmListSelectPos(userset_names, 1, True); else qmonUsersetFillConf(userset_names, NULL); } } DEXIT; }
bool test_lCopyWhat(void) { bool ret = true; lEnumeration *what1 = lWhat("%T(ALL)", TEST_Type); lEnumeration *what2 = lWhat("%T(NONE)", TEST_Type); lEnumeration *what3 = lWhat("%T(%I %I " "%I -> %T(%I %I -> %T(%I %I)) " "%I -> %T(NONE) " "%I -> %T(ALL))", TEST_Type, TEST_int, TEST_host, TEST_list, TEST1_Type, TEST1_int, TEST1_object, TEST1_Type, TEST1_int, TEST1_host, TEST_object, TEST1_Type, TEST_ref, TEST1_Type); lEnumeration *dst_what1 = lCopyWhat(what1); lEnumeration *dst_what2 = lCopyWhat(what2); lEnumeration *dst_what3 = lCopyWhat(what3); ret &= (enumeration_compare(what1, dst_what1) == 0); ret &= (enumeration_compare(what2, dst_what2) == 0); ret &= (enumeration_compare(what3, dst_what3) == 0); #if 0 /* debug */ lWriteWhatTo(what1, stderr); fprintf(stderr, "\n"); lWriteWhatTo(what2, stderr); fprintf(stderr, "\n"); lWriteWhatTo(what3, stderr); fprintf(stderr, "\n"); lWriteWhatTo(dst_what1, stderr); fprintf(stderr, "\n"); lWriteWhatTo(dst_what2, stderr); fprintf(stderr, "\n"); lWriteWhatTo(dst_what3, stderr); fprintf(stderr, "\n"); #endif lFreeWhat(&what1); lFreeWhat(&what2); lFreeWhat(&what3); lFreeWhat(&dst_what1); lFreeWhat(&dst_what2); lFreeWhat(&dst_what3); return ret; }
bool test_lWhat_complex(void) { bool ret = true; lEnumeration *what = lWhat("%T(%I %I " "%I -> %T(%I %I -> %T(%I %I)) " "%I -> %T(NONE) " "%I -> %T(ALL))", TEST_Type, TEST_int, TEST_host, TEST_object, TEST1_Type, TEST1_int, TEST1_object, TEST1_Type, TEST1_int, TEST1_host, TEST_object, TEST1_Type, TEST_object, TEST1_Type); int result[] = {1, 7, 0, 0, 2, 12, 1, 0, 11, 10, 10, 3, 51, 7, 0, 0, 61, 10, 10, 3, 51, 7, 0, 0, 52, 12, 1, 0, NoName, lEndT, 0, 0, NoName, lEndT, 0, 0, 11, 10, 10, 2, -99, -99, -2, 0, NoName, lEndT, 0, 0, 11, 10, 10, 2, -99, -99, -1, 0, NoName, lEndT, 0, 0, NoName, lEndT, 0, 0}; const int max = 6; int pos_what = 0; int pos_result = 0; ret &= test_lWhat_enumeration(what, result, &pos_what, &pos_result, max); lFreeWhat(&what); return ret; }
/*-------------------------------------------------------------------------*/ void updateQueueList(void) { lList *qlp = NULL; lList *hl = NULL; lList *rl = NULL; lList *cl = NULL; lEnumeration *whatall = NULL; lCondition *where = NULL; static Boolean filter_on = False; DENTER(GUI_LAYER, "updateQueueList"); cl = qmonMirrorList(SGE_CE_LIST); /* ** copy of host list */ hl = lCopyList("HL", qmonMirrorList(SGE_EH_LIST)); /* ** ** select a subset of the whole queue list (->where) ** and get the list sorted ** */ #ifdef FIXME where = lWhere("%T(%I!=%s)", QU_Type, QU_qname, QU_TEMPLATE); whatall = lWhat("%T(ALL)", QU_Type); #else whatall = lWhat("%T(ALL)", CQ_Type); #endif qlp = lSelect("SQL", qmonMirrorList(SGE_CQ_LIST), where, whatall); lFreeWhere(&where); lFreeWhat(&whatall); #ifdef FIXME /* ** additional filtering */ rl = qmonQFilterRequest(); if (rl) { if (!filter_on) { setButtonLabel(queue_customize, "@{Customize +}"); filter_on = True; } match_queue(&qlp, rl, cl, hl); } else { if (filter_on) { setButtonLabel(queue_customize, "@{Customize}"); filter_on = False; } } /* ** sort the queues according to sequence number and alphabetically */ lPSortList(qlp, "%I+ %I+ %I+", QU_seq_no, QU_qhostname, QU_qname); #endif /* ** save the queue in hash table */ qmonQueueHash(qlp, hl); qmonQueueSetPos(qlp); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ** qlp must not be freed it is referenced in qmonHashQueue ** and freed there */ DEXIT; }
static void qevent_testsuite_mode(sge_evc_class_t *evc) { #ifndef QEVENT_SHOW_ALL u_long32 timestamp; lCondition *where =NULL; lEnumeration *what = NULL; const int job_nm[] = { JB_job_number, JB_host, JB_category, JB_project, JB_ja_tasks, JB_ja_structure, JB_ja_n_h_ids, JB_ja_u_h_ids, JB_ja_s_h_ids, JB_ja_o_h_ids, JB_ja_template, NoName }; const int jat_nm[] = { JAT_status, JAT_task_number, NoName }; #endif DENTER(TOP_LAYER, "qevent_testsuite_mode"); sge_mirror_initialize(evc, EV_ID_ANY, "qevent", true, NULL, NULL, NULL, NULL, NULL); #ifdef QEVENT_SHOW_ALL sge_mirror_subscribe(evc, SGE_TYPE_ALL, print_event, NULL, NULL, NULL, NULL); #else /* QEVENT_SHOW_ALL */ where = NULL; what = lIntVector2What(JB_Type, job_nm); sge_mirror_subscribe(evc, SGE_TYPE_JOB, print_jatask_event, NULL, NULL, where, what); lFreeWhere(&where); lFreeWhat(&what); where = NULL; what = lIntVector2What(JAT_Type, jat_nm); sge_mirror_subscribe(evc, SGE_TYPE_JATASK, print_jatask_event, NULL, NULL, where, what); lFreeWhere(&where); lFreeWhat(&what); /* we want a 5 second event delivery interval */ evc->ec_set_edtime(evc, 5); /* and have our events flushed immediately */ evc->ec_set_flush(evc, sgeE_JATASK_MOD, true, 1); evc->ec_set_flush(evc, sgeE_JOB_FINAL_USAGE, true, 1); evc->ec_set_flush(evc, sgeE_JOB_ADD, true, 1); evc->ec_set_flush(evc, sgeE_JOB_DEL, true, 1); #endif /* QEVENT_SHOW_ALL */ while (!shut_me_down) { sge_mirror_error error = sge_mirror_process_events(evc); if (error == SGE_EM_TIMEOUT && !shut_me_down) { sleep(10); continue; } #ifndef QEVENT_SHOW_ALL timestamp = sge_get_gmt(); fprintf(stdout,"ECL_STATE (jobs_running=%ld:jobs_registered=%ld:ECL_TIME="sge_U32CFormat")\n", Global_jobs_running,Global_jobs_registered,sge_u32c(timestamp)); fflush(stdout); #endif } sge_mirror_shutdown(evc); DEXIT; }
int main(int argc, char *argv[]) { qevent_options enabled_options; dstring errors = DSTRING_INIT; int i, gdi_setup; lList *alp = NULL; sge_gdi_ctx_class_t *ctx = NULL; sge_evc_class_t *evc = NULL; DENTER_MAIN(TOP_LAYER, "qevent"); /* sge_mt_init(); */ /* dump pid to file */ qevent_dump_pid_file(); /* parse command line */ enabled_options.error_message = &errors; qevent_set_option_struct(&enabled_options); qevent_parse_command_line(argc, argv, &enabled_options); /* check if help option is set */ if (enabled_options.help_option) { qevent_show_usage(); sge_dstring_free(enabled_options.error_message); SGE_EXIT((void**)&ctx, 0); } /* are there command line parsing errors ? */ if (sge_dstring_get_string(enabled_options.error_message)) { ERROR((SGE_EVENT, "%s", sge_dstring_get_string(enabled_options.error_message) )); qevent_show_usage(); sge_dstring_free(enabled_options.error_message); SGE_EXIT((void**)&ctx, 1); } log_state_set_log_gui(1); sge_setup_sig_handlers(QEVENT); /* setup event client */ gdi_setup = sge_gdi2_setup(&ctx, QEVENT, MAIN_THREAD, &alp); if (gdi_setup != AE_OK) { answer_list_output(&alp); sge_dstring_free(enabled_options.error_message); SGE_EXIT((void**)&ctx, 1); } /* TODO: how is the memory we allocate here released ???, SGE_EXIT doesn't */ if (false == sge_gdi2_evc_setup(&evc, ctx, EV_ID_ANY, &alp, NULL)) { answer_list_output(&alp); sge_dstring_free(enabled_options.error_message); SGE_EXIT((void**)&ctx, 1); } /* ok, start over ... */ /* check for testsuite option */ if (enabled_options.testsuite_option) { /* only for testsuite */ qevent_testsuite_mode(evc); sge_dstring_free(enabled_options.error_message); SGE_EXIT((void**)&ctx, 0); } /* check for subscribe option */ if (enabled_options.subscribe_option) { /* only for testsuite */ qevent_subscribe_mode(evc); sge_dstring_free(enabled_options.error_message); SGE_EXIT((void**)&ctx, 0); } if (enabled_options.trigger_option_count > 0) { lCondition *where =NULL; lEnumeration *what = NULL; sge_mirror_initialize(evc, EV_ID_ANY, "sge_mirror -trigger", true, NULL, NULL, NULL, NULL, NULL); evc->ec_set_busy_handling(evc, EV_BUSY_UNTIL_ACK); /* put out information about -trigger option */ for (i=0;i<enabled_options.trigger_option_count;i++) { INFO((SGE_EVENT, "trigger script for %s events: %s\n", qevent_get_event_name((enabled_options.trigger_option_events)[i]), (enabled_options.trigger_option_scripts)[i])); switch((enabled_options.trigger_option_events)[i]) { case QEVENT_JB_END: /* build mask for the job structure to contain only the needed elements */ where = NULL; what = lWhat("%T(%I %I %I %I %I %I %I %I)", JB_Type, JB_job_number, JB_ja_tasks, JB_ja_structure, JB_ja_n_h_ids, JB_ja_u_h_ids, JB_ja_s_h_ids,JB_ja_o_h_ids, JB_ja_template); /* register for job events */ sge_mirror_subscribe(evc, SGE_TYPE_JOB, analyze_jatask_event, NULL, NULL, where, what); evc->ec_set_flush(evc, sgeE_JOB_DEL,true, 1); /* the mirror interface registers more events, than we need, thus we free the ones, we do not need */ /* evc->ec_unsubscribe(evc, sgeE_JOB_LIST); */ evc->ec_unsubscribe(evc, sgeE_JOB_MOD); evc->ec_unsubscribe(evc, sgeE_JOB_MOD_SCHED_PRIORITY); evc->ec_unsubscribe(evc, sgeE_JOB_USAGE); evc->ec_unsubscribe(evc, sgeE_JOB_FINAL_USAGE); /* evc->ec_unsubscribe(evc, sgeE_JOB_ADD); */ /* free the what and where mask */ lFreeWhere(&where); lFreeWhat(&what); break; case QEVENT_JB_TASK_END: /* build mask for the job structure to contain only the needed elements */ where = NULL; what = lWhat("%T(%I)", JAT_Type, JAT_status); /* register for JAT events */ sge_mirror_subscribe(evc, SGE_TYPE_JATASK, analyze_jatask_event, NULL, NULL, where, what); evc->ec_set_flush(evc, sgeE_JATASK_DEL,true, 1); /* the mirror interface registers more events, than we need, thus we free the ones, we do not need */ evc->ec_unsubscribe(evc, sgeE_JATASK_ADD); evc->ec_unsubscribe(evc, sgeE_JATASK_MOD); /* free the what and where mask */ lFreeWhere(&where); lFreeWhat(&what); break; } } while(!shut_me_down) { sge_mirror_error error = sge_mirror_process_events(evc); if (error == SGE_EM_TIMEOUT && !shut_me_down ) { sleep(10); continue; } } sge_mirror_shutdown(evc); sge_dstring_free(enabled_options.error_message); sge_prof_cleanup(); SGE_EXIT((void**)&ctx, 0); return 0; } ERROR((SGE_EVENT, "no option selected\n" )); qevent_show_usage(); sge_dstring_free(enabled_options.error_message); sge_prof_cleanup(); SGE_EXIT((void**)&ctx, 1); return 1; }
int main(int argc, char *argv[]) { lList *queuelist = NULL, *joblist = NULL; enum { MATCH_REQUEST, LOOP_JOBS_QUEUES /* SUBWHERE */ }; int scene, fulfilled, numdiddeldum; lList *erglist = NULL; lListElem *job, *queue; lCondition *where = NULL; lEnumeration *w0, *w1, *nothing, *all; lList *queuecomplexes = NULL, *attributes = NULL; lListElem *attribute, *request; const char *operator; DENTER_MAIN(TOP_LAYER, "example2"); if (argc != 3) usage(); sscanf(argv[1], "%d", &scene); sscanf(argv[2], "%d", &numdiddeldum); /* neccessary for comfortable output */ lInit(nmv); queuelist = buildQueueList(); printf("\n\nQUEUELIST\n\n"); lWriteList(queuelist); COMPLEXLIST = buildComplexList(); printf("\n\nCOMPLEXLIST\n\n"); lWriteList(COMPLEXLIST); joblist = buildJobList(numdiddeldum); printf("\n\nJOBLIST\n\n"); lWriteList(joblist); printf("\n******** BEGIN PROCESSING *********\n\n"); switch (scene) { case MATCH_REQUEST: /* find for each job in the joblist all queues that suffer the request of this job ( implemented with quick list functions ) */ for_each(job, joblist) { printf("\n-------------------------------" "-------------------------------\n"); printf("*** job %s may get started in the following queues ***\n\n", lGetString(job, J_name)); for_each(queue, queuelist) { if (matchRequest(lGetList(queue, Q_complexname), lGetList(job, J_hardrequest))) { if (!erglist) if (!(erglist = lCreateList("erglist", QueueT))) { printf("case MATCH_REQUEST: lCreateList" " failure\n"); exit(-1); } lAppendElem(erglist, lCopyElem(queue)); } } printf("\n\n**** ERGLIST ****\n\n"); if (erglist) { lWriteList(erglist); lFreeList(&erglist); erglist = NULL; } } break; case LOOP_JOBS_QUEUES: /* find for each job in the joblist all queues that suffer the request of this job ( implemented with mighty database-like functions ) */ for_each(job, joblist) { printf("\n--------------------------------------------------------------\n"); printf("*** job %s may get started in the following queues ***\n\n", lGetString(job, J_name)); for_each(queue, queuelist) { /* build a list of the complexes of the queue therefore: build a subset of the complex list with the queues complex name list as a selector join the complex name list of the queue ( join field: N_complexname) with the global complex list ( join field: C_name ) select nothing from the queue's complex name list (w0) and only the attributes of the global complex list (w1) every valid combination is needed, so the where parameter is NULL for both lists */ w0 = lWhat("%T(NONE)", ComplexNameT); /* NIX */ w1 = lWhat("%T(%I)", ComplexT, C_attribute); queuecomplexes = lJoin("queuecomplexes", N_complexname, lGetList(queue, Q_complexname), NULL, w0, C_name, COMPLEXLIST, NULL, w1); lFreeWhat(&w0); lFreeWhat(&w1); /* try to find a hard request of this job that is not fulfilled by the queue's complexes */ fulfilled = 1; for_each(request, lGetList(job, J_hardrequest)) { /* build a flat complex attribute list with only these attributes of the request this produces a attribute list of all complexes */ nothing = lWhat("%T(NONE)", lGetListDescr(queuecomplexes)); all = lWhat("%T(ALL)", ComplexAttributeT); where = lWhere("%T( %I == %s )", ComplexAttributeT, A_name, lGetString(request, R_name)); attributes = lJoinSublist("attributelist", C_attribute, queuecomplexes, NULL, nothing, ComplexAttributeT, where, all); lFreeWhere(&where); lFreeWhat(¬hing); lFreeWhat(&all); /* if we get an empty list then the queue has no complex fulfilling the request of this job */ /* right now the lJoinSublist function returns an empty list (no elements) if there was no sublist */ if (lGetNumberOfElem(attributes) == 0) { fulfilled = 0; break; /* leave request loop */ } /* if there are attributes the values of at least one complex of the queue must fulfill the request */ for_each(attribute, attributes) { operator = lGetString(request, R_operator); if (strcmp(operator, "==") == 0) { fulfilled = (!strcmp( lGetString(attribute, A_value), lGetString(request, R_value))); } else if (strcmp(operator, "!=") == 0) { fulfilled = (strcmp( lGetString(attribute, A_value), lGetString(request, R_value))); } /* else if .. ( for all operators ) */ if (fulfilled) break; /* leave attribute loop */ }
static sge_gdi_task_class_t * sge_gdi_task_create(sge_gdi_packet_class_t * packet, lList **answer_list, u_long32 target, u_long32 command, lList **lp, lList **a_list, lCondition **condition, lEnumeration **enumeration, bool do_copy, bool do_verify) { sge_gdi_task_class_t *task = NULL; DENTER(TOP_LAYER, "sge_gdi_task_create"); task = (sge_gdi_task_class_t *) sge_malloc(sizeof(sge_gdi_task_class_t)); if (task != NULL) { task->id = ((packet->last_task != NULL) ? (packet->last_task->id + 1) : 1); task->command = command; task->target = target; task->next = NULL; task->do_select_pack_simultaneous = false; if (do_copy) { if (enumeration != NULL && *enumeration != NULL) { task->data_list = (((lp != NULL) && (*lp != NULL)) ? lSelect("", *lp, NULL, *enumeration) : NULL); } else { task->data_list = (((lp != NULL) && (*lp != NULL)) ? lCopyList("", *lp) : NULL); } task->answer_list = (((a_list != NULL) && (*a_list != NULL)) ? lCopyList("", *a_list) : NULL); task->condition = (((condition != NULL) && (*condition != NULL)) ? lCopyWhere(*condition) : NULL); task->enumeration = (((enumeration != NULL) && (*enumeration != NULL)) ? lCopyWhat(*enumeration) : NULL); } else { if ((lp != NULL) && (*lp != NULL)) { task->data_list = *lp; *lp = NULL; } else { task->data_list = NULL; } if ((a_list != NULL) && (*a_list != NULL)) { task->answer_list = *a_list; *a_list = NULL; } else { task->answer_list = NULL; } if ((condition != NULL) && (*condition != NULL)) { task->condition = *condition; *condition = NULL; } else { task->condition = NULL; } if ((enumeration != NULL) && (*enumeration != NULL)) { task->enumeration = *enumeration; *enumeration = NULL; } else { task->enumeration = NULL; } } if (do_verify && !sge_gdi_task_verify(task, answer_list)) { if (do_copy == true) { lFreeList(&(task->data_list)); lFreeList(&(task->answer_list)); lFreeWhere(&(task->condition)); lFreeWhat(&(task->enumeration)); } else { task->data_list = NULL; task->answer_list = NULL; task->condition = NULL; task->enumeration = NULL; } sge_gdi_task_free(&task); } } else { answer_list_add_sprintf(answer_list, STATUS_EMALLOC, ANSWER_QUALITY_ERROR, MSG_MEMORY_MALLOCFAILED); } DRETURN(task); }
bool test_lWhat_lSelect(void) { bool ret = true; lEnumeration *what = lWhat("%T(%I %I -> %T( %I %I -> %T (%I %I %I %I) %I %I) %I -> %T(%I) %I)", TEST_Type, TEST_int, TEST_list, TEST1_Type, TEST1_int, TEST1_list, TEST_Type, TEST_int, TEST_list, TEST_object, TEST_string, TEST1_object, TEST1_string, TEST_object, TEST1_Type, TEST1_string, TEST_string); lListElem *elem; lListElem *elem1; lList *list = lCreateList("", TEST_Type); lList *list1 = NULL; int i; elem = lCreateElem(TEST_Type); lSetInt(elem, TEST_int, 0); lSetHost(elem, TEST_host, "zero"); lSetString(elem, TEST_string, "zero"); lSetFloat(elem, TEST_float, 0); lSetDouble(elem, TEST_double, 0); lSetChar(elem, TEST_char, 'z'); lSetLong(elem, TEST_long, 0); lSetUlong(elem, TEST_ulong, 0); lSetBool(elem, TEST_bool, false); elem1 = lCreateElem(TEST1_Type); lSetInt(elem1, TEST1_int, 1); lSetHost(elem1, TEST1_host, "one"); lSetString(elem1, TEST1_string, "one"); lSetFloat(elem1, TEST1_float, 1); lSetDouble(elem1, TEST1_double, 1); lSetChar(elem1, TEST1_char, 'o'); lSetLong(elem1, TEST1_long, 1); lSetUlong(elem1, TEST1_ulong, 1); lSetBool(elem1, TEST1_bool, true); for (i = 0; i < 5; i++) { lList *tmp_list = lCreateList("", TEST1_Type); lListElem *tmp_elem = lCopyElem(elem); int j; for (j = 0; j < 5; j++) { lList *tmp_list1 = lCreateList("", TEST_Type); lListElem *tmp_elem1 = lCopyElem(elem); int k; for (k = 0; k < 5; k++) { lList *tmp_list2 = lCreateList("", TEST1_Type); lListElem *tmp_elem2 = lCopyElem(elem); lSetList(tmp_elem2, TEST_list, tmp_list2); lAppendElem(tmp_list1, tmp_elem2); } lSetList(tmp_elem1, TEST_list, tmp_list1); lAppendElem(tmp_list, tmp_elem1); } lSetList(tmp_elem, TEST_list, tmp_list); lAppendElem(list, tmp_elem); } list1 = lSelect("", list, NULL, what); /* EB: Replace this function */ #if 0 lWriteListTo(list1, stderr); #endif lFreeWhat(&what); lFreeElem(&elem); lFreeElem(&elem1); lFreeList(&list); lFreeList(&list1); return ret; }
/*-------------------------------------------------------------------------*/ static void qmonManopDelete(Widget w, XtPointer cld, XtPointer cad) { int type = dialog_mode; lList *lp = NULL; lList *alp = NULL; lEnumeration *what = NULL; lDescr *dp; int nm; int rows, i; DENTER(GUI_LAYER, "qmonManopDelete"); switch (type) { case SGE_UM_LIST: lp = XmStringToCull(manager_list, UM_Type, UM_name, SELECTED_ITEMS); dp = UM_Type; nm = UM_name; break; case SGE_UO_LIST: lp = XmStringToCull(operator_list, UO_Type, UO_name, SELECTED_ITEMS); dp = UO_Type; nm = UO_name; break; case SGE_UU_LIST: rows = XbaeMatrixNumRows(user_matrix); for (i=0; i<rows; i++) { String s = XbaeMatrixGetCell(user_matrix, i, 0); if (XbaeMatrixIsRowSelected(user_matrix, i) && s && strcmp(s, "")) lAddElemStr(&lp, UU_name, s, UU_Type); } XbaeMatrixDeselectAll(user_matrix); dp = UU_Type; nm = UU_name; break; case SGE_US_LIST: qmonUsersetDelete(w, NULL, NULL); DEXIT; return; default: DEXIT; return; } if (lp) { what = lWhat("%T(ALL)", dp); alp = qmonDelList(type, qmonMirrorListRef(type), nm, &lp, NULL, what); qmonMessageBox(w, alp, 0); updateManopList(); lFreeList(&alp); lFreeList(&lp); lFreeWhat(&what); } DEXIT; }
/*-------------------------------------------------------------------------*/ static void qmonManopAdd(Widget w, XtPointer cld, XtPointer cad) { int type = dialog_mode; lList *lp = NULL; lList *alp = NULL; lEnumeration *what = NULL; String user = NULL; Widget username; int nm; lDescr *dp; DENTER(GUI_LAYER, "qmonManopAdd"); switch (type) { case SGE_UM_LIST: dp = UM_Type; nm = UM_name; username = manager_name; break; case SGE_UO_LIST: dp = UO_Type; nm = UO_name; username = operator_name; break; case SGE_UU_LIST: dp = UU_Type; nm = UU_name; username = user_name; break; case SGE_US_LIST: if ((long)cld == 1) qmonUsersetAdd(w, NULL, NULL); else qmonUsersetModify(w, NULL, NULL); DEXIT; return; default: DEXIT; return; } user = XmtInputFieldGetString(username); if (user && user[0] != '\0' && user[0] != ' ') { what = lWhat("%T(ALL)", dp); if (!(lp = lCreateElemList("AH", dp, 1))) { fprintf(stderr, "lCreateElemList failed\n"); lFreeWhat(&what); DEXIT; return; } lSetString(lFirst(lp), nm, user); /* if (type == SGE_UU_LIST) */ /* lSetString(lFirst(lp), UU_default_project, "NONE"); */ alp = qmonAddList(type, qmonMirrorListRef(type), nm, &lp, NULL, what); qmonMessageBox(w, alp, 0); updateManopList(); XmtInputFieldSetString(username, ""); lFreeWhat(&what); lFreeList(&lp); lFreeList(&alp); } DEXIT; }
/*-------------------------------------------------------------------------*/ static void qmonUsersetOk(Widget w, XtPointer cld, XtPointer cad) { String usetname = NULL; XmString xusetname = NULL; lList *lp = NULL; lList *ul = NULL; lList *alp = NULL; lListElem *up = NULL; lEnumeration *what = NULL; Boolean status = False; int usettype = 0; DENTER(GUI_LAYER, "qmonUsersetOk"); /* ** get the dialog data and */ usetname = XmtInputFieldGetString(uset_name); usettype = XmtChooserGetState(uset_type); /* ** usetname required, show warning dialog */ if (usetname && usetname[0] != '\0') { ul = XmStringToCull(uset_user_list, UE_Type, UE_name, ALL_ITEMS); /* ** do gdi stuff here */ if (add_mode) { lAddElemStr(&lp, US_name, usetname, US_Type); } else { up = lCopyElem(lGetElemStr(qmonMirrorList(SGE_US_LIST), US_name, usetname)); lp = lCreateList("userset", US_Type); lAppendElem(lp, up); } lSetList(lFirst(lp), US_entries, ul); lSetUlong(lFirst(lp), US_type, usettype); what = lWhat("%T(ALL)", US_Type); if (add_mode) { alp = qmonAddList(SGE_US_LIST, qmonMirrorListRef(SGE_US_LIST), US_name, &lp, NULL, what); } else { alp = qmonModList(SGE_US_LIST, qmonMirrorListRef(SGE_US_LIST), US_name, &lp, NULL, what); } if (!qmonMessageBox(w, alp, 0)) status = True; updateUsersetList(); xusetname = XmtCreateXmString(usetname); XmListSelectItem(userset_names, xusetname, True); XmStringFree(xusetname); lFreeWhat(&what); lFreeList(&lp); lFreeList(&alp); } else { qmonMessageShow(w, True, "Userset List Name required !"); } if (status) XtUnmanageChild(userset_ask_layout); DEXIT; }
/****** gdi/request_internal/sge_gdi_packet_pack_task() ********************** * NAME * sge_gdi_packet_pack_task() -- pack a single GDI task * * SYNOPSIS * bool * sge_gdi_packet_pack_task(sge_gdi_packet_class_t * packet, * sge_gdi_task_class_t * task, * lList **answer_list, * sge_pack_buffer *pb) * * FUNCTION * This functions packs all data representing one GDI request * of a mutli GDI request (represented by "packet" and "task") * into "pb". Errors will be reported with a corresponding * "answer_list" message and a negative return value. * * "pb" has to be initialized before this function is called. * init_packbuffer() or a similar function has do be used to * initialize this "pb". The function sge_gdi_packet_get_pb_size() * might be used to calculate the maximum size as if the buffer * would be needed to pack all tasks of a multi GDI request. * Using this size as initial size for the "pb" * will prevent continuous reallocation of memory in this * function. * * INPUTS * sge_gdi_packet_class_t * packet - GDI packet * sge_gdi_task_class_t * task - GDI task * lList **answer_list - answer_list * sge_pack_buffer *pb - packing buffer * * RESULT * bool - error state * true - success * false - failure * * NOTES * MT-NOTE: sge_gdi_packet_pack_task() is MT safe * * SEE ALSO * gdi/request_internal/sge_gdi_packet_get_pb_size() * gdi/request_internal/sge_gdi_packet_pack() *******************************************************************************/ bool sge_gdi_packet_pack_task(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task, lList **answer_list, sge_pack_buffer *pb) { bool ret = true; int pack_ret = PACK_SUCCESS; DENTER(TOP_LAYER, "sge_gdi_packet_pack_task"); if ((task != NULL) && (packet != NULL) && (packet->is_intern_request == false)) { sge_pack_gdi_info(task->command); /* ===> pack the prefix */ pack_ret = packint(pb, task->command); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = packint(pb, task->target); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = packint(pb, packet->version); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } /* * if the lSelect call was postponed then it will be done here. * here we are able to pack the result list directly into the packbuffer. * additionally it is necessary to add an answer to the answer list. * (which will be packed below). */ if (task->do_select_pack_simultaneous) { lSelectHashPack("", task->data_list, task->condition, task->enumeration, false, pb); lFreeWhat(&(task->enumeration)); lFreeWhere(&(task->condition)); task->data_list = NULL; /* DIRTY HACK: The "ok" message should be removed from the answer list * 05/21/2007 qualitiy was ANSWER_QUALITY_INFO but this results in "ok" * messages on qconf side */ answer_list_add(&(task->answer_list), MSG_GDI_OKNL, STATUS_OK, ANSWER_QUALITY_END); } else { /* ===> pack the list */ pack_ret = cull_pack_list(pb, task->data_list); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } } /* ===> pack the suffix */ pack_ret = cull_pack_list(pb, task->answer_list); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = cull_pack_cond(pb, task->condition); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = cull_pack_enum(pb, task->enumeration); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = packstr(pb, packet->auth_info); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = packint(pb, task->id); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = packint(pb, packet->id); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } pack_ret = packint(pb, (task->next != NULL) ? 1 : 0); if (pack_ret != PACK_SUCCESS) { goto error_with_mapping; } } DRETURN(ret); error_with_mapping: ret = sge_gdi_map_pack_errors(pack_ret, answer_list); DRETURN(ret); }
/****** qmaster/threads/sge_scheduler_main() ********************************** * NAME * sge_scheduler_main() -- main function of the scheduler thread * * SYNOPSIS * void * sge_scheduler_main(void *arg) * * FUNCTION * Main function of the scheduler thread, * * INPUTS * void *arg - pointer to the thread function (type cl_thread_settings_t*) * * RESULT * void * - always NULL * * NOTES * MT-NOTE: sge_scheduler_main() is MT safe * * MT-NOTE: this is a thread function. Do NOT use this function * MT-NOTE: in any other way! * * SEE ALSO * qmaster/threads/sge_scheduler_initialize() * qmaster/threads/sge_scheduler_cleanup_thread() * qmaster/threads/sge_scheduler_terminate() * qmaster/threads/sge_scheduler_main() *******************************************************************************/ void * sge_scheduler_main(void *arg) { time_t next_prof_output = 0; monitoring_t monitor; sge_gdi_ctx_class_t *ctx = NULL; sge_evc_class_t *evc = NULL; lList *alp = NULL; sge_where_what_t where_what; cl_thread_settings_t *thread_config = (cl_thread_settings_t*)arg; bool do_shutdown = false; bool do_endlessly = true; bool local_ret = true; DENTER(TOP_LAYER, "sge_scheduler_main"); memset(&where_what, 0, sizeof(where_what)); /* * startup */ if (local_ret) { /* initialize commlib thread */ cl_thread_func_startup(thread_config); /* initialize monitoring */ sge_monitor_init(&monitor, thread_config->thread_name, SCH_EXT, SCT_WARNING, SCT_ERROR); sge_qmaster_thread_init(&ctx, SCHEDD, SCHEDD_THREAD, true); /* register at profiling module */ set_thread_name(pthread_self(), "Scheduler Thread"); conf_update_thread_profiling("Scheduler Thread"); DPRINTF((SFN" started\n", thread_config->thread_name)); /* initialize schedd_runnlog logging */ schedd_set_schedd_log_file(ctx); } /* set profiling parameters */ prof_set_level_name(SGE_PROF_EVENTMASTER, NULL, NULL); prof_set_level_name(SGE_PROF_SPOOLING, NULL, NULL); prof_set_level_name(SGE_PROF_CUSTOM0, "scheduler", NULL); prof_set_level_name(SGE_PROF_CUSTOM1, "pending ticket calculation", NULL); prof_set_level_name(SGE_PROF_CUSTOM3, "job sorting", NULL); prof_set_level_name(SGE_PROF_CUSTOM4, "job dispatching", NULL); prof_set_level_name(SGE_PROF_CUSTOM5, "send orders", NULL); prof_set_level_name(SGE_PROF_CUSTOM6, "scheduler event loop", NULL); prof_set_level_name(SGE_PROF_CUSTOM7, "copy lists", NULL); prof_set_level_name(SGE_PROF_SCHEDLIB4, NULL, NULL); /* set-up needed for 'schedule' file */ serf_init(schedd_serf_record_func, schedd_serf_newline); schedd_set_serf_log_file(ctx); /* * prepare event client/mirror mechanism */ if (local_ret) { local_ret = sge_gdi2_evc_setup(&evc, ctx, EV_ID_SCHEDD, &alp, "scheduler"); DPRINTF(("prepared event client/mirror mechanism\n")); } /* * register as event mirror */ if (local_ret) { sge_mirror_initialize(evc, EV_ID_SCHEDD, "scheduler", false, &event_update_func, &sge_mod_event_client, &sge_add_event_client, &sge_remove_event_client, &sge_handle_event_ack); evc->ec_register(evc, false, NULL, &monitor); evc->ec_set_busy_handling(evc, EV_BUSY_UNTIL_RELEASED); DPRINTF(("registered at event mirror\n")); } /* * subscribe necessary data */ if (local_ret) { ensure_valid_what_and_where(&where_what); subscribe_scheduler(evc, &where_what); DPRINTF(("subscribed necessary data from event master\n")); } /* * schedulers main loop */ if (local_ret) { while (do_endlessly) { bool handled_events = false; lList *event_list = NULL; int execute = 0; double prof_copy = 0.0; double prof_total = 0.0; double prof_init = 0.0; double prof_free = 0.0; double prof_run = 0.0; lList *orders = NULL; if (sconf_get_profiling()) { prof_start(SGE_PROF_OTHER, NULL); prof_start(SGE_PROF_PACKING, NULL); prof_start(SGE_PROF_EVENTCLIENT, NULL); prof_start(SGE_PROF_MIRROR, NULL); prof_start(SGE_PROF_GDI, NULL); prof_start(SGE_PROF_HT_RESIZE, NULL); prof_start(SGE_PROF_CUSTOM0, NULL); prof_start(SGE_PROF_CUSTOM1, NULL); prof_start(SGE_PROF_CUSTOM3, NULL); prof_start(SGE_PROF_CUSTOM4, NULL); prof_start(SGE_PROF_CUSTOM5, NULL); prof_start(SGE_PROF_CUSTOM6, NULL); prof_start(SGE_PROF_CUSTOM7, NULL); prof_start(SGE_PROF_SCHEDLIB4, NULL); } else { prof_stop(SGE_PROF_OTHER, NULL); prof_stop(SGE_PROF_PACKING, NULL); prof_stop(SGE_PROF_EVENTCLIENT, NULL); prof_stop(SGE_PROF_MIRROR, NULL); prof_stop(SGE_PROF_GDI, NULL); prof_stop(SGE_PROF_HT_RESIZE, NULL); prof_stop(SGE_PROF_CUSTOM0, NULL); prof_stop(SGE_PROF_CUSTOM1, NULL); prof_stop(SGE_PROF_CUSTOM3, NULL); prof_stop(SGE_PROF_CUSTOM4, NULL); prof_stop(SGE_PROF_CUSTOM5, NULL); prof_stop(SGE_PROF_CUSTOM6, NULL); prof_stop(SGE_PROF_CUSTOM7, NULL); prof_stop(SGE_PROF_SCHEDLIB4, NULL); } /* * Wait for new events */ MONITOR_IDLE_TIME(sge_scheduler_wait_for_event(evc, &event_list), (&monitor), mconf_get_monitor_time(), mconf_is_monitor_message()); /* If we lost connection we have to register again */ if (evc->ec_need_new_registration(evc)) { lFreeList(&event_list); if (evc->ec_register(evc, false, NULL, &monitor) == true) { DPRINTF(("re-registered at event master!\n")); } } if (event_list != NULL) { /* check for shutdown */ do_shutdown = (lGetElemUlong(event_list, ET_type, sgeE_SHUTDOWN) != NULL) ? true : false; /* update mirror and free data */ if (do_shutdown == false && sge_mirror_process_event_list(evc, event_list) == SGE_EM_OK) { handled_events = true; DPRINTF(("events handled\n")); } else { DPRINTF(("events contain shutdown event - ignoring events\n")); } lFreeList(&event_list); } /* if we actually got events, start the scheduling run and further event processing */ if (handled_events == true) { lList *answer_list = NULL; scheduler_all_data_t copy; lList *master_cqueue_list = *(object_type_get_master_list(SGE_TYPE_CQUEUE)); lList *master_job_list = *object_type_get_master_list(SGE_TYPE_JOB); lList *master_userset_list = *object_type_get_master_list(SGE_TYPE_USERSET); lList *master_project_list = *object_type_get_master_list(SGE_TYPE_PROJECT); lList *master_exechost_list= *object_type_get_master_list(SGE_TYPE_EXECHOST); lList *master_rqs_list= *object_type_get_master_list(SGE_TYPE_RQS); lList *master_centry_list = *object_type_get_master_list(SGE_TYPE_CENTRY); lList *master_ckpt_list = *object_type_get_master_list(SGE_TYPE_CKPT); lList *master_user_list = *object_type_get_master_list(SGE_TYPE_USER); lList *master_ar_list = *object_type_get_master_list(SGE_TYPE_AR); lList *master_pe_list = *object_type_get_master_list(SGE_TYPE_PE); lList *master_hgrp_list = *object_type_get_master_list(SGE_TYPE_HGROUP); lList *master_sharetree_list = *object_type_get_master_list(SGE_TYPE_SHARETREE); /* delay scheduling for test purposes, see issue GE-3306 */ if (SGE_TEST_DELAY_SCHEDULING > 0) { sleep(SGE_TEST_DELAY_SCHEDULING); } PROF_START_MEASUREMENT(SGE_PROF_CUSTOM6); PROF_START_MEASUREMENT(SGE_PROF_CUSTOM7); if (__CONDITION(INFOPRINT)) { dstring ds; char buffer[128]; sge_dstring_init(&ds, buffer, sizeof(buffer)); DPRINTF(("================[SCHEDULING-EPOCH %s]==================\n", sge_at_time(0, &ds))); sge_dstring_free(&ds); } /* * If there were new events then * copy/filter data necessary for the scheduler run * and run the scheduler method */ memset(©, 0, sizeof(copy)); copy.dept_list = lSelect("", master_userset_list, where_what.where_dept, where_what.what_acldept); copy.acl_list = lSelect("", master_userset_list, where_what.where_acl, where_what.what_acldept); DPRINTF(("RAW CQ:%d, J:%d, H:%d, C:%d, A:%d, D:%d, P:%d, CKPT:%d," " US:%d, PR:%d, RQS:%d, AR:%d, S:nd:%d/lf:%d\n", lGetNumberOfElem(master_cqueue_list), lGetNumberOfElem(master_job_list), lGetNumberOfElem(master_exechost_list), lGetNumberOfElem(master_centry_list), lGetNumberOfElem(copy.acl_list), lGetNumberOfElem(copy.dept_list), lGetNumberOfElem(master_project_list), lGetNumberOfElem(master_ckpt_list), lGetNumberOfElem(master_user_list), lGetNumberOfElem(master_project_list), lGetNumberOfElem(master_rqs_list), lGetNumberOfElem(master_ar_list), lGetNumberOfNodes(NULL, master_sharetree_list, STN_children), lGetNumberOfLeafs(NULL, master_sharetree_list, STN_children) )); sge_rebuild_job_category(master_job_list, master_userset_list, master_project_list, master_rqs_list); PROF_STOP_MEASUREMENT(SGE_PROF_CUSTOM7); prof_init = prof_get_measurement_wallclock(SGE_PROF_CUSTOM7, true, NULL); PROF_START_MEASUREMENT(SGE_PROF_CUSTOM7); sge_before_dispatch(evc); /* prepare data for the scheduler itself */ copy.host_list = lCopyList("", master_exechost_list); /* * Within the scheduler we do only need QIs */ { lListElem *cqueue = NULL; lEnumeration *what_queue3 = NULL; for_each(cqueue, master_cqueue_list) { lList *qinstance_list = lGetList(cqueue, CQ_qinstances); lList *t; if (!qinstance_list) { continue; } /* all_queue_list contains all queue instances with state and full queue name only */ if (!what_queue3) { what_queue3 = lWhat("%T(%I%I)", lGetListDescr(qinstance_list), QU_full_name, QU_state); } t = lSelect("t", qinstance_list, NULL, what_queue3); if (t) { if (copy.all_queue_list == NULL) { copy.all_queue_list = lCreateList("all", lGetListDescr(t)); } lAppendList(copy.all_queue_list, t); lFreeList (&t); } t = lSelect("t", qinstance_list, where_what.where_queue, where_what.what_queue2); if (t) { if (copy.queue_list == NULL) { copy.queue_list = lCreateList("enabled", lGetListDescr(t)); } lAppendList(copy.queue_list, t); lFreeList (&t); } t = lSelect("t", qinstance_list, where_what.where_queue2, where_what.what_queue2); if (t) { if (copy.dis_queue_list == NULL) { copy.dis_queue_list = lCreateList("disabled", lGetListDescr(t)); } lAppendList(copy.dis_queue_list, t); lFreeList (&t); } } if (what_queue3) { lFreeWhat(&what_queue3); } } if (sconf_is_job_category_filtering()) { copy.job_list = sge_category_job_copy(copy.queue_list, &orders, evc->monitor_next_run); } else { copy.job_list = lCopyList("", master_job_list); } /* no need to copy these lists, they are read only used */ copy.centry_list = master_centry_list; copy.ckpt_list = master_ckpt_list; copy.hgrp_list = master_hgrp_list; /* these lists need to be copied because they are modified during scheduling run */ copy.share_tree = lCopyList("", master_sharetree_list); copy.pe_list = lCopyList("", master_pe_list); copy.user_list = lCopyList("", master_user_list); copy.project_list = lCopyList("", master_project_list); copy.rqs_list = lCopyList("", master_rqs_list); copy.ar_list = lCopyList("", master_ar_list); /* report number of reduced and raw (in brackets) lists */ DPRINTF(("Q:%d, AQ:%d J:%d(%d), H:%d(%d), C:%d, A:%d, D:%d, P:%d, CKPT:%d," " US:%d, PR:%d, RQS:%d, AR:%d, S:nd:%d/lf:%d \n", lGetNumberOfElem(copy.queue_list), lGetNumberOfElem(copy.all_queue_list), lGetNumberOfElem(copy.job_list), lGetNumberOfElem(master_job_list), lGetNumberOfElem(copy.host_list), lGetNumberOfElem(master_exechost_list), lGetNumberOfElem(copy.centry_list), lGetNumberOfElem(copy.acl_list), lGetNumberOfElem(copy.dept_list), lGetNumberOfElem(copy.pe_list), lGetNumberOfElem(copy.ckpt_list), lGetNumberOfElem(copy.user_list), lGetNumberOfElem(copy.project_list), lGetNumberOfElem(copy.rqs_list), lGetNumberOfElem(copy.ar_list), lGetNumberOfNodes(NULL, copy.share_tree, STN_children), lGetNumberOfLeafs(NULL, copy.share_tree, STN_children) )); if (getenv("SGE_ND")) { printf("Q:%d, AQ:%d J:%d(%d), H:%d(%d), C:%d, A:%d, D:%d, " "P:%d, CKPT:%d, US:%d, PR:%d, RQS:%d, AR:%d, S:nd:%d/lf:%d \n", lGetNumberOfElem(copy.queue_list), lGetNumberOfElem(copy.all_queue_list), lGetNumberOfElem(copy.job_list), lGetNumberOfElem(master_job_list), lGetNumberOfElem(copy.host_list), lGetNumberOfElem(master_exechost_list), lGetNumberOfElem(copy.centry_list), lGetNumberOfElem(copy.acl_list), lGetNumberOfElem(copy.dept_list), lGetNumberOfElem(copy.pe_list), lGetNumberOfElem(copy.ckpt_list), lGetNumberOfElem(copy.user_list), lGetNumberOfElem(copy.project_list), lGetNumberOfElem(copy.rqs_list), lGetNumberOfElem(copy.ar_list), lGetNumberOfNodes(NULL, copy.share_tree, STN_children), lGetNumberOfLeafs(NULL, copy.share_tree, STN_children) ); } else { schedd_log("-------------START-SCHEDULER-RUN-------------", NULL, evc->monitor_next_run); } PROF_STOP_MEASUREMENT(SGE_PROF_CUSTOM7); prof_copy = prof_get_measurement_wallclock(SGE_PROF_CUSTOM7, true, NULL); PROF_START_MEASUREMENT(SGE_PROF_CUSTOM7); scheduler_method(evc, &answer_list, ©, &orders); answer_list_output(&answer_list); PROF_STOP_MEASUREMENT(SGE_PROF_CUSTOM7); prof_run = prof_get_measurement_wallclock(SGE_PROF_CUSTOM7, true, NULL); PROF_START_MEASUREMENT(SGE_PROF_CUSTOM7); /* .. which gets deleted after using */ lFreeList(&(copy.host_list)); lFreeList(&(copy.queue_list)); lFreeList(&(copy.dis_queue_list)); lFreeList(&(copy.all_queue_list)); lFreeList(&(copy.job_list)); lFreeList(&(copy.acl_list)); lFreeList(&(copy.dept_list)); lFreeList(&(copy.pe_list)); lFreeList(&(copy.share_tree)); lFreeList(&(copy.user_list)); lFreeList(&(copy.project_list)); lFreeList(&(copy.rqs_list)); lFreeList(&(copy.ar_list)); PROF_STOP_MEASUREMENT(SGE_PROF_CUSTOM7); prof_free = prof_get_measurement_wallclock(SGE_PROF_CUSTOM7, true, NULL); /* * need to sync with event master thread * if schedd configuration changed then settings in evm can be adjusted */ if (sconf_is_new_config()) { /* set scheduler interval / event delivery interval */ u_long32 interval = sconf_get_schedule_interval(); if (evc->ec_get_edtime(evc) != interval) { evc->ec_set_edtime(evc, interval); } /* set job / ja_task event flushing */ set_job_flushing(evc); /* no need to ec_commit here - we do it when resetting the busy state */ /* now we handled the new schedd config - no need to do it twice */ sconf_reset_new_config(); } /* block till master handled all GDI orders */ sge_schedd_block_until_orders_processed(evc->get_gdi_ctx(evc), NULL); schedd_order_destroy(); /* * Stop profiling for "schedd run total" and the subcategories */ PROF_STOP_MEASUREMENT(SGE_PROF_CUSTOM6); prof_total = prof_get_measurement_wallclock(SGE_PROF_CUSTOM6, true, NULL); if (prof_is_active(SGE_PROF_CUSTOM6)) { PROFILING((SGE_EVENT, "PROF: schedd run took: %.3f s (init: %.3f s, copy: %.3f s, " "run:%.3f, free: %.3f s, jobs: %d, categories: %d/%d)", prof_total, prof_init, prof_copy, prof_run, prof_free, lGetNumberOfElem(*object_type_get_master_list(SGE_TYPE_JOB)), sge_category_count(), sge_cs_category_count() )); } if (getenv("SGE_ND") != NULL) { printf("--------------STOP-SCHEDULER-RUN-------------\n"); } else { schedd_log("--------------STOP-SCHEDULER-RUN-------------", NULL, evc->monitor_next_run); } thread_output_profiling("scheduler thread profiling summary:\n", &next_prof_output); sge_monitor_output(&monitor); } /* reset the busy state */ evc->ec_set_busy(evc, 0); evc->ec_commit(evc, NULL); /* stop logging into schedd_runlog (enabled via -tsm) */ evc->monitor_next_run = false; /* * pthread cancelation point * * sge_scheduler_cleanup_thread() is the last function which should * be called so it is pushed first */ pthread_cleanup_push(sge_scheduler_cleanup_thread, (void *) &ctx); pthread_cleanup_push((void (*)(void *))sge_scheduler_cleanup_monitor, (void *)&monitor); pthread_cleanup_push((void (*)(void *))sge_scheduler_cleanup_event_client, (void *)evc); cl_thread_func_testcancel(thread_config); pthread_cleanup_pop(execute); pthread_cleanup_pop(execute); pthread_cleanup_pop(execute); DPRINTF(("passed cancelation point\n")); }