[][src]Struct libraft::raft::Raft

pub struct Raft<T: Storage> {
    pub id: u64,
    pub term: u64,
    pub vote: u64,
    pub read_states: Vec<ReadState>,
    pub raft_log: RaftLog<T>,
    pub max_inflight: u64,
    pub max_msg_size: u64,
    pub prs: HashMap<u64, Progress>,
    pub learner_prs: HashMap<u64, Progress>,
    pub state: StateType,
    pub is_learner: bool,
    pub votes: HashMap<u64, bool>,
    pub msgs: Vec<Message>,
    pub lead: u64,
    pub lead_transferee: u64,
    pub pending_conf_index: u64,
    pub read_only: ReadOnly,
    pub election_elapsed: u64,
    pub heartbeat_elapsed: u64,
    pub check_quorum: bool,
    pub pre_vote: bool,
    pub heartbeat_timeout: u64,
    pub election_timeout: u64,
    pub randomized_election_timeout: u64,
    pub disable_proposal_forwarding: bool,
    // some fields omitted
}

Fields

id: u64term: u64vote: u64read_states: Vec<ReadState>raft_log: RaftLog<T>max_inflight: u64max_msg_size: u64prs: HashMap<u64, Progress>learner_prs: HashMap<u64, Progress>state: StateTypeis_learner: boolvotes: HashMap<u64, bool>msgs: Vec<Message>lead: u64lead_transferee: u64pending_conf_index: u64read_only: ReadOnlyelection_elapsed: u64heartbeat_elapsed: u64check_quorum: boolpre_vote: boolheartbeat_timeout: u64election_timeout: u64randomized_election_timeout: u64disable_proposal_forwarding: bool

Methods

impl<T: Storage> Raft<T>
[src]

pub fn new(c: &mut Config, storage: T) -> Raft<T>
[src]

Storage is the storage for raft. raft generates entries and states to be stored in storage. raft reads the persisted entries and states out of Storage when it needs. raft reads out the previous state and configuration out of storage when restarting.

pub fn get_status(&self) -> Status
[src]

pub fn load_state(&mut self, state: &HardState)
[src]

pub fn append_entry(&mut self, ents: &mut [Entry])
[src]

pub fn maybe_commit(&mut self) -> bool
[src]

pub fn become_follower(&mut self, term: u64, lead: u64)
[src]

pub fn become_leader(&mut self)
[src]

pub fn become_candidate(&mut self)
[src]

pub fn become_pre_candidate(&mut self)
[src]

pub fn reset(&mut self, term: u64)
[src]

pub fn reset_randomized_election_timeout(&mut self)
[src]

pub fn abort_leader_transfer(&mut self)
[src]

pub fn nodes(&self) -> Vec<u64>
[src]

pub fn learner_nodes(&self) -> Vec<u64>
[src]

pub fn add_node(&mut self, id: u64)
[src]

pub fn add_learner(&mut self, id: u64)
[src]

pub fn add_node_or_learner_node(&mut self, id: u64, is_learner: bool)
[src]

pub fn remove_node(&mut self, id: u64)
[src]

pub fn del_progress(&mut self, id: u64)
[src]

pub fn get_mut_progress(&mut self, id: u64) -> Option<&mut Progress>
[src]

pub fn get_progress(&self, id: u64) -> Option<&Progress>
[src]

pub fn set_progress(
    &mut self,
    id: u64,
    matched: u64,
    next: u64,
    is_learner: bool
)
[src]

pub fn soft_state(&self) -> SoftState
[src]

pub fn hard_state(&self) -> HardState
[src]

pub fn tick(&mut self)
[src]

pub fn promotable(&self) -> bool
[src]

promotable indicates whether state machine can be promoted to leader, which is true when its own id is in progress list.

pub fn past_election_timeout(&self) -> bool
[src]

past_election_timeout returns true iff r.electionElapsed is greater than or equal to the randomized election timeout in [electiontimeout, 2 * electiontimeout - 1].

pub fn step(&mut self, msg: Message) -> Result<()>
[src]

pub fn bcast_append(&mut self)
[src]

pub fn set_prs(&mut self, prs: HashMap<u64, Progress>)
[src]

pub fn take_prs(&mut self) -> HashMap<u64, Progress>
[src]

pub fn take_learner_prs(&mut self) -> HashMap<u64, Progress>
[src]

pub fn set_learner_prs(&mut self, learner_prs: HashMap<u64, Progress>)
[src]

pub fn restore(&mut self, s: Snapshot) -> bool
[src]

pub fn handle_heartbeat(&mut self, msg: Message)
[src]

pub fn handle_append_entries(&mut self, msg: &Message)
[src]

pub fn campaign(&mut self, campaign_type: &[u8])
[src]

Trait Implementations

impl<T: Default + Storage> Default for Raft<T>
[src]

Auto Trait Implementations

impl<T> Send for Raft<T> where
    T: Send

impl<T> Sync for Raft<T> where
    T: Sync

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]