[][src]Struct libraft::raft_log::RaftLog

pub struct RaftLog<T: Storage> {
    pub storage: T,
    pub unstable: Unstable,
    pub committed: u64,
    pub applied: u64,
    pub tag: String,
}

Fields

storage: T

storage contains all stable entries since the last snapshot.

unstable: Unstable

unstable contains all unstable entries and snapshot. they will be saved into storage.

committed: u64

committed is the highest log position that is known to be in stable storage on a quorum of nodes.

applied: u64

applied is the highest log position that the application has been instructed to apply to its state machine. Invariant: applied <= committed

tag: String

tag only used for logger.

Methods

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

pub fn new(storage: T, tag: String) -> RaftLog<T>
[src]

pub fn last_index(&self) -> u64
[src]

pub fn first_index(&self) -> u64
[src]

pub fn applied_to(&mut self, i: u64)
[src]

pub fn last_term(&self) -> u64
[src]

pub fn term(&self, i: u64) -> Result<u64>
[src]

pub fn get_applied(&self) -> u64
[src]

pub fn get_storage(&self) -> &T
[src]

pub fn append(&mut self, ents: &[Entry]) -> u64
[src]

pub fn maybe_commit(&mut self, max_index: u64, term: u64) -> bool
[src]

pub fn commit_to(&mut self, tocommit: u64)
[src]

pub fn zero_term_on_err_compacted(&self, t: Result<u64>) -> u64
[src]

pub fn must_check_out_of_bounds(&self, low: u64, hight: u64) -> Result<()>
[src]

pub fn slice(&self, lo: u64, hi: u64, max_size: u64) -> Result<Vec<Entry>>
[src]

pub fn entries(&self, i: u64, max_size: u64) -> Result<Vec<Entry>>
[src]

pub fn is_up_to_date(&self, index: u64, term: u64) -> bool
[src]

is_up_to_date determines if the given (last_index,term) log is more up-to-date by comparing the index and term of the last entries in the existing logs. If the logs have last entries with different terms, then the log with the later term is more up-to-date. If the logs end with the same term, then whichever log has the larger last_index is more up-to-date. If the logs are the same, the given log is up-to-date.

pub fn match_term(&self, i: u64, term: u64) -> bool
[src]

pub fn maybe_append(
    &mut self,
    index: u64,
    log_term: u64,
    committed: u64,
    ents: &[Entry]
) -> Option<u64>
[src]

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

pub fn snapshot(&self) -> Result<Snapshot>
[src]

pub fn unstable_entries(&self) -> Vec<Entry>
[src]

pub fn next_ents(&self) -> Vec<Entry>
[src]

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

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

pub fn stable_snap_to(&mut self, index: u64)
[src]

pub fn all_entries(&self) -> Vec<Entry>
[src]

Trait Implementations

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

impl<T: Storage> ToString for RaftLog<T>
[src]

impl<T: Debug + Storage> Debug for RaftLog<T>
[src]

Auto Trait Implementations

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

impl<T> Sync for RaftLog<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> ToString for T where
    T: Display + ?Sized
[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]