fn propose_transfer_leader<T, C>(
        &mut self,
        ctx: &mut PollContext<EK, ER, T, C>,
        req: RaftCmdRequest,
        cb: Callback<EK::Snapshot>,
    ) -> bool {
        ctx.raft_metrics.propose.transfer_leader += 1;

        let transfer_leader = get_transfer_leader_cmd(&req).unwrap();
        let peer = transfer_leader.get_peer();

        let transferred = self.pre_transfer_leader(peer);

        // transfer leader command doesn't need to replicate log and apply, so we
        // return immediately. Note that this command may fail, we can view it just as an advice
        cb.invoke_with_response(make_transfer_leader_response());

        transferred
    }
/// Return true to if the transfer leader request is accepted.
///
/// When transferring leadership begins, leader sends a pre-transfer
/// to target follower first to ensures it's ready to become leader.
/// After that the real transfer leader process begin.
///
/// 1. pre_transfer_leader on leader:
///     Leader will send a MsgTransferLeader to follower.
/// 2. execute_transfer_leader on follower
///     If follower passes all necessary checks, it will reply an
///     ACK with type MsgTransferLeader and its promised persistent index.
/// 3. execute_transfer_leader on leader:
///     Leader checks if it's appropriate to transfer leadership. If it
///     does, it calls raft transfer_leader API to do the remaining work.
///
/// See also: tikv/rfcs#37.
Return true to if the transfer leader request is accepted.
When transferring leadership begins, leader sends a pre-transfer
to target follower first to ensures it's ready to become leader.
After that the real transfer leader process begin.

1. pre_transfer_leader on leader:
Leader will send a MsgTransferLeader to follower.
2. execute_transfer_leader on follower
If follower passes all necessary checks, it will reply an
ACK with type MsgTransferLeader and its promised persistent index.
3. execute_transfer_leader on leader:
Leader checks if it's appropriate to transfer leadership. If it
does, it calls raft transfer_leader API to do the remaining work.

See also: tikv/rfcs#37.
Return true to if the transfer leader request is accepted . When transferring leadership begins leader sends a pre - transfer to target follower first to ensures it ' s ready to become leader . After that the real transfer leader process begin . 1 . pre_transfer_leader on leader : Leader will send a MsgTransferLeader to follower . 2 . execute_transfer_leader on follower If follower passes all necessary checks it will reply an ACK with type MsgTransferLeader and its promised persistent index . 3 . execute_transfer_leader on leader : Leader checks if it ' s appropriate to transfer leadership . If it does it calls raft transfer_leader API to do the remaining work . See also : tikv / rfcs#37 .
fn propose_transfer_leader<T, C>(
        &mut self,
        ctx: &mut PollContext<EK, ER, T, C>,
        req: RaftCmdRequest,
        cb: Callback<EK::Snapshot>,
    ) -> bool {
        ctx.raft_metrics.propose.transfer_leader += 1;
        let transfer_leader = get_transfer_leader_cmd(&req).unwrap();
        let peer = transfer_leader.get_peer();
        let transferred = self.pre_transfer_leader(peer);
        // transfer leader command doesn't need to replicate log and apply, so we
        // return immediately. Note that this command may fail, we can view it just as an advice
        cb.invoke_with_response(make_transfer_leader_response());
        transferred
    }
fn propose_transfer_leader < T , C > ( & mut self , ctx : & mut PollContext < EK , ER , T , C > , req : RaftCmdRequest , cb : Callback < EK :: Snapshot > , ) -> bool { ctx . raft_metrics . propose . transfer_leader += 1 ; let transfer_leader = get_transfer_leader_cmd ( & req ) . unwrap ( ) ; let peer = transfer_leader . get_peer ( ) ; let transferred = self . pre_transfer_leader ( peer ) ; // transfer leader command doesn't need to replicate log and apply, so we // return immediately. Note that this command may fail, we can view it just as an advice cb . invoke_with_response ( make_transfer_leader_response ( ) ) ; transferred }
Return true to if the transfer leader request is accepted.
Return true to if the transfer leader request is accepted .
&mut self
ctx
&mut PollContext<EK, ER, T, C>
req
RaftCmdRequest
cb
Callback<EK::Snapshot>