pub struct RebalanceManager { /* private fields */ }Expand description
Manager for automatic rebalancing
Implementations§
Source§impl RebalanceManager
impl RebalanceManager
Sourcepub fn new(config: RebalanceConfig) -> Self
pub fn new(config: RebalanceConfig) -> Self
Create a new rebalance manager
Sourcepub fn register_node(&self, load: NodeLoad)
pub fn register_node(&self, load: NodeLoad)
Register a node with its load information
Sourcepub fn unregister_node(&self, node_id: &str)
pub fn unregister_node(&self, node_id: &str)
Remove a node from tracking
Sourcepub fn update_node_load(
&self,
node_id: &str,
update: impl FnOnce(&mut NodeLoad),
)
pub fn update_node_load( &self, node_id: &str, update: impl FnOnce(&mut NodeLoad), )
Update node load information
Sourcepub fn register_shard(&self, shard_id: &str, node_id: &str)
pub fn register_shard(&self, shard_id: &str, node_id: &str)
Register a shard assignment
Sourcepub fn unregister_shard(&self, shard_id: &str)
pub fn unregister_shard(&self, shard_id: &str)
Remove a shard assignment
Sourcepub fn calculate_imbalance(&self) -> f64
pub fn calculate_imbalance(&self) -> f64
Calculate cluster imbalance score (0.0 = perfectly balanced, 1.0 = maximally imbalanced)
Sourcepub fn needs_rebalance(&self) -> bool
pub fn needs_rebalance(&self) -> bool
Check if rebalance is needed
Sourcepub fn can_rebalance(&self) -> bool
pub fn can_rebalance(&self) -> bool
Check if enough time has passed since last rebalance
Sourcepub fn trigger_rebalance(
&self,
trigger: RebalanceTrigger,
) -> Result<RebalancePlan>
pub fn trigger_rebalance( &self, trigger: RebalanceTrigger, ) -> Result<RebalancePlan>
Trigger a rebalance operation
Sourcepub fn create_move_plan(&self) -> Result<Vec<ShardMove>>
pub fn create_move_plan(&self) -> Result<Vec<ShardMove>>
Plan the shard movements
Sourcepub fn start_execution(&self) -> Result<()>
pub fn start_execution(&self) -> Result<()>
Start executing the rebalance plan
Sourcepub fn start_move(&self, move_id: &str) -> Result<()>
pub fn start_move(&self, move_id: &str) -> Result<()>
Start a specific move
Sourcepub fn update_move_progress(
&self,
move_id: &str,
bytes_transferred: u64,
total_bytes: u64,
) -> Result<()>
pub fn update_move_progress( &self, move_id: &str, bytes_transferred: u64, total_bytes: u64, ) -> Result<()>
Update move progress
Sourcepub fn advance_to_verify(&self, move_id: &str) -> Result<()>
pub fn advance_to_verify(&self, move_id: &str) -> Result<()>
Advance move to verification stage
Sourcepub fn advance_to_routing(&self, move_id: &str) -> Result<()>
pub fn advance_to_routing(&self, move_id: &str) -> Result<()>
Advance move to routing update stage
Sourcepub fn complete_move(&self, move_id: &str) -> Result<()>
pub fn complete_move(&self, move_id: &str) -> Result<()>
Complete a move
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if rebalance was cancelled
Sourcepub fn get_plan(&self) -> Option<RebalancePlan>
pub fn get_plan(&self) -> Option<RebalancePlan>
Get the current rebalance plan
Sourcepub fn get_queued_moves(&self) -> Vec<String>
pub fn get_queued_moves(&self) -> Vec<String>
Get moves that are ready to start
Sourcepub fn get_active_moves(&self) -> Vec<ShardMove>
pub fn get_active_moves(&self) -> Vec<ShardMove>
Get currently executing moves
Sourcepub fn get_stats(&self) -> RebalanceStats
pub fn get_stats(&self) -> RebalanceStats
Get rebalance statistics
Sourcepub fn get_node_load(&self, node_id: &str) -> Option<NodeLoad>
pub fn get_node_load(&self, node_id: &str) -> Option<NodeLoad>
Get node load information
Sourcepub fn get_all_node_loads(&self) -> Vec<NodeLoad>
pub fn get_all_node_loads(&self) -> Vec<NodeLoad>
Get all node loads
Sourcepub fn on_node_joined(
&self,
node_id: &str,
capacity: u64,
) -> Result<Option<RebalancePlan>>
pub fn on_node_joined( &self, node_id: &str, capacity: u64, ) -> Result<Option<RebalancePlan>>
Handle node join event
Sourcepub fn on_node_left(&self, node_id: &str) -> Result<Option<RebalancePlan>>
pub fn on_node_left(&self, node_id: &str) -> Result<Option<RebalancePlan>>
Handle node leave event
Auto Trait Implementations§
impl !Freeze for RebalanceManager
impl !RefUnwindSafe for RebalanceManager
impl Send for RebalanceManager
impl Sync for RebalanceManager
impl Unpin for RebalanceManager
impl UnsafeUnpin for RebalanceManager
impl !UnwindSafe for RebalanceManager
Blanket Implementations§
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
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