5 #include "rsm_protocol.h"
11 // rsm client interface.
13 // The client stubs package up an rpc, and then call the invoke procedure
14 // on the replicated state machine passing the RPC as an argument. This way
15 // the replicated state machine isn't service specific; any server can use it.
21 std::vector<std::string> known_mems;
22 pthread_mutex_t rsm_client_mutex;
23 void primary_failure();
26 rsm_client(std::string dst);
27 rsm_protocol::status invoke(int proc, std::string req, std::string &rep);
29 template<class R, class A1>
30 int call(unsigned int proc, const A1 & a1, R &r);
32 template<class R, class A1, class A2>
33 int call(unsigned int proc, const A1 & a1, const A2 & a2, R &r);
35 template<class R, class A1, class A2, class A3>
36 int call(unsigned int proc, const A1 & a1, const A2 & a2, const A3 & a3,
39 template<class R, class A1, class A2, class A3, class A4>
40 int call(unsigned int proc, const A1 & a1, const A2 & a2, const A3 & a3,
43 template<class R, class A1, class A2, class A3, class A4, class A5>
44 int call(unsigned int proc, const A1 & a1, const A2 & a2, const A3 & a3,
45 const A4 & a4, const A5 & a5, R &r);
47 template<class R> int call_m(unsigned int proc, marshall &req, R &r);
51 int rsm_client::call_m(unsigned int proc, marshall &req, R &r) {
54 int intret = invoke(proc, req.str(), rep);
55 VERIFY( intret == rsm_client_protocol::OK );
58 if (intret < 0) return intret;
61 fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
62 "You probably forgot to set the reply string in "
63 "rsm::client_invoke, or you may call RPC 0x%x with wrong return "
66 return rpc_const::unmarshal_reply_failure;
71 fprintf(stderr, "rsm_client::call_m: failed to unmarshall the reply.\n"
72 "You are probably calling RPC 0x%x with wrong return "
75 return rpc_const::unmarshal_reply_failure;
80 template<class R, class A1>
81 int rsm_client::call(unsigned int proc, const A1 & a1, R & r) {
84 return call_m(proc, m, r);
87 template<class R, class A1, class A2>
88 int rsm_client::call(unsigned int proc, const A1 & a1, const A2 & a2, R & r) {
92 return call_m(proc, m, r);
95 template<class R, class A1, class A2, class A3>
96 int rsm_client::call(unsigned int proc, const A1 & a1, const A2 & a2, const A3 & a3, R & r) {
103 return call_m(proc, m, r);
106 template<class R, class A1, class A2, class A3, class A4>
107 int rsm_client::call(unsigned int proc, const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4, R & r) {
115 return call_m(proc, m, r);
118 template<class R, class A1, class A2, class A3, class A4, class A5>
119 int rsm_client::call(unsigned int proc, const A1 & a1, const A2 & a2, const A3 & a3, const A4 & a4, const A5 & a5, R & r) {
128 return call_m(proc, m, r);