コード例 #1
0
ファイル: jstatctl.c プロジェクト: dongahn/flux-core
static void job_state_cb (flux_t h, flux_msg_handler_t *w,
                          const flux_msg_t *msg, void *arg)
{
    int64_t jobid = -1;
    json_object *o = NULL;
    const char *topic = NULL;
    const char *json_str = NULL;
    const char *state = NULL;
    int len = 12;

    if (flux_msg_get_topic (msg, &topic) < 0)
        goto done;

    if (flux_event_decode (msg, NULL, &json_str) < 0
            || !(o = Jfromstr (json_str))
            || !Jget_int64 (o, "lwj", &jobid)) {
        flux_log (h, LOG_ERR, "%s: bad message", __FUNCTION__);
        goto done;
    }

    if (strncmp (topic, "jsc", 3) == 0)
       len = 10;

    state = topic + len;
    if (strcmp (state, jsc_job_num2state (J_RESERVED)) == 0)
        fixup_newjob_event (h, jobid);

    if (invoke_cbs (h, jobid, get_update_jcb (h, jobid, state), 0) < 0)
        flux_log (h, LOG_ERR, "job_state_cb: failed to invoke callbacks");

    if (job_is_finished (state))
        delete_jobinfo (h, jobid);
done:
    return;
}
コード例 #2
0
ファイル: jstatctl.c プロジェクト: dinesh121991/flux-core
static int job_state_cb (const char *key, const char *val, void *arg, int errnum)
{
    int64_t jobid = -1;
    flux_t h = (flux_t) arg;

    if (chk_errnum (h, errnum) < 0) 
        flux_log (h, LOG_ERR, "job_state_cb: key(%s), val(%s)", key, val);
    else if (parse_jobid (key, &jobid) != 0) 
        flux_log (h, LOG_ERR, "job_state_cb: key ill-formed");
    else if (invoke_cbs (h, jobid, get_update_jcb (h, jobid, val), errnum) < 0) 
        flux_log (h, LOG_ERR, "job_state_cb: failed to invoke callbacks");

    /* always return 0 so that reactor will not return */
    return 0;
}
コード例 #3
0
ファイル: jstatctl.c プロジェクト: trws/flux-core
static void job_state_cb (flux_t *h, flux_msg_handler_t *mh,
                          const flux_msg_t *msg, void *arg)
{
    json_object *jcb = NULL;
    int64_t jobid = -1;
    const char *topic = NULL;
    const char *state = NULL;
    const char *kvs_path = NULL;
    int len = 12;

    if (flux_msg_get_topic (msg, &topic) < 0)
        goto done;

    if (flux_event_unpack (msg, NULL, "{ s:I }", "lwj", &jobid) < 0) {
        flux_log (h, LOG_ERR, "%s: bad message", __FUNCTION__);
        goto done;
    }

    if (!flux_event_unpack (msg, NULL, "{ s:s }", "kvs_path", &kvs_path)) {
        if (jscctx_add_jobid_path (getctx (h), jobid, kvs_path) < 0)
            flux_log_error (h, "jscctx_add_jobid_path");
    }

    if (strncmp (topic, "jsc", 3) == 0)
       len = 10;

    state = topic + len;
    if (strcmp (state, jsc_job_num2state (J_RESERVED)) == 0)
        fixup_newjob_event (h, jobid);

    if (invoke_cbs (h, jobid, jcb = get_update_jcb (h, jobid, state), 0) < 0)
        flux_log (h, LOG_ERR, "job_state_cb: failed to invoke callbacks");

    if (job_is_finished (state))
        delete_jobinfo (h, jobid);
done:
    Jput (jcb);
    return;
}