예제 #1
0
/**
 * @brief
 *		update_queue_on_end - update a queue when a resource resv
 *				has finished running
 *
 * @par	NOTE:	job must be in pre-ended state
 *
 * @param[in,out]	qinfo	-	the queue to update
 * @param[in]	resresv	-	the resource resv which is no longer running
 * @param[in]  job_state -	the old state of a job if resresv is a job
 *				If the old_state is found to be suspended
 *				then only resources that were released
 *				during suspension will be accounted.
 *
 * @return	nothing
 *
 */
void
update_queue_on_end(queue_info *qinfo, resource_resv *resresv,
	char *job_state)
{
	schd_resource *res = NULL;			/* resource from queue */
	resource_req *req = NULL;			/* resource request from job */
	counts *cts;					/* update user/group counts */

	if (qinfo == NULL || resresv == NULL)
		return;

	if (resresv->is_job && resresv->job ==NULL)
		return;

	if (resresv->is_job) {
		if (resresv->job->is_running) {
			qinfo->sc.running--;
			remove_resresv_from_array(qinfo->running_jobs, resresv);
		}
		else if (resresv->job->is_exiting)
			qinfo->sc.exiting--;

		state_count_add(&(qinfo->sc), job_state, 1);
	}

	if ((job_state != NULL) && (*job_state == 'S'))
		req = resresv->job->resreq_rel;
	else
		req = resresv->resreq;

	while (req != NULL) {
		res = find_resource(qinfo->qres, req->def);

		if (res != NULL)
			res->assigned -= req->amount;

		req = req->next;
	}

	if (qinfo->has_soft_limit || qinfo->has_hard_limit) {
		if (is_resresv_running(resresv)) {
			update_total_counts_on_end(NULL, qinfo, resresv , QUEUE);
			cts = find_counts(qinfo->group_counts, resresv->group);

			if (cts != NULL)
				update_counts_on_end(cts, resresv->resreq);

			cts = find_counts(qinfo->project_counts, resresv->project);

			if (cts != NULL)
				update_counts_on_end(cts, resresv->resreq);

			cts = find_counts(qinfo->user_counts, resresv->user);

			if (cts != NULL)
				update_counts_on_end(cts, resresv->resreq);

			cts = find_alloc_counts(qinfo->alljobcounts, "o:" PBS_ALL_ENTITY);

			if (cts != NULL)
				update_counts_on_end(cts, resresv->resreq);
		}
	}
}
예제 #2
0
/**
 * @brief
 *		is_resource_resv_valid - do simple validity checks for a resource resv
 *
 *
 *	@param[in] resresv - the resource_resv to do check
 *	@param[out] err - error struct to return why resource_resv is invalid
 *
 *	@returns int
 *	@retva1 1 if valid
 *	@retval 0 if invalid (err returns reason why)
 */
int
is_resource_resv_valid(resource_resv *resresv, schd_error *err)
{
	if (resresv == NULL)
		return 0;

	if (resresv->server == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "No server pointer");
		return 0;
	}

	if (resresv->is_job && resresv->job == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "Job has no job sub-structure");
		return 0;
	}

	if (resresv->is_resv && resresv->resv == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "Reservation has no resv sub-structure");
		return 0;
	}

	if (resresv->name == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "No Name");
		return 0;
	}

	if (resresv->user == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "No User");
		return 0;
	}

	if (resresv->group == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "No Group");
		return 0;
	}

	if (resresv->select == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "No Select");
		return 0;
	}

	if (resresv->place_spec == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "No Place");
		return 0;
	}

	if (!resresv->is_job && !resresv->is_resv) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "Is neither job nor resv");
		return 0;
	}

	if (is_resresv_running(resresv)) {
		if (resresv->nspec_arr == NULL) {
			set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
			set_schd_error_arg(err, SPECMSG, "Is running w/o exec_vnode1");
			return 0;
		}

		if (resresv->ninfo_arr == NULL) {
			set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
			set_schd_error_arg(err, SPECMSG, "Is running w/o exec_vnode2");
			return 0;
	}
	}

	if (resresv->ninfo_arr != NULL && resresv->nspec_arr == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "exec_vnode mismatch 1");
		return 0;
	}

	if (resresv->nspec_arr != NULL && resresv->ninfo_arr == NULL) {
		set_schd_error_codes(err, NEVER_RUN, ERR_SPECIAL);
		set_schd_error_arg(err, SPECMSG, "exec_vnode mismatch 2");
		return 0;
	}

	return 1;
}