pub struct StorageTierBalancer {
pub tiers: HashMap<TierKind, TierStatus>,
pub pending_tasks: Vec<MoveTask>,
pub next_task_id: u64,
pub total_completed_tasks: u64,
}Expand description
Balances data across storage tiers by monitoring utilization and generating rebalancing plans.
Rebalancing proceeds tier-by-tier: for each over-target tier the balancer
selects candidate blocks (in the order supplied by the caller) until the
estimated excess is covered, creating a MoveTask for each block. The
destination is always the under-target tier with the most free bytes.
Fields§
§tiers: HashMap<TierKind, TierStatus>Registered tiers indexed by TierKind.
pending_tasks: Vec<MoveTask>Outstanding move tasks, sorted by priority descending (highest first).
next_task_id: u64Monotonically increasing counter used to generate unique task IDs.
total_completed_tasks: u64Total number of tasks that have been completed via Self::complete_task.
Implementations§
Source§impl StorageTierBalancer
impl StorageTierBalancer
Sourcepub fn add_tier(&mut self, status: TierStatus)
pub fn add_tier(&mut self, status: TierStatus)
Registers a tier with the balancer. Overwrites any existing entry for
the same TierKind.
Sourcepub fn update_usage(&mut self, kind: TierKind, used_bytes: u64)
pub fn update_usage(&mut self, kind: TierKind, used_bytes: u64)
Updates the used_bytes counter for an existing tier.
If the tier has not been registered the call is a no-op.
Sourcepub fn plan_rebalance(
&mut self,
candidates: Vec<(String, u64, TierKind)>,
) -> Vec<&MoveTask>
pub fn plan_rebalance( &mut self, candidates: Vec<(String, u64, TierKind)>, ) -> Vec<&MoveTask>
Plans a rebalancing run given a list of candidate blocks.
§Parameters
candidates—(cid, size_bytes, current_tier)tuples describing blocks eligible for migration.
§Returns
Shared references to the newly created MoveTasks in their sorted
(priority-descending) order within Self::pending_tasks.
Sourcepub fn complete_task(&mut self, task_id: u64) -> bool
pub fn complete_task(&mut self, task_id: u64) -> bool
Marks a task as completed and removes it from the pending queue.
Returns true when the task was found and removed, false otherwise.
Sourcepub fn tier_status(&self, kind: TierKind) -> Option<&TierStatus>
pub fn tier_status(&self, kind: TierKind) -> Option<&TierStatus>
Returns a reference to the TierStatus for the given kind, if any.
Sourcepub fn stats(&self) -> BalancerStats
pub fn stats(&self) -> BalancerStats
Returns aggregate statistics about the balancer’s current state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StorageTierBalancer
impl RefUnwindSafe for StorageTierBalancer
impl Send for StorageTierBalancer
impl Sync for StorageTierBalancer
impl Unpin for StorageTierBalancer
impl UnsafeUnpin for StorageTierBalancer
impl UnwindSafe for StorageTierBalancer
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