pub struct LoadBalancer<F: IntegrateFloat> { /* private fields */ }Expand description
Load balancer for distributing work chunks across nodes
Implementations§
Source§impl<F: IntegrateFloat> LoadBalancer<F>
impl<F: IntegrateFloat> LoadBalancer<F>
Sourcepub fn new(strategy: LoadBalancingStrategy, config: LoadBalancerConfig) -> Self
pub fn new(strategy: LoadBalancingStrategy, config: LoadBalancerConfig) -> Self
Create a new load balancer
Sourcepub fn register_node(&self, node_id: NodeId) -> DistributedResult<()>
pub fn register_node(&self, node_id: NodeId) -> DistributedResult<()>
Register a new node
Sourcepub fn deregister_node(&self, node_id: NodeId) -> DistributedResult<()>
pub fn deregister_node(&self, node_id: NodeId) -> DistributedResult<()>
Deregister a node
Sourcepub fn get_strategy(&self) -> LoadBalancingStrategy
pub fn get_strategy(&self) -> LoadBalancingStrategy
Get current strategy
Sourcepub fn set_strategy(&self, strategy: LoadBalancingStrategy)
pub fn set_strategy(&self, strategy: LoadBalancingStrategy)
Set strategy
Sourcepub fn assign_chunk(
&self,
chunk: &WorkChunk<F>,
available_nodes: &[NodeInfo],
) -> DistributedResult<NodeId>
pub fn assign_chunk( &self, chunk: &WorkChunk<F>, available_nodes: &[NodeInfo], ) -> DistributedResult<NodeId>
Assign a work chunk to a node
Sourcepub fn report_completion(
&self,
node_id: NodeId,
estimated_cost: f64,
processing_time: Duration,
success: bool,
)
pub fn report_completion( &self, node_id: NodeId, estimated_cost: f64, processing_time: Duration, success: bool, )
Report chunk completion
Sourcepub fn get_load_distribution(&self) -> HashMap<NodeId, usize>
pub fn get_load_distribution(&self) -> HashMap<NodeId, usize>
Get current load distribution
Sourcepub fn needs_rebalancing(&self) -> bool
pub fn needs_rebalancing(&self) -> bool
Check if rebalancing is needed
Sourcepub fn get_overloaded_nodes(&self) -> Vec<(NodeId, usize)>
pub fn get_overloaded_nodes(&self) -> Vec<(NodeId, usize)>
Get nodes with excess work (candidates for work stealing)
Sourcepub fn get_underloaded_nodes(&self) -> Vec<(NodeId, usize)>
pub fn get_underloaded_nodes(&self) -> Vec<(NodeId, usize)>
Get nodes with room for more work
Sourcepub fn get_statistics(&self) -> LoadBalancerStatistics
pub fn get_statistics(&self) -> LoadBalancerStatistics
Get performance statistics
Auto Trait Implementations§
impl<F> !Freeze for LoadBalancer<F>
impl<F> RefUnwindSafe for LoadBalancer<F>where
F: RefUnwindSafe,
impl<F> Send for LoadBalancer<F>where
F: Send,
impl<F> Sync for LoadBalancer<F>where
F: Sync,
impl<F> Unpin for LoadBalancer<F>where
F: Unpin,
impl<F> UnsafeUnpin for LoadBalancer<F>
impl<F> UnwindSafe for LoadBalancer<F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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