pub struct PartitionDetector {
pub last_seen: HashMap<NodeId, u64>,
pub timeout_rounds: u64,
pub current_round: u64,
pub total_nodes: usize,
}Expand description
Partition detector identifies network splits by tracking node reachability.
Maintains a heartbeat map. Nodes that haven’t been heard from within
timeout_rounds are considered partitioned. The detector then checks
if the remaining reachable nodes form a quorum.
Fields§
§last_seen: HashMap<NodeId, u64>§timeout_rounds: u64§current_round: u64§total_nodes: usizeImplementations§
Source§impl PartitionDetector
impl PartitionDetector
pub fn new(total_nodes: usize, timeout_rounds: u64) -> Self
pub fn heartbeat(&mut self, node_id: NodeId)
pub fn advance_round(&mut self)
pub fn is_alive(&self, node_id: NodeId) -> bool
pub fn alive_nodes(&self) -> Vec<NodeId> ⓘ
pub fn partitioned_nodes(&self) -> Vec<NodeId> ⓘ
pub fn has_quorum(&self) -> bool
pub fn is_partitioned(&self) -> bool
Trait Implementations§
Source§impl Clone for PartitionDetector
impl Clone for PartitionDetector
Source§fn clone(&self) -> PartitionDetector
fn clone(&self) -> PartitionDetector
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PartitionDetector
impl RefUnwindSafe for PartitionDetector
impl Send for PartitionDetector
impl Sync for PartitionDetector
impl Unpin for PartitionDetector
impl UnsafeUnpin for PartitionDetector
impl UnwindSafe for PartitionDetector
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