pub struct StorageTracker { /* private fields */ }Expand description
Real-time storage statistics tracker.
Maintains in-memory counters that are updated on every write operation. Thread-safe via RwLock for concurrent access.
Implementations§
Source§impl StorageTracker
impl StorageTracker
Sourcepub fn total_stats(&self) -> TierStats
pub fn total_stats(&self) -> TierStats
Get total storage stats across all tiers.
Sourcepub fn stats_by_type(&self, tier: Tier) -> HashMap<KeyKind, StorageStats>
pub fn stats_by_type(&self, tier: Tier) -> HashMap<KeyKind, StorageStats>
Get stats aggregated by KeyKind for a specific tier.
Sourcepub fn stats_by_type_all_tiers(&self) -> HashMap<KeyKind, TierStats>
pub fn stats_by_type_all_tiers(&self) -> HashMap<KeyKind, TierStats>
Get stats aggregated by KeyKind across all tiers.
Sourcepub fn stats_for_object(&self, object_id: ObjectId) -> Option<TierStats>
pub fn stats_for_object(&self, object_id: ObjectId) -> Option<TierStats>
Get stats for a specific object across all tiers.
Sourcepub fn objects_by_tier(&self, tier: Tier) -> Vec<(ObjectId, StorageStats)>
pub fn objects_by_tier(&self, tier: Tier) -> Vec<(ObjectId, StorageStats)>
Get all objects for a specific tier, sorted by total bytes descending.
Sourcepub fn top_objects_by_size(&self, n: usize) -> Vec<(ObjectId, TierStats)>
pub fn top_objects_by_size(&self, n: usize) -> Vec<(ObjectId, TierStats)>
Get top N objects by total storage consumption across all tiers.
Sourcepub fn config(&self) -> StorageTrackerConfig
pub fn config(&self) -> StorageTrackerConfig
Get configuration.
Source§impl StorageTracker
impl StorageTracker
Sourcepub fn new(config: StorageTrackerConfig) -> StorageTracker
pub fn new(config: StorageTrackerConfig) -> StorageTracker
Create a new storage tracker with the given configuration.
Sourcepub fn with_defaults() -> StorageTracker
pub fn with_defaults() -> StorageTracker
Create a new tracker with default configuration.
Sourcepub fn record_write(
&self,
tier: Tier,
key: &[u8],
key_bytes: u64,
value_bytes: u64,
pre_version: Option<PreVersionInfo>,
)
pub fn record_write( &self, tier: Tier, key: &[u8], key_bytes: u64, value_bytes: u64, pre_version: Option<PreVersionInfo>, )
Record a write operation (insert or update).
tier: Which storage tier this write goes tokey: The encoded key bytes (unversioned, used for KeyKind lookup)key_bytes: Size of the key as stored (typically versioned key size)value_bytes: Size of the value being writtenpre_version: Information about the previous version, if the key already existed
Sourcepub fn record_delete(
&self,
tier: Tier,
key: &[u8],
key_bytes: u64,
pre_version: Option<PreVersionInfo>,
)
pub fn record_delete( &self, tier: Tier, key: &[u8], key_bytes: u64, pre_version: Option<PreVersionInfo>, )
Record a delete operation (tombstone).
tier: Which storage tier this delete goes tokey: The encoded key bytes (unversioned, used for KeyKind lookup)key_bytes: Size of the tombstone key as stored (typically versioned key size)pre_version: Information about the previous version being deleted
Sourcepub fn record_drop(
&self,
tier: Tier,
key: &[u8],
versioned_key_bytes: u64,
value_bytes: u64,
)
pub fn record_drop( &self, tier: Tier, key: &[u8], versioned_key_bytes: u64, value_bytes: u64, )
Record a drop operation (physical removal of historical version entry).
Unlike delete, drop doesn’t create tombstones - it physically removes entries from storage. Used for MVCC cleanup of old versions.
tier: Which storage tier the drop occurred inkey: The original (unversioned) encoded key bytesversioned_key_bytes: Size of the versioned key being droppedvalue_bytes: Size of the value being dropped
Sourcepub fn record_cdc_for_change(
&self,
tier: Tier,
key: &[u8],
value_bytes: u64,
count: u64,
)
pub fn record_cdc_for_change( &self, tier: Tier, key: &[u8], value_bytes: u64, count: u64, )
Record CDC bytes for a specific change.
Called for each change in a CDC entry to attribute bytes to the source object.
tier: Which storage tier the CDC entry was written tokey: The change key (identifies the source object)value_bytes: Bytes attributed to this change (distributed overhead)count: Number of CDC entries to record (typically 1)
Sourcepub fn record_tier_migration(
&self,
from_tier: Tier,
to_tier: Tier,
key: &[u8],
value_bytes: u64,
is_current: bool,
)
pub fn record_tier_migration( &self, from_tier: Tier, to_tier: Tier, key: &[u8], value_bytes: u64, is_current: bool, )
Record data migration between tiers.
When data moves from one tier to another (e.g., hot -> warm), this updates the stats for both tiers.
Sourcepub fn should_checkpoint(&self) -> bool
pub fn should_checkpoint(&self) -> bool
Check if a checkpoint is needed based on elapsed time.
Sourcepub async fn checkpoint_async<S>(&self, storage: &S) -> Result<(), Error>where
S: PrimitiveStorage,
pub async fn checkpoint_async<S>(&self, storage: &S) -> Result<(), Error>where
S: PrimitiveStorage,
Persist current stats to storage.
Writes all tracked stats to the storage using KeyKind::StorageTracker keys.
Sourcepub async fn restore_async<S>(
storage: &S,
config: StorageTrackerConfig,
) -> Result<StorageTracker, Error>where
S: PrimitiveStorage,
pub async fn restore_async<S>(
storage: &S,
config: StorageTrackerConfig,
) -> Result<StorageTracker, Error>where
S: PrimitiveStorage,
Restore stats from storage on startup.
Loads previously persisted stats from storage using KeyKind::StorageTracker keys.
Trait Implementations§
Source§impl Clone for StorageTracker
impl Clone for StorageTracker
Source§fn clone(&self) -> StorageTracker
fn clone(&self) -> StorageTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more