Trait engine_traits::raft_engine::RaftEngine[][src]

pub trait RaftEngine: Clone + Sync + Send + 'static {
    type LogBatch: RaftLogBatch;
    fn log_batch(&self, capacity: usize) -> Self::LogBatch;
fn sync(&self) -> Result<()>;
fn get_raft_state(
        &self,
        raft_group_id: u64
    ) -> Result<Option<RaftLocalState>>;
fn get_entry(&self, raft_group_id: u64, index: u64) -> Result<Option<Entry>>;
fn fetch_entries_to(
        &self,
        raft_group_id: u64,
        begin: u64,
        end: u64,
        max_size: Option<usize>,
        to: &mut Vec<Entry>
    ) -> Result<usize>;
fn consume(&self, batch: &mut Self::LogBatch, sync: bool) -> Result<usize>;
fn consume_and_shrink(
        &self,
        batch: &mut Self::LogBatch,
        sync: bool,
        max_capacity: usize,
        shrink_to: usize
    ) -> Result<usize>;
fn clean(
        &self,
        raft_group_id: u64,
        state: &RaftLocalState,
        batch: &mut Self::LogBatch
    ) -> Result<()>;
fn append(&self, raft_group_id: u64, entries: Vec<Entry>) -> Result<usize>;
fn put_raft_state(
        &self,
        raft_group_id: u64,
        state: &RaftLocalState
    ) -> Result<()>;
fn gc(&self, raft_group_id: u64, from: u64, to: u64) -> Result<usize>;
fn purge_expired_files(&self) -> Result<Vec<u64>>;
fn dump_stats(&self) -> Result<String>; fn has_builtin_entry_cache(&self) -> bool { ... }
fn gc_entry_cache(&self, _raft_group_id: u64, _to: u64) { ... }
fn flush_metrics(&self, _instance: &str) { ... }
fn flush_stats(&self) -> Option<CacheStats> { ... }
fn reset_statistics(&self) { ... }
fn stop(&self) { ... } }

Associated Types

type LogBatch: RaftLogBatch[src]

Loading content...

Required methods

fn log_batch(&self, capacity: usize) -> Self::LogBatch[src]

fn sync(&self) -> Result<()>[src]

Synchronize the Raft engine.

fn get_raft_state(&self, raft_group_id: u64) -> Result<Option<RaftLocalState>>[src]

fn get_entry(&self, raft_group_id: u64, index: u64) -> Result<Option<Entry>>[src]

fn fetch_entries_to(
    &self,
    raft_group_id: u64,
    begin: u64,
    end: u64,
    max_size: Option<usize>,
    to: &mut Vec<Entry>
) -> Result<usize>
[src]

Return count of fetched entries.

fn consume(&self, batch: &mut Self::LogBatch, sync: bool) -> Result<usize>[src]

Consume the write batch by moving the content into the engine itself and return written bytes.

fn consume_and_shrink(
    &self,
    batch: &mut Self::LogBatch,
    sync: bool,
    max_capacity: usize,
    shrink_to: usize
) -> Result<usize>
[src]

Like consume but shrink batch if need.

fn clean(
    &self,
    raft_group_id: u64,
    state: &RaftLocalState,
    batch: &mut Self::LogBatch
) -> Result<()>
[src]

fn append(&self, raft_group_id: u64, entries: Vec<Entry>) -> Result<usize>[src]

Append some log entries and return written bytes.

Note: RaftLocalState won’t be updated in this call.

fn put_raft_state(
    &self,
    raft_group_id: u64,
    state: &RaftLocalState
) -> Result<()>
[src]

fn gc(&self, raft_group_id: u64, from: u64, to: u64) -> Result<usize>[src]

Like cut_logs but the range could be very large. Return the deleted count. Generally, from can be passed in 0.

fn purge_expired_files(&self) -> Result<Vec<u64>>[src]

Purge expired logs files and return a set of Raft group ids which needs to be compacted ASAP.

fn dump_stats(&self) -> Result<String>[src]

Loading content...

Provided methods

fn has_builtin_entry_cache(&self) -> bool[src]

The RaftEngine has a builtin entry cache or not.

fn gc_entry_cache(&self, _raft_group_id: u64, _to: u64)[src]

GC the builtin entry cache.

fn flush_metrics(&self, _instance: &str)[src]

fn flush_stats(&self) -> Option<CacheStats>[src]

fn reset_statistics(&self)[src]

fn stop(&self)[src]

Loading content...

Implementors

Loading content...