Beispiel #1
0
static ctx_t *getctx (flux_t *h)
{
    ctx_t *ctx = (ctx_t *)flux_aux_get (h, "sim_exec");

    if (!ctx) {
        ctx = xzmalloc (sizeof (*ctx));
        ctx->h = h;
        ctx->sim_state = NULL;
        ctx->queued_events = zlist_new ();
        ctx->running_jobs = zlist_new ();
        ctx->prev_sim_time = 0;
        ctx->rdllib = rdllib_open ();
        ctx->rdl = NULL;
        flux_aux_set  (h, "sim_exec", ctx, freectx);
    }

    return ctx;
}
Beispiel #2
0
resrc_flow_t *resrc_flow_generate_rdl (const char *path, char *uri)
{
    resrc_flow_t *flow = NULL;
    struct rdl *rdl = NULL;
    struct rdllib *l = NULL;
    struct resource *r = NULL;

    if (!(l = rdllib_open ()) || !(rdl = rdl_loadfile (l, path)))
        goto ret;

    if ((r = rdl_resource_get (rdl, uri)))
        flow = resrc_flow_add_rdl (NULL, r);

    rdl_destroy (rdl);
    rdllib_close (l);
ret:
    return flow;
}
Beispiel #3
0
int main (int argc, char *argv[])
{
    struct rdllib *l;
    struct rdl *rdl1, *rdl2;
    struct rdl_accumulator *a;
    struct resource *r, *c;
    int64_t val;
    const char *h = NULL;

    const char *filename = argv[1];

    log_init (basename (argv[0]));
    rdllib_set_default_errf (NULL, &perr);

    if (!(l = rdllib_open ()))
        log_err_exit ("rdllib_open");

    if (filename == NULL || *filename == '\0')
        filename = getenv ("TESTRDL_INPUT_FILE");

    if (!(rdl1 = rdl_loadfile (l, filename)))
        log_err_exit ("loadfile: %s", filename);

    while ((h = rdl_next_hierarchy (rdl1, h)))
        fprintf (stderr, "%s\n", h);

    if (!(rdl2 = rdl_copy (rdl1)))
        log_err_exit ("copy");

    r = rdl_resource_get (rdl1, "default");
    if (rdl_resource_set_int (r, "test-tag", 5959) < 0)
        exit (1);
    rdl_resource_get_int (r, "test-tag", &val);
    if (val != 5959)
        exit (1);
     rdl_resource_delete_tag (r, "test-tag");

    c = rdl_resource_next_child (r);

    a = rdl_accumulator_create (rdl1);
    if (rdl_accumulator_add (a, c) < 0)
        exit (1);

    rdl2 = rdl_accumulator_copy (a);
    rdl_accumulator_destroy (a);

    print_resource (rdl_resource_get (rdl2, "default"), 0);

    /*
     *  Test find
     */
    json_t *args = Jnew ();
    Jadd_str (args, "type", "node");
    Jadd_int (args, "id", 300);
    rdl2 = rdl_find (rdl1, args);
    if (rdl2 == NULL)
        log_err_exit ("rdl_find");
    json_decref (args);
    r = rdl_resource_get (rdl2, "default");
    if (r == NULL)
        exit (1);

    c = rdl_resource_next_child (r);
    printf ("found %s\n", rdl_resource_name (c));

    rdl_resource_destroy (r);
    rdl_destroy (rdl2);

    r = rdl_resource_get (rdl1, "default:/hype/hype300/socket0/memory");
    if (r == NULL)
        exit (1);

    print_resource (r, 0);
    rdl_resource_alloc (r, 1024);
    printf ("After alloc:\n");
    print_resource (r, 0);
    rdl_resource_free (r, 1024);
    printf ("After free:\n");
    print_resource (r, 0);

    rdllib_close (l);

    log_fini ();

    return 0;
}