static int handle_query_req (flux_t h, int64_t j, const char *k, const char *n) { JSON jcb = NULL; jstatctx_t *ctx = NULL; char *jcbstr; ctx = getctx (h); ctx->op = n? open_test_outfile (n) : stdout; if (jsc_query_jcb (h, j, k, &jcbstr) != 0) { flux_log (h, LOG_ERR, "jsc_query_jcb reported an error"); return -1; } jcb = Jfromstr (jcbstr); fprintf (ctx->op, "Job Control Block: attribute %s for job %ld\n", k, j); fprintf (ctx->op, "%s\n", jcb == NULL ? jcbstr : json_object_to_json_string_ext (jcb, JSON_C_TO_STRING_PRETTY)); Jput (jcb); free (jcbstr); return 0; }
static bool complete_job (wjctx_t *ctx) { JSON jcb = NULL; JSON o = NULL; bool rc = false; char *json_str = NULL; int64_t state = J_NULL; if (jsc_query_jcb (ctx->h, ctx->jobid, JSC_STATE_PAIR, &json_str) == 0) { jcb = Jfromstr (json_str); Jget_obj (jcb, JSC_STATE_PAIR, &o); Jget_int64 (o, JSC_STATE_PAIR_NSTATE, &state); Jput (jcb); free (json_str); flux_log (ctx->h, LOG_INFO, "%"PRId64" already started (%s)", ctx->jobid, jsc_job_num2state (state)); if (state == J_COMPLETE) { flux_log (ctx->h, LOG_INFO, "%"PRId64" already completed", ctx->jobid); rc = true; } } return rc; }