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.
Implementations§
Source§impl<T: Storage> RaftLog<T>
impl<T: Storage> RaftLog<T>
pub fn new(storage: T, tag: String) -> RaftLog<T>
pub fn last_index(&self) -> u64
pub fn first_index(&self) -> u64
pub fn applied_to(&mut self, i: u64)
pub fn last_term(&self) -> u64
pub fn term(&self, i: u64) -> Result<u64>
pub fn get_applied(&self) -> u64
pub fn get_storage(&self) -> &T
pub fn append(&mut self, ents: &[Entry]) -> u64
pub fn maybe_commit(&mut self, max_index: u64, term: u64) -> bool
pub fn commit_to(&mut self, tocommit: u64)
pub fn zero_term_on_err_compacted(&self, t: Result<u64>) -> u64
pub fn must_check_out_of_bounds(&self, low: u64, hight: u64) -> Result<()>
pub fn slice(&self, lo: u64, hi: u64, max_size: u64) -> Result<Vec<Entry>>
pub fn entries(&self, i: u64, max_size: u64) -> Result<Vec<Entry>>
Sourcepub fn is_up_to_date(&self, index: u64, term: u64) -> bool
pub fn is_up_to_date(&self, index: u64, term: u64) -> bool
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.