Skip to content

Commit 63c0918

Browse files
authored
Revert changes (#144)
Revert some changes from #141 I've realized these functions might be required, either for snapshotting process or testing. e.g: `raft_node_set_voting()` is required after snapshot: https://github.com/RedisLabs/raft/blame/master/docs/Using.md#L306 For now, we can keep them in raft.h . Over time, we can revisit this decision and move into raft_private.h if necessary.
1 parent 6ca5609 commit 63c0918

File tree

2 files changed

+39
-32
lines changed

2 files changed

+39
-32
lines changed

include/raft.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,10 @@ raft_node_t *raft_get_node(raft_server_t *me, raft_node_id_t id);
11661166
* @return node pointed to by node idx */
11671167
raft_node_t *raft_get_node_from_idx(raft_server_t *me, raft_index_t idx);
11681168

1169+
/**
1170+
* @return node ID of who I voted for */
1171+
raft_node_id_t raft_get_voted_for(raft_server_t *me);
1172+
11691173
/** Get what this node thinks the node ID of the leader is.
11701174
* @return node of what this node thinks is the valid leader;
11711175
* RAFT_NODE_ID_NONE if there is no leader */
@@ -1326,6 +1330,41 @@ raft_index_t raft_get_snapshot_last_idx(raft_server_t *me);
13261330
/** Return last applied entry term that snapshot includes. */
13271331
raft_term_t raft_get_snapshot_last_term(raft_server_t *me);
13281332

1333+
/** Turn a node into a voting node.
1334+
* Voting nodes can take part in elections and in-regards to committing entries,
1335+
* are counted in majorities. */
1336+
void raft_node_set_voting(raft_node_t *node, int voting);
1337+
1338+
/** Tell if a node is a voting node or not.
1339+
* @return 1 if this is a voting node. Otherwise 0. */
1340+
int raft_node_is_voting(raft_node_t *node);
1341+
1342+
/** Check if a node is active.
1343+
* Active nodes could become voting nodes.
1344+
* This should be used for creating the membership snapshot.
1345+
**/
1346+
int raft_node_is_active(raft_node_t *node);
1347+
1348+
/** Make the node active.
1349+
* @param[in] active Set a node as active if this is 1
1350+
**/
1351+
void raft_node_set_active(raft_node_t *node, int active);
1352+
1353+
/** Confirm that a node's voting status is final
1354+
* @param[in] node The node
1355+
* @param[in] voting Whether this node's voting status is committed or not */
1356+
void raft_node_set_voting_committed(raft_node_t *node, int voting);
1357+
1358+
/** Confirm that a node's voting status is final
1359+
* @param[in] node The node
1360+
* @param[in] committed Whether this node's membership is committed or not */
1361+
void raft_node_set_addition_committed(raft_node_t *node, int committed);
1362+
1363+
/** Set next entry index to deliver
1364+
* @param[in] node The node
1365+
* @param[in] idx Next entry index to deliver */
1366+
void raft_node_set_next_idx(raft_node_t *node, raft_index_t idx);
1367+
13291368
/** Check if a node's voting status has been committed.
13301369
* This should be used for creating the membership snapshot.
13311370
**/

include/raft_private.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ void raft_node_set_match_idx(raft_node_t *node, raft_index_t idx);
168168

169169
raft_index_t raft_node_get_match_idx(raft_node_t *node);
170170

171-
void raft_node_set_next_idx(raft_node_t *node, raft_index_t idx);
172-
173171
raft_index_t raft_node_get_next_idx(raft_node_t *node);
174172

175173
void raft_node_clear_flags(raft_node_t *node);
@@ -180,38 +178,12 @@ int raft_node_has_vote_for_me(raft_node_t *node);
180178

181179
void raft_node_set_has_sufficient_logs(raft_node_t *node, int sufficient_logs);
182180

183-
void raft_node_set_voting_committed(raft_node_t *node, int voting);
184-
185-
/** Check if a node is active.
186-
* Active nodes could become voting nodes.
187-
* This should be used for creating the membership snapshot.
188-
**/
189-
int raft_node_is_active(raft_node_t *node);
190181

191-
/** Make the node active.
192-
*
193-
* The user sets this to 1 between raft_begin_load_snapshot and
194-
* raft_end_load_snapshot.
195-
*
196-
* @param[in] active Set a node as active if this is 1
197-
**/
198-
void raft_node_set_active(raft_node_t *node, int active);
199-
200-
/** Turn a node into a voting node.
201-
* Voting nodes can take part in elections and in-regards to committing entries,
202-
* are counted in majorities. */
203-
void raft_node_set_voting(raft_node_t *node, int voting);
204-
205-
/** Tell if a node is a voting node or not.
206-
* @return 1 if this is a voting node. Otherwise 0. */
207-
int raft_node_is_voting(raft_node_t *node);
208182

209183
/** Check if a node has sufficient logs to be able to join the cluster.
210184
**/
211185
int raft_node_has_sufficient_logs(raft_node_t *node);
212186

213-
void raft_node_set_addition_committed(raft_node_t *node, int committed);
214-
215187
int raft_is_single_node_voting_cluster(raft_server_t *me);
216188

217189
int raft_votes_is_majority(int nnodes, int nvotes);
@@ -290,10 +262,6 @@ int raft_vote_for_nodeid(raft_server_t* me, raft_node_id_t nodeid);
290262
* @return number of votes this server has received this election */
291263
int raft_get_nvotes_for_me(raft_server_t* me);
292264

293-
/**
294-
* @return node ID of who I voted for */
295-
raft_node_id_t raft_get_voted_for(raft_server_t *me);
296-
297265
/**
298266
* @return currently elapsed timeout in milliseconds */
299267
raft_time_t raft_get_timeout_elapsed(raft_server_t *me);

0 commit comments

Comments
 (0)