Skip to content

Commit 806b77a

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 806b77a

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/raft.rs

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

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_replicate_state(&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)