Skip to main content

Module tier_migration_engine

Module tier_migration_engine 

Source
Expand description

StorageTierMigrator — intelligent block migration engine for storage tiers.

Moves blocks between Hot, Warm, Cold, and Archive tiers based on access frequency, age, and configurable size policies. Supports dry-run mode, batched execution, and detailed migration logs.

§Example

use ipfrs_storage::tier_migration_engine::{
    BlockMeta, MigratorConfig, StorageTierMigrator, TierPolicy,
    StorageTier as TmStorageTier,
};

let policy = TierPolicy {
    tier: TmStorageTier::Hot,
    max_age_ms: Some(3_600_000),   // 1 hour
    min_access_count: Some(5),
    max_block_size_bytes: None,
    min_block_size_bytes: None,
};
let config = MigratorConfig {
    policies: vec![policy],
    dry_run: false,
    batch_size: 100,
    max_migrations_per_run: 1000,
};
let mut migrator = StorageTierMigrator::new(config);

let now_ms = 1_000_000_u64;
let meta = BlockMeta {
    cid: "QmTest1".to_string(),
    size_bytes: 4096,
    access_count: 2,
    last_accessed_ms: now_ms - 10_000_000,
    created_ms: now_ms - 20_000_000,
    current_tier: TmStorageTier::Hot,
};
migrator.register_block(meta);
let result = migrator.run_migration_cycle(now_ms + 5_000_000);
assert!(result.actions_planned >= 1);

Structs§

BlockMeta
Runtime metadata for a single content-addressed block tracked by the migrator.
MigrationAction
A planned or executed migration for a single block.
MigrationResult
Summary produced by StorageTierMigrator::execute_migrations or StorageTierMigrator::run_migration_cycle.
MigratorConfig
Configuration for StorageTierMigrator.
MigratorStats
Snapshot of migrator statistics for observability.
StorageTierMigrator
Production-grade intelligent block migration engine.
TierPolicy
Policy that governs when blocks should be demoted out of a given tier.

Enums§

MigrationReason
Reason code explaining why a migration was triggered.
StorageTier
Storage tier classification — Hot is fastest/most expensive; Archive is slowest/cheapest. priority() returns a descending-urgency value (Hot=3).