@@ -2,9 +2,9 @@ syntax = "proto3";
22package eraftpb ;
33
44enum EntryType {
5- EntryNormal = 0 ;
6- EntryConfChange = 1 ;
7- EntryConfChangeV2 = 2 ;
5+ EntryNormal = 0 ;
6+ EntryConfChange = 1 ;
7+ EntryConfChangeV2 = 2 ;
88}
99
1010// The entry is a type of change that needs to be applied. It contains two data fields.
@@ -18,134 +18,134 @@ enum EntryType {
1818// context will provide anything needed to assist the configuration change. The context
1919// if for the user to set and use in this case.
2020message Entry {
21- EntryType entry_type = 1 ;
22- uint64 term = 2 ;
23- uint64 index = 3 ;
24- bytes data = 4 ;
25- bytes context = 6 ;
26-
27- // Deprecated! It is kept for backward compatibility.
28- // TODO: remove it in the next major release.
29- bool sync_log = 5 ;
21+ EntryType entry_type = 1 ;
22+ uint64 term = 2 ;
23+ uint64 index = 3 ;
24+ bytes data = 4 ;
25+ bytes context = 6 ;
26+
27+ // Deprecated! It is kept for backward compatibility.
28+ // TODO: remove it in the next major release.
29+ bool sync_log = 5 ;
3030}
3131
3232message SnapshotMetadata {
33- // The current `ConfState`.
34- ConfState conf_state = 1 ;
35- // The applied index.
36- uint64 index = 2 ;
37- // The term of the applied index.
38- uint64 term = 3 ;
33+ // The current `ConfState`.
34+ ConfState conf_state = 1 ;
35+ // The applied index.
36+ uint64 index = 2 ;
37+ // The term of the applied index.
38+ uint64 term = 3 ;
3939}
4040
4141message Snapshot {
42- bytes data = 1 ;
43- SnapshotMetadata metadata = 2 ;
42+ bytes data = 1 ;
43+ SnapshotMetadata metadata = 2 ;
4444}
4545
4646enum MessageType {
47- MsgHup = 0 ;
48- MsgBeat = 1 ;
49- MsgPropose = 2 ;
50- MsgAppend = 3 ;
51- MsgAppendResponse = 4 ;
52- MsgRequestVote = 5 ;
53- MsgRequestVoteResponse = 6 ;
54- MsgSnapshot = 7 ;
55- MsgHeartbeat = 8 ;
56- MsgHeartbeatResponse = 9 ;
57- MsgUnreachable = 10 ;
58- MsgSnapStatus = 11 ;
59- MsgCheckQuorum = 12 ;
60- MsgTransferLeader = 13 ;
61- MsgTimeoutNow = 14 ;
62- MsgReadIndex = 15 ;
63- MsgReadIndexResp = 16 ;
64- MsgRequestPreVote = 17 ;
65- MsgRequestPreVoteResponse = 18 ;
47+ MsgHup = 0 ;
48+ MsgBeat = 1 ;
49+ MsgPropose = 2 ;
50+ MsgAppend = 3 ;
51+ MsgAppendResponse = 4 ;
52+ MsgRequestVote = 5 ;
53+ MsgRequestVoteResponse = 6 ;
54+ MsgSnapshot = 7 ;
55+ MsgHeartbeat = 8 ;
56+ MsgHeartbeatResponse = 9 ;
57+ MsgUnreachable = 10 ;
58+ MsgSnapStatus = 11 ;
59+ MsgCheckQuorum = 12 ;
60+ MsgTransferLeader = 13 ;
61+ MsgTimeoutNow = 14 ;
62+ MsgReadIndex = 15 ;
63+ MsgReadIndexResp = 16 ;
64+ MsgRequestPreVote = 17 ;
65+ MsgRequestPreVoteResponse = 18 ;
6666}
6767
6868message Message {
69- MessageType msg_type = 1 ;
70- uint64 to = 2 ;
71- uint64 from = 3 ;
72- uint64 term = 4 ;
73- uint64 log_term = 5 ;
74- uint64 index = 6 ;
75- repeated Entry entries = 7 ;
76- uint64 commit = 8 ;
77- Snapshot snapshot = 9 ;
78- uint64 request_snapshot = 13 ;
79- bool reject = 10 ;
80- uint64 reject_hint = 11 ;
81- bytes context = 12 ;
82- uint64 deprecated_priority = 14 ;
83- // If this new field is not set, then use the above old field; otherwise
84- // use the new field. When broadcasting request vote, both fields are
85- // set if the priority is larger than 0. This change is not a fully
86- // compatible change, but it makes minimal impact that only new priority
87- // is not recognized by the old nodes during rolling update.
88- int64 priority = 15 ;
69+ MessageType msg_type = 1 ;
70+ uint64 to = 2 ;
71+ uint64 from = 3 ;
72+ uint64 term = 4 ;
73+ uint64 log_term = 5 ;
74+ uint64 index = 6 ;
75+ repeated Entry entries = 7 ;
76+ uint64 commit = 8 ;
77+ Snapshot snapshot = 9 ;
78+ uint64 request_snapshot = 13 ;
79+ bool reject = 10 ;
80+ uint64 reject_hint = 11 ;
81+ bytes context = 12 ;
82+ uint64 deprecated_priority = 14 ;
83+ // If this new field is not set, then use the above old field; otherwise
84+ // use the new field. When broadcasting request vote, both fields are
85+ // set if the priority is larger than 0. This change is not a fully
86+ // compatible change, but it makes minimal impact that only new priority
87+ // is not recognized by the old nodes during rolling update.
88+ int64 priority = 15 ;
8989}
9090
9191message HardState {
92- uint64 term = 1 ;
93- uint64 vote = 2 ;
94- uint64 commit = 3 ;
92+ uint64 term = 1 ;
93+ uint64 vote = 2 ;
94+ uint64 commit = 3 ;
9595}
9696
9797enum ConfChangeTransition {
98- // Automatically use the simple protocol if possible, otherwise fall back
99- // to ConfChangeType::Implicit. Most applications will want to use this.
100- Auto = 0 ;
101- // Use joint consensus unconditionally, and transition out of them
102- // automatically (by proposing a zero configuration change).
103- //
104- // This option is suitable for applications that want to minimize the time
105- // spent in the joint configuration and do not store the joint configuration
106- // in the state machine (outside of InitialState).
107- Implicit = 1 ;
108- // Use joint consensus and remain in the joint configuration until the
109- // application proposes a no-op configuration change. This is suitable for
110- // applications that want to explicitly control the transitions, for example
111- // to use a custom payload (via the Context field).
112- Explicit = 2 ;
98+ // Automatically use the simple protocol if possible, otherwise fall back
99+ // to ConfChangeType::Implicit. Most applications will want to use this.
100+ Auto = 0 ;
101+ // Use joint consensus unconditionally, and transition out of them
102+ // automatically (by proposing a zero configuration change).
103+ //
104+ // This option is suitable for applications that want to minimize the time
105+ // spent in the joint configuration and do not store the joint configuration
106+ // in the state machine (outside of InitialState).
107+ Implicit = 1 ;
108+ // Use joint consensus and remain in the joint configuration until the
109+ // application proposes a no-op configuration change. This is suitable for
110+ // applications that want to explicitly control the transitions, for example
111+ // to use a custom payload (via the Context field).
112+ Explicit = 2 ;
113113}
114114
115115message ConfState {
116- repeated uint64 voters = 1 ;
117- repeated uint64 learners = 2 ;
118-
119- // The voters in the outgoing config. If not empty the node is in joint consensus.
120- repeated uint64 voters_outgoing = 3 ;
121- // The nodes that will become learners when the outgoing config is removed.
122- // These nodes are necessarily currently in nodes_joint (or they would have
123- // been added to the incoming config right away).
124- repeated uint64 learners_next = 4 ;
125- // If set, the config is joint and Raft will automatically transition into
126- // the final config (i.e. remove the outgoing config) when this is safe.
127- bool auto_leave = 5 ;
116+ repeated uint64 voters = 1 ;
117+ repeated uint64 learners = 2 ;
118+
119+ // The voters in the outgoing config. If not empty the node is in joint consensus.
120+ repeated uint64 voters_outgoing = 3 ;
121+ // The nodes that will become learners when the outgoing config is removed.
122+ // These nodes are necessarily currently in nodes_joint (or they would have
123+ // been added to the incoming config right away).
124+ repeated uint64 learners_next = 4 ;
125+ // If set, the config is joint and Raft will automatically transition into
126+ // the final config (i.e. remove the outgoing config) when this is safe.
127+ bool auto_leave = 5 ;
128128}
129129
130130enum ConfChangeType {
131- AddNode = 0 ;
132- RemoveNode = 1 ;
133- AddLearnerNode = 2 ;
131+ AddNode = 0 ;
132+ RemoveNode = 1 ;
133+ AddLearnerNode = 2 ;
134134}
135135
136136message ConfChange {
137- ConfChangeType change_type = 2 ;
138- uint64 node_id = 3 ;
139- bytes context = 4 ;
137+ ConfChangeType change_type = 2 ;
138+ uint64 node_id = 3 ;
139+ bytes context = 4 ;
140140
141- uint64 id = 1 ;
141+ uint64 id = 1 ;
142142}
143143
144144// ConfChangeSingle is an individual configuration change operation. Multiple
145145// such operations can be carried out atomically via a ConfChangeV2.
146146message ConfChangeSingle {
147- ConfChangeType change_type = 1 ;
148- uint64 node_id = 2 ;
147+ ConfChangeType change_type = 1 ;
148+ uint64 node_id = 2 ;
149149}
150150
151151// ConfChangeV2 messages initiate configuration changes. They support both the
@@ -181,7 +181,7 @@ message ConfChangeSingle {
181181//
182182// [1]: https://github.com/ongardie/dissertation/blob/master/online-trim.pdf
183183message ConfChangeV2 {
184- ConfChangeTransition transition = 1 ;
185- repeated ConfChangeSingle changes = 2 ;
186- bytes context = 3 ;
184+ ConfChangeTransition transition = 1 ;
185+ repeated ConfChangeSingle changes = 2 ;
186+ bytes context = 3 ;
187187}
0 commit comments