File tree Expand file tree Collapse file tree 3 files changed +54
-6
lines changed Expand file tree Collapse file tree 3 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -3045,4 +3045,52 @@ impl<T: Storage> Raft<T> {
3045
3045
pr. ins . set_cap ( cap) ;
3046
3046
}
3047
3047
}
3048
+
3049
+ /// Whether this RawNode is active recently.
3050
+ pub fn is_recent_active ( & self , id : u64 ) -> bool {
3051
+ if let Some ( pr) = self . prs ( ) . get ( id) {
3052
+ if pr. recent_active {
3053
+ return true ;
3054
+ }
3055
+ }
3056
+ false
3057
+ }
3058
+
3059
+ /// Get the next idx of peer.
3060
+ #[ inline]
3061
+ pub fn get_next_idx ( & self , id : u64 ) -> Option < u64 > {
3062
+ self . prs ( ) . get ( id) . map ( |pr| pr. next_idx )
3063
+ }
3064
+
3065
+ /// Get the matched of peer.
3066
+ #[ inline]
3067
+ pub fn get_matched ( & self , id : u64 ) -> Option < u64 > {
3068
+ self . prs ( ) . get ( id) . map ( |pr| pr. matched )
3069
+ }
3070
+
3071
+ /// Determine whether a progress is in Replicate state.
3072
+ pub fn is_replicate_state ( & self , id : u64 ) -> bool {
3073
+ if let Some ( pr) = self . prs ( ) . get ( id) {
3074
+ if pr. is_replicate_state ( ) {
3075
+ return true ;
3076
+ }
3077
+ }
3078
+ false
3079
+ }
3080
+
3081
+ /// Determine whether a progress lags.
3082
+ pub fn is_lag ( & self , id : u64 ) -> bool {
3083
+ if let Some ( pr) = self . prs ( ) . get ( id) {
3084
+ if pr. lag {
3085
+ return true ;
3086
+ }
3087
+ }
3088
+ false
3089
+ }
3090
+
3091
+ /// Determine whether this is the leader.
3092
+ #[ inline]
3093
+ pub fn is_leader ( & self ) -> bool {
3094
+ self . id == self . leader_id
3095
+ }
3048
3096
}
Original file line number Diff line number Diff line change @@ -786,12 +786,6 @@ impl<T: Storage> RawNode<T> {
786
786
pub fn skip_bcast_commit ( & mut self , skip : bool ) {
787
787
self . raft . skip_bcast_commit ( skip)
788
788
}
789
-
790
- /// Set whether to batch append msg at runtime.
791
- #[ inline]
792
- pub fn set_batch_append ( & mut self , batch_append : bool ) {
793
- self . raft . set_batch_append ( batch_append)
794
- }
795
789
}
796
790
797
791
#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -212,6 +212,12 @@ impl Progress {
212
212
true
213
213
}
214
214
215
+ /// Determine whether progress is in the Replicate state;
216
+ #[ inline]
217
+ pub fn is_replicate_state ( & self ) -> bool {
218
+ self . state == ProgressState :: Replicate
219
+ }
220
+
215
221
/// Determine whether progress is paused.
216
222
#[ inline]
217
223
pub fn is_paused ( & self ) -> bool {
You can’t perform that action at this time.
0 commit comments