Skip to main content

RebalanceManager

Struct RebalanceManager 

Source
pub struct RebalanceManager { /* private fields */ }
Expand description

Manager for automatic rebalancing

Implementations§

Source§

impl RebalanceManager

Source

pub fn new(config: RebalanceConfig) -> Self

Create a new rebalance manager

Source

pub fn register_node(&self, load: NodeLoad)

Register a node with its load information

Source

pub fn unregister_node(&self, node_id: &str)

Remove a node from tracking

Source

pub fn update_node_load( &self, node_id: &str, update: impl FnOnce(&mut NodeLoad), )

Update node load information

Source

pub fn register_shard(&self, shard_id: &str, node_id: &str)

Register a shard assignment

Source

pub fn unregister_shard(&self, shard_id: &str)

Remove a shard assignment

Source

pub fn calculate_imbalance(&self) -> f64

Calculate cluster imbalance score (0.0 = perfectly balanced, 1.0 = maximally imbalanced)

Source

pub fn needs_rebalance(&self) -> bool

Check if rebalance is needed

Source

pub fn can_rebalance(&self) -> bool

Check if enough time has passed since last rebalance

Source

pub fn trigger_rebalance( &self, trigger: RebalanceTrigger, ) -> Result<RebalancePlan>

Trigger a rebalance operation

Source

pub fn create_move_plan(&self) -> Result<Vec<ShardMove>>

Plan the shard movements

Source

pub fn start_execution(&self) -> Result<()>

Start executing the rebalance plan

Source

pub fn start_move(&self, move_id: &str) -> Result<()>

Start a specific move

Source

pub fn update_move_progress( &self, move_id: &str, bytes_transferred: u64, total_bytes: u64, ) -> Result<()>

Update move progress

Source

pub fn advance_to_verify(&self, move_id: &str) -> Result<()>

Advance move to verification stage

Source

pub fn advance_to_routing(&self, move_id: &str) -> Result<()>

Advance move to routing update stage

Source

pub fn complete_move(&self, move_id: &str) -> Result<()>

Complete a move

Source

pub fn fail_move(&self, move_id: &str, error: &str) -> Result<()>

Fail a move

Source

pub fn cancel(&self) -> Result<()>

Cancel the current rebalance

Source

pub fn is_cancelled(&self) -> bool

Check if rebalance was cancelled

Source

pub fn get_plan(&self) -> Option<RebalancePlan>

Get the current rebalance plan

Source

pub fn get_queued_moves(&self) -> Vec<String>

Get moves that are ready to start

Source

pub fn get_active_moves(&self) -> Vec<ShardMove>

Get currently executing moves

Source

pub fn get_stats(&self) -> RebalanceStats

Get rebalance statistics

Source

pub fn get_node_load(&self, node_id: &str) -> Option<NodeLoad>

Get node load information

Source

pub fn get_all_node_loads(&self) -> Vec<NodeLoad>

Get all node loads

Source

pub fn on_node_joined( &self, node_id: &str, capacity: u64, ) -> Result<Option<RebalancePlan>>

Handle node join event

Source

pub fn on_node_left(&self, node_id: &str) -> Result<Option<RebalancePlan>>

Handle node leave event

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,