fn generate_snap(
        &self,
        region_id: u64,
        last_applied_index_term: u64,
        last_applied_state: RaftApplyState,
        kv_snap: EK::Snapshot,
        notifier: SyncSender<RaftSnapshot>,
    ) -> Result<()> {
        // do we need to check leader here?
        let snap = box_try!(store::do_snapshot::<EK>(
            self.mgr.clone(),
            &self.engines.kv,
            kv_snap,
            region_id,
            last_applied_index_term,
            last_applied_state,
        ));
        // Only enable the fail point when the region id is equal to 1, which is
        // the id of bootstrapped region in tests.
        fail_point!("region_gen_snap", region_id == 1, |_| Ok(()));
        if let Err(e) = notifier.try_send(snap) {
            info!(
                "failed to notify snap result, leadership may have changed, ignore error";
                "region_id" => region_id,
                "err" => %e,
            );
        }
        // The error can be ignored as snapshot will be sent in next heartbeat in the end.
        let _ = self
            .router
            .send(region_id, CasualMessage::SnapshotGenerated);
        Ok(())
    }
/// Generates the snapshot of the Region.
Generates the snapshot of the Region.
Generates the snapshot of the Region .
fn generate_snap(
        &self,
        region_id: u64,
        last_applied_index_term: u64,
        last_applied_state: RaftApplyState,
        kv_snap: EK::Snapshot,
        notifier: SyncSender<RaftSnapshot>,
    ) -> Result<()> {
        // do we need to check leader here?
        let snap = box_try!(store::do_snapshot::<EK>(
            self.mgr.clone(),
            &self.engines.kv,
            kv_snap,
            region_id,
            last_applied_index_term,
            last_applied_state,
        ));
        // Only enable the fail point when the region id is equal to 1, which is
        // the id of bootstrapped region in tests.
        fail_point!("region_gen_snap", region_id == 1, |_| Ok(()));
        if let Err(e) = notifier.try_send(snap) {
            info!(
                "failed to notify snap result, leadership may have changed, ignore error";
                "region_id" => region_id,
                "err" => %e,
            );
        }
        // The error can be ignored as snapshot will be sent in next heartbeat in the end.
        let _ = self
            .router
            .send(region_id, CasualMessage::SnapshotGenerated);
        Ok(())
    }
fn generate_snap ( & self , region_id : u64 , last_applied_index_term : u64 , last_applied_state : RaftApplyState , kv_snap : EK :: Snapshot , notifier : SyncSender < RaftSnapshot > , ) -> Result < ( ) > { // do we need to check leader here? let snap = box_try ! ( store do_snapshot EK ( self mgr clone ( ) self engines kv kv_snap region_id last_applied_index_term last_applied_state ) ) ; // Only enable the fail point when the region id is equal to 1, which is // the id of bootstrapped region in tests. fail_point ! ( " " region_id 1 Ok ( ( ) ) ) ; if let Err ( e ) = notifier . try_send ( snap ) { info ! ( " " " " region_id " " e ) ; } // The error can be ignored as snapshot will be sent in next heartbeat in the end. let _ = self . router . send ( region_id , CasualMessage :: SnapshotGenerated ) ; Ok ( ( ) ) }
Generates the snapshot of the Region.
Generates the snapshot of the Region .
&self
region_id
u64
last_applied_index_term
u64
last_applied_state
RaftApplyState
kv_snap
EK::Snapshot
notifier
SyncSender<RaftSnapshot>