rpc_result<Res> rpc_mclient::join_( const std::string& method, const pfi::lang::function<Res(Res, Res)>& reducer) { rpc_result<Res> result; if (futures_.empty()) { throw JUBATUS_EXCEPTION(rpc_no_client() << error_method(method)); } size_t result_count = 0; for (size_t i = 0; i < futures_.size(); ++i) { try { join_one_(method, futures_[i], result, reducer); ++result_count; } catch (...) { // continue process next result when exception thrown. // store exception_thrower to list of errors result.error.push_back( rpc_error(hosts_[i].first, hosts_[i].second, jubatus::core::common::exception::get_current_exception())); } } if (result_count == 0) { rpc_no_result e; if (result.has_error()) { e << error_multi_rpc(result.error); } throw JUBATUS_EXCEPTION(e << error_method(method)); } return result; }
static int remotetest_exec(int dest, u64 *val) { void *dev_handle; void *event_handles[3]; void *cb_handle; int ret; u64 errmask = 0; uint32_t ouint; uint32_t oalen; /* */ ret = daldevice_attach(REMOTE_UNITTEST_DEVICEID, NULL, dest, &dev_handle); if (ret) { printk(KERN_INFO "%s: failed to attach (%d)\n", __func__, ret); *val = 0xffffffff; return 0; } /* */ ret = remote_unittest_0(dev_handle, REMOTE_UNITTEST_INARG_1); if (ret) rpc_error(0); /* */ ret = remote_unittest_1(dev_handle, REMOTE_UNITTEST_INARG_1, REMOTE_UNITTEST_INARG_2); if (ret) rpc_error(1); /* */ ouint = 0; ret = remote_unittest_2(dev_handle, REMOTE_UNITTEST_INARG_1, &ouint); if (ret) rpc_error(2); else if (ouint != REMOTE_UNITTEST_OUTARG_1) verify_error(2, "ouint"); /* */ ret = remote_unittest_3(dev_handle, REMOTE_UNITTEST_INARG_1, REMOTE_UNITTEST_INARG_2, REMOTE_UNITTEST_INARG_3); if (ret) rpc_error(3); /* */ ouint = 0; ret = remote_unittest_4(dev_handle, REMOTE_UNITTEST_INARG_1, REMOTE_UNITTEST_INARG_2, &ouint); if (ret) rpc_error(4); else if (ouint != REMOTE_UNITTEST_OUTARG_1) verify_error(4, "ouint"); /* */ init_data(&in_data); ret = remote_unittest_5(dev_handle, &in_data, sizeof(in_data)); if (ret) rpc_error(5); /* */ init_data(&in_data); ret = remote_unittest_6(dev_handle, REMOTE_UNITTEST_INARG_1, &in_data.test, sizeof(in_data.test)); if (ret) rpc_error(6); /* */ init_data(&in_data); memset(&out_data, 0, sizeof(out_data)); ret = remote_unittest_7(dev_handle, &in_data, sizeof(in_data), &out_data.test, sizeof(out_data.test), &oalen); if (ret) rpc_error(7); else if (oalen != sizeof(out_data.test)) verify_error(7, "oalen"); else if (verify_uint32_buffer(out_data.test)) verify_error(7, "obuf"); /* */ init_bytebuf(in_bytebuf); memset(&out_data, 0, sizeof(out_data)); ret = remote_unittest_8(dev_handle, in_bytebuf, sizeof(in_bytebuf), &out_data, sizeof(out_data)); if (ret) rpc_error(8); else if (verify_data(&out_data)) verify_error(8, "obuf"); /* */ memset(&out_bytebuf, 0, sizeof(out_bytebuf)); ret = remote_unittest_9(dev_handle, out_bytebuf, sizeof(out_bytebuf)); if (ret) rpc_error(9); else if (verify_bytebuf(out_bytebuf)) verify_error(9, "obuf"); /* */ init_bytebuf(in_bytebuf); memset(&out_bytebuf, 0, sizeof(out_bytebuf)); ret = remote_unittest_10(dev_handle, REMOTE_UNITTEST_INARG_1, in_bytebuf, sizeof(in_bytebuf), out_bytebuf, sizeof(out_bytebuf), &oalen); if (ret) rpc_error(10); else if (oalen != sizeof(out_bytebuf)) verify_error(10, "oalen"); else if (verify_bytebuf(out_bytebuf)) verify_error(10, "obuf"); /* */ memset(&out_bytebuf, 0, sizeof(out_bytebuf)); ret = remote_unittest_11(dev_handle, REMOTE_UNITTEST_INARG_1, out_bytebuf, sizeof(out_bytebuf)); if (ret) rpc_error(11); else if (verify_bytebuf(out_bytebuf)) verify_error(11, "obuf"); /* */ memset(&out_bytebuf, 0, sizeof(out_bytebuf)); ret = remote_unittest_12(dev_handle, REMOTE_UNITTEST_INARG_1, out_bytebuf, sizeof(out_bytebuf), &oalen); if (ret) rpc_error(12); else if (oalen != sizeof(out_bytebuf)) verify_error(12, "oalen"); else if (verify_bytebuf(out_bytebuf)) verify_error(12, "obuf"); /* */ init_data(&in_data); memset(&out_data, 0, sizeof(out_data)); ret = remote_unittest_13(dev_handle, in_data.test, sizeof(in_data.test), &in_data, sizeof(in_data), &out_data, sizeof(out_data)); if (ret) rpc_error(13); else if (verify_data(&out_data)) verify_error(13, "obuf"); /* */ init_data(&in_data); memset(out_bytebuf, 0, sizeof(out_bytebuf)); memset(out_bytebuf2, 0, sizeof(out_bytebuf2)); ret = remote_unittest_14(dev_handle, in_data.test, sizeof(in_data.test), out_bytebuf, sizeof(out_bytebuf), out_bytebuf2, sizeof(out_bytebuf2), &oalen); if (ret) rpc_error(14); else if (verify_bytebuf(out_bytebuf)) verify_error(14, "obuf"); else if (oalen != sizeof(out_bytebuf2)) verify_error(14, "oalen"); else if (verify_bytebuf(out_bytebuf2)) verify_error(14, "obuf2"); /* */ init_data(&in_data); memset(out_bytebuf, 0, sizeof(out_bytebuf)); memset(&out_data, 0, sizeof(out_data)); ret = remote_unittest_15(dev_handle, in_data.test, sizeof(in_data.test), &in_data, sizeof(in_data), &out_data, sizeof(out_data), &oalen, out_bytebuf, sizeof(out_bytebuf)); if (ret) rpc_error(15); else if (oalen != sizeof(out_data)) verify_error(15, "oalen"); else if (verify_bytebuf(out_bytebuf)) verify_error(15, "obuf"); else if (verify_data(&out_data)) verify_error(15, "obuf2"); /* */ event_handles[0] = dalrpc_alloc_event(dev_handle); event_handles[1] = dalrpc_alloc_event(dev_handle); event_handles[2] = dalrpc_alloc_event(dev_handle); cb_handle = dalrpc_alloc_cb(dev_handle, test_cb, &out_data); in_data.regular_event = (uint32_t)event_handles[2]; in_data.payload_event = (uint32_t)cb_handle; ret = remote_unittest_eventcfg(dev_handle, &in_data, sizeof(in_data)); if (ret) { errmask |= (1 << 16); printk(KERN_INFO "%s: failed to configure asynch (%d)\n", __func__, ret); } /* */ ret = remote_unittest_eventtrig(dev_handle, REMOTE_UNITTEST_REGULAR_EVENT); if (ret) { errmask |= (1 << 17); printk(KERN_INFO "%s: failed to trigger event (%d)\n", __func__, ret); } ret = dalrpc_event_wait(event_handles[2], 1000); if (ret) { errmask |= (1 << 18); printk(KERN_INFO "%s: failed to receive event (%d)\n", __func__, ret); } /* */ ret = remote_unittest_eventtrig(dev_handle, REMOTE_UNITTEST_REGULAR_EVENT); if (ret) { errmask |= (1 << 19); printk(KERN_INFO "%s: failed to trigger event (%d)\n", __func__, ret); } ret = dalrpc_event_wait_multiple(3, event_handles, 1000); if (ret != 2) { errmask |= (1 << 20); printk(KERN_INFO "%s: failed to receive event (%d)\n", __func__, ret); } /* */ ret = remote_unittest_eventtrig(dev_handle, REMOTE_UNITTEST_CALLBACK_EVENT); if (ret) { errmask |= (1 << 21); printk(KERN_INFO "%s: failed to trigger callback (%d)\n", __func__, ret); } else while (block_until_cb) ; dalrpc_dealloc_cb(dev_handle, cb_handle); dalrpc_dealloc_event(dev_handle, event_handles[0]); dalrpc_dealloc_event(dev_handle, event_handles[1]); dalrpc_dealloc_event(dev_handle, event_handles[2]); /* */ ret = daldevice_detach(dev_handle); if (ret) { errmask |= (1 << 22); printk(KERN_INFO "%s: failed to detach (%d)\n", __func__, ret); } printk(KERN_INFO "%s: remote_unittest complete\n", __func__); *val = errmask; return 0; }