messaging_service: Add wrapper for READ_MUTATION_DATA verb

This commit is contained in:
Asias He
2015-07-16 08:53:48 +08:00
parent 85c6dc0b7e
commit c19f5edefe
3 changed files with 13 additions and 2 deletions

View File

@@ -293,4 +293,11 @@ future<query::result> messaging_service::send_read_data(shard_id id, query::read
return send_message<query::result>(messaging_verb::READ_DATA, std::move(id), cmd, pr);
}
void messaging_service::register_read_mutation_data(std::function<future<foreign_ptr<lw_shared_ptr<reconcilable_result>>> (query::read_command cmd, query::partition_range pr)>&& func) {
register_handler(net::messaging_verb::READ_MUTATION_DATA, std::move(func));
}
future<reconcilable_result> messaging_service::send_read_mutation_data(shard_id id, query::read_command& cmd, query::partition_range& pr) {
return send_message<reconcilable_result>(messaging_verb::READ_MUTATION_DATA, std::move(id), cmd, pr);
}
} // namespace net

View File

@@ -423,6 +423,10 @@ public:
void register_read_data(std::function<future<foreign_ptr<lw_shared_ptr<query::result>>> (query::read_command cmd, query::partition_range pr)>&& func);
future<query::result> send_read_data(shard_id id, query::read_command& cmd, query::partition_range& pr);
// Wrapper for READ_MUTATION_DATA
void register_read_mutation_data(std::function<future<foreign_ptr<lw_shared_ptr<reconcilable_result>>> (query::read_command cmd, query::partition_range pr)>&& func);
future<reconcilable_result> send_read_mutation_data(shard_id id, query::read_command& cmd, query::partition_range& pr);
private:
// Return rpc::protocol::client for a shard which is a ip + cpuid pair.
rpc_protocol_client_wrapper& get_rpc_client(shard_id id);

View File

@@ -1470,7 +1470,7 @@ protected:
return _proxy.query_mutations_locally(_cmd, _partition_range);
} else {
auto& ms = net::get_local_messaging_service();
return ms.send_message<reconcilable_result>(net::messaging_verb::READ_MUTATION_DATA, net::messaging_service::shard_id{ep, 0}, *_cmd, _partition_range).then([this](reconcilable_result&& result) {
return ms.send_read_mutation_data(net::messaging_service::shard_id{ep, 0}, *_cmd, _partition_range).then([this](reconcilable_result&& result) {
return make_foreign(::make_lw_shared<reconcilable_result>(std::move(result)));
});
}
@@ -2829,7 +2829,7 @@ void storage_proxy::init_messaging_service() {
return query_singular_local(cmd, pr);
});
});
ms.register_handler(net::messaging_verb::READ_MUTATION_DATA, [this] (query::read_command cmd, query::partition_range pr) {
ms.register_read_mutation_data([this] (query::read_command cmd, query::partition_range pr) {
return do_with(std::move(pr), [this, cmd = make_lw_shared<query::read_command>(std::move(cmd))] (const query::partition_range& pr) {
return query_mutations_locally(cmd, pr);
});