Struct raft::ProgressTracker
source · pub struct ProgressTracker { /* private fields */ }
Expand description
ProgressTracker
contains several Progress
es,
which could be Leader
, Follower
and Learner
.
Implementations§
source§impl ProgressTracker
impl ProgressTracker
sourcepub fn with_capacity(voters: usize, learners: usize, max_inflight: usize) -> Self
pub fn with_capacity(voters: usize, learners: usize, max_inflight: usize) -> Self
Create a progress set with the specified sizes already reserved.
sourcepub fn enable_group_commit(&mut self, enable: bool)
pub fn enable_group_commit(&mut self, enable: bool)
Configures group commit.
sourcepub fn group_commit(&self) -> bool
pub fn group_commit(&self) -> bool
Whether enable group commit.
sourcepub fn is_singleton(&self) -> bool
pub fn is_singleton(&self) -> bool
Returns true if (and only if) there is only one voting member (i.e. the leader) in the current configuration.
sourcepub fn get_mut(&mut self, id: u64) -> Option<&mut Progress>
pub fn get_mut(&mut self, id: u64) -> Option<&mut Progress>
Grabs a mutable reference to the progress of a node.
sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (&u64, &Progress)>
pub fn iter(&self) -> impl ExactSizeIterator<Item = (&u64, &Progress)>
Returns an iterator across all the nodes and their progress.
Note: Do not use this for majority/quorum calculation. The Raft node may be
transitioning to a new configuration and have two qourums. Use has_quorum
instead.
sourcepub fn iter_mut(
&mut self
) -> impl ExactSizeIterator<Item = (&u64, &mut Progress)>
pub fn iter_mut( &mut self ) -> impl ExactSizeIterator<Item = (&u64, &mut Progress)>
Returns a mutable iterator across all the nodes and their progress.
Note: Do not use this for majority/quorum calculation. The Raft node may be
transitioning to a new configuration and have two qourums. Use has_quorum
instead.
sourcepub fn maximal_committed_index(&mut self) -> (u64, bool)
pub fn maximal_committed_index(&mut self) -> (u64, bool)
Returns the maximal committed index for the cluster. The bool flag indicates whether the index is computed by group commit algorithm successfully.
Eg. If the matched indexes are [2,2,2,4,5]
, it will return 2
.
If the matched indexes and groups are [(1, 1), (2, 2), (3, 2)]
, it will return 1
.
sourcepub fn reset_votes(&mut self)
pub fn reset_votes(&mut self)
Prepares for a new round of vote counting via recordVote.
sourcepub fn record_vote(&mut self, id: u64, vote: bool)
pub fn record_vote(&mut self, id: u64, vote: bool)
Records that the node with the given id voted for this Raft instance if v == true (and declined it otherwise).
sourcepub fn tally_votes(&self) -> (usize, usize, VoteResult)
pub fn tally_votes(&self) -> (usize, usize, VoteResult)
TallyVotes returns the number of granted and rejected Votes, and whether the election outcome is known.
sourcepub fn vote_result(
&self,
votes: &HashMap<u64, bool, BuildHasherDefault<FxHasher>>
) -> VoteResult
pub fn vote_result( &self, votes: &HashMap<u64, bool, BuildHasherDefault<FxHasher>> ) -> VoteResult
Returns the Candidate’s eligibility in the current election.
If it is still eligible, it should continue polling nodes and checking.
Eventually, the election will result in this returning either Elected
or Ineligible
, meaning the election can be concluded.
sourcepub fn quorum_recently_active(&mut self, perspective_of: u64) -> bool
pub fn quorum_recently_active(&mut self, perspective_of: u64) -> bool
Determines if the current quorum is active according to the this raft node.
Doing this will set the recent_active
of each peer to false.
This should only be called by the leader.
sourcepub fn has_quorum(
&self,
potential_quorum: &HashSet<u64, BuildHasherDefault<FxHasher>>
) -> bool
pub fn has_quorum( &self, potential_quorum: &HashSet<u64, BuildHasherDefault<FxHasher>> ) -> bool
Determine if a quorum is formed from the given set of nodes.
This is the only correct way to verify you have reached a quorum for the whole group.
sourcepub fn apply_conf(
&mut self,
conf: Configuration,
changes: MapChange,
next_idx: u64
)
pub fn apply_conf( &mut self, conf: Configuration, changes: MapChange, next_idx: u64 )
Applies configuration and updates progress map to match the configuration.
Trait Implementations§
source§impl Clone for ProgressTracker
impl Clone for ProgressTracker
source§fn clone(&self) -> ProgressTracker
fn clone(&self) -> ProgressTracker
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more