Struct raftstore::store::PeerStorage [−][src]
Fields
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>
tag: String
Implementations
impl<EK, ER> PeerStorage<EK, ER> where
EK: KvEngine,
ER: RaftEngine,
[src][−]
EK: KvEngine,
ER: RaftEngine,
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]
engines: Engines<EK, ER>,
region: &Region,
region_sched: Scheduler<RegionTask<EK::Snapshot>>,
peer_id: u64,
tag: String
) -> Result<PeerStorage<EK, ER>>
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]
&mut self,
invoke_ctx: &mut InvokeContext,
entries: Vec<Entry>,
ready_ctx: &mut H
) -> Result<u64>
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]
&mut self,
ctx: &mut InvokeContext,
snap: &Snapshot,
kv_wb: &mut EK::WriteBatch,
raft_wb: &mut ER::LogBatch,
destroy_regions: &[Region]
) -> Result<()>
pub fn clear_meta(
&mut self,
kv_wb: &mut EK::WriteBatch,
raft_wb: &mut ER::LogBatch
) -> Result<()>
[src][−]
&mut self,
kv_wb: &mut EK::WriteBatch,
raft_wb: &mut ER::LogBatch
) -> Result<()>
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][−]
&self,
old_region: &Region,
new_region: &Region
) -> Result<()>
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][−]
&self,
start_key: Vec<u8>,
end_key: Vec<u8>
) -> Result<()>
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][−]
&mut self,
ready_ctx: &mut H,
ready: &mut Ready,
destroy_regions: Vec<Region>
) -> Result<InvokeContext>
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][+]
EK: KvEngine,
ER: RaftEngine,
Auto Trait Implementations
impl<EK, ER> !RefUnwindSafe for PeerStorage<EK, ER>
impl<EK, ER> Send for PeerStorage<EK, ER> where
ER: Send,
ER: Send,
impl<EK, ER> !Sync for PeerStorage<EK, ER>
impl<EK, ER> Unpin for PeerStorage<EK, ER> where
ER: Unpin,
ER: Unpin,
impl<EK, ER> !UnwindSafe for PeerStorage<EK, ER>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>,
[src][+]
W: ConvertTo<V>,
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][+]
U: From<T>,
impl<T> Pointable for T
[src][+]
impl<T> Pointable for T
[src][+]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src][+]
V: MultiLane<T>,