Skip to content

Commit d0834f5

Browse files
author
LintianShi
committed
Interface of querying the information of progress which supports agent selection
Signed-off-by: LintianShi <lintian.shi@pingcap.com>
1 parent 40a8fcd commit d0834f5

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/raft.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3036,4 +3036,28 @@ impl<T: Storage> Raft<T> {
30363036
pr.ins.set_cap(cap);
30373037
}
30383038
}
3039+
3040+
/// Whether this RawNode is active recently.
3041+
#[inline]
3042+
pub fn is_recent_active(&self, id: u64) -> bool {
3043+
self.prs().get(id).map_or(false, |pr| pr.recent_active)
3044+
}
3045+
3046+
/// Get the next idx of peer.
3047+
#[inline]
3048+
pub fn get_next_idx(&self, id: u64) -> Option<u64> {
3049+
self.prs().get(id).map(|pr| pr.next_idx)
3050+
}
3051+
3052+
/// Get the matched of peer.
3053+
#[inline]
3054+
pub fn get_matched(&self, id: u64) -> Option<u64> {
3055+
self.prs().get(id).map(|pr| pr.matched)
3056+
}
3057+
3058+
/// Determine whether a progress is in Replicate state.
3059+
#[inline]
3060+
pub fn is_replicating(&self, id: u64) -> bool {
3061+
self.prs().get(id).map_or(false, |pr| pr.is_replicating())
3062+
}
30393063
}

src/tracker/progress.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ impl Progress {
203203
true
204204
}
205205

206+
/// Determine whether progress is in the Replicate state;
207+
#[inline]
208+
pub fn is_replicating(&self) -> bool {
209+
self.state == ProgressState::Replicate
210+
}
211+
206212
/// Determine whether progress is paused.
207213
#[inline]
208214
pub fn is_paused(&self) -> bool {

0 commit comments

Comments
 (0)