Struct raftstore::store::fsm::apply::ApplyDelegate [−][src]
The apply delegate of a Region which is responsible for handling committed raft log entries of a Region.
Apply is a term of Raft, which means executing the actual commands.
In Raft, once some log entries are committed, for every peer of the Raft
group will apply the logs one by one. For write commands, it does write or
delete to local engine; for admin commands, it does some meta change of the
Raft group.
Delegate is just a structure to congregate all apply related fields of a
Region. The apply worker receives all the apply tasks of different Regions
located at this store, and it will get the corresponding apply delegate to
handle the apply task to make the code logic more clear.
Fields
id: u64The ID of the peer.
term: u64The term of the Region.
region: RegionThe Region information of the peer.
tag: StringPeer_tag, “[region region_id] peer_id”.
stopped: boolIf the delegate should be stopped from polling. A delegate can be stopped in conf change, merge or requested by destroy message.
handle_start: Option<Instant>The start time of the current round to execute commands.
pending_remove: boolSet to true when removing itself because of ConfChangeType::RemoveNode, and then
any following committed logs in same Ready should be applied failed.
pending_cmds: PendingCmdQueue<EK::Snapshot>The commands waiting to be committed and applied
pending_request_snapshot_count: Arc<AtomicUsize>The counter of pending request snapshots. See more in Peer.
is_merging: boolIndicates the peer is in merging, if that compact log won’t be performed.
last_merge_version: u64Records the epoch version after the last merge.
yield_state: Option<YieldState<EK>>wait_merge_state: Option<WaitSourceMergeState>A temporary state that keeps track of the progress of the source peer state when CommitMerge is unable to be executed.
ready_source_region_id: u64apply_state: RaftApplyStateTiKV writes apply_state to KV RocksDB, in one write batch together with kv data.
If we write it to Raft RocksDB, apply_state and kv data (Put, Delete) are in separate WAL file. When power failure, for current raft log, apply_index may synced to file, but KV data may not synced to file, so we will lose data.
applied_index_term: u64The term of the raft log at applied index.
last_sync_apply_index: u64The latest synced apply index.
observe_info: CmdObserveInfoInfo about cmd observer.
metrics: ApplyMetricsThe local metrics, and it will be flushed periodically.
priority: PriorityPriority in batch system. When applying some commands which have high latency, we decrease the priority of current fsm to reduce the impact on other normal commands.
Implementations
impl<EK> ApplyDelegate<EK> where
EK: KvEngine, [src]
EK: KvEngine,
fn from_registration(reg: Registration) -> ApplyDelegate<EK>[src]
pub fn region_id(&self) -> u64[src]
pub fn id(&self) -> u64[src]
fn handle_raft_committed_entries<W: WriteBatch<EK>>(
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
committed_entries_drainer: Drain<'_, Entry>
)[src]
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
committed_entries_drainer: Drain<'_, Entry>
)
Handles all the committed_entries, namely, applies the committed entries.
fn update_metrics<W: WriteBatch<EK>>(&mut self, apply_ctx: &ApplyContext<EK, W>)[src]
fn write_apply_state<W: WriteBatch<EK>>(&self, wb: &mut W)[src]
fn handle_raft_entry_normal<W: WriteBatch<EK>>(
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
entry: &Entry
) -> ApplyResult<EK::Snapshot>[src]
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
entry: &Entry
) -> ApplyResult<EK::Snapshot>
fn handle_raft_entry_conf_change<W: WriteBatch<EK>>(
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
entry: &Entry
) -> ApplyResult<EK::Snapshot>[src]
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
entry: &Entry
) -> ApplyResult<EK::Snapshot>
fn find_pending(
&mut self,
index: u64,
term: u64,
is_conf_change: bool
) -> Option<Callback<EK::Snapshot>>[src]
&mut self,
index: u64,
term: u64,
is_conf_change: bool
) -> Option<Callback<EK::Snapshot>>
fn process_raft_cmd<W: WriteBatch<EK>>(
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
index: u64,
term: u64,
cmd: RaftCmdRequest
) -> ApplyResult<EK::Snapshot>[src]
&mut self,
apply_ctx: &mut ApplyContext<EK, W>,
index: u64,
term: u64,
cmd: RaftCmdRequest
) -> ApplyResult<EK::Snapshot>
fn apply_raft_cmd<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
index: u64,
term: u64,
req: &RaftCmdRequest
) -> (RaftCmdResponse, ApplyResult<EK::Snapshot>)[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
index: u64,
term: u64,
req: &RaftCmdRequest
) -> (RaftCmdResponse, ApplyResult<EK::Snapshot>)
Applies raft command.
An apply operation can fail in the following situations:
- it encounters an error that will occur on all stores, it can continue applying next entry safely, like epoch not match for example;
- it encounters an error that may not occur on all stores, in this case we should try to apply the entry again or panic. Considering that this usually due to disk operation fail, which is rare, so just panic is ok.
fn destroy<W: WriteBatch<EK>>(&mut self, apply_ctx: &mut ApplyContext<EK, W>)[src]
fn clear_all_commands_as_stale(&mut self)[src]
fn new_ctx(&self, index: u64, term: u64) -> ExecContext[src]
impl<EK> ApplyDelegate<EK> where
EK: KvEngine, [src]
EK: KvEngine,
fn exec_raft_cmd<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &RaftCmdRequest
) -> Result<(RaftCmdResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &RaftCmdRequest
) -> Result<(RaftCmdResponse, ApplyResult<EK::Snapshot>)>
fn exec_admin_cmd<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &RaftCmdRequest
) -> Result<(RaftCmdResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &RaftCmdRequest
) -> Result<(RaftCmdResponse, ApplyResult<EK::Snapshot>)>
fn exec_write_cmd<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &RaftCmdRequest
) -> Result<(RaftCmdResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &RaftCmdRequest
) -> Result<(RaftCmdResponse, ApplyResult<EK::Snapshot>)>
impl<EK> ApplyDelegate<EK> where
EK: KvEngine, [src]
EK: KvEngine,
fn handle_put<W: WriteBatch<EK>>(
&mut self,
wb: &mut W,
req: &Request
) -> Result<Response>[src]
&mut self,
wb: &mut W,
req: &Request
) -> Result<Response>
fn handle_delete<W: WriteBatch<EK>>(
&mut self,
wb: &mut W,
req: &Request
) -> Result<Response>[src]
&mut self,
wb: &mut W,
req: &Request
) -> Result<Response>
fn handle_delete_range(
&mut self,
engine: &EK,
req: &Request,
ranges: &mut Vec<Range>,
use_delete_range: bool
) -> Result<Response>[src]
&mut self,
engine: &EK,
req: &Request,
ranges: &mut Vec<Range>,
use_delete_range: bool
) -> Result<Response>
fn handle_ingest_sst(
&mut self,
importer: &Arc<SSTImporter>,
engine: &EK,
req: &Request,
ssts: &mut Vec<SSTMetaInfo>
) -> Result<Response>[src]
&mut self,
importer: &Arc<SSTImporter>,
engine: &EK,
req: &Request,
ssts: &mut Vec<SSTMetaInfo>
) -> Result<Response>
impl<EK> ApplyDelegate<EK> where
EK: KvEngine, [src]
EK: KvEngine,
fn exec_change_peer<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
request: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
request: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_change_peer_v2<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
request: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
request: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn apply_conf_change(
&mut self,
kind: ConfChangeKind,
changes: &[ChangePeerRequest]
) -> Result<Region>[src]
&mut self,
kind: ConfChangeKind,
changes: &[ChangePeerRequest]
) -> Result<Region>
fn apply_leave_joint(&self) -> Result<Region>[src]
fn exec_split<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_batch_split<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_prepare_merge<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_commit_merge<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_rollback_merge<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_compact_log<W: WriteBatch<EK>>(
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&mut self,
ctx: &mut ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_compute_hash<W: WriteBatch<EK>>(
&self,
ctx: &ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&self,
ctx: &ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
fn exec_verify_hash<W: WriteBatch<EK>>(
&self,
_: &ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>[src]
&self,
_: &ApplyContext<EK, W>,
req: &AdminRequest
) -> Result<(AdminResponse, ApplyResult<EK::Snapshot>)>
Trait Implementations
Auto Trait Implementations
impl<EK> !RefUnwindSafe for ApplyDelegate<EK>
impl<EK> Send for ApplyDelegate<EK>
impl<EK> !Sync for ApplyDelegate<EK>
impl<EK> Unpin for ApplyDelegate<EK>
impl<EK> !UnwindSafe for ApplyDelegate<EK>
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,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<V, W> ConvertFrom<W> for V where
W: ConvertTo<V>, [src]
W: ConvertTo<V>,
pub fn convert_from(ctx: &mut EvalContext, from: W) -> Result<V, Error>[src]
impl<T> From<T> for T[src]
impl<T> Instrument for T[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>[src]
pub fn in_current_span(self) -> Instrumented<Self>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T[src]
pub const ALIGN: usize[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T[src]
pub unsafe fn drop(ptr: usize)[src]
impl<T> Pointable for T[src]
pub const ALIGN: usize[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T[src]
pub unsafe fn drop(ptr: usize)[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>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>, [src]
V: MultiLane<T>,