pub struct StorageState {
pub next_file_id: u64,
pub config: StorageConfiguration,
pub per_process_configs: HashMap<IpAddr, StorageConfiguration>,
pub disk_episodes: HashMap<IpAddr, DiskDegradationState>,
pub files: BTreeMap<FileId, StorageFileState>,
pub path_to_file: BTreeMap<String, FileId>,
pub deleted_paths: HashSet<String>,
pub sync_failures: HashSet<(FileId, u64)>,
}Expand description
Storage-related state management for the simulation.
Fields§
§next_file_id: u64Counter for generating unique file IDs
config: StorageConfigurationDefault storage configuration (used when no per-process config is set)
per_process_configs: HashMap<IpAddr, StorageConfiguration>Per-process storage configurations, keyed by IP address.
When a file’s owner IP has an entry here, that config is used for fault injection and latency calculations instead of the global default.
disk_episodes: HashMap<IpAddr, DiskDegradationState>Active disk-degradation episode per owning process IP.
Real disks degrade at the device level: a stall/throttle window applies to every file owned by the process for the episode’s duration, modelling the correlated backpressure a per-file episode cannot (issue #147).
files: BTreeMap<FileId, StorageFileState>Active files indexed by their ID
path_to_file: BTreeMap<String, FileId>Mapping from path to file ID for quick lookup
deleted_paths: HashSet<String>Set of paths that have been deleted (for create_new semantics)
sync_failures: HashSet<(FileId, u64)>Set of (file_id, op_seq) pairs for sync operations that failed
Implementations§
Source§impl StorageState
impl StorageState
Sourcepub fn new(config: StorageConfiguration) -> Self
pub fn new(config: StorageConfiguration) -> Self
Create a new storage state with the given configuration.
Sourcepub fn config_for(&self, ip: IpAddr) -> &StorageConfiguration
pub fn config_for(&self, ip: IpAddr) -> &StorageConfiguration
Resolve storage configuration for a given IP address.
Returns the per-process config if one is set, otherwise the global default.