pub struct BlockTierMigrator {
pub records: HashMap<String, BlockTierRecord>,
pub policy: MigrationPolicy,
}Expand description
Manages migration of blocks between storage tiers based on access patterns
and a configurable MigrationPolicy.
Fields§
§records: HashMap<String, BlockTierRecord>Tracked block records keyed by CID.
policy: MigrationPolicyActive migration policy.
Implementations§
Source§impl BlockTierMigrator
impl BlockTierMigrator
Sourcepub fn new(policy: MigrationPolicy) -> Self
pub fn new(policy: MigrationPolicy) -> Self
Create a new migrator with the given policy.
Sourcepub fn register(
&mut self,
cid: String,
tier: StorageTier,
size_bytes: u64,
now_secs: u64,
)
pub fn register( &mut self, cid: String, tier: StorageTier, size_bytes: u64, now_secs: u64, )
Register a new block in the given tier.
If a block with the same CID already exists it is overwritten.
Sourcepub fn record_access(&mut self, cid: &str, now_secs: u64)
pub fn record_access(&mut self, cid: &str, now_secs: u64)
Record an access for a block.
Updates last_accessed_secs, increments access_count, and promotes
the block back to StorageTier::Hot if it is currently in a colder tier.
Sourcepub fn plan_migrations(&self, now_secs: u64) -> Vec<MigrationTask>
pub fn plan_migrations(&self, now_secs: u64) -> Vec<MigrationTask>
Compute a set of migration tasks based on current idle times and the active policy.
Only tasks where the target tier differs from the current tier are emitted.
Small blocks (below policy.min_size_for_cold) are never moved to Cold or
Archive.
Sourcepub fn apply_migration(&mut self, task: &MigrationTask)
pub fn apply_migration(&mut self, task: &MigrationTask)
Apply a previously planned migration task, updating the stored tier.
If the block referenced by the task is not found, this is a no-op.
Sourcepub fn stats(&self) -> MigratorStats
pub fn stats(&self) -> MigratorStats
Compute aggregate statistics over all tracked blocks.
Auto Trait Implementations§
impl Freeze for BlockTierMigrator
impl RefUnwindSafe for BlockTierMigrator
impl Send for BlockTierMigrator
impl Sync for BlockTierMigrator
impl Unpin for BlockTierMigrator
impl UnsafeUnpin for BlockTierMigrator
impl UnwindSafe for BlockTierMigrator
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more