5 #include "rsm_protocol.h"
8 // rsm client interface.
10 // The client stubs package up an rpc, and then call the invoke procedure
11 // on the replicated state machine passing the RPC as an argument. This way
12 // the replicated state machine isn't service specific; any server can use it.
18 std::vector<std::string> known_mems;
19 std::mutex rsm_client_mutex;
20 void primary_failure(lock & rsm_client_mutex_lock);
21 bool init_members(lock & rsm_client_mutex_lock);
23 rsm_client(std::string dst);
24 rsm_protocol::status invoke(unsigned int proc, std::string &rep, const std::string &req);
26 template<class R, class ...Args>
27 int call(unsigned int proc, R & r, const Args & ...a1);
29 template<class R> int call_m(unsigned int proc, R & r, const marshall & req);
33 int rsm_client::call_m(unsigned int proc, R & r, const marshall & req) {
36 int intret = invoke(proc, rep, req.cstr());
37 VERIFY( intret == rsm_client_protocol::OK );
40 if (intret < 0) return intret;
43 fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
44 "You probably forgot to set the reply string in "
45 "rsm::client_invoke, or you may call RPC 0x%x with wrong return "
48 return rpc_const::unmarshal_reply_failure;
53 fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
54 "You are probably calling RPC 0x%x with wrong return "
57 return rpc_const::unmarshal_reply_failure;
62 template<class R, class ...Args>
63 int rsm_client::call(unsigned int proc, R & r, const Args & ...a1) {
64 return call_m(proc, r, marshall{a1...});