⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getconfig.c

📁 openPBS的开放源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	    DBPRT(("%s\n", log_buffer));	    return (0);	}        if (schd_PT_WALLT_LIMIT <= 0) {            (void)sprintf(log_buffer,                 "ENFORCE_PRIME_TIME set but no PRIME_TIME_WALLT_LIMIT given.");            log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);            DBPRT(("%s\n", log_buffer));            return (0);        }    }    DBPRT(("%s: verify that queue sets are disjoint\n", id));    if (!qlist_disjoint(schd_SubmitQueue, schd_BatchQueues)) {	(void)sprintf(log_buffer, 	    "SUBMIT_QUEUE %s cannot be listed in BATCH_QUEUES.%s",		schd_SubmitQueue->queue->qname, xit);	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	DBPRT(("%s\n", log_buffer));	return (0);    }    DBPRT(("%s: verify fair share settings\n", id));    if (!verify_fairshare()) {	return (0);    }    DBPRT(("%s: Scheduler configuration appears valid.\n", id));    return (1);}/* print_config(): Dump the current config to the log */static voidprint_config(void){    char   *id = "print_config";    QueueList *qptr;    if (schd_SubmitQueue) {	(void)sprintf(log_buffer, "%-24s = %s@%s", "SUBMIT_QUEUE",	    schd_SubmitQueue->queue->qname, schd_SubmitQueue->queue->exechost);	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    }    if (schd_EXPRESS_Q_NAME[0] != '\0') {	(void)sprintf(log_buffer, "%-24s = %s@%s", "EXPRESS_QUEUE",	    schd_EXPRESS_Q_NAME, schd_SubmitQueue->queue->exechost);	log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    }    if (schd_BatchQueues) {	for (qptr = schd_BatchQueues; qptr != NULL; qptr = qptr->next) {	    (void)sprintf(log_buffer, "%-24s = %s@%s", 		(qptr == schd_BatchQueues) ? "BATCH_QUEUES" : "",		qptr->queue->qname, qptr->queue->exechost);	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	}    }    (void)sprintf(log_buffer, "%-24s = %s", "ENFORCE_PRIME_TIME",	schd_booltime2val(schd_ENFORCE_PRIME_TIME));    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %s", "PRIME_TIME_WALLT_LIMIT",         schd_sec2val(schd_PT_WALLT_LIMIT));    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %s", "PRIME_TIME_START",	schd_sec2val(schd_PRIME_TIME_START));    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %s", "PRIME_TIME_END",	schd_sec2val(schd_PRIME_TIME_END));    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %d%%", "TARGET_LOAD_PCT",	schd_TARGET_LOAD_PCT);    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = -%d%%,+%d%%", "TARGET_LOAD_VARIANCE",	schd_TARGET_LOAD_MINUS, schd_TARGET_LOAD_PLUS);    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %d%%", "SUSPEND_THRESHOLD",	schd_SUSPEND_THRESHOLD);    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %d%%", "FORCE_REQUEUE",	schd_FORCE_REQUEUE);    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %s", "SCHED_HOST",	schd_SCHED_HOST ? schd_SCHED_HOST : "[null]");    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    (void)sprintf(log_buffer, "%-24s = %s", "SCHED_RESTART_ACTION",	(schd_SCHED_RESTART_ACTION == SCHD_RESTART_NONE ? "NONE" : 	(schd_SCHED_RESTART_ACTION == SCHD_RESTART_RESUBMIT ? "RESUBMIT" :	(schd_SCHED_RESTART_ACTION == SCHD_RESTART_RERUN ? "RERUN" : "?"))));    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    if (schd_JOB_DUMPFILE) {        (void)sprintf(log_buffer, "%-24s = %s", "SORTED_JOB_DUMPFILE",	    schd_JOB_DUMPFILE);        log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);    }    schd_print_fairshare();}static int arg_to_qlist(char *arg, char *sep, QueueList **qlist_ptr){    char	*id = "arg_to_qlist";    QueueList  *qptr = NULL, *new;    int     num = 0;    char   *name, *exechost;#if 0    /* canonalization disabled per P.Wright @ MSIC */    char canon[PBS_MAXHOSTNAME + 1];#endif    /*     * Multiple lines may be used to add queues to the queue list.  Find     * the tail of the passed-in list (if there is one), and assign the     * qptr to the tail element.  Later, the new element will be hung off     * qptr's next field (or qptr will be set to it.)     */    if (*qlist_ptr) {	for (qptr = *qlist_ptr; qptr->next != NULL; qptr = qptr->next)	    /* Walk the list, looking for last element. */;    } else {	qptr = NULL;    }    for (name = strtok(arg, sep); name != NULL; name = strtok(NULL, sep)) {	/* 	 * If the list is NULL, create the first element and point qptr	 * at it.  If not, take the qptr from the last iteration (which	 * will be the head the second time through) and place a new	 * element on its next pointer.  Then replace qptr with the	 * address of the newly allocated struct.	 */		new = (QueueList *)malloc(sizeof (QueueList));	if (new == NULL) {	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,		"malloc(newQueue)");	    goto error_in_list;	}	memset(new, 0, sizeof (QueueList));	if (qptr == NULL) {	    *qlist_ptr = new;	    qptr = *qlist_ptr;	} else {	    qptr->next = new;	    qptr = new;	}	new->queue = (Queue *)malloc(sizeof (Queue));	if (new->queue == NULL) {	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,		"malloc(newQueue->queue)");	    goto error_in_list;	}	memset(new->queue, 0, sizeof (Queue));	/*	 * Queue names may be either 'queue3' or 'queue3@exechost'.	 * If there is a '@', convert it to a '\0' and copy the two	 * halves of the string into the qname and exechost fields.	 * Otherwise, this queue is local to this host - paste in the	 * "local" hostname.	 */	if ((exechost = strchr(name, '@')) != NULL) {	    /* Parse queue@host into queue and hostname. */	    *exechost = '\0';		/* '@' ==> '\0' to terminate qname   */	    exechost ++;		/* Next character after the new '\0' */#if 0/* Disable canonicalization per Pat Wright at MSIC */	    if (get_fullhostname(exechost, canon, PBS_MAXHOSTNAME) == 0) {		exechost = canon;	/* Point at canonical name. */	    } else {		sprintf(log_buffer, "Warning: Cannot canonicalize queue %s@%s",		    name, exechost);		log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, 		    log_buffer);		DBPRT(("%s: %s\n", id, log_buffer));	    }#endif	} else {	    exechost = schd_ThisHost;	/* Queue lives on localhost. */	}	new->queue->qname = schd_strdup(name);	if (new->queue->qname == NULL) {	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,		"schd_strdup(qname)");	    goto error_in_list;	}	new->queue->exechost = schd_strdup(exechost);	if (new->queue->exechost == NULL) {	    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,		"schd_strdup(exechost)");	    goto error_in_list;	}	num++;    }    return (0);error_in_list:    /* Something went wrong - delete the new list and return a fatal error. */    if (*qlist_ptr) {	schd_destroy_qlist(*qlist_ptr);	*qlist_ptr = NULL;    }    return (-1);}static intqlist_disjoint(QueueList *qlist1, QueueList *qlist2){    QueueList *q1, *q2;    /*     * If both pointers are NULL, or they point to the same list, then     * they are obviously not disjoint sets.     */    if (qlist1 == qlist2)	return (0);    /*     * If any element of one list cannot be found in any element of the     * other list, than the sets are disjoint.  Walk the first list, and     * search for the queue on the second list.  If not found, then they     * are disjoint.     */    for (q1 = qlist1; q1 != NULL; q1 = q1->next) {	for (q2 = qlist2; q2 != NULL; q2 = q2->next)	    /* Check the name, then break ties with exechost. */	    if ((strcmp(q1->queue->qname, q2->queue->qname) == 0) &&	        (strcmp(q1->queue->exechost, q2->queue->exechost) == 0))	    {		break;	    }	if (q2 == NULL)	    return (1);    }    /*     * Walk the second list, searching for the named queue on the first     * list.  If not found, then they are disjoint.     */    for (q1 = qlist1; q1 != NULL; q1 = q1->next) {	for (q2 = qlist2; q2 != NULL; q2 = q2->next)	    /* Make sure both the name and execution host match. */	    if ((strcmp(q1->queue->qname, q2->queue->qname) == 0) &&	        (strcmp(q1->queue->exechost, q2->queue->exechost) == 0))	    {		break;	    }	if (q2 == NULL)	    return (1);    }    /*     * Both lists contain the same set of (possibly repeated) elements.     * They are not disjoint.     */    return (0);}static intqlist_unique(QueueList *qlist){    QueueList *q1, *q2;    /* No member of the empty set is repeated. */    if (qlist == NULL)	return (1);    /* A list with only 1 element cannot have repeated elements. */    if (qlist->next == NULL)	return (1);    /*     * For each element in the list, see if any other element in the list     * matches its queue name.  If so, the members of the set are not unique.     */    for (q1 = qlist; q1 != NULL; q1 = q1->next)	for (q2 = qlist; q2 != NULL; q2 = q2->next) {	    /* Is this the *same pointer* (not the same name)? */	    if (q1 == q2)		continue;	    	    /* 	     * If the queues match, then the list members are not unique.	     * Make sure both the name and execution host match.	     */	    if ((strcmp(q1->queue->qname, q2->queue->qname) == 0) &&	        (strcmp(q1->queue->exechost, q2->queue->exechost) == 0))	    {		return (0);	    }	}    /* No repeated elements found in the list -- it is unique. */    return (1);}static intget_variance(char *string, int *lowp, int *highp){/*    char   *id = "get_variance"; */    char   *ptr, *buf, *end, sign;    long    n;    int     i, low = -1, high = -1;    if ((string == NULL) || ((buf = schd_strdup(string)) == NULL))	return (-1);    ptr = strtok(buf, ",");    while (ptr != NULL) {	/* Ensure that the string matches '{+-}[0-9][0-9]*%'. */	sign = *ptr;	if ((sign != '+') && (sign != '-'))	    goto parse_error;	ptr++;	if ((*ptr < '0') || (*ptr > '9'))	    goto parse_error;	n = strtol(ptr, &end, 10);	if (n > INT_MAX)	    goto parse_error;	i = (int)n;		if (*end != '%')	    goto parse_error;	if (sign == '-') {	    if (low >= 0)		/* Already set. */		goto parse_error;	    else		low = i;	} else {	    if (high >= 0)		/* Already set. */		goto parse_error;	    else		high = i;	}	ptr = strtok(NULL, ",");    }    free(buf);    *lowp  = (low >= 0) ? low : 0;    *highp = (high >= 0) ? high : 0;    return (0);parse_error:    free(buf);    return (-1);}static intverify_fairshare(void){    char  	   *id = "verify_fairshare";    FairAccessList *FALptr;    AccessEntry    *AEptr;    int 	    shares = 0;  if (schd_FairACL) {    for (FALptr = schd_FairACL; FALptr != NULL; FALptr = FALptr->next) {        for (AEptr = FALptr->entry; AEptr != NULL; AEptr = AEptr->next)             if (AEptr->name)		shares += AEptr->max_percent;    }    if (shares < 100) {        sprintf(log_buffer,"FAIR_SHARE: total shares (%d) < 100 %%",	    shares);        log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	return(0);    }    if (shares > 100) {        sprintf(log_buffer,"FAIR_SHARE: total shares (%d) > 100 %%",	    shares);        log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);	return(0);    }  }  return (1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -