-
Notifications
You must be signed in to change notification settings - Fork 2
/
kvraft_tool_impl.cpp
executable file
·81 lines (53 loc) · 1.71 KB
/
kvraft_tool_impl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* kvraft_tool_impl.cpp
Generated by phxrpc_pb2tool from kvraft.proto
*/
#include "kvraft_tool_impl.h"
#include "kvraft_client.h"
#include "phxrpc/file.h"
using namespace phxrpc;
using namespace std;
KVRaftToolImpl::KVRaftToolImpl() {
}
KVRaftToolImpl::~KVRaftToolImpl() {
}
int KVRaftToolImpl::PHXEcho(phxrpc::OptMap &opt_map) {
google::protobuf::StringValue req;
google::protobuf::StringValue resp;
if (nullptr == opt_map.Get('s')) return -1;
req.set_value(opt_map.Get('s'));
KVRaftClient client;
int ret{client.PHXEcho(req, &resp)};
printf("%s return %d\n", __func__, ret);
printf("resp: {\n%s}\n", resp.DebugString().c_str());
return ret;
}
int KVRaftToolImpl::RequestVote(phxrpc::OptMap &opt_map) {
kvraft::RequestVoteArgs req;
kvraft::RequestVoteReply resp;
// TODO: fill req from opt_map
KVRaftClient client;
int ret{client.RequestVote(req, &resp)};
printf("%s return %d\n", __func__, ret);
printf("resp: {\n%s}\n", resp.DebugString().c_str());
return ret;
}
int KVRaftToolImpl::AppendEntries(phxrpc::OptMap &opt_map) {
kvraft::AppendEntriesArgs req;
kvraft::AppendEntriesReply resp;
// TODO: fill req from opt_map
KVRaftClient client;
int ret{client.AppendEntries(req, &resp)};
printf("%s return %d\n", __func__, ret);
printf("resp: {\n%s}\n", resp.DebugString().c_str());
return ret;
}
int KVRaftToolImpl::Command(phxrpc::OptMap &opt_map) {
kvraft::KVArgs req;
kvraft::KVReply resp;
// TODO: fill req from opt_map
KVRaftClient client;
int ret{client.Command(req, &resp)};
printf("%s return %d\n", __func__, ret);
printf("resp: {\n%s}\n", resp.DebugString().c_str());
return ret;
}