Esempio n. 1
0
static int update_pdesc (flux_t h, int64_t j, JSON o)
{
    int i = 0;
    int rc = -1;
    int64_t size = 0;
    JSON h_arr = NULL, e_arr = NULL, pd_arr = NULL, pde = NULL;

    if (!Jget_int64 (o, JSC_PDESC_SIZE, &size)) return -1;
    if (!Jget_obj (o, JSC_PDESC_PDARRAY, &pd_arr)) return -1;
    if (!Jget_obj (o, JSC_PDESC_HOSTNAMES, &h_arr)) return -1; 
    if (!Jget_obj (o, JSC_PDESC_EXECS, &e_arr)) return -1;  

    for (i=0; i < (int) size; ++i) {
        if (!Jget_ar_obj (pd_arr, i, &pde))
            goto done;
        if ( (rc = update_1pdesc (h, i, j, pde, h_arr, e_arr)) < 0) 
            goto done;
    }
    if (kvs_commit (h) < 0) {
        flux_log (h, LOG_ERR, "update_pdesc commit failed"); 
        goto done;
    }
    rc = 0;

done:
    return rc;
}
Esempio n. 2
0
static int update_pdesc (flux_t *h, int64_t j, json_object *o)
{
    int i = 0;
    int rc = -1;
    int64_t size = 0;
    json_object *h_arr = NULL;
    json_object *e_arr = NULL;
    json_object *pd_arr = NULL;
    json_object *pde = NULL;
    flux_kvs_txn_t *txn = NULL;
    flux_future_t *f = NULL;

    if (!Jget_int64 (o, JSC_PDESC_SIZE, &size))
        goto done;
    if (!Jget_obj (o, JSC_PDESC_PDARRAY, &pd_arr))
        goto done;
    if (!Jget_obj (o, JSC_PDESC_HOSTNAMES, &h_arr))
        goto done;
    if (!Jget_obj (o, JSC_PDESC_EXECS, &e_arr))
        goto done;
    if (!(txn = flux_kvs_txn_create ())) {
        flux_log_error (h, "txn_create");
        goto done;
    }
    for (i=0; i < (int) size; ++i) {
        if (!Jget_ar_obj (pd_arr, i, &pde))
            goto done;
        if ( (rc = update_1pdesc (h, txn, i, j, pde, h_arr, e_arr)) < 0)
            goto done;
    }
    if (!(f = flux_kvs_commit (h, 0, txn)) || flux_future_get (f, NULL) < 0) {
        flux_log (h, LOG_ERR, "update_pdesc commit failed");
        goto done;
    }
    rc = 0;

done:
    flux_kvs_txn_destroy (txn);
    flux_future_destroy (f);
    return rc;
}