예제 #1
0
void resrc_reqst_list_destroy (resrc_reqst_list_t *resrc_reqst_list)
{
    if (resrc_reqst_list) {
        if (resrc_reqst_list_size (resrc_reqst_list)) {
            resrc_reqst_t *child = resrc_reqst_list_first (resrc_reqst_list);
            while (child) {
                resrc_reqst_destroy (child);
                child = resrc_reqst_list_next (resrc_reqst_list);
            }
        }
        zlist_destroy (&(resrc_reqst_list->list));
        free (resrc_reqst_list);
    }
}
예제 #2
0
int resrc_reqst_set_starttime (resrc_reqst_t *resrc_reqst, int64_t time)
{
    if (resrc_reqst) {
        resrc_reqst->starttime = time;
        if (resrc_reqst_num_children (resrc_reqst)) {
            resrc_reqst_t *child = resrc_reqst_list_first
                (resrc_reqst->children);
            while (child) {
                resrc_reqst_set_starttime (child, time);
                child = resrc_reqst_list_next (resrc_reqst->children);
            }
        }
        return 0;
    }
    return -1;
}
예제 #3
0
int resrc_reqst_clear_found (resrc_reqst_t *resrc_reqst)
{
    if (resrc_reqst) {
        resrc_reqst->nfound = 0;
        if (resrc_reqst_num_children (resrc_reqst)) {
            resrc_reqst_t *child = resrc_reqst_list_first
                (resrc_reqst->children);
            while (child) {
                resrc_reqst_clear_found (child);
                child = resrc_reqst_list_next (resrc_reqst->children);
            }
        }
        return 0;
    }
    return -1;
}
예제 #4
0
void resrc_reqst_print (resrc_reqst_t *resrc_reqst)
{
    if (resrc_reqst) {
        char *shared = resrc_reqst->exclusive ? "exclusive" : "shared";

        printf ("%"PRId64" of %"PRId64" %s ", resrc_reqst->nfound,
                resrc_reqst->reqrd_qty, shared);
        resrc_print_resource (resrc_reqst->resrc);
        resrc_graph_req_print (resrc_reqst->g_reqs);
        if (resrc_reqst_num_children (resrc_reqst)) {
            resrc_reqst_t *child = resrc_reqst_list_first
                (resrc_reqst->children);
            while (child) {
                resrc_reqst_print (child);
                child = resrc_reqst_list_next (resrc_reqst->children);
            }
        }
    }
}
예제 #5
0
/*
 * cycles through all of the resource requests and returns true if all
 * of the requested children were selected
 */
static bool select_children (flux_t *h, resrc_tree_list_t *children,
                             resrc_reqst_list_t *reqst_children,
                             resrc_tree_t *selected_parent)
{
    resrc_reqst_t *child_reqst = NULL;
    bool selected = false;

    child_reqst = resrc_reqst_list_first (reqst_children);
    while (child_reqst) {
        resrc_reqst_clear_found (child_reqst);
        selected = false;

        if (!select_child (h, children, child_reqst, selected_parent))
            break;
        selected = true;
        child_reqst = resrc_reqst_list_next (reqst_children);
    }

    return selected;
}
예제 #6
0
bool resrc_reqst_all_found (resrc_reqst_t *resrc_reqst)
{
    bool all_found = false;

    if (resrc_reqst) {
        if (resrc_reqst_nfound (resrc_reqst) >=
            resrc_reqst_reqrd_qty (resrc_reqst))
            all_found = true;

        if (resrc_reqst_num_children (resrc_reqst)) {
            resrc_reqst_t *child = resrc_reqst_list_first(resrc_reqst->children);
            while (child) {
                if (!resrc_reqst_all_found (child)) {
                    all_found = false;
                    break;
                }
                child = resrc_reqst_list_next (resrc_reqst->children);
            }
        }
    }
    return all_found;
}
예제 #7
0
/*
 * cycles through all of the resource requests and returns true if all
 * of the requested children were found
 */
static bool match_children (resrc_tree_list_t *r_trees,
                            resrc_reqst_list_t *req_trees,
                            resrc_tree_t *found_parent, bool available)
{
    bool found = false;
    resrc_reqst_t *resrc_reqst = resrc_reqst_list_first (req_trees);

    while (resrc_reqst) {
        resrc_reqst->nfound = 0;
        found = false;

        if (match_child (r_trees, resrc_reqst, found_parent, available)) {
            if (resrc_reqst->nfound >= resrc_reqst->reqrd_qty)
                found = true;
        }
        if (!found)
            break;

        resrc_reqst = resrc_reqst_list_next (req_trees);
    }

    return found;
}