Struct raftstore::store::PeerStorage[][src]

pub struct PeerStorage<EK, ER> where
    EK: KvEngine
{ pub engines: Engines<EK, ER>, peer_id: u64, region: Region, raft_state: RaftLocalState, apply_state: RaftApplyState, applied_index_term: u64, last_term: u64, snap_state: RefCell<SnapState>, gen_snap_task: RefCell<Option<GenSnapTask>>, region_sched: Scheduler<RegionTask<EK::Snapshot>>, snap_tried_cnt: RefCell<usize>, cache: Option<EntryCache>, pub tag: String, }

Fields

engines: Engines<EK, ER>peer_id: u64region: Regionraft_state: RaftLocalStateapply_state: RaftApplyStateapplied_index_term: u64last_term: u64snap_state: RefCell<SnapState>gen_snap_task: RefCell<Option<GenSnapTask>>region_sched: Scheduler<RegionTask<EK::Snapshot>>snap_tried_cnt: RefCell<usize>cache: Option<EntryCache>tag: String

Implementations

impl<EK, ER> PeerStorage<EK, ER> where
    EK: KvEngine,
    ER: RaftEngine
[src]

pub fn new(
    engines: Engines<EK, ER>,
    region: &Region,
    region_sched: Scheduler<RegionTask<EK::Snapshot>>,
    peer_id: u64,
    tag: String
) -> Result<PeerStorage<EK, ER>>
[src]

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

pub fn initial_state(&self) -> Result<RaftState>[src]

fn check_range(&self, low: u64, high: u64) -> Result<()>[src]

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

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

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

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

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

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

pub fn set_applied_state(&mut self, apply_state: RaftApplyState)[src]

pub fn set_applied_term(&mut self, applied_index_term: u64)[src]

pub fn apply_state(&self) -> &RaftApplyState[src]

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

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

pub fn set_commit_index(&mut self, commit: u64)[src]

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

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

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

pub fn region(&self) -> &Region[src]

pub fn set_region(&mut self, region: Region)[src]

pub fn raw_snapshot(&self) -> EK::Snapshot[src]

fn validate_snap(&self, snap: &Snapshot, request_index: u64) -> bool[src]

pub fn snapshot(&self, request_index: u64) -> Result<Snapshot>[src]

Gets a snapshot. Returns SnapshotTemporarilyUnavailable if there is no unavailable snapshot.

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

pub fn mut_gen_snap_task(&mut self) -> &mut Option<GenSnapTask>[src]

pub fn take_gen_snap_task(&mut self) -> Option<GenSnapTask>[src]

pub fn append<H: HandleRaftReadyContext<EK::WriteBatch, ER::LogBatch>>(
    &mut self,
    invoke_ctx: &mut InvokeContext,
    entries: Vec<Entry>,
    ready_ctx: &mut H
) -> Result<u64>
[src]

pub fn compact_to(&mut self, idx: u64)[src]

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

pub fn maybe_gc_cache(&mut self, replicated_idx: u64, apply_idx: u64)[src]

pub fn flush_cache_metrics(&mut self)[src]

pub fn apply_snapshot(
    &mut self,
    ctx: &mut InvokeContext,
    snap: &Snapshot,
    kv_wb: &mut EK::WriteBatch,
    raft_wb: &mut ER::LogBatch,
    destroy_regions: &[Region]
) -> Result<()>
[src]

pub fn clear_meta(
    &mut self,
    kv_wb: &mut EK::WriteBatch,
    raft_wb: &mut ER::LogBatch
) -> Result<()>
[src]

Delete all meta belong to the region. Results are stored in wb.

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

Delete all data belong to the region. If return Err, data may get partial deleted.

fn clear_extra_data(
    &self,
    old_region: &Region,
    new_region: &Region
) -> Result<()>
[src]

Delete all data that is not covered by new_region.

pub fn clear_extra_split_data(
    &self,
    start_key: Vec<u8>,
    end_key: Vec<u8>
) -> Result<()>
[src]

Delete all extra split data from the start_key to end_key.

pub fn get_raft_engine(&self) -> ER[src]

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

Check whether the storage has finished applying snapshot.

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

pub fn check_applying_snap(&mut self) -> CheckApplyingSnapStatus[src]

Check if the storage is applying a snapshot.

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

Cancel applying snapshot, return true if the job can be considered not be run again.

pub fn cancel_generating_snap(&mut self, compact_to: Option<u64>)[src]

Cancel generating snapshot.

pub fn set_snap_state(&mut self, state: SnapState)[src]

pub fn is_snap_state(&self, state: SnapState) -> bool[src]

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

pub fn schedule_applying_snapshot(&mut self)[src]

pub fn handle_raft_ready<H: HandleRaftReadyContext<EK::WriteBatch, ER::LogBatch>>(
    &mut self,
    ready_ctx: &mut H,
    ready: &mut Ready,
    destroy_regions: Vec<Region>
) -> Result<InvokeContext>
[src]

Save memory states to disk.

This function only write data to ready_ctx’s WriteBatch. It’s caller’s duty to write it explicitly to disk. If it’s flushed to disk successfully, post_ready should be called to update the memory states properly. WARNING: If this function returns error, the caller must panic(details in append function).

pub fn post_ready(&mut self, ctx: InvokeContext) -> Option<ApplySnapResult>[src]

Update the memory state after ready changes are flushed to disk successfully.

Trait Implementations

impl<EK, ER> Storage for PeerStorage<EK, ER> where
    EK: KvEngine,
    ER: RaftEngine
[src]

Auto Trait Implementations

impl<EK, ER> !RefUnwindSafe for PeerStorage<EK, ER>

impl<EK, ER> Send for PeerStorage<EK, ER> where
    ER: Send

impl<EK, ER> !Sync for PeerStorage<EK, ER>

impl<EK, ER> Unpin for PeerStorage<EK, ER> where
    ER: Unpin

impl<EK, ER> !UnwindSafe for PeerStorage<EK, ER>

Blanket Implementations

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

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

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

impl<V, W> ConvertFrom<W> for V where
    W: ConvertTo<V>, 
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

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

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]