fn handle_apply(&mut self, region_id: u64, status: Arc<AtomicUsize>) {
        status.compare_and_swap(JOB_STATUS_PENDING, JOB_STATUS_RUNNING, Ordering::SeqCst);
        SNAP_COUNTER.apply.all.inc();
        // let apply_histogram = SNAP_HISTOGRAM.with_label_values(&["apply"]);
        // let timer = apply_histogram.start_coarse_timer();
        let start = tikv_util::time::Instant::now();

        match self.apply_snap(region_id, Arc::clone(&status)) {
            Ok(()) => {
                status.swap(JOB_STATUS_FINISHED, Ordering::SeqCst);
                SNAP_COUNTER.apply.success.inc();
            }
            Err(Error::Abort) => {
                warn!("applying snapshot is aborted"; "region_id" => region_id);
                assert_eq!(
                    status.swap(JOB_STATUS_CANCELLED, Ordering::SeqCst),
                    JOB_STATUS_CANCELLING
                );
                SNAP_COUNTER.apply.abort.inc();
            }
            Err(e) => {
                error!("failed to apply snap!!!"; "err" => %e, "error_code" => %e.error_code());

                status.swap(JOB_STATUS_FAILED, Ordering::SeqCst);
                SNAP_COUNTER.apply.fail.inc();
            }
        }

        SNAP_HISTOGRAM.apply.observe(start.elapsed_secs());
    }
/// Tries to apply the snapshot of the specified Region. It calls `apply_snap` to do the actual work.
Tries to apply the snapshot of the specified Region. It calls `apply_snap` to do the actual work.
Tries to apply the snapshot of the specified Region . It calls ` apply_snap ` to do the actual work .
fn handle_apply(&mut self, region_id: u64, status: Arc<AtomicUsize>) {
        status.compare_and_swap(JOB_STATUS_PENDING, JOB_STATUS_RUNNING, Ordering::SeqCst);
        SNAP_COUNTER.apply.all.inc();
        // let apply_histogram = SNAP_HISTOGRAM.with_label_values(&["apply"]);
        // let timer = apply_histogram.start_coarse_timer();
        let start = tikv_util::time::Instant::now();
        match self.apply_snap(region_id, Arc::clone(&status)) {
            Ok(()) => {
                status.swap(JOB_STATUS_FINISHED, Ordering::SeqCst);
                SNAP_COUNTER.apply.success.inc();
            }
            Err(Error::Abort) => {
                warn!("applying snapshot is aborted"; "region_id" => region_id);
                assert_eq!(
                    status.swap(JOB_STATUS_CANCELLED, Ordering::SeqCst),
                    JOB_STATUS_CANCELLING
                );
                SNAP_COUNTER.apply.abort.inc();
            }
            Err(e) => {
                error!("failed to apply snap!!!"; "err" => %e, "error_code" => %e.error_code());
                status.swap(JOB_STATUS_FAILED, Ordering::SeqCst);
                SNAP_COUNTER.apply.fail.inc();
            }
        }
        SNAP_HISTOGRAM.apply.observe(start.elapsed_secs());
    }
fn handle_apply ( & mut self , region_id : u64 , status : Arc < AtomicUsize > ) { status . compare_and_swap ( JOB_STATUS_PENDING , JOB_STATUS_RUNNING , Ordering :: SeqCst ) ; SNAP_COUNTER . apply . all . inc ( ) ; // let apply_histogram = SNAP_HISTOGRAM.with_label_values(&["apply"]); // let timer = apply_histogram.start_coarse_timer(); let start = tikv_util :: time :: Instant :: now ( ) ; match self . apply_snap ( region_id , Arc :: clone ( & status ) ) { Ok ( ( ) ) => { status . swap ( JOB_STATUS_FINISHED , Ordering :: SeqCst ) ; SNAP_COUNTER . apply . success . inc ( ) ; } Err ( Error :: Abort ) => { warn ! ( " " " " region_id ) ; assert_eq ! ( status swap ( JOB_STATUS_CANCELLED Ordering SeqCst ) JOB_STATUS_CANCELLING ) ; SNAP_COUNTER . apply . abort . inc ( ) ; } Err ( e ) => { error ! ( " " " " e " " e error_code ( ) ) ; status . swap ( JOB_STATUS_FAILED , Ordering :: SeqCst ) ; SNAP_COUNTER . apply . fail . inc ( ) ; } } SNAP_HISTOGRAM . apply . observe ( start . elapsed_secs ( ) ) ; }
Tries to apply the snapshot of the specified Region.
Tries to apply the snapshot of the specified Region .
&mut self
region_id
u64
status
Arc<AtomicUsize>