Struct raft::ProgressTracker

source ·
pub struct ProgressTracker { /* private fields */ }
Expand description

ProgressTracker contains several Progresses, which could be Leader, Follower and Learner.

Implementations§

source§

impl ProgressTracker

source

pub fn conf(&self) -> &Configuration

The current configuration state of the cluster.

source§

impl ProgressTracker

source

pub fn new(max_inflight: usize) -> Self

Creates a new ProgressTracker.

source

pub fn with_capacity(voters: usize, learners: usize, max_inflight: usize) -> Self

Create a progress set with the specified sizes already reserved.

source

pub fn enable_group_commit(&mut self, enable: bool)

Configures group commit.

source

pub fn group_commit(&self) -> bool

Whether enable group commit.

source

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.

source

pub fn get(&self, id: u64) -> Option<&Progress>

Grabs a reference to the progress of a node.

source

pub fn get_mut(&mut self, id: u64) -> Option<&mut Progress>

Grabs a mutable reference to the progress of a node.

source

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.

source

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.

source

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.

source

pub fn reset_votes(&mut self)

Prepares for a new round of vote counting via recordVote.

source

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).

source

pub fn tally_votes(&self) -> (usize, usize, VoteResult)

TallyVotes returns the number of granted and rejected Votes, and whether the election outcome is known.

source

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.

source

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.

source

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.

source

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

source§

fn clone(&self) -> ProgressTracker

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,