diff --git a/src/traft/failover.rs b/src/traft/failover.rs index 5872a6722db679a538f169acfb417d10914b7990..1e6b3342b5c841c34f5d478d90dd46970cc434e0 100644 --- a/src/traft/failover.rs +++ b/src/traft/failover.rs @@ -30,7 +30,7 @@ pub fn on_shutdown() { node.storage .peers .get(&raft_id) - .map(|peer| peer.is_active()) + .map(|peer| peer.is_online()) .unwrap_or(false) }); let raft_id = node.status().id; diff --git a/src/traft/mod.rs b/src/traft/mod.rs index 24a7992004f5fae69723131b6a2775b074688645..f8498548bb7ae7167ab2263b85b61a67d1078b83 100644 --- a/src/traft/mod.rs +++ b/src/traft/mod.rs @@ -457,7 +457,7 @@ pub struct Peer { impl Encode for Peer {} impl Peer { - pub fn is_active(&self) -> bool { + pub fn is_online(&self) -> bool { matches!(self.current_grade, CurrentGrade::Online) } diff --git a/src/traft/node.rs b/src/traft/node.rs index c7726aadffb1945f4e54ecf3ea2a0aaf85f2a609..dce2ff8667d912221870a6a46f77b7afc152a01d 100644 --- a/src/traft/node.rs +++ b/src/traft/node.rs @@ -906,7 +906,7 @@ fn raft_conf_change(storage: &RaftSpaceAccess, peers: &[Peer]) -> Option<raft::C HashSet::from_iter(storage.learners().unwrap().unwrap_or_default()); let peer_is_active: HashMap<RaftId, bool> = peers .iter() - .map(|peer| (peer.raft_id, peer.is_active())) + .map(|peer| (peer.raft_id, peer.is_online())) .collect(); let (active_voters, to_demote): (Vec<RaftId>, Vec<RaftId>) = voter_ids diff --git a/src/traft/topology.rs b/src/traft/topology.rs index 7cd2741feb85b6059deedb5c21bae54dd1b03ee8..eaa19905fc163e685386e9dee25a8faa7b7f65ca 100644 --- a/src/traft/topology.rs +++ b/src/traft/topology.rs @@ -139,7 +139,7 @@ impl Topology { if let Some(id) = instance_id.as_ref() { let existing_peer: Option<&Peer> = self.instance_map.get(id); - if matches!(existing_peer, Some(peer) if peer.is_active()) { + if matches!(existing_peer, Some(peer) if peer.is_online()) { let e = format!("{} is already joined", id); return Err(e); }