JSON kp_tcommit_enc (const char *sender, JSON dirents, const char *fence, int nprocs) { JSON o = Jnew (); if (dirents) { json_object_iter iter; json_object_object_foreachC (dirents, iter) { Jadd_obj (o, iter.key, iter.val); /* takes a ref on iter.val */ } }
JSON kp_tcommit_enc (const char *sender, JSON ops, const char *fence, int nprocs) { JSON o = Jnew (); Jadd_obj (o, "ops", ops); /* takes a ref on ops */ if (sender) Jadd_str (o, ".arg_sender", sender); if (fence) { Jadd_str (o, ".arg_fence", fence); Jadd_int (o, ".arg_nprocs", nprocs); } return o; }
// Given the kvs dir of a job, change the state of the job and // timestamp the change static int update_job_state (ctx_t *ctx, int64_t jobid, flux_kvsdir_t *kvs_dir, job_state_t new_state, double update_time) { int rc; double t_starting = SIM_TIME_NONE; double t_running = SIM_TIME_NONE; double t_completing = SIM_TIME_NONE; double t_complete = SIM_TIME_NONE; switch (new_state) { case J_STARTING: t_starting = update_time; break; case J_RUNNING: t_running = update_time; break; case J_COMPLETING: t_completing = update_time; break; case J_COMPLETE: t_complete = update_time; break; default: flux_log (ctx->h, LOG_ERR, "Unknown state %d", (int) new_state); return -1; } json_t *jcb = Jnew (); json_t *o = Jnew (); Jadd_int64 (o, JSC_STATE_PAIR_NSTATE, (int64_t) new_state); Jadd_obj (jcb, JSC_STATE_PAIR, o); jsc_update_jcb(ctx->h, jobid, JSC_STATE_PAIR, Jtostr (jcb)); rc = set_job_timestamps (kvs_dir, t_starting, t_running, t_completing, t_complete, SIM_TIME_NONE); // io if (rc < 0) flux_log_error (ctx->h, "%s: set_job_timestamps", __FUNCTION__); Jput (jcb); Jput (o); return rc; }
JSON kp_tsetroot_enc (int rootseq, const char *rootdir, JSON root, const char *fence) { JSON o = NULL; if (!rootdir) { errno = EINVAL; goto done; } o = Jnew (); Jadd_int (o, "rootseq", rootseq); Jadd_str (o, "rootdir", rootdir); if (fence) Jadd_str (o, "fence", fence); if (root) Jadd_obj (o, "rootdirval", root); /* takes a ref */ done: return o; }