flux_rpc_t *flux_rpc_raw (flux_t *h, const char *topic, const void *data, int len, uint32_t nodeid, int flags) { flux_rpc_t *rpc; int rx_expected = 1; if ((flags & FLUX_RPC_NORESPONSE)) rx_expected = 0; if (!(rpc = rpc_create (h, rx_expected))) goto error; #if HAVE_CALIPER cali_begin_string_byname ("flux.message.rpc", "single"); cali_begin_int_byname ("flux.message.response_expected", !(flags & FLUX_RPC_NORESPONSE)); #endif if (rpc_request_send_raw (rpc, topic, nodeid, data, len) < 0) goto error; #if HAVE_CALIPER cali_end_byname ("flux.message.response_expected"); cali_end_byname ("flux.message.rpc"); #endif return rpc; error: flux_rpc_destroy (rpc); return NULL; }
static flux_rpc_t *flux_vrpcf (flux_t *h, const char *topic, uint32_t nodeid, int flags, const char *fmt, va_list ap) { flux_rpc_t *rpc; int rx_expected = 1; if ((flags & FLUX_RPC_NORESPONSE)) rx_expected = 0; if (!(rpc = rpc_create (h, rx_expected))) goto error; #if HAVE_CALIPER cali_begin_string_byname ("flux.message.rpc", "single"); cali_begin_int_byname ("flux.message.rpc.nodeid", nodeid); cali_begin_int_byname ("flux.message.response_expected", !(flags & FLUX_RPC_NORESPONSE)); #endif if (rpc_request_vsendf (rpc, topic, nodeid, fmt, ap) < 0) goto error; #if HAVE_CALIPER cali_end_byname ("flux.message.response_expected"); cali_end_byname ("flux.message.rpc.nodeid"); cali_end_byname ("flux.message.rpc"); #endif return rpc; error: flux_rpc_destroy (rpc); return NULL; }
static int rpc_get (flux_rpc_t *rpc) { int rc = -1; if (rpc->rx_errnum) { errno = rpc->rx_errnum; goto done; } if (!rpc->rx_msg && !rpc->rx_errnum) { #if HAVE_CALIPER cali_begin_string_byname("flux.message.rpc", "single"); #endif if (!(rpc->rx_msg = flux_recv (rpc->h, rpc->m, 0))) { rpc->rx_errnum = errno; goto done; } #if HAVE_CALIPER cali_end_byname("flux.message.rpc"); #endif rpc->rx_count++; } rc = 0; done: return rc; }
int main() { cali_config_preset("CALI_CALIPER_FLUSH_ON_EXIT", "false"); cali_id_t iter_attr = cali_create_attribute("iteration", CALI_TYPE_INT, CALI_ATTR_ASVALUE); cali_begin_string_byname("phase", "loop"); for (int i = 0; i < 4; ++i) { cali_begin_int(iter_attr, i); cali_end(iter_attr); } cali_end_byname("phase"); cali_begin_byname("ci_test_c_ann.meta-attr"); cali_id_t meta_attr = cali_create_attribute("meta-attr", CALI_TYPE_INT, CALI_ATTR_DEFAULT); int val = 47; size_t meta_sizes = sizeof(int); const void* meta_val[1] = { &val }; cali_id_t test_attr = cali_create_attribute_with_metadata("test-attr-with-metadata", CALI_TYPE_STRING, CALI_ATTR_DEFAULT, 1, &meta_attr, meta_val, &meta_sizes); cali_set_string(test_attr, "abracadabra"); cali_end_byname("ci_test_c_ann.meta-attr"); cali_begin_byname("ci_test_c_ann.setbyname"); cali_set_int_byname("attr.int", 20); cali_set_double_byname("attr.dbl", 1.25); cali_set_string_byname("attr.str", "fidibus"); cali_end_byname("ci_test_c_ann.setbyname"); cali_flush(CALI_FLUSH_CLEAR_BUFFERS); }
flux_rpc_t *flux_rpc_multi (flux_t *h, const char *topic, const char *json_str, const char *nodeset, int flags) { nodeset_t *ns = NULL; nodeset_iterator_t *itr = NULL; flux_rpc_t *rpc = NULL; int i; uint32_t count; int rx_expected; if (!topic || !nodeset) { errno = EINVAL; goto error; } if (!strcmp (nodeset, "all")) { if (flux_get_size (h, &count) < 0) goto error; ns = nodeset_create_range (0, count - 1); } else { if ((ns = nodeset_create_string (nodeset))) count = nodeset_count (ns); } if (!ns) { errno = EINVAL; goto error; } rx_expected = count; if ((flags & FLUX_RPC_NORESPONSE)) rx_expected = 0; if (!(rpc = rpc_create (h, rx_expected))) goto error; if (!(itr = nodeset_iterator_create (ns))) goto error; #if HAVE_CALIPER cali_begin_string_byname ("flux.message.rpc", "multi"); cali_begin_int_byname ("flux.message.response_expected", !(flags & FLUX_RPC_NORESPONSE)); #endif for (i = 0; i < count; i++) { uint32_t nodeid = nodeset_next (itr); assert (nodeid != NODESET_EOF); #if HAVE_CALIPER cali_begin_int_byname ("flux.message.rpc.nodeid", nodeid); #endif if (rpc_request_send (rpc, topic, nodeid, json_str) < 0) goto error; #if HAVE_CALIPER cali_end_byname ("flux.message.rpc.nodeid"); #endif } #if HAVE_CALIPER cali_end_byname ("flux.message.response_expected"); cali_end_byname ("flux.message.rpc"); #endif nodeset_iterator_destroy (itr); return rpc; error: if (rpc) flux_rpc_destroy (rpc); if (itr) nodeset_iterator_destroy (itr); if (ns) nodeset_destroy (ns); return NULL; }