static int extract_raw_state (flux_t h, int64_t j, int64_t *s) { int rc = 0; char key[20] = {'\0'}; char *state = NULL; snprintf (key, 20, "lwj.%ld.state", j); if (kvs_get_string (h, key, &state) < 0) { flux_log (h, LOG_ERR, "extract %s: %s", key, strerror (errno)); rc = -1; } else { *s = jsc_job_state2num (state); flux_log (h, LOG_DEBUG, "extract %s: %s", key, state); } if (state) free (state); return rc; }
static int extract_raw_state (flux_t h, int64_t j, int64_t *s) { int rc = 0; char *key = xasprintf ("lwj.%"PRId64".state", j); char *state = NULL; if (kvs_get_string (h, key, &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); if (state) free (state); return rc; }
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; }
static json_object *get_update_jcb (flux_t *h, int64_t j, const char *val) { json_object *o = NULL; json_object *ss = NULL; jscctx_t *ctx = getctx (h); int64_t ostate = (int64_t) J_FOR_RENT; int64_t nstate = (int64_t) J_FOR_RENT; nstate = jsc_job_state2num (val); if ( (ostate = fetch_and_update_state (ctx->active_jobs, j, nstate)) < 0) { flux_log (h, LOG_INFO, "%"PRId64"'s old state unavailable", j); ostate = nstate; } o = Jnew (); ss = Jnew (); Jadd_int64 (o, JSC_JOBID, j); Jadd_int64 (ss, JSC_STATE_PAIR_OSTATE , (int64_t) ostate); Jadd_int64 (ss, JSC_STATE_PAIR_NSTATE, (int64_t) nstate); json_object_object_add (o, JSC_STATE_PAIR, ss); return o; }