pub fn check_before_tick(&self, cfg: &Config) -> CheckTickResult {
        let mut res = CheckTickResult::default();
        if !self.is_leader() {
            return res;
        }
        res.leader = true;
        if self.raft_group.raft.election_elapsed + 1 < cfg.raft_election_timeout_ticks {
            return res;
        }
        let status = self.raft_group.status();
        let last_index = self.raft_group.raft.raft_log.last_index();
        for (id, pr) in status.progress.unwrap().iter() {
            // Only recent active peer is considered, so that an isolated follower
            // won't waste leader's resource.
            if *id == self.peer.get_id() || !pr.recent_active {
                continue;
            }
            // Keep replicating data to active followers.
            if pr.matched != last_index {
                return res;
            }
        }
        if self.raft_group.raft.pending_read_count() > 0 {
            return res;
        }
        if self.raft_group.raft.lead_transferee.is_some() {
            return res;
        }
        // Unapplied entries can change the configuration of the group.
        if self.get_store().applied_index() < last_index {
            return res;
        }
        if self.replication_mode_need_catch_up() {
            return res;
        }
        res.up_to_date = true;
        res
    }
/// Check whether the peer can be hibernated.
///
/// This should be used with `check_after_tick` to get a correct conclusion.
Check whether the peer can be hibernated.
This should be used with `check_after_tick` to get a correct conclusion.
Check whether the peer can be hibernated . This should be used with ` check_after_tick ` to get a correct conclusion .
pub fn check_before_tick(&self, cfg: &Config) -> CheckTickResult {
        let mut res = CheckTickResult::default();
        if !self.is_leader() {
            return res;
        }
        res.leader = true;
        if self.raft_group.raft.election_elapsed + 1 < cfg.raft_election_timeout_ticks {
            return res;
        }
        let status = self.raft_group.status();
        let last_index = self.raft_group.raft.raft_log.last_index();
        for (id, pr) in status.progress.unwrap().iter() {
            // Only recent active peer is considered, so that an isolated follower
            // won't waste leader's resource.
            if *id == self.peer.get_id() || !pr.recent_active {
                continue;
            }
            // Keep replicating data to active followers.
            if pr.matched != last_index {
                return res;
            }
        }
        if self.raft_group.raft.pending_read_count() > 0 {
            return res;
        }
        if self.raft_group.raft.lead_transferee.is_some() {
            return res;
        }
        // Unapplied entries can change the configuration of the group.
        if self.get_store().applied_index() < last_index {
            return res;
        }
        if self.replication_mode_need_catch_up() {
            return res;
        }
        res.up_to_date = true;
        res
    }
pub fn check_before_tick ( & self , cfg : & Config ) -> CheckTickResult { let mut res = CheckTickResult :: default ( ) ; if ! self . is_leader ( ) { return res ; } res . leader = true ; if self . raft_group . raft . election_elapsed + 1 < cfg . raft_election_timeout_ticks { return res ; } let status = self . raft_group . status ( ) ; let last_index = self . raft_group . raft . raft_log . last_index ( ) ; for ( id , pr ) in status . progress . unwrap ( ) . iter ( ) { // Only recent active peer is considered, so that an isolated follower // won't waste leader's resource. if * id == self . peer . get_id ( ) || ! pr . recent_active { continue ; } // Keep replicating data to active followers. if pr . matched != last_index { return res ; } } if self . raft_group . raft . pending_read_count ( ) > 0 { return res ; } if self . raft_group . raft . lead_transferee . is_some ( ) { return res ; } // Unapplied entries can change the configuration of the group. if self . get_store ( ) . applied_index ( ) < last_index { return res ; } if self . replication_mode_need_catch_up ( ) { return res ; } res . up_to_date = true ; res }
Check whether the peer can be hibernated.
Check whether the peer can be hibernated .
&self
cfg
&Config