pub struct Node {
pub info: NodeInfo,
pub state: NodeState,
pub incarnation: u64,
pub last_seen: Instant,
pub partition_leader_count: u32,
pub partition_replica_count: u32,
pub is_raft_leader: bool,
}Expand description
Full node state including runtime information
Fields§
§info: NodeInfoStatic node information
state: NodeStateCurrent node state
incarnation: u64Incarnation number (for SWIM protocol)
last_seen: InstantLast time we heard from this node
partition_leader_count: u32Number of partitions led by this node
partition_replica_count: u32Number of partition replicas on this node
is_raft_leader: boolWhether this node is the Raft leader
Implementations§
Source§impl Node
impl Node
Sourcepub fn mark_alive(&mut self, incarnation: u64) -> bool
pub fn mark_alive(&mut self, incarnation: u64) -> bool
Mark as alive with incarnation-based CAS.
Returns true if the transition was accepted.
Enforces state machine rules:
- Unknown/Suspect → Alive: always valid with >= incarnation
- Dead → Alive: only valid with strictly higher incarnation (rejoin)
- Alive → Alive: valid with higher incarnation (state refresh)
Sourcepub fn mark_suspect(&mut self) -> bool
pub fn mark_suspect(&mut self) -> bool
Mark as suspect with state machine guard.
Returns true if the transition was accepted.
Only Alive|Unknown → Suspect is valid. Dead → Suspect is explicitly rejected to prevent the Suspect→Dead→Suspect race condition.
Sourcepub fn mark_dead(&mut self) -> bool
pub fn mark_dead(&mut self) -> bool
Mark as dead with state machine guard.
Returns true if the transition was accepted.
Only Suspect → Dead is valid in SWIM. Direct Alive → Dead is rejected (must go through Suspect first). Already Dead is a no-op (idempotent).
Sourcepub fn mark_leaving(&mut self) -> bool
pub fn mark_leaving(&mut self) -> bool
Mark as leaving.
Returns true if the transition was accepted.
Valid from any non-Dead state (graceful shutdown).
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Check if node is healthy
Sourcepub fn cluster_addr(&self) -> SocketAddr
pub fn cluster_addr(&self) -> SocketAddr
Get cluster address
Sourcepub fn client_addr(&self) -> SocketAddr
pub fn client_addr(&self) -> SocketAddr
Get client address
Sourcepub fn load_score(&self) -> u32
pub fn load_score(&self) -> u32
Calculate load score (lower is better for placement)