lList *buildRequestList(int n) { lList *requestlist = NULL; lListElem *request; requestlist = lCreateList("requestlist", JobRequestT); request = lCreateElem(JobRequestT); lSetString(request, R_name, "ARCH"); lSetString(request, R_operator, "=="); lSetString(request, R_value, "irix"); lAppendElem(requestlist, request); if (n) { request = lCreateElem(JobRequestT); lSetString(request, R_name, "editor"); lSetString(request, R_operator, "=="); lSetString(request, R_value, "vi"); lAppendElem(requestlist, request); } request = lCreateElem(JobRequestT); lSetString(request, R_name, "GROUP"); lSetString(request, R_operator, "=="); lSetString(request, R_value, "graphic"); lAppendElem(requestlist, request); return requestlist; }
static lList *test_create_rqs(void) { lList* rqs_list = lCreateList("my_rqs", RQS_Type); lListElem* rqs; lList* rule_list; lListElem* rule; lListElem* filter; lListElem* limit; lList * limit_list; rqs = lCreateElem(RQS_Type); lSetString(rqs, RQS_name, "Test_Name1"); lSetBool(rqs, RQS_enabled, true); rule_list = lCreateList("Rule_List", RQR_Type); rule = lCreateElem(RQR_Type); filter = lCreateElem(RQRF_Type); lSetBool(filter, RQRF_expand, true); lAddSubStr(filter, ST_name, "rqs_user", RQRF_scope, ST_Type); lSetObject(rule, RQR_filter_users, filter); limit_list = lCreateList("limit_list", RQRL_Type); limit = lCreateElem(RQRL_Type); lSetString(limit, RQRL_name, "slots"); lSetString(limit, RQRL_value, "2*$num_proc"); lAppendElem(limit_list, limit); lSetList(rule, RQR_limit, limit_list); lAppendElem(rule_list, rule); lSetList(rqs, RQS_rule, rule_list); lAppendElem(rqs_list, rqs); return rqs_list; }
/****** sge_orders/sge_add_schedd_info() *************************************** * NAME * sge_add_schedd_info() -- retrieves the messages and generates an order out * of it. * * SYNOPSIS * lList* sge_add_schedd_info(lList *or_list, int *global_mes_count, int * *job_mes_count) * * FUNCTION * retrieves all messages, puts them into an order package, and frees the * orginal messages. It also returns the number of global and job messages. * * INPUTS * lList *or_list - int: the order list to which the message order is added * int *global_mes_count - out: global message count * int *job_mes_count - out: job message count * * RESULT * lList* - the order list * * NOTES * MT-NOTE: sge_add_schedd_info() is not MT safe * *******************************************************************************/ lList *sge_add_schedd_info(lList *or_list, int *global_mes_count, int *job_mes_count) { lList *jlist; lListElem *sme, *ep; DENTER(TOP_LAYER, "sge_add_schedd_info"); sme = schedd_mes_obtain_package(global_mes_count, job_mes_count); if (!sme || (lGetNumberOfElem(lGetList(sme, SME_message_list)) < 1 && lGetNumberOfElem(lGetList(sme, SME_global_message_list)) < 1)) { DEXIT; return or_list; } /* create orders list if not existent */ if (!or_list) { or_list = lCreateList("orderlist", OR_Type); } /* build order */ ep=lCreateElem(OR_Type); jlist = lCreateList("", SME_Type); lAppendElem(jlist, sme); lSetList(ep, OR_joker, jlist); lSetUlong(ep, OR_type, ORT_job_schedd_info); lAppendElem(or_list, ep); DEXIT; return or_list; }
/****** Eventmirror/schedd_conf/schedd_conf_update_master_list() *************** * NAME * schedd_conf_update_master_list() -- update the scheduler configuration * * SYNOPSIS * bool * schedd_conf_update_master_list(sge_object_type type, * sge_event_action action, * lListElem *event, void *clientdata) * * FUNCTION * Update the global master list of scheduler configurations * based on an event. * The function is called from the event mirroring interface. * The list only contains one element that is replaced when a * modify event arrives. * * INPUTS * sge_object_type type - event type * sge_event_action action - action to perform * lListElem *event - the raw event * void *clientdata - client data * * RESULT * bool - true, if update is successfull, else false * * NOTES * The function should only be called from the event mirror interface. * * SEE ALSO * Eventmirror/--Eventmirror *******************************************************************************/ sge_callback_result schedd_conf_update_master_list(sge_evc_class_t *evc, object_description *object_base, sge_object_type type, sge_event_action action, lListElem *event, void *clientdata) { lList *list = NULL; lList *answer_list = NULL; lDescr *list_descr; lList *data_list; lListElem *ep = NULL; DENTER(TOP_LAYER, "schedd_conf_update_master_list"); list_descr = SC_Type; if ((data_list = lGetList(event, ET_new_version)) != NULL) { if ((ep = lFirst(data_list)) != NULL) { ep = lDechainElem(data_list, ep); } } /* if neccessary, create list and copy schedd info */ if (ep != NULL) { list = lCreateList("schedd config", list_descr); lAppendElem(list, ep); } if (!sconf_set_config(&list, &answer_list)) { lFreeList(&list); answer_list_output(&answer_list); } DEXIT; return SGE_EMA_OK; }
static int do_qeti_test(lListElem *cr, u_long32 *qeti_expected_result) { lList *cr_list; sge_qeti_t *iter; u_long32 pe_time; int ret = 0; int i = 0; /* sge_qeti_allocate() */ cr_list = lCreateList("", RUE_Type); lAppendElem(cr_list, cr); iter = sge_qeti_allocate2(cr_list); /* sge_qeti_first() */ for (pe_time = sge_qeti_first(iter), i=0; pe_time; pe_time = sge_qeti_next(iter), i++) { if (qeti_expected_result == NULL) { printf("failed: qeti returned "sge_U32CFormat", expected no iteration\n", sge_u32c(pe_time)); ret++; } else if (qeti_expected_result[i] != pe_time) { printf("failed: qeti returned "sge_U32CFormat", expected "sge_U32CFormat"\n", sge_u32c(pe_time), sge_u32c(qeti_expected_result[i])); ret++; } else { printf("success: QETI returned "sge_U32CFormat"\n", sge_u32c(pe_time)); } } lDechainElem(cr_list, cr); sge_qeti_release(&iter); lFreeList(&cr_list); return ret; }
sge_callback_result job_schedd_info_update_master_list(sge_evc_class_t *evc, object_description *object_base, sge_object_type type, sge_event_action action, lListElem *event, void *clientdata) { lList **list = NULL; const lDescr *list_descr = NULL; lList *data_list; lListElem *ep = NULL; DENTER(TOP_LAYER, "job_schedd_info_update_master_list"); list = sge_master_list(object_base, type); list_descr = lGetListDescr(lGetList(event, ET_new_version)); /* We always update the whole list (consisting of one list element) */ lFreeList(list); if((data_list = lGetList(event, ET_new_version)) != NULL) { if((ep = lFirst(data_list)) != NULL) { ep = lDechainElem(data_list, ep); } } /* if neccessary, create list and copy schedd info */ if(ep != NULL) { *list = lCreateList("job schedd info", list_descr); lAppendElem(*list, ep); } DEXIT; return SGE_EMA_OK; }
/****** sgeobj/var/var_list_split_prefix_vars() ******************************* * NAME * var_list_split_prefix_vars() -- split a list of variables * * SYNOPSIS * void var_list_split_prefix_vars(lList **varl, * lList **pefix_vars, * const char *prefix) * * FUNCTION * Move all variable elements form "varl" to "pefix_vars" which * begin with "prefix". *pefix_vars will be created if is does not * exist. * * INPUTS * lList **varl - VA_Type list * lList **pefix_vars - pointer to VA_Type list * const char *prefix - string (e.g. VAR_PREFIX) * * RESULT * void - None * * SEE ALSO * sgeobj/var/var_list_remove_prefix_vars() ******************************************************************************/ void var_list_split_prefix_vars(lList **varl, lList **pefix_vars, const char *prefix) { int prefix_len = strlen(prefix); lListElem *var_elem = NULL; lListElem *next_var_elem = NULL; DENTER(TOP_LAYER, "var_list_remove_prefix_vars"); next_var_elem = lFirst(*varl); while((var_elem = next_var_elem)) { const char *prefix_name = lGetString(var_elem, VA_variable); next_var_elem = lNext(var_elem); if (!strncmp(prefix_name, prefix, prefix_len)) { lListElem *dechained_elem = lDechainElem(*varl, var_elem); if (*pefix_vars == NULL) { *pefix_vars = lCreateList("", VA_Type); } lAppendElem(*pefix_vars, dechained_elem); } } DEXIT; return; }
int sge_read_sched_configuration(sge_gdi_ctx_class_t *ctx, lListElem *aSpoolContext, lList **anAnswer) { lList *sched_conf = NULL; bool job_spooling = ctx->get_job_spooling(ctx); DENTER(TOP_LAYER, "sge_read_sched_configuration"); spool_read_list(anAnswer, aSpoolContext, &sched_conf, SGE_TYPE_SCHEDD_CONF); if (lGetNumberOfElem(sched_conf) == 0) { lListElem *ep = sconf_create_default(); if (sched_conf == NULL) { sched_conf = lCreateList("schedd_config_list", SC_Type); } lAppendElem(sched_conf, ep); spool_write_object(anAnswer, spool_get_default_context(), ep, "schedd_conf", SGE_TYPE_SCHEDD_CONF, job_spooling); } if (!sconf_set_config(&sched_conf, anAnswer)) { lFreeList(&sched_conf); DEXIT; return -1; } check_reprioritize_interval(ctx, anAnswer, "local" , "local"); DEXIT; return 0; }
/*-------------------------------------------------------------------------*/ lList* qmonGetCE_Type( Widget w ) { lList *lp = NULL; lListElem *ep; int row; int max_rows; char *ce_entry[CE_MAX]; int k; DENTER(GUI_LAYER, "qmonGetCE_Type"); XtVaGetValues(w, XmNrows, &max_rows, NULL); lp = lCreateList(XtName(w), CE_Type); for (row=0; row<max_rows && lp; row++) { for (k=0; k<CE_MAX; k++) ce_entry[k] = XbaeMatrixGetCell(w, row, k); if (ce_entry[CE_NAME] && ce_entry[CE_NAME][0] != '\0') { ep = lCreateElem(CE_Type); setCE_TypeValues(ep, ce_entry); lAppendElem(lp, ep); } else break; } DEXIT; return lp; }
void xml_addAttribute(lListElem *xml_elem, const char *name, const char *value) { lListElem *attr_elem = lCreateElem(XMLA_Type); lList *attr_list = NULL; dstring mod_value = DSTRING_INIT; bool is_mod_value; DENTER(CULL_LAYER, "xml_addAttribute"); is_mod_value = escape_string(value, &mod_value); if (attr_elem) { lSetString(attr_elem, XMLA_Name, name); lSetString(attr_elem, XMLA_Value, (is_mod_value?sge_dstring_get_string(&mod_value):"")); if (lGetPosViaElem(xml_elem, XMLH_Attribute, SGE_NO_ABORT) != -1) { attr_list = lGetList(xml_elem, XMLH_Attribute); if (!attr_list) lSetList(xml_elem, XMLH_Attribute, (attr_list = lCreateList("Attributes", XMLA_Type))); } else if (lGetPosViaElem(xml_elem, XMLE_Attribute, SGE_NO_ABORT) != -1) { attr_list = lGetList(xml_elem, XMLE_Attribute); if (!attr_list) lSetList(xml_elem, XMLE_Attribute, (attr_list = lCreateList("Attributes", XMLA_Type))); } else { sge_dstring_free(&mod_value); CRITICAL((SGE_EVENT, "xml_addAttribute() called on wrong cull structure")); DEXIT; abort(); } lAppendElem(attr_list, attr_elem); } sge_dstring_free(&mod_value); DEXIT; return; }
lList *buildComplexNameListB(void) { lList *complexnamelist = NULL; lListElem *complexname; complexnamelist = lCreateList("complexnamelistB", ComplexNameT); complexname = lCreateElem(ComplexNameT); lSetString(complexname, N_complexname, "default"); lAppendElem(complexnamelist, complexname); complexname = lCreateElem(ComplexNameT); lSetString(complexname, N_complexname, "hardware"); lAppendElem(complexnamelist, complexname); return complexnamelist; }
/****** test_category/test_create_access() ************************************* * NAME * test_create_access() -- creates an access list from AccessList * * SYNOPSIS * lList* test_create_access() * * RESULT * lList* - NULL or valid acces list * * NOTES * MT-NOTE: test_create_access() is not MT safe * *******************************************************************************/ static lList *test_create_access(void) { lList *access_list = NULL; access_list = lCreateList("access", US_Type); if (access_list != NULL) { int i; for (i = 0; AccessList[i] != NULL; i++) { char *access_cp = NULL; char *access_str = NULL; char *iter_dash = NULL; access_cp = strdup(AccessList[i]); for (access_str = strtok_r(access_cp, " ", &iter_dash); access_str; access_str = strtok_r(NULL, " ", &iter_dash)) { lListElem *acc_elem = NULL; acc_elem = lCreateElem(US_Type); if (acc_elem != NULL) { lList *users = lCreateList("user", UE_Type); lSetString(acc_elem, US_name, access_str); lSetList(acc_elem, US_entries, users); lSetBool(acc_elem, US_consider_with_categories, true); lAppendElem(access_list, acc_elem); for (access_str = strtok_r(NULL, " ", &iter_dash); access_str; access_str = strtok_r(NULL, " ", &iter_dash)) { lListElem *user = lCreateElem(UE_Type); lSetString(user, UE_name, access_str); lAppendElem(users, user); } } } if (access_cp != NULL) { sge_free(&access_cp); } } } return access_list; }
lList *buildComplexList(void) { lList *complexlist = NULL; lListElem *complex; /* It is better to test every list for its existence (list != NULL) */ complexlist = lCreateList("complexlist", ComplexT); complex = lCreateElem(ComplexT); lSetString(complex, C_name, "default"); lSetList(complex, C_attribute, readComplexFile("default")); lAppendElem(complexlist, complex); complex = lCreateElem(ComplexT); lSetString(complex, C_name, "software"); lSetList(complex, C_attribute, readComplexFile("software")); lAppendElem(complexlist, complex); return complexlist; }
/* ** operator lList* ** ** Wandelt das HostSet in eine Cull-Liste um. ** HINWEIS: Die zurückgegebene Cull-Liste muß von der aufrufenden Funktion ** gelöscht werden! */ CHostSet::operator lList* () { lList *lp = lCreateList("hosts", EH_Type); ASSERT(NULL != lp); lListElem *ep; for (CHostList::iterator Iterator = m_Hosts.begin(); Iterator != m_Hosts.end(); Iterator++) { ep = (lListElem *) *Iterator; ASSERT(NULL != ep); lAppendElem(lp, ep); } return lp; }
/****** sgeobj/var/var_list_add_as_set() *************************************** * NAME * var_list_add_as_set() -- Concatenate two lists as sets * * SYNOPSIS * int var_list_add_as_set(lList *lp0, lList *lp1) * * FUNCTION * Concatenate two lists of equal type throwing away the second list. * Elements in the second list will replace elements with the same key in the * the first list. If the first list contains duplicate element keys, only * the first element with a given key will be replaced by an element from the * second list with the same key. * * INPUTS * lList *lp0 - first list * lList *lp1 - second list * * RESULT * int - error state * 0 - OK * -1 - Error ******************************************************************************/ int var_list_add_as_set(lList *lp0, lList *lp1) { lListElem *ep0, *ep1; const lDescr *dp0, *dp1; const char *name, *value; DENTER(CULL_LAYER, "var_list_add_as_set"); if (lp1 == NULL || lp0 == NULL) { DRETURN(-1); } /* Check if the two lists are equal */ dp0 = lGetListDescr(lp0); dp1 = lGetListDescr(lp1); if (lCompListDescr(dp0, dp1) != 0) { DRETURN(-1); } while (lp1->first != NULL) { /* Get the first element from the second list */ if ((ep1 = lDechainElem(lp1, lp1->first)) == NULL) { DRETURN(-1); } /* Get it's name, and use the name to look for a matching element in the * first list. */ name = lGetString(ep1, VA_variable); ep0 = lGetElemStr(lp0, VA_variable, name); /* If there is a matching element in the first list, set it's value to the * value of the element from the second list. */ if (ep0 != NULL) { value = lGetString(ep1, VA_value); lSetString(ep0, VA_value, value); lFreeElem(&ep1); } /* If there is no matching element, add the element from the second list * to the first list. */ else { if (lAppendElem(lp0, ep1) == -1) { DRETURN(-1); } } } /* The second list is no longer needed. */ lFreeList(&lp1); DRETURN(0); }
/****** cull/db/lSplit() ****************************************************** * NAME * lSplit() -- Splits a list into two list * * SYNOPSIS * int lSplit(lList **slp, lList **ulp, const char *ulp_name, * const lCondition *cp) * * FUNCTION * Unchains the list elements from the list 'slp' NOT fullfilling * the condition 'cp' and returns a list containing the * unchained elements in 'ulp' * * INPUTS * lList **slp - source list pointer * lList **ulp - unchained list pointer * const char *ulp_name - 'ulp' list name * const lCondition *cp - selects rows within 'slp' * * RESULT * int - error status * 0 - OK * -1 - Error ******************************************************************************/ int lSplit(lList **slp, lList **ulp, const char *ulp_name, const lCondition *cp) { lListElem *ep, *next; int has_been_allocated = 0; DENTER(TOP_LAYER, "lSplit"); /* iterate through the source list call lCompare and chain all elems that don't fullfill the condition into a new list. */ if (!slp) { DEXIT; return -1; } for (ep = lFirst(*slp); ep; ep = next) { next = ep->next; /* this is important, cause the elem is dechained */ if (!lCompare(ep, cp)) { if (ulp && !*ulp) { *ulp = lCreateList(ulp_name ? ulp_name : "ulp", (*slp)->descr); if (!*ulp) { DEXIT; return -1; } has_been_allocated = 1; } if (ulp) { ep = lDechainElem(*slp, ep); lAppendElem(*ulp, ep); } else { lRemoveElem(*slp, &ep); } } } /* if no elements remain, free the list and return NULL */ if (*slp && lGetNumberOfElem(*slp) == 0) { lFreeList(slp); } if (has_been_allocated && *ulp && lGetNumberOfElem(*ulp) == 0) { lFreeList(ulp); } DEXIT; return 0; }
/************************************************************ sge_mod_sched_configuration - Master code Modify scheduler configuration. We have only one entry in Master_Sched_Config_List. So we replace it with the new one. ************************************************************/ int sge_mod_sched_configuration( sge_gdi_ctx_class_t *ctx, lListElem *confp, lList **alpp, char *ruser, char *rhost ) { lList *temp_conf_list = NULL; DENTER(TOP_LAYER, "sge_mod_sched_configuration"); if ( !confp || !ruser || !rhost ) { CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC)); answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR); DEXIT; return STATUS_EUNKNOWN; } temp_conf_list = lCreateList("sched config", SC_Type); lSetUlong(confp, SC_weight_tickets_override, sconf_get_weight_tickets_override()); confp = lCopyElem(confp); lAppendElem(temp_conf_list, confp); /* just check and log */ if (!sconf_set_config(&temp_conf_list, alpp)) { lFreeList(&temp_conf_list); DEXIT; return STATUS_EUNKNOWN; } if (!sge_event_spool(ctx, alpp, 0, sgeE_SCHED_CONF, 0, 0, "schedd_conf", NULL, NULL, confp, NULL, NULL, true, true)) { answer_list_add(alpp, MSG_SCHEDCONF_CANTCREATESCHEDULERCONFIGURATION, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR); DEXIT; return -1; } check_reprioritize_interval(ctx, alpp, ruser, rhost); INFO((SGE_EVENT, MSG_SGETEXT_MODIFIEDINLIST_SSSS, ruser, rhost, "scheduler", "scheduler configuration")); answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO); DEXIT; return STATUS_OK; } /* sge_mod_sched_configuration */
void xml_addStylesheet(lListElem *xml_head, const char* name, const char *url, const char *version) { lListElem *stylesheet_elem = lCreateElem(XMLS_Type); lList *stylesheet_list = NULL; if (stylesheet_elem) { lSetString(stylesheet_elem, XMLS_Name, name); lSetString(stylesheet_elem, XMLS_Value, url); lSetString(stylesheet_elem, XMLS_Version, version); stylesheet_list = lGetList(xml_head, XMLH_Stylesheet); if (!stylesheet_list) lSetList(xml_head, XMLH_Stylesheet, (stylesheet_list = lCreateList("Stylesheet", XMLS_Type))); lAppendElem(stylesheet_list, stylesheet_elem); } }
/****** sge_complex_schedd/get_attribute_list_by_names() *********************** * NAME * get_attribute_list_by_names() -- generates a list of attributes from the given names * * SYNOPSIS * static lList* get_attribute_list_by_names(lListElem *global, lListElem * *host, lListElem *queue, lList *centry_list, lList *attrnames) * * FUNCTION * Assembles a list of attributes for a given queue, host, global, which contains all * the specified elements. The general sort order is, global, host, queue. If an * element could not be found, it will not exist. If no elements exist, the function * will return NULL * * INPUTS * lListElem *global - global host * lListElem *host - host (or NULL, if only global resources are asked for ) * lListElem *queue - queue (or NULL, if only global / host resources are asked for) * lList *centry_list - the system wide attribut config list * lList *attrnames - ST_Type list of attribute names * * RESULT * static lList* - a CULL list of elements or NULL * *******************************************************************************/ static lList *get_attribute_list_by_names(lListElem *global, lListElem *host, lListElem *queue, const lList *centry_list, lList *attrnames) { lListElem *attr, *elem; lList *list = NULL; for_each(elem, attrnames) { attr = get_attribute_by_name(global, host, queue, lGetString(elem, ST_name), centry_list, DISPATCH_TIME_NOW, 0); if (attr) { if (!list ) list = lCreateList("attr", CE_Type); lAppendElem(list, attr); } }
lList *buildQueueList(void) { lList *queuelist = NULL; lListElem *element; queuelist = lCreateList("queuelist", QueueT); element = lCreateElem(QueueT); lSetString(element, Q_name, "balin.q"); lSetList(element, Q_complexname, buildComplexNameListA()); lAppendElem(queuelist, element); element = lCreateElem(QueueT); lSetString(element, Q_name, "durin.q"); lSetList(element, Q_complexname, buildComplexNameListB()); lAppendElem(queuelist, element); element = lCreateElem(QueueT); lSetString(element, Q_name, "gloin.q"); lSetList(element, Q_complexname, buildComplexNameListC()); lAppendElem(queuelist, element); return queuelist; }
static bool cqueue_add_qinstances(sge_gdi_ctx_class_t *ctx, lListElem *cqueue, lList **answer_list, lList *add_hosts, monitoring_t *monitor) { bool ret = true; DENTER(TOP_LAYER, "cqueue_add_qinstances"); if (cqueue != NULL && add_hosts != NULL) { lListElem *href = NULL; for_each(href, add_hosts) { const char *hostname = lGetHost(href, HR_name); lList *list = lGetList(cqueue, CQ_qinstances); lListElem* qinstance = lGetElemHost(list, QU_qhostname, hostname); if (qinstance != NULL) { if (qinstance_state_is_orphaned(qinstance)) { sge_qmaster_qinstance_state_set_orphaned(qinstance, false); lSetUlong(qinstance, QU_tag, SGE_QI_TAG_MOD); } else { /* * We might already have this QI if it is in orphaned state. * If this is not true, than there is a bug! */ ERROR((SGE_EVENT, MSG_QINSTANCE_QIALREADYHERE_S, hostname)); answer_list_add(answer_list, SGE_EVENT, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR); } } else { bool is_ambiguous = false; if (list == NULL) { list = lCreateList("", QU_Type); lSetList(cqueue, CQ_qinstances, list); } qinstance = qinstance_create(ctx, cqueue, answer_list, hostname, &is_ambiguous, monitor); if (is_ambiguous) { DPRINTF(("qinstance %s has ambiguous conf\n", hostname)); } lSetUlong(qinstance, QU_tag, SGE_QI_TAG_ADD); lAppendElem(list, qinstance); } } }
lList *readComplexFile( char *complexname ) { FILE *calf; /* complex attribute list file */ char name[MAX_STRINGLENGTH]; char value[MAX_STRINGLENGTH]; char listname[MAX_STRINGLENGTH]; char filename[MAX_STRINGLENGTH]; char *s; int result; lList *calp = NULL; /* complex attribute list ptr */ lListElem *calep; /* complex attribute list element pointer */ strcpy(filename, DATA_DIR); strcat(filename, complexname); strcat(filename, ".cplx"); if (!(calf = fopen(filename, "r"))) { printf("readComplexFile(): unable to read from file: %s\n", filename); exit(-1); } while ((result = fscanf(calf, "%s %s", name, value)) != EOF) { if (result != 2) { printf("readComplexFile: wrong format in complexfile %s\n", filename); exit(-1); } if (!calp) { s = strrchr(filename, '/'); sprintf(listname, "ComplexAttributes_from_%s", s ? s + 1 : filename); calp = lCreateList(filename, ComplexAttributeT); } calep = lCreateElem(ComplexAttributeT); lSetString(calep, A_name, name); lSetString(calep, A_value, value); lAppendElem(calp, calep); } /* lWriteList(calp); */ return calp; }
int schedd_log_list(lList **monitor_alpp, bool monitor_next_run, const char *logstr, lList *lp, int nm) { int fields[] = { 0, 0 }; const char *delis[] = {NULL, " ", NULL}; lList *lp_part = NULL; lListElem *ep = NULL; DENTER(TOP_LAYER, "schedd_log_list"); #ifndef WIN32NATIVE if (monitor_alpp == NULL && !monitor_next_run) { DRETURN(0); } fields[0] = nm; for_each(ep, lp) { if (!lp_part) { lp_part = lCreateList("partial list", lGetListDescr(lp)); } lAppendElem(lp_part, lCopyElem(ep)); if ((lGetNumberOfElem(lp_part) == NUM_ITEMS_ON_LINE) || !lNext(ep)) { char log_string[2048]; sge_strlcpy(log_string, logstr, sizeof(log_string)); #ifndef WIN32NATIVE uni_print_list(NULL, log_string + strlen(log_string), sizeof(log_string) - strlen(log_string) - 1, lp_part, fields, delis, 0); #endif schedd_log(log_string, monitor_alpp, monitor_next_run); lFreeList(&lp_part); lp_part = NULL; } } #else DPRINTF(("schedd_log_list does nothing for QMonNT !!!\n")); #endif DEXIT; return 0; }
/* * Class: com_sun_grid_proxy_SGEAdapter * Method: submitJob * Signature: (Lcom/sun/grid/Job;)Ljava/lang/Object; */ JNIEXPORT void JNICALL Java_com_sun_grid_proxy_SGEAdapter_submitJob (JNIEnv* env, jobject thisObj, jstring skel, jstring jobId) { char error_header[256]; lListElem* job = NULL; lList* answer = NULL; /* create list of JB_Type with 1 element */ jobs = lCreateElemList("JGrid Job", JB_Type, 1); /* set job to defaults */ answer = cull_parse_job_parameter (NULL, &job); lAppendElem(jobs, job); /* submit (add) the job */ answer = sge_gdi(SGE_JOB_LIST, SGE_GDI_ADD | SGE_GDI_RETURN_NEW_VERSION, &jobs, NULL, NULL); // printf("================ SUBMITTED JOB ================\n"); // lWriteListTo(jobs, stdout); // printf("================ END of JOB LIST ================\n"); sprintf(error_header, "failed to submit job \"%s\" :", name); check_answer_status(env, answer, "nativeSubmitJob", error_header); if(env->ExceptionCheck() == JNI_TRUE) { delete sgeJob; return; } sgeJob->freeSGEVars(); sgeJob->resolveId(); if(env->ExceptionCheck() == JNI_TRUE) { delete sgeJob; return; } int job_id = sgeJob->getId(); delete sgeJob; int ret = 0; ret = callSetIntMethod(env, job, "setID", job_id); if(!ret) throw_exception(env, "Update job id failed : error executing setID method."); }
lList *buildJobList(int num) { lList *joblist = NULL; lListElem *job; int n; char name[20]; joblist = lCreateList("joblist", JobT); for (n = 0; n < num; n++) { sprintf(name, "Job%d", n); job = lCreateElem(JobT); lSetUlong(job, J_id, n); lSetString(job, J_name, name); lSetList(job, J_hardrequest, buildRequestList(n)); lAppendElem(joblist, job); } return joblist; }
/****** sge_orders/sge_create_orders() ***************************************** * NAME * sge_create_orders() -- Create a new order-list or add orders to an existing one * * SYNOPSIS * lList* sge_create_orders(lList *or_list, u_long32 type, lListElem *job, * lListElem *ja_task, lList *granted, bool update_execd) * * FUNCTION * - If the or_list is NULL, a new one will be generated * * - in case of a clear_pri order, teh ja_task is improtant. If NULL is put * in for ja_task, only the pendin tasks of the spedified job are set to NULL. * If a ja_task is put in, all tasks of the job are set to NULL * * INPUTS * lList *or_list - the order list * u_long32 type - order type * lListElem *job - job * lListElem *ja_task - ja_task ref or NULL(there is only one case, where it can be NULL) * lList *granted - granted queue list * bool update_execd - should the execd get new ticket values? * * RESULT * lList* - returns the orderlist * * NOTES * MT-NOTE: sge_create_orders() is MT safe * * SEE ALSO * ???/??? *******************************************************************************/ lList *sge_create_orders(lList *or_list, u_long32 type, lListElem *job, lListElem *ja_task, lList *granted , bool update_execd) { lList *ql = NULL; lListElem *gel, *ep, *ep2; u_long32 qslots; DENTER(TOP_LAYER, "sge_create_orders"); if (!job) { lFreeList(&or_list); DEXIT; return or_list; } /* create orders list if not existent */ if (!or_list) { or_list = lCreateList("orderlist", OR_Type); } /* build sublist of granted */ if (update_execd) { for_each(gel, granted) { qslots = lGetUlong(gel, JG_slots); if (qslots) { /* ignore Qs with slots==0 */ ep2=lCreateElem(OQ_Type); lSetUlong(ep2, OQ_slots, qslots); lSetString(ep2, OQ_dest_queue, lGetString(gel, JG_qname)); lSetUlong(ep2, OQ_dest_version, lGetUlong(gel, JG_qversion)); lSetDouble(ep2, OQ_ticket, lGetDouble(gel, JG_ticket)); lSetDouble(ep2, OQ_oticket, lGetDouble(gel, JG_oticket)); lSetDouble(ep2, OQ_fticket, lGetDouble(gel, JG_fticket)); lSetDouble(ep2, OQ_sticket, lGetDouble(gel, JG_sticket)); if (!ql) ql=lCreateList("orderlist",OQ_Type); lAppendElem(ql, ep2); } } }
/****** test_category/test_create_request() ************************************ * NAME * test_create_request() -- creats a request list from the request string * * SYNOPSIS * lList* test_create_request(const char *requestStr, int count) * * INPUTS * const char *requestStr - request string * int count - how many times the request string should be used * (multiplyer, needs to between 1 and ...) * * RESULT * lList* - NULL or request list * * NOTES * MT-NOTE: test_create_request() is MT safe * *******************************************************************************/ static lList *test_create_request(const char *requestStr, int count) { lList *requests = NULL; char *request_cp = NULL; char *iter_dash = NULL; requests = lCreateList("requests", CE_Type); if (requests != NULL) { int i; for (i = 0; i < count; i++) { char *request_str; request_cp = strdup(requestStr); for (request_str = strtok_r(request_cp, " ", &iter_dash); request_str; request_str = strtok_r(NULL, " ", &iter_dash)) { lListElem *request = NULL; request = lCreateElem(CE_Type); if (request != NULL) { lSetString(request, CE_name, request_str); lSetString(request, CE_stringval, strtok_r(NULL, " ", &iter_dash)); } else { lFreeList(&requests); goto end; } lAppendElem(requests, request); } if (request_cp != NULL) { sge_free(&request_cp); } } } end: if (request_cp != NULL) { sge_free(&request_cp); } return requests; }
bool cuser_add_del_mod_via_gdi(sge_gdi_ctx_class_t *ctx, lListElem *this_elem, lList **answer_list, u_long32 gdi_command) { bool ret = false; DENTER(TOP_LAYER, "cuser_add_del_mod_via_gdi"); if (this_elem != NULL) { lList *cuser_list = NULL; lList *gdi_answer_list = NULL; cuser_list = lCreateList("", CU_Type); lAppendElem(cuser_list, this_elem); gdi_answer_list = ctx->gdi(ctx, SGE_USER_MAPPING_LIST, gdi_command, &cuser_list, NULL, NULL); answer_list_replace(answer_list, &gdi_answer_list); } DRETURN(ret); }
/****** test_category/test_create_queue() ************************************** * NAME * test_create_queue() -- creates a request queue list from the queue string * * SYNOPSIS * lList* test_create_queue(const char *queueStr, int count) * * INPUTS * const char *queueStr - the queue string used as a bases * int count - how many times the request string should be used * (multiplyer, needs to between 1 and ...) * * RESULT * lList* - NULL or valid queue request list * * NOTES * MT-NOTE: test_create_queue() is MT safe * *******************************************************************************/ static lList *test_create_queue(const char *queueStr, int count) { lList *queues = NULL; char *queue_cp = NULL; char *iter_dash = NULL; queues = lCreateList("queues", QR_Type); if (queues != NULL) { int i; for (i = 0; i < count; i++) { char *queues_str; queue_cp = strdup(queueStr); for (queues_str = strtok_r(queue_cp, " ", &iter_dash); queues_str; queues_str = strtok_r(NULL, " ", &iter_dash)) { lListElem *queue = NULL; queue = lCreateElem(QR_Type); if (queue != NULL) { lSetString(queue, QR_name, queues_str); } else { lFreeList(&queues); goto end; } lAppendElem(queues, queue); } if (queue_cp != NULL) { sge_free(&queue_cp); } } } end: if (queue_cp != NULL) { sge_free(&queue_cp); } return queues; }
/****** sge_usage/usage_list_sum() ********************************************* * NAME * usage_list_sum() -- sum up usage of two lists * * SYNOPSIS * void * usage_list_sum(lList *usage_list, const lList *add_usage_list) * * FUNCTION * Add the usage reported in add_usage_list to usage_list. * Summing up of usage will only be done for certain attributes: * - cpu * - io * - iow * - mem * - vmem * - maxvmem * - all ru_* attributes (see man getrusage.2) * * INPUTS * lList *usage_list - the usage list to contain all usage * const lList *add_usage_list - usage to add to usage_list * * NOTES * MT-NOTE: usage_list_sum() is MT safe *******************************************************************************/ void usage_list_sum(lList *usage_list, const lList *add_usage_list) { const lListElem *usage; for_each(usage, add_usage_list) { const char *name = lGetString(usage, UA_name); /* Sum up all usage attributes. */ if (strcmp(name, USAGE_ATTR_CPU) == 0 || strcmp(name, USAGE_ATTR_IO) == 0 || strcmp(name, USAGE_ATTR_IOW) == 0 || strcmp(name, USAGE_ATTR_VMEM) == 0 || strcmp(name, USAGE_ATTR_MEM) == 0 || strncmp(name, "acct_", 5) == 0 || strncmp(name, "ru_", 3) == 0) { lListElem *sum = lGetElemStr(usage_list, UA_name, name); if (sum == NULL) { lAppendElem(usage_list, lCopyElem(usage)); } else { lAddDouble(sum, UA_value, lGetDouble(usage, UA_value)); } } } }