コード例 #1
0
ファイル: flux-jstat.c プロジェクト: tpatki/flux-core
static int handle_update_req (flux_t h, int64_t j, const char *k, 
                              const char *jcbstr, const char *n)
{
    jstatctx_t *ctx = NULL;
    ctx = getctx (h);
    ctx->op = n?  open_test_outfile (n) : stdout;

    return (jsc_update_jcb (ctx->h, j, k, jcbstr));
}
コード例 #2
0
ファイル: sim_execsrv.c プロジェクト: garlick/flux-sched
// 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;
}