static void schedd_mes_find_others(lListElem *tmp_sme, lList *job_list, int ignore_category) { if (tmp_sme && job_list) { lListElem *message_elem = NULL; /* MES_Type */ lRef category = NULL; /* Category pointer (void*) */ lList *jid_cat_list = NULL; /* ULNG */ lList *message_list = lGetList(tmp_sme, SME_message_list); /* * Here we have a list of message elements where each * MES_job_number_list contains only one id. * We have to find the other jobs (jids) which have the same category. */ for_each(message_elem, message_list) { lList *jid_list = lGetList(message_elem, MES_job_number_list); u_long32 jid; lRef jid_category; jid = lGetUlong(lFirst(jid_list), ULNG_value); jid_category = schedd_mes_get_category(jid, job_list); /* * Initialize jid_cat_list if not initialized * or if category differs from the last run */ if (category != jid_category || ignore_category) { jid_cat_list = schedd_mes_get_same_category_jids(jid_category, job_list, ignore_category); category = jid_category; lSetList(message_elem, MES_job_number_list, jid_cat_list); } else { lSetList(message_elem, MES_job_number_list, lCopyList("", jid_cat_list)); } }
void job_report_init_from_job_with_usage(lListElem *job_report, lListElem *job, lListElem *ja_task, lListElem *pe_task, u_long32 time_stamp) { lListElem *ep; lListElem *obj; int nm; DENTER(TOP_LAYER, "job_report_init_from_job_with_usage"); /* * initialize the job jeport like any other job report... */ job_report_init_from_job(job_report, job, ja_task, pe_task); /* * ... and now add the online usage plus some fileds which are needed for the accounting */ lSetUlong(job_report, JR_wait_status, SGE_SET_WEXITSTATUS(SGE_WEXITED_BIT, 0)); lSetUlong(job_report, JR_failed, SSTATE_QMASTER_ENFORCED_LIMIT); if (pe_task == NULL) { nm = JAT_scaled_usage_list; obj = ja_task; } else { nm = PET_scaled_usage; obj = pe_task; lSetString(job_report, JR_pe_task_id_str, lGetString(pe_task, PET_id)); } ep = lAddSubStr(obj, UA_name, "submission_time", nm, UA_Type); lSetDouble(ep, UA_value, lGetUlong(job, JB_submission_time)); ep = lAddSubStr(obj, UA_name, "start_time", nm, UA_Type); lSetDouble(ep, UA_value, lGetUlong(ja_task, JAT_start_time)); ep = lAddSubStr(obj, UA_name, "end_time", nm, UA_Type); lSetDouble(ep, UA_value, time_stamp); ep = lAddSubStr(obj, UA_name, "ru_wallclock", nm, UA_Type); lSetDouble(ep, UA_value, 0.0); lSetList(job_report, JR_usage, lCopyList("", lGetList(obj, nm))); DEXIT; }
/*-------------------------------------------------------------------------*/ static void qmonManopFillList(void) { lList *lp, *cl; lListElem *ep; DENTER(GUI_LAYER, "qmonManopFillList"); /* manager list */ lp = qmonMirrorList(SGE_UM_LIST); lPSortList(lp, "%I+", UM_name); UpdateXmListFromCull(manager_list, XmFONTLIST_DEFAULT_TAG, lp, UM_name); /* operator list */ lp = qmonMirrorList(SGE_UO_LIST); lPSortList(lp, "%I+", UO_name); UpdateXmListFromCull(operator_list, XmFONTLIST_DEFAULT_TAG, lp, UO_name); /* userset list */ updateUsersetList(); /* user list */ lp = qmonMirrorList(SGE_UU_LIST); lPSortList(lp, "%I+", UU_name); /* ** set UU_default_project to NONE */ cl = lCopyList("cl", lp); for_each (ep, cl) { if (ep && !lGetString(ep, UU_default_project)) lSetString(ep, UU_default_project, "NONE"); } qmonSetNxN(user_matrix, cl, 3, UU_name, UU_default_project, UU_delete_time); lFreeList(&cl); DEXIT; }
/*-------------------------------------------------------------------------*/ 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 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); }
/****** gdi/sge/sge_qexecve() ************************************************ * NAME * sge_qexecve() -- start a task in a tightly integrated par. job * * SYNOPSIS * sge_tid_t sge_qexecve(const char *hostname, const char *queuename, * const char *cwd, const lList *environment * const lList *path_aliases) * * FUNCTION * Starts a task in a tightly integrated job. * Builds a job object describing the task, * connects to the commd on the targeted execution host, * deliveres the job object and waits for an answer. * The answer from the execution daemon on the execution host * contains a task id that is returned to the caller of the function. * * INPUTS * const char *hostname - name of the host on which to start the task * const lList *environment - list containing environment variable * settings for the task that override the * default environment * const lList *path_aliases - optional a path alias list * * RESULT * sge_tid_t - the task id, if the task can be executed, * a value <= 0 indicates an error. * * NOTES * MT-NOTE: sge_qexecve() is not MT safe ******************************************************************************/ sge_tid_t sge_qexecve(sge_gdi_ctx_class_t *ctx, const char *hostname, const char *queuename, const char *cwd, const lList *environment, const lList *path_aliases) { char myname[256]; const char *s; int ret, uid; sge_tid_t tid = NULL; lListElem *petrep; lListElem *rt; sge_pack_buffer pb; u_long32 jobid, jataskid; u_long32 dummymid = 0; const char *env_var_name = "SGE_TASK_ID"; DENTER(TOP_LAYER, "sge_qexecve"); if (hostname == NULL) { sprintf(lasterror, MSG_GDI_INVALIDPARAMETER_SS, "sge_qexecve", "hostname"); DRETURN(NULL); } /* resolve user */ if (sge_uid2user((uid=getuid()), myname, sizeof(myname)-1, MAX_NIS_RETRIES)) { sprintf(lasterror, MSG_GDI_RESOLVINGUIDTOUSERNAMEFAILED_IS , uid, strerror(errno)); DRETURN(NULL); } if ((s=getenv("JOB_ID")) == NULL) { sprintf(lasterror, MSG_GDI_MISSINGINENVIRONMENT_S, "JOB_ID"); DRETURN(NULL); } if (sscanf(s, sge_u32, &jobid) != 1) { sprintf(lasterror, MSG_GDI_STRINGISINVALID_SS, s, "JOB_ID"); DRETURN(NULL); } if ((s=getenv(env_var_name)) != NULL) { if (strcmp(s, "undefined") == 0) { jataskid = 1; } else { if (sscanf(s, sge_u32, &jataskid) != 1) { sprintf(lasterror, MSG_GDI_STRINGISINVALID_SS, s, env_var_name); DRETURN(NULL); } } } else { sprintf(lasterror, MSG_GDI_MISSINGINENVIRONMENT_S, env_var_name); DRETURN(NULL); } /* ---- build up pe task request structure (see gdilib/sge_petaskL.h) */ petrep = lCreateElem(PETR_Type); lSetUlong(petrep, PETR_jobid, jobid); lSetUlong(petrep, PETR_jataskid, jataskid); lSetString(petrep, PETR_owner, myname); lSetUlong(petrep, PETR_submission_time, sge_get_gmt()); if (cwd != NULL) { lSetString(petrep, PETR_cwd, cwd); } if (environment != NULL) { lSetList(petrep, PETR_environment, lCopyList("environment", environment)); } if (path_aliases != NULL) { lSetList(petrep, PETR_path_aliases, lCopyList("path_aliases", path_aliases)); } if (queuename != NULL) { lSetString(petrep, PETR_queuename, queuename); } if (init_packbuffer(&pb, 1024, 0) != PACK_SUCCESS) { lFreeElem(&petrep); sprintf(lasterror, SFNMAX, MSG_GDI_OUTOFMEMORY); DRETURN(NULL); } pack_job_delivery(&pb, petrep); ret = gdi2_send_message_pb(ctx, 1, prognames[EXECD], 1, hostname, TAG_JOB_EXECUTION, &pb, &dummymid); clear_packbuffer(&pb); lFreeElem(&petrep); if (ret != CL_RETVAL_OK) { sprintf(lasterror, MSG_GDI_SENDTASKTOEXECDFAILED_SS, hostname, cl_get_error_text(ret)); DRETURN(NULL); } /* add list into our remote task list */ rt = lAddElemStr(&remote_task_list, RT_tid, "none", RT_Type); lSetHost(rt, RT_hostname, hostname); lSetUlong(rt, RT_state, RT_STATE_WAIT4ACK); rcv_from_execd(ctx, OPT_SYNCHRON, TAG_JOB_EXECUTION); tid = (sge_tid_t) lGetString(rt, RT_tid); if (strcmp(tid, "none") == 0) { tid = NULL; sprintf(lasterror, MSG_GDI_EXECDONHOSTDIDNTACCEPTTASK_S, hostname); } /* now close message to execd */ cl_commlib_shutdown_handle(cl_com_get_handle("execd_handle", 0), false); DRETURN(tid); }
static bool hgroup_mod_hostlist(lListElem *hgroup, lList **answer_list, lListElem *reduced_elem, int sub_command, lList **add_hosts, lList **rem_hosts, lList **occupant_groups) { bool ret = true; DENTER(TOP_LAYER, "hgroup_mod_hostlist"); if (hgroup != NULL && reduced_elem != NULL) { int pos = lGetPosViaElem(reduced_elem, HGRP_host_list, SGE_NO_ABORT); if (pos >= 0) { lList *list = lGetPosList(reduced_elem, pos); lList *old_href_list = lCopyList("", lGetList(hgroup, HGRP_host_list)); lList *master_list = *(hgroup_list_get_master_list()); lList *href_list = NULL; lList *add_groups = NULL; lList *rem_groups = NULL; if (ret) { ret &= href_list_resolve_hostnames(list, answer_list, true); } if (ret) { attr_mod_sub_list(answer_list, hgroup, HGRP_host_list, HR_name, reduced_elem, sub_command, SGE_ATTR_HOSTLIST, SGE_OBJ_HGROUP, 0); href_list = lGetList(hgroup, HGRP_host_list); } if (ret) { ret &= href_list_find_diff(href_list, answer_list, old_href_list, add_hosts, rem_hosts, &add_groups, &rem_groups); } if (ret && add_groups != NULL) { ret &= hgroup_list_exists(master_list, answer_list, add_groups); } if (ret) { ret &= href_list_find_effective_diff(answer_list, add_groups, rem_groups, master_list, add_hosts, rem_hosts); } if (ret) { ret &= href_list_resolve_hostnames(*add_hosts, answer_list, false); } /* * Try to find cycles in the definition */ if (ret) { ret &= hgroup_find_all_referencees(hgroup, answer_list, master_list, occupant_groups); ret &= href_list_add(occupant_groups, answer_list, lGetHost(hgroup, HGRP_name)); if (ret) { if (*occupant_groups != NULL && add_groups != NULL) { lListElem *add_group = NULL; for_each(add_group, add_groups) { const char *name = lGetHost(add_group, HR_name); if (href_list_has_member(*occupant_groups, name)) { break; } } if (add_group == NULL) { /* * No cycle found => success */ ; } else { SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_HGROUP_CYCLEINDEF_SS, lGetHost(add_group, HR_name), lGetHost(hgroup, HGRP_name))); answer_list_add(answer_list, SGE_EVENT, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR); ret = false; } } } }
/****** 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")); }
/*-------------------------------------------------------------------------*/ static Boolean qmonSchedSet(lListElem *sep) { static char schedd_job_info[BUFSIZ]; DENTER(GUI_LAYER, "qmonSchedSet"); if (!sep) { DRETURN(False); } /* printf("------> qmonSchedSet\n"); */ /* lWriteElemTo(sep, stdout); */ data.algorithm = sge_strdup(data.algorithm, (StringConst)lGetString(sep, SC_algorithm)); data.schedule_interval = sge_strdup(data.schedule_interval, (StringConst)lGetString(sep, SC_schedule_interval)); data.sc_params = sge_strdup(data.sc_params, (StringConst)lGetString(sep, SC_params)); data.maxujobs = lGetUlong(sep, SC_maxujobs); data.flush_submit_secs = lGetUlong(sep, SC_flush_submit_sec); data.flush_finish_secs = lGetUlong(sep, SC_flush_finish_sec); data.max_reservation = lGetUlong(sep, SC_max_reservation); /* this depends on the kind queue_sort_method is represented */ data.queue_sort_method = lGetUlong(sep, SC_queue_sort_method); /* ** load adjustments need special treatment */ data.job_load_adjustments = lCopyList("copy", lGetList(sep, SC_job_load_adjustments)); data.load_adjustment_decay_time = sge_strdup(data.load_adjustment_decay_time, (StringConst)lGetString(sep, SC_load_adjustment_decay_time)); data.load_formula = sge_strdup(data.load_formula, (StringConst)lGetString(sep, SC_load_formula)); data.reprioritize_interval = sge_strdup(data.reprioritize_interval, (StringConst)lGetString(sep, SC_reprioritize_interval)); data.default_duration = sge_strdup(data.default_duration, (StringConst)lGetString(sep, SC_default_duration)); /** printf("->data.algorithm: '%s'\n", data.algorithm ? data.algorithm : "-NA-"); printf("->data.schedule_interval: '%s'\n", data.schedule_interval ? data.schedule_interval : "-NA-"); printf("->data.sc_params: '%s'\n", data.sc_params ? data.sc_params : "-NA-"); printf("->data.maxujobs: '%d'\n", data.maxujobs ); printf("->data.flush_submit_secs: '%d'\n", data.flush_submit_secs ); printf("->data.flush_finish_secs: '%d'\n", data.flush_finish_secs ); printf("->data.max_reservation: '%d'\n", data.max_reservation ); printf("->data.queue_sort_method: '%d'\n", data.queue_sort_method ); printf("->data.load_adjustment_decay_time: '%s'\n", data.load_adjustment_decay_time ? data.load_adjustment_decay_time : "-NA-"); printf("->data.load_formula: '%s'\n", data.load_formula ? data.load_formula : "-NA-"); **/ /* ** set the dialog values */ XmtDialogSetDialogValues(qmon_sconf, (XtPointer) &data); /* ** schedd_job_info needs some extras ** attention: order must match order of labels in qmon_sconf.ad ** ** Qmon*sconf_general*sconf_job_info.chooserType: ChooserOption ** Qmon*sconf_general*sconf_job_info.strings: \ ** "False", \ ** "True", \ ** "Job Range" */ if (lGetString(sep, SC_schedd_job_info)) sge_strlcpy(schedd_job_info, lGetString(sep, SC_schedd_job_info), BUFSIZ); else strcpy(schedd_job_info, "false"); if (!strcasecmp(schedd_job_info, "false")) { XmtChooserSetState(sconf_job_info, 0, True); XmtInputFieldSetString(sconf_job_range, ""); } else if (!strcasecmp(schedd_job_info, "true")) { XmtChooserSetState(sconf_job_info, 1, True); XmtInputFieldSetString(sconf_job_range, ""); } else { char *sji; strtok(schedd_job_info, " \t"); sji = strtok(NULL, "\n"); XmtChooserSetState(sconf_job_info, 2, True); XmtInputFieldSetString(sconf_job_range, sji); } qmonSchedFreeData(); DRETURN(True); }
lList *cull_unparse_job_parameter( sge_gdi_ctx_class_t *ctx, lList **pcmdline, lListElem *job, int flags ) { const char *cp; u_long32 ul; lList *answer = NULL; char str[1024 + 1]; lList *lp; int ret; lListElem *ep_opt; const char *username = ctx->get_username(ctx); const char *qualified_hostname = ctx->get_qualified_hostname(ctx); DENTER(TOP_LAYER, "cull_unparse_job_parameter"); /* ** -a ** problem with submission time, but that is not a good ** default option anyway, is not unparsed */ /* ** -A */ if (sge_unparse_account_string(job, pcmdline, &answer) != 0) { DEXIT; return answer; } /* ** -c */ if (sge_unparse_checkpoint_option(job, pcmdline, &answer) != 0) { DEXIT; return answer; } /* * -ckpt */ if (sge_unparse_string_option(job, JB_checkpoint_name, "-ckpt", pcmdline, &answer) != 0) { DEXIT; return answer; } /* ** -cwd */ if (lGetString(job, JB_cwd)) { ep_opt = sge_add_noarg(pcmdline, cwd_OPT, "-cwd", NULL); } /* * -P */ if (sge_unparse_string_option(job, JB_project, "-P", pcmdline, &answer) != 0) { DEXIT; return answer; } #if 0 /* ** -C */ if (sge_unparse_string_option(job, JB_directive_prefix, "-C", pcmdline, &answer) != 0) { DEXIT; return answer; } #endif /* ** -e */ if (sge_unparse_path_list(job, JB_stderr_path_list, "-e", pcmdline, &answer) != 0) { DEXIT; return answer; } /* ** -h, here only user hold supported at the moment */ if ((ul = lGetUlong(lFirst(lGetList(job, JB_ja_tasks)), JAT_hold))) { ep_opt = sge_add_noarg(pcmdline, h_OPT, "-h", NULL); } /* ** -hold_jid */ if ((lp = lGetList(job, JB_jid_request_list))) { int fields[] = { JRE_job_name, 0 }; const char *delis[] = {NULL, ",", NULL}; ret = uni_print_list(NULL, str, sizeof(str) - 1, lp, fields, delis, 0); if (ret) { DPRINTF(("Error %d formatting jid_request_list as -hold_jid\n", ret)); sprintf(str, MSG_LIST_ERRORFORMATINGJIDPREDECESSORLISTASHOLDJID); answer_list_add(&answer, str, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR); return answer; } ep_opt = sge_add_arg(pcmdline, hold_jid_OPT, lListT, "-hold_jid", str); lSetList(ep_opt, SPA_argval_lListT, lCopyList("hold_jid list", lp)); } /* ** -hold_jid_ad */ if ((lp = lGetList(job, JB_ja_ad_request_list))) { int fields[] = { JRE_job_name, 0 }; const char *delis[] = {NULL, ",", NULL}; ret = uni_print_list(NULL, str, sizeof(str) - 1, lp, fields, delis, 0); if (ret) { DPRINTF(("Error %d formatting ja_ad_request_list as -hold_jid_ad\n", ret)); sprintf(str, MSG_LIST_ERRORFORMATINGJIDPREDECESSORLISTASHOLDJIDAD); answer_list_add(&answer, str, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR); return answer; } ep_opt = sge_add_arg(pcmdline, hold_jid_ad_OPT, lListT, "-hold_jid_ad", str); lSetList(ep_opt, SPA_argval_lListT, lCopyList("hold_jid_ad list", lp)); } /* ** -i */ if (sge_unparse_path_list(job, JB_stdin_path_list, "-i", pcmdline, &answer) != 0) { DEXIT; return answer; } /* ** -j */ if ((ul = lGetBool(job, JB_merge_stderr))) { ep_opt = sge_add_arg(pcmdline, j_OPT, lIntT, "-j", "y"); lSetInt(ep_opt, SPA_argval_lIntT, true); } /* ** -jid */ if ((lp = lGetList(job, JB_job_identifier_list))) { int fields[] = { JRE_job_number, 0}; const char *delis[] = {"", ",", NULL}; ret = uni_print_list(NULL, str, sizeof(str) - 1, lp, fields, delis, 0); if (ret) { DPRINTF(("Error %d formatting job_identifier_list as -jid\n", ret)); sprintf(str, MSG_LIST_ERRORFORMATINGJOBIDENTIFIERLISTASJID); answer_list_add(&answer, str, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR); return answer; } ep_opt = sge_add_arg(pcmdline, jid_OPT, lListT, "-jid", str); lSetList(ep_opt, SPA_argval_lListT, lCopyList("jid list", lp)); } /* ** -js */ if ((ul = lGetUlong(job, JB_jobshare)) != 0) { sprintf(str, sge_u32, ul); ep_opt = sge_add_arg(pcmdline, js_OPT, lUlongT, "-js", str); lSetUlong(ep_opt, SPA_argval_lUlongT, ul); } /* ** -lj is in parsing but can't be unparsed here */ /* ** -l */ if (sge_unparse_resource_list(job, JB_hard_resource_list, pcmdline, &answer) != 0) { DEXIT; return answer; } if (sge_unparse_resource_list(job, JB_soft_resource_list, pcmdline, &answer) != 0) { DEXIT; return answer; } /* ** -m */ if ((ul = lGetUlong(job, JB_mail_options))) { cp = sge_unparse_mail_options(ul); if (!cp) { DPRINTF(("Error unparsing mail options\n")); sprintf(str, MSG_PARSE_ERRORUNPARSINGMAILOPTIONS); answer_list_add(&answer, str, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR); return answer; } ep_opt = sge_add_arg(pcmdline, m_OPT, lIntT, "-m", cp); lSetInt(ep_opt, SPA_argval_lIntT, ul); } /* ** -M obviously a problem!!! ** not unparsed at the moment ** does it make sense as a default, after all? */ if ((lp = lGetList(job, JB_mail_list))) { lList *lp_new = NULL; lListElem *ep_new = NULL; lListElem *ep = NULL; const char *host; const char *user; /* ** or rather take all if there are more than one elements? */ for_each(ep, lp) { user = lGetString(ep, MR_user); host = lGetHost(ep, MR_host); if (sge_strnullcmp(user, username) || sge_hostcmp(host, qualified_hostname)) { lp_new = lCreateList("mail list", MR_Type); ep_new = lAddElemStr(&lp_new, MR_user, user, MR_Type); lSetHost(ep_new, MR_host, host); } }
/************************************************************************ Master routine for job exit We need a rusage struct filled. In normal cases this is done by the execd, sending this structure to notify master about job finish. In case of an error noticed by the master which needs the job to be removed we can fill this structure by hand. We need: rusage->job_number rusage->qname to clean up the queue (if we didn't find it we nevertheless clean up the job for functions regarding rusage see sge_rusage.c ************************************************************************/ void sge_job_exit(sge_gdi_ctx_class_t *ctx, lListElem *jr, lListElem *jep, lListElem *jatep, monitoring_t *monitor) { lListElem *queueep = NULL; const char *err_str = NULL; const char *qname = NULL; const char *hostname = MSG_OBJ_UNKNOWNHOST; u_long32 jobid, jataskid; lListElem *hep = NULL; u_long32 timestamp; object_description *object_base = object_type_get_object_description(); u_long32 failed, general_failure; lList *saved_gdil; DENTER(TOP_LAYER, "sge_job_exit"); /* JG: TODO: we'd prefer some more precise timestamp, e.g. from jr */ timestamp = sge_get_gmt(); qname = lGetString(jr, JR_queue_name); if (qname == NULL) { qname = (char *)MSG_OBJ_UNKNOWNQ; } err_str = lGetString(jr, JR_err_str); if (err_str == NULL) { err_str = MSG_UNKNOWNREASON; } jobid = lGetUlong(jr, JR_job_number); jataskid = lGetUlong(jr, JR_ja_task_number); failed = lGetUlong(jr, JR_failed); general_failure = lGetUlong(jr, JR_general_failure); cancel_job_resend(jobid, jataskid); /* This only has a meaning for Hibernator jobs. The job pid must * be saved accross restarts, since jobs get their old pid */ lSetUlong(jatep, JAT_pvm_ckpt_pid, lGetUlong(jr, JR_job_pid)); DPRINTF(("reaping job "sge_u32"."sge_u32" in queue >%s< job_pid %d\n", jobid, jataskid, qname, (int) lGetUlong(jatep, JAT_pvm_ckpt_pid))); queueep = cqueue_list_locate_qinstance(*object_base[SGE_TYPE_CQUEUE].list, qname); if (queueep == NULL) { ERROR((SGE_EVENT, MSG_JOB_WRITEJFINISH_S, qname)); } sge_job_remove_enforce_limit_trigger(jobid, jataskid); /* retrieve hostname for later use */ if (queueep != NULL) { hostname = lGetHost(queueep, QU_qhostname); } if (failed) { /* a problem occured */ WARNING((SGE_EVENT, MSG_JOB_FAILEDONHOST_UUSSSS, sge_u32c(jobid), sge_u32c(jataskid), hostname, general_failure ? MSG_GENERAL : "", get_sstate_description(failed), err_str)); } else { INFO((SGE_EVENT, MSG_JOB_JFINISH_UUS, sge_u32c(jobid), sge_u32c(jataskid), hostname)); } /*-------------------------------------------------*/ /* test if this job is in state JRUNNING or JTRANSFERING */ if (lGetUlong(jatep, JAT_status) != JRUNNING && lGetUlong(jatep, JAT_status) != JTRANSFERING) { ERROR((SGE_EVENT, MSG_JOB_JEXITNOTRUN_UU, sge_u32c(lGetUlong(jep, JB_job_number)), sge_u32c(jataskid))); DRETURN_VOID; } saved_gdil = lCopyList("cpy", lGetList(jatep, JAT_granted_destin_identifier_list)); /* * case 1: job being trashed because * --> failed starting interactive job * --> job was deleted * --> a failed batch job that explicitely shall not enter error state */ if (((lGetUlong(jatep, JAT_state) & JDELETED) == JDELETED) || (failed && !lGetString(jep, JB_exec_file)) || (failed && general_failure==GFSTATE_JOB && JOB_TYPE_IS_NO_ERROR(lGetUlong(jep, JB_type)))) { reporting_create_acct_record(ctx, NULL, jr, jep, jatep, false); /* JG: TODO: we need more information in the log message */ reporting_create_job_log(NULL, timestamp, JL_DELETED, MSG_EXECD, hostname, jr, jep, jatep, NULL, MSG_LOG_JREMOVED); sge_commit_job(ctx, jep, jatep, jr, COMMIT_ST_FINISHED_FAILED_EE, COMMIT_DEFAULT | COMMIT_NEVER_RAN, monitor); if (lGetUlong(jep, JB_ar) != 0 && (lGetUlong(jatep, JAT_state) & JDELETED) == JDELETED) { /* get AR and remove it if no other jobs are debited */ lList *master_ar_list = *object_base[SGE_TYPE_AR].list; lListElem *ar = ar_list_locate(master_ar_list, lGetUlong(jep, JB_ar)); if (ar != NULL && lGetUlong(ar, AR_state) == AR_DELETED) { lListElem *ar_queue; u_long32 ar_id = lGetUlong(ar, AR_id); for_each(ar_queue, lGetList(ar, AR_reserved_queues)) { if (qinstance_slots_used(ar_queue) != 0) { break; } } if (ar_queue == NULL) { /* no jobs registered in advance reservation */ dstring buffer = DSTRING_INIT; sge_dstring_sprintf(&buffer, sge_U32CFormat, sge_u32c(ar_id)); ar_do_reservation(ar, false); reporting_create_ar_log_record(NULL, ar, ARL_DELETED, "AR deleted", timestamp); reporting_create_ar_acct_records(NULL, ar, timestamp); lRemoveElem(master_ar_list, &ar); sge_event_spool(ctx, NULL, 0, sgeE_AR_DEL, ar_id, 0, sge_dstring_get_string(&buffer), NULL, NULL, NULL, NULL, NULL, true, true); sge_dstring_free(&buffer); } }
/*-------------------------------------------------------------------------*/ void qmonRequestPopup(Widget w, XtPointer cld, XtPointer cad) { Widget request_hardsoft, parent, request_clear, request_okay, request_cancel; lList *hrl = NULL; lList *srl = NULL; lList *rll = NULL; lListElem *ep = NULL; lListElem *rp = NULL; lList *alp = NULL; DENTER(GUI_LAYER, "qmonRequestPopup"); parent = XmtGetShell(w); DPRINTF(("parent = %s\n", XtName(parent) )); if (!request_dialog) { request_dialog = XmtBuildQueryDialog(parent, "request_shell", NULL, 0, "request_rtype", &request_rtype, "request_rr", &request_rr, "request_hr", &request_hr, "request_sr", &request_sr, "request_hardsoft", &request_hardsoft, "request_clear", &request_clear, "request_okay", &request_okay, "request_cancel", &request_cancel, NULL); XtAddCallback(request_rr, XmNactivateCallback, qmonRequestEditResource, (XtPointer)0); XtAddCallback(request_hr, XmNactivateCallback, qmonRequestEditResource, (XtPointer)1); XtAddCallback(request_hr, XmNremoveCallback, qmonRequestRemoveResource, NULL); XtAddCallback(request_sr, XmNactivateCallback, qmonRequestEditResource, (XtPointer)1); XtAddCallback(request_sr, XmNremoveCallback, qmonRequestRemoveResource, NULL); XtAddCallback(request_hardsoft, XmtNvalueChangedCallback, qmonToggleHardSoft2, NULL); XtAddCallback(request_clear, XmNactivateCallback, qmonRequestClear, NULL); XtAddCallback(request_okay, XmNactivateCallback, qmonRequestOkay, NULL); XtAddCallback(request_cancel, XmNactivateCallback, qmonRequestCancel, NULL); XtAddEventHandler(XtParent(request_dialog), StructureNotifyMask, False, SetMinShellSize, NULL); } /* ** set the type labelString */ XtVaSetValues(request_rtype, XmtNlabel, qmonSubmitRequestType(), NULL); qmonMirrorMultiAnswer(CENTRY_T, &alp); if (alp) { qmonMessageBox(w, alp, 0); lFreeList(&alp); /* set normal cursor */ XmtDisplayDefaultCursor(w); DEXIT; return; } rll = qmonGetResources(qmonMirrorList(SGE_CE_LIST), REQUESTABLE_RESOURCES); hrl = qmonSubmitHR(); lFreeList(&hard_requests); if (hrl) { hard_requests = lCopyList("hr", hrl); for_each(ep, hard_requests) { rp = lGetElemStr(rll, CE_name, lGetString(ep, CE_name)); if (!rp) rp = lGetElemStr(rll, CE_shortcut, lGetString(ep, CE_name)); if (rp) { lSetString(ep, CE_name, lGetString(rp, CE_name)); lSetString(ep, CE_default, NULL); lSetUlong(ep, CE_valtype, lGetUlong(rp, CE_valtype)); } } }
static void do_test(bool unique_hash, bool non_unique_hash, int num_objects, int num_names) { lList *lp = NULL; lList *copy; lListElem *ep; clock_t now, start; struct tms tms_buffer; #ifdef MALLINFO struct mallinfo meminfo; #endif int i; #ifdef HASH_STATISTICS cull_htable cht; dstring stat_dstring = DSTRING_INIT; #endif /* measurement data */ double prof_create, /* create objects */ prof_copy, /* copy list including all hashtables */ prof_rau, /* random access by unique attrib */ prof_inu, /* iterate by non unique attrib */ prof_curo, /* change unique attrib of random object */ prof_cnuro, /* change non unique attrib of random object */ prof_dru, /* delete random object by unique attribute */ prof_dinu; /* delete by iterating over non unique attrib */ int objs_dru, /* objects deleted by random unique */ objs_dinu; /* objects deleted by iterate non unique */ /* create list and hash tables */ lp = lCreateList("test list ", DESCR); if (unique_hash) { cull_hash_new(lp, NM_ULONG, true); } if (non_unique_hash) { cull_hash_new(lp, NM_STRING, false); } #ifdef HASH_STATISTICS cht = lp->descr[1].ht; printf("%s\n", cull_hash_statistics(cht, &stat_dstring)); #endif start = times(&tms_buffer); /* TEST: build objects */ for (i = 0; i < num_objects; i++) { ep = lAddElemUlong(&lp, NM_ULONG, i, DESCR); lSetString(ep, NM_STRING, names[rand() % num_names]); } /* measure time */ now = times(&tms_buffer); prof_create = (now - start) * 1.0 / clk_tck; #ifdef HASH_STATISTICS printf("%s\n", cull_hash_statistics(cht, &stat_dstring)); #endif /* measure memory usage */ #ifdef MALLINFO meminfo = mallinfo(); #endif /* TEST: copy list */ start = times(&tms_buffer); copy = lCopyList("copy", lp); /* measure time */ now = times(&tms_buffer); prof_copy = (now - start) * 1.0 / clk_tck; lFreeList(©); /* TEST: random access by unique attrib */ start = times(&tms_buffer); for (i = 0; i < num_objects; i++) { ep = lGetElemUlong(lp, NM_ULONG, rand() % num_objects); } /* measure time */ now = times(&tms_buffer); prof_rau = (now - start) * 1.0 / clk_tck; start = now; /* TEST: iterate by non unique attrib */ for (i = 0; i < num_names; i++) { const void *iterator = NULL; lListElem *next_ep; next_ep = lGetElemStrFirst(lp, NM_STRING, names[i], &iterator); while ((ep = next_ep) != NULL) { next_ep = lGetElemStrNext(lp, NM_STRING, names[i], &iterator); } } /* measure time */ now = times(&tms_buffer); prof_inu = (now - start) * 1.0 / clk_tck; start = now; /* TEST: change unique attribute of random object */ /* measure time */ for (i = 0; i < num_objects; i++) { /* object to access */ int unique = rand() % num_objects; /* new value to set, make sure we stay unique */ int newval = unique + num_objects; /* search object */ ep = lGetElemUlong(lp, NM_ULONG, unique); /* set a new value */ lSetUlong(ep, NM_ULONG, newval); /* restore old value */ lSetUlong(ep, NM_ULONG, unique); } now = times(&tms_buffer); prof_curo = (now - start) * 1.0 / clk_tck; start = now; /* TEST: change non unique attribute of random object */ for (i = 0; i < num_objects; i++) { /* search object */ ep = lGetElemUlong(lp, NM_ULONG, rand() % num_objects); /* set a new value */ lSetString(ep, NM_STRING, names[rand() % num_names]); } /* measure time */ now = times(&tms_buffer); prof_cnuro = (now - start) * 1.0 / clk_tck; start = now; /* TEST: delete random object */ objs_dru = 0; for (i = 0; i < num_objects / 2; i++) { /* search object */ ep = lGetElemUlong(lp, NM_ULONG, rand() % num_objects); /* if same rand showed up earlier, object does no longer exist! */ if (ep != NULL) { lRemoveElem(lp, &ep); objs_dru++; } } /* measure time */ now = times(&tms_buffer); prof_dru = (now - start) * 1.0 / clk_tck; start = now; /* TEST: delete all objects having the same non unique attribute */ objs_dinu = 0; for (i = 0; i < num_names; i++) { const void *iterator = NULL; lListElem *next_ep; next_ep = lGetElemStrFirst(lp, NM_STRING, names[i], &iterator); while ((ep = next_ep) != NULL) { next_ep = lGetElemStrNext(lp, NM_STRING, names[i], &iterator); lRemoveElem(lp, &ep); objs_dinu++; } } /* measure time */ now = times(&tms_buffer); prof_dinu = (now - start) * 1.0 / clk_tck; start = now; printf(DATA_FORMAT, unique_hash ? " * " : " ", non_unique_hash ? " * " : " ", prof_create, prof_copy, prof_rau, prof_inu, prof_curo, prof_cnuro, prof_dru, objs_dru, prof_dinu, objs_dinu, #ifdef MALLINFO (meminfo.usmblks + meminfo.uordblks) / 1024 #else 0L #endif ); #ifdef HASH_STATISTICS printf("%s\n", cull_hash_statistics(cht, &stat_dstring)); sge_dstring_free(&stat_dstring); #endif lFreeList(&lp); }