pub struct RocksDBStateMachine { /* private fields */ }Expand description
RocksDB-based state machine implementation with lease support
Implementations§
Source§impl RocksDBStateMachine
impl RocksDBStateMachine
Sourcepub fn new<P>(path: P) -> Result<RocksDBStateMachine, Error>
pub fn new<P>(path: P) -> Result<RocksDBStateMachine, Error>
Opens (or creates) a dedicated RocksDB instance for state machine storage.
Used when unified_db = false (default): each engine owns its own DB instance.
Sourcepub fn set_lease(&mut self, lease: Arc<DefaultLease>)
pub fn set_lease(&mut self, lease: Arc<DefaultLease>)
Sets the lease manager for this state machine.
This is an internal method called by NodeBuilder during initialization.
The lease will also be restored from snapshot during apply_snapshot_from_file().
Also available for testing and benchmarks.
Sourcepub async fn load_lease_data(&self) -> Result<(), Error>
pub async fn load_lease_data(&self) -> Result<(), Error>
Loads TTL state from RocksDB metadata after lease injection.
Called after NodeBuilder injects the lease. Also available for testing and benchmarks.
Sourcepub fn scan_prefix(&self, prefix: &[u8]) -> Result<ScanResult, Error>
pub fn scan_prefix(&self, prefix: &[u8]) -> Result<ScanResult, Error>
Scans all entries whose key starts with prefix.
Uses set_iterate_upper_bound(prefix_successor) so RocksDB stops at the
block level — O(results), not O(total keys). No prefix_extractor needed.
revision in the result equals last_applied_index — the watch-filter anchor.
Trait Implementations§
Source§impl Debug for RocksDBStateMachine
impl Debug for RocksDBStateMachine
Source§impl Drop for RocksDBStateMachine
impl Drop for RocksDBStateMachine
Source§impl StateMachine for RocksDBStateMachine
impl StateMachine for RocksDBStateMachine
Source§fn apply_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk: &'life1 [ApplyEntry],
) -> Pin<Box<dyn Future<Output = Result<Vec<ApplyResult>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RocksDBStateMachine: 'async_trait,
fn apply_chunk<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk: &'life1 [ApplyEntry],
) -> Pin<Box<dyn Future<Output = Result<Vec<ApplyResult>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RocksDBStateMachine: 'async_trait,
Thread-safe: called serially by single-task CommitHandler
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
Source§fn stop(&self) -> Result<(), Error>
fn stop(&self) -> Result<(), Error>
Source§fn is_running(&self) -> bool
fn is_running(&self) -> bool
Source§fn get(&self, key_buffer: &[u8]) -> Result<Option<Bytes>, Error>
fn get(&self, key_buffer: &[u8]) -> Result<Option<Bytes>, Error>
Source§fn entry_term(&self, _entry_id: u64) -> Option<u64>
fn entry_term(&self, _entry_id: u64) -> Option<u64>
Source§fn len(&self) -> usize
fn len(&self) -> usize
Source§fn update_last_applied(&self, last_applied: LogId)
fn update_last_applied(&self, last_applied: LogId)
Source§fn last_applied(&self) -> LogId
fn last_applied(&self) -> LogId
Source§fn persist_last_applied(&self, last_applied: LogId) -> Result<(), Error>
fn persist_last_applied(&self, last_applied: LogId) -> Result<(), Error>
Source§fn update_last_snapshot_metadata(
&self,
snapshot_metadata: &SnapshotMetadata,
) -> Result<(), Error>
fn update_last_snapshot_metadata( &self, snapshot_metadata: &SnapshotMetadata, ) -> Result<(), Error>
Source§fn snapshot_metadata(&self) -> Option<SnapshotMetadata>
fn snapshot_metadata(&self) -> Option<SnapshotMetadata>
Source§fn persist_last_snapshot_metadata(
&self,
snapshot_metadata: &SnapshotMetadata,
) -> Result<(), Error>
fn persist_last_snapshot_metadata( &self, snapshot_metadata: &SnapshotMetadata, ) -> Result<(), Error>
Source§fn apply_snapshot_from_file<'life0, 'life1, 'async_trait>(
&'life0 self,
metadata: &'life1 SnapshotMetadata,
snapshot_dir: PathBuf,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RocksDBStateMachine: 'async_trait,
fn apply_snapshot_from_file<'life0, 'life1, 'async_trait>(
&'life0 self,
metadata: &'life1 SnapshotMetadata,
snapshot_dir: PathBuf,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
RocksDBStateMachine: 'async_trait,
Source§fn generate_snapshot_data<'life0, 'async_trait>(
&'life0 self,
new_snapshot_dir: PathBuf,
last_included: LogId,
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
fn generate_snapshot_data<'life0, 'async_trait>(
&'life0 self,
new_snapshot_dir: PathBuf,
last_included: LogId,
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
last_included_index. Read moreSource§fn save_hard_state(&self) -> Result<(), Error>
fn save_hard_state(&self) -> Result<(), Error>
Source§fn flush(&self) -> Result<(), Error>
fn flush(&self) -> Result<(), Error>
Source§fn flush_async<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
fn flush_async<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
Source§fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
Source§fn lease_background_cleanup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
fn lease_background_cleanup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
RocksDBStateMachine: 'async_trait,
Source§fn scan_prefix(&self, prefix: &[u8]) -> Result<ScanResult, Error>
fn scan_prefix(&self, prefix: &[u8]) -> Result<ScanResult, Error>
(key, value) pairs whose key starts with prefix, plus
the last_applied_index at the time of the scan. Read moreAuto Trait Implementations§
impl !Freeze for RocksDBStateMachine
impl !RefUnwindSafe for RocksDBStateMachine
impl Send for RocksDBStateMachine
impl Sync for RocksDBStateMachine
impl Unpin for RocksDBStateMachine
impl UnsafeUnpin for RocksDBStateMachine
impl !UnwindSafe for RocksDBStateMachine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request