int flux_recover (flux_t h, int rank) { uint32_t nodeid = (rank == -1 ? FLUX_NODEID_ANY : rank); JSON response = NULL; int rc = -1; if (flux_json_rpc (h, nodeid, "live.recover", NULL, &response) < 0) goto done; rc = 0; done: Jput (response); return rc; }
/* The req.clog request will not be answered until req.flush is called. */ static int stuck_request_cb (flux_t h, int typemask, zmsg_t **zmsg, void *arg) { if (flux_json_rpc (h, FLUX_NODEID_ANY, "req.clog", NULL, NULL) < 0) { flux_log (h, LOG_ERR, "%s: req.clog RPC: %s", __FUNCTION__, strerror (errno)); return -1; } if (flux_err_respond (h, 0, zmsg) < 0) { flux_log (h, LOG_ERR, "%s: responding: %s", __FUNCTION__, strerror (errno)); return -1; } return 0; }
static int op_event_unsubscribe (void *impl, const char *topic) { ctx_t *ctx = impl; assert (ctx->magic == MODHANDLE_MAGIC); JSON in = Jnew (); int rc = -1; if (connect_socket (ctx) < 0) goto done; Jadd_str (in, "topic", topic); if (flux_json_rpc (ctx->h, FLUX_NODEID_ANY, "cmb.unsub", in, NULL) < 0) goto done; rc = 0; done: Jput (in); return rc; }
static int wait_for_lwj_watch_init (flux_t h, int64_t id) { int rc; json_object *rpc_o; json_object *rpc_resp; rpc_o = util_json_object_new_object (); util_json_object_add_string (rpc_o, "key", "lwj.next-id"); util_json_object_add_int64 (rpc_o, "val", id); rc = flux_json_rpc (h, FLUX_NODEID_ANY, "sim_sched.lwj-watch", rpc_o, &rpc_resp); if (rc >= 0) { util_json_object_get_int (rpc_resp, "rc", &rc); json_object_put (rpc_resp); } json_object_put (rpc_o); return rc; }
/* * Tree-wide call for lwj_next_id. If not treeroot forward request * up the tree. Otherwise increment jobid and return result. */ static unsigned long lwj_next_id (flux_t h) { unsigned long ret; if (flux_rank (h) == 0) ret = increment_jobid (h); else { json_object *na = json_object_new_object (); json_object *o = NULL; if (flux_json_rpc (h, FLUX_NODEID_ANY, "job.next-id", na, &o) < 0 || util_json_object_get_int64 (o, "id", (int64_t *) &ret) < 0) { err ("lwj_next_id: Bad object!"); ret = 0; } json_object_put (o); json_object_put (na); } return (ret); }
static flux_msg_t *op_recv (void *impl, int flags) { ctx_t *ctx = impl; assert (ctx->magic == MODHANDLE_MAGIC); zmq_pollitem_t zp = { .events = ZMQ_POLLIN, .socket = ctx->sock, .revents = 0, .fd = -1, }; flux_msg_t *msg = NULL; if (connect_socket (ctx) < 0) goto done; if ((flags & FLUX_O_NONBLOCK)) { int n; if ((n = zmq_poll (&zp, 1, 0L)) < 0) goto done; /* likely: EWOULDBLOCK | EAGAIN */ assert (n == 1); assert (zp.revents == ZMQ_POLLIN); } msg = zmsg_recv (ctx->sock); done: return msg; } static int op_event_subscribe (void *impl, const char *topic) { ctx_t *ctx = impl; assert (ctx->magic == MODHANDLE_MAGIC); JSON in = Jnew (); int rc = -1; if (connect_socket (ctx) < 0) goto done; Jadd_str (in, "topic", topic); if (flux_json_rpc (ctx->h, FLUX_NODEID_ANY, "cmb.sub", in, NULL) < 0) goto done; rc = 0; done: Jput (in); return rc; }