Skip to content

Commit

Permalink
Interface of querying the information of progress which supports agen…
Browse files Browse the repository at this point in the history
…t selection

Signed-off-by: LintianShi <[email protected]>
  • Loading branch information
LintianShi committed Sep 27, 2022
1 parent 40a8fcd commit d0834f5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3036,4 +3036,28 @@ impl<T: Storage> Raft<T> {
pr.ins.set_cap(cap);
}
}

/// Whether this RawNode is active recently.
#[inline]
pub fn is_recent_active(&self, id: u64) -> bool {
self.prs().get(id).map_or(false, |pr| pr.recent_active)
}

/// Get the next idx of peer.
#[inline]
pub fn get_next_idx(&self, id: u64) -> Option<u64> {
self.prs().get(id).map(|pr| pr.next_idx)
}

/// Get the matched of peer.
#[inline]
pub fn get_matched(&self, id: u64) -> Option<u64> {
self.prs().get(id).map(|pr| pr.matched)
}

/// Determine whether a progress is in Replicate state.
#[inline]
pub fn is_replicating(&self, id: u64) -> bool {
self.prs().get(id).map_or(false, |pr| pr.is_replicating())
}
}
6 changes: 6 additions & 0 deletions src/tracker/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ impl Progress {
true
}

/// Determine whether progress is in the Replicate state;
#[inline]
pub fn is_replicating(&self) -> bool {
self.state == ProgressState::Replicate
}

/// Determine whether progress is paused.
#[inline]
pub fn is_paused(&self) -> bool {
Expand Down

0 comments on commit d0834f5

Please sign in to comment.