-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpc.proto
61 lines (50 loc) · 1.86 KB
/
rpc.proto
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
syntax = "proto3";
package raft_rpc;
message rpc_Entry {
int32 term = 1;
int32 index = 2; // (wrong!even empty AE, we must send prelog_index)we can't put index in ae rpc, because: if we want to send an empty HB, we only need the term in ae
string msg = 3;
}
message AppendEntryRpc {
int32 term = 1;
int32 prelog_term = 2;
int32 commit_index = 3;
int32 lsn = 4;
string ip = 5;
int32 port = 6;
repeated rpc_Entry entry = 7;
int32 prelog_index = 8; //though entry has index, prelog_index can be caculated with index, however we still must have prelog_index because empty AE needs it to let itself verified by follower
}
message Resp_AppendEntryRpc {
bool ok = 1;
int32 term = 2;
int32 lsn = 3;
string ip = 4;
int32 port = 5;
/* why we must known the context of rpc (specifically, when received a resp_rpc, we must known the call rpc), why? here is the scene:
* Scene 1:
* P and F steady with [0], P haven't send any empty AE as HB, client apply [1], P AE with [1], P received resp_ae,
* ok:1, last_send_index: 1, follower_saved_index: 0, entry size: 2. P should add nextIndex to 2.
* Scene 2:
* P and F steady with [0], P send empty AE as HB, client apply [1], P received resp_ae,
* ok:1, last_send_index: 1, follower_saved_index: 0, entry size: 2. It is completely same with scene 1, but P should add nextIndex to 2,
* P should stay nextIndex to 1, and immediately trigger the next AE to send rpc_ae with entry [1].
* That's why we need extra information (the call of AE)
*/
bool is_empty_ae = 6;
}
message RequestVoteRpc {
int32 term = 1;
int32 latest_index = 2;
int32 latest_term = 3;
int32 lsn = 4;
string ip = 5;
int32 port = 6;
}
message Resp_RequestVoteRpc {
bool ok = 1;
int32 term = 2;
int32 lsn = 3;
string ip = 4;
int32 port = 5;
}