本文整理汇总了C++中dsn::rpc_address::is_invalid方法的典型用法代码示例。如果您正苦于以下问题:C++ rpc_address::is_invalid方法的具体用法?C++ rpc_address::is_invalid怎么用?C++ rpc_address::is_invalid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dsn::rpc_address
的用法示例。
在下文中一共展示了rpc_address::is_invalid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_address
//ERR_OBJECT_NOT_FOUND not in cache.
//ERR_IO_PENDING in cache but invalid, remove from cache.
//ERR_OK in cache and valid
error_code replication_app_client_base::get_address(int pidx, bool is_write, /*out*/ dsn::rpc_address& addr, read_semantic_t semantic)
{
partition_configuration config;
{
zauto_read_lock l(_config_lock);
auto it = _config_cache.find(pidx);
if(it != _config_cache.end())
{
config = it->second;
addr = get_address(is_write, semantic, config);
if (addr.is_invalid())
{
return ERR_IO_PENDING;
}
else
{
return ERR_OK;
}
}
else
{
return ERR_OBJECT_NOT_FOUND;
}
}
}
示例2: call_with_address
void replication_app_client_base::call_with_address(dsn::rpc_address addr, request_context_ptr request)
{
auto& msg = request->request;
dbg_dassert(!addr.is_invalid(), "");
dbg_dassert(_app_id > 0, "");
if (request->header_pos != 0)
{
if (request->is_read)
{
request->read_header.gpid.app_id = _app_id;
request->read_header.gpid.pidx = request->partition_index;
blob buffer(request->header_pos, 0, sizeof(request->read_header));
binary_writer writer(buffer);
marshall(writer, request->read_header);
dsn_msg_options_t opts;
opts.timeout_ms = request->timeout_ms;
opts.thread_hash = gpid_to_hash(request->read_header.gpid);
opts.vnid = *(uint64_t*)(&request->read_header.gpid);
dsn_msg_set_options(request->request, &opts, DSN_MSGM_HASH | DSN_MSGM_TIMEOUT); // TODO: not supported yet DSN_MSGM_VNID);
}
else
{
request->write_header.gpid.app_id = _app_id;
request->write_header.gpid.pidx = request->partition_index;
blob buffer(request->header_pos, 0, sizeof(request->write_header));
binary_writer writer(buffer);
marshall(writer, request->write_header);
dsn_msg_options_t opts;
opts.timeout_ms = request->timeout_ms;
opts.thread_hash = gpid_to_hash(request->write_header.gpid);
opts.vnid = *(uint64_t*)(&request->write_header.gpid);
dsn_msg_set_options(request->request, &opts, DSN_MSGM_HASH | DSN_MSGM_TIMEOUT); // TODO: not supported yet DSN_MSGM_VNID | DSN_MSGM_CONTEXT);
}
request->header_pos = 0;
}
{
zauto_lock l(request->lock);
rpc::call(
addr,
msg,
this,
std::bind(
&replication_app_client_base::replica_rw_reply,
this,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3,
request
)
);
}
}
示例3: dassert
::dsn::rpc_address replication_failure_detector::find_next_meta_server(::dsn::rpc_address current)
{
if (current.is_invalid())
return _meta_servers[random32(0, 100) % _meta_servers.size()];
else
{
auto it = std::find(_meta_servers.begin(), _meta_servers.end(), current);
dassert (it != _meta_servers.end(), "");
it++;
if (it != _meta_servers.end())
return *it;
else
return _meta_servers.at(0);
}
}