Beispiel #1
0
static int extract_raw_rdl_alloc (flux_t *h, int64_t j, json_object *jcb)
{
    int i;
    json_object *ra = Jnew_ar ();
    bool processing = true;

    for (i=0; processing; ++i) {
        char *key = lwj_key (h, j, ".rank.%d.cores", i);
        flux_future_t *f = NULL;
        int64_t cores = 0;
        if (!key || !(f = flux_kvs_lookup (h, 0, key))
                 || flux_kvs_lookup_get_unpack (f, "I", &cores) < 0) {
            if (errno != EINVAL)
                flux_log_error (h, "extract %s", key);
            processing = false;
        } else {
            json_object *elem = Jnew ();
            json_object *o = Jnew ();
            Jadd_int64 (o, JSC_RDL_ALLOC_CONTAINED_NCORES, cores);
            json_object_object_add (elem, JSC_RDL_ALLOC_CONTAINED, o);
            json_object_array_add (ra, elem);
        }
        free (key);
        flux_future_destroy (f);
    }
    json_object_object_add (jcb, JSC_RDL_ALLOC, ra);
    return 0;
}
void watch_continuation (flux_future_t *f, void *arg)
{
    int *last = arg;
    int i;

    if (flux_kvs_lookup_get_unpack (f, "i", &i) < 0) {
        if (errno == ENODATA) {
            flux_future_destroy (f); // ENODATA (like EOF on response stream)
            if (verbose)
                printf ("< ENODATA\n");
        }
        else
            log_err_exit ("flux_lookup_get_unpack");
        return;
    }
    if (verbose)
        printf ("< %s=%d\n", key, i);
    if (i != *last + 1)
        log_msg_exit ("%s: got %d, expected %d", __FUNCTION__, i, *last + 1);
    if (++wrxcount == totcount)
        flux_kvs_lookup_cancel (f);
    *last = i;

    flux_future_reset (f);
}
Beispiel #3
0
static int extract_raw_walltime (flux_t *h, int64_t j, int64_t *walltime)
{
    int rc = 0;
    char *key = lwj_key (h, j, ".walltime");
    flux_future_t *f = NULL;

    if (!key || !(f = flux_kvs_lookup (h, 0, key))
             || flux_kvs_lookup_get_unpack (f, "I", walltime) < 0) {
        flux_log_error (h, "extract %s", key);
        rc = -1;
    }
    else
        flux_log (h, LOG_DEBUG, "extract %s: %"PRId64"", key, *walltime);
    free (key);
    flux_future_destroy (f);
    return rc;
}
Beispiel #4
0
void errors (void)
{
    flux_future_t *f;
    /* check simple error cases */

    errno = 0;
    ok (flux_kvs_lookup (NULL, NULL, 0, NULL) == NULL && errno == EINVAL,
        "flux_kvs_lookup fails on bad input");

    errno = 0;
    ok (flux_kvs_lookupat (NULL, 0, NULL, NULL) == NULL && errno == EINVAL,
        "flux_kvs_lookupat fails on bad input");

    errno = 0;
    ok (flux_kvs_lookup_get (NULL, NULL) < 0 && errno == EINVAL,
        "flux_kvs_lookup_get fails on bad input");

    errno = 0;
    ok (flux_kvs_lookup_get_unpack (NULL, NULL) < 0 && errno == EINVAL,
        "flux_kvs_lookup_get_unpack fails on bad input");

    errno = 0;
    ok (flux_kvs_lookup_get_raw (NULL, NULL, NULL) < 0 && errno == EINVAL,
        "flux_kvs_lookup_get_raw fails on bad input");

    errno = 0;
    ok (flux_kvs_lookup_get_key (NULL) == NULL && errno == EINVAL,
        "flux_kvs_lookup_get_key future=NULL fails with EINVAL");

    errno = 0;
    ok (flux_kvs_lookup_cancel (NULL) == -1 && errno == EINVAL,
        "flux_kvs_lookup_cancel future=NULL fails with EINVAL");

    if (!(f = flux_future_create (NULL, NULL)))
        BAIL_OUT ("flux_future_create failed");

    errno = 0;
    ok (flux_kvs_lookup_get_key (f) == NULL && errno == EINVAL,
        "flux_kvs_lookup_get_key future=(wrong type) fails with EINVAL");

    errno = 0;
    ok (flux_kvs_lookup_cancel (f) == -1 && errno == EINVAL,
        "flux_kvs_lookup_cancel future=(wrong type) fails with EINVAL");

    flux_future_destroy (f);
}
Beispiel #5
0
static int extract_raw_state (flux_t *h, int64_t j, int64_t *s)
{
    int rc = 0;
    char *key = lwj_key (h, j, ".state");
    const char *state;
    flux_future_t *f = NULL;

    if (!key || !(f = flux_kvs_lookup (h, 0, key))
             || flux_kvs_lookup_get_unpack (f, "s", &state) < 0) {
        flux_log_error (h, "extract %s", key);
        rc = -1;
    }
    else {
        *s = jsc_job_state2num (state);
        flux_log (h, LOG_DEBUG, "extract %s: %s", key, state);
    }
    free (key);
    flux_future_destroy (f);
    return rc;
}
Beispiel #6
0
static int extract_raw_rdl (flux_t *h, int64_t j, char **rdlstr)
{
    int rc = 0;
    char *key = lwj_key (h, j, ".rdl");
    const char *s;
    flux_future_t *f = NULL;

    if (!key || !(f = flux_kvs_lookup (h, 0, key))
             || flux_kvs_lookup_get_unpack (f, "s", &s) < 0) {
        flux_log_error (h, "extract %s", key);
        rc = -1;
    }
    else {
        *rdlstr = xstrdup (s);
        flux_log (h, LOG_DEBUG, "rdl under %s extracted", key);
    }
    free (key);
    flux_future_destroy (f);
    return rc;
}
Beispiel #7
0
void errors (void)
{
    /* check simple error cases */

    errno = 0;
    ok (flux_kvs_lookup (NULL, 0, NULL) == NULL && errno == EINVAL,
        "flux_kvs_lookup fails on bad input");

    errno = 0;
    ok (flux_kvs_lookupat (NULL, 0, NULL, NULL) == NULL && errno == EINVAL,
        "flux_kvs_lookupat fails on bad input");

    errno = 0;
    ok (flux_kvs_lookup_get (NULL, NULL) < 0 && errno == EINVAL,
        "flux_kvs_lookup_get fails on bad input");

    errno = 0;
    ok (flux_kvs_lookup_get_unpack (NULL, NULL) < 0 && errno == EINVAL,
        "flux_kvs_lookup_get_unpack fails on bad input");

    errno = 0;
    ok (flux_kvs_lookup_get_raw (NULL, NULL, NULL) < 0 && errno == EINVAL,
        "flux_kvs_lookup_get_raw fails on bad input");
}