Unverified Commit 63c09185 authored by Ozan Tezcan's avatar Ozan Tezcan Committed by GitHub
Browse files

Revert changes (#144)

Revert some changes from https://github.com/RedisLabs/raft/pull/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. 
parent 6ca56090
...@@ -1166,6 +1166,10 @@ raft_node_t *raft_get_node(raft_server_t *me, raft_node_id_t id); ...@@ -1166,6 +1166,10 @@ raft_node_t *raft_get_node(raft_server_t *me, raft_node_id_t id);
* @return node pointed to by node idx */ * @return node pointed to by node idx */
raft_node_t *raft_get_node_from_idx(raft_server_t *me, raft_index_t idx); raft_node_t *raft_get_node_from_idx(raft_server_t *me, raft_index_t idx);
/**
* @return node ID of who I voted for */
raft_node_id_t raft_get_voted_for(raft_server_t *me);
/** Get what this node thinks the node ID of the leader is. /** Get what this node thinks the node ID of the leader is.
* @return node of what this node thinks is the valid leader; * @return node of what this node thinks is the valid leader;
* RAFT_NODE_ID_NONE if there is no leader */ * 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); ...@@ -1326,6 +1330,41 @@ raft_index_t raft_get_snapshot_last_idx(raft_server_t *me);
/** Return last applied entry term that snapshot includes. */ /** Return last applied entry term that snapshot includes. */
raft_term_t raft_get_snapshot_last_term(raft_server_t *me); raft_term_t raft_get_snapshot_last_term(raft_server_t *me);
/** Turn a node into a voting node.
* Voting nodes can take part in elections and in-regards to committing entries,
* are counted in majorities. */
void raft_node_set_voting(raft_node_t *node, int voting);
/** Tell if a node is a voting node or not.
* @return 1 if this is a voting node. Otherwise 0. */
int raft_node_is_voting(raft_node_t *node);
/** Check if a node is active.
* Active nodes could become voting nodes.
* This should be used for creating the membership snapshot.
**/
int raft_node_is_active(raft_node_t *node);
/** Make the node active.
* @param[in] active Set a node as active if this is 1
**/
void raft_node_set_active(raft_node_t *node, int active);
/** Confirm that a node's voting status is final
* @param[in] node The node
* @param[in] voting Whether this node's voting status is committed or not */
void raft_node_set_voting_committed(raft_node_t *node, int voting);
/** Confirm that a node's voting status is final
* @param[in] node The node
* @param[in] committed Whether this node's membership is committed or not */
void raft_node_set_addition_committed(raft_node_t *node, int committed);
/** Set next entry index to deliver
* @param[in] node The node
* @param[in] idx Next entry index to deliver */
void raft_node_set_next_idx(raft_node_t *node, raft_index_t idx);
/** Check if a node's voting status has been committed. /** Check if a node's voting status has been committed.
* This should be used for creating the membership snapshot. * This should be used for creating the membership snapshot.
**/ **/
......
...@@ -168,8 +168,6 @@ void raft_node_set_match_idx(raft_node_t *node, raft_index_t idx); ...@@ -168,8 +168,6 @@ void raft_node_set_match_idx(raft_node_t *node, raft_index_t idx);
raft_index_t raft_node_get_match_idx(raft_node_t *node); raft_index_t raft_node_get_match_idx(raft_node_t *node);
void raft_node_set_next_idx(raft_node_t *node, raft_index_t idx);
raft_index_t raft_node_get_next_idx(raft_node_t *node); raft_index_t raft_node_get_next_idx(raft_node_t *node);
void raft_node_clear_flags(raft_node_t *node); void raft_node_clear_flags(raft_node_t *node);
...@@ -180,38 +178,12 @@ int raft_node_has_vote_for_me(raft_node_t *node); ...@@ -180,38 +178,12 @@ int raft_node_has_vote_for_me(raft_node_t *node);
void raft_node_set_has_sufficient_logs(raft_node_t *node, int sufficient_logs); void raft_node_set_has_sufficient_logs(raft_node_t *node, int sufficient_logs);
void raft_node_set_voting_committed(raft_node_t *node, int voting);
/** Check if a node is active.
* Active nodes could become voting nodes.
* This should be used for creating the membership snapshot.
**/
int raft_node_is_active(raft_node_t *node);
/** Make the node active.
*
* The user sets this to 1 between raft_begin_load_snapshot and
* raft_end_load_snapshot.
*
* @param[in] active Set a node as active if this is 1
**/
void raft_node_set_active(raft_node_t *node, int active);
/** Turn a node into a voting node.
* Voting nodes can take part in elections and in-regards to committing entries,
* are counted in majorities. */
void raft_node_set_voting(raft_node_t *node, int voting);
/** Tell if a node is a voting node or not.
* @return 1 if this is a voting node. Otherwise 0. */
int raft_node_is_voting(raft_node_t *node);
/** Check if a node has sufficient logs to be able to join the cluster. /** Check if a node has sufficient logs to be able to join the cluster.
**/ **/
int raft_node_has_sufficient_logs(raft_node_t *node); int raft_node_has_sufficient_logs(raft_node_t *node);
void raft_node_set_addition_committed(raft_node_t *node, int committed);
int raft_is_single_node_voting_cluster(raft_server_t *me); int raft_is_single_node_voting_cluster(raft_server_t *me);
int raft_votes_is_majority(int nnodes, int nvotes); 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); ...@@ -290,10 +262,6 @@ int raft_vote_for_nodeid(raft_server_t* me, raft_node_id_t nodeid);
* @return number of votes this server has received this election */ * @return number of votes this server has received this election */
int raft_get_nvotes_for_me(raft_server_t* me); int raft_get_nvotes_for_me(raft_server_t* me);
/**
* @return node ID of who I voted for */
raft_node_id_t raft_get_voted_for(raft_server_t *me);
/** /**
* @return currently elapsed timeout in milliseconds */ * @return currently elapsed timeout in milliseconds */
raft_time_t raft_get_timeout_elapsed(raft_server_t *me); raft_time_t raft_get_timeout_elapsed(raft_server_t *me);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment