Skip to main content

SimStorage

Struct SimStorage 

Source
pub struct SimStorage { /* private fields */ }
Expand description

Simulated persistent storage with WAL and fault injection.

BTreeMap-backed for deterministic iteration order.

Implementations§

Source§

impl SimStorage

Source

pub fn new(node_id: NodeId) -> Self

Create a new simulated storage for the given node.

Source

pub fn with_disk_model(node_id: NodeId, disk_model: DiskModel) -> Self

Create with a custom disk model.

Source

pub fn set_snapshot_failure(&mut self, fail: bool)

Set snapshot failure fault.

Source

pub fn set_silent_corrupt_probability(&mut self, p: f64)

Set silent corruption probability.

Source

pub fn set_faults(&mut self, faults: StorageFaultConfig)

Set fault configuration.

Source

pub fn set_disk_full(&mut self, full: bool)

Enable disk full fault.

Source

pub fn set_read_error(&mut self, err: bool)

Enable read error fault.

Source

pub fn crash(&mut self)

Simulate a crash: lose unfsynced WAL entries, recover from fsynced.

Source

pub fn crash_and_recover(&mut self, rng: &mut DetRng)

Simulate a crash and restart with optional write reordering.

Source

pub fn wal(&self) -> &SimWal

Get the WAL.

Source

pub fn node_id(&self) -> NodeId

Node this storage belongs to.

Source

pub fn total_reads(&self) -> u64

Stats: total reads.

Source

pub fn total_writes(&self) -> u64

Stats: total writes.

Source

pub fn faults(&self) -> &StorageFaultConfig

Get fault configuration.

Trait Implementations§

Source§

impl VortexStorage for SimStorage

Source§

fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>

Get the value for a key.
Source§

fn put(&mut self, key: &[u8], value: &[u8]) -> Result<()>

Put a key-value pair.
Source§

fn delete(&mut self, key: &[u8]) -> Result<()>

Delete a key.
Source§

fn scan(&self, start: &[u8], end: &[u8]) -> Result<Vec<(Vec<u8>, Vec<u8>)>>

Scan a range of keys [start, end).
Source§

fn write_batch(&mut self, ops: Vec<StorageOp>) -> Result<()>

Apply a batch of operations atomically.
Source§

fn flush(&mut self) -> Result<()>

Flush pending writes to durable storage.
Source§

fn snapshot(&self) -> Result<Vec<(Vec<u8>, Vec<u8>)>>

Create a point-in-time snapshot.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.