fn apply(
        &mut self,
        cfg: &mut Config,
        prs: &mut ProgressMap,
        ccs: &mut [ConfChangeSingle],
    ) -> Result<(), String> {
        info!("execute change.apply");
        for cc in ccs {
            if cc.get_node_id() == 0 {
                // etcd replace the nodeID with zero if it decides (downstream of
                // raft) to not apply a change, so we have to have explicit code
                // here to ignore these.
                continue;
            }
            match cc.get_field_type() {
                ConfChangeType::ConfChangeAddNode => {
                    self.make_voter(cfg, prs, cc.get_node_id());
                }
                ConfChangeType::ConfChangeAddLearnerNode => {
                    self.make_learner(cfg, prs, cc.get_node_id());
                }
                ConfChangeType::ConfChangeRemoveNode => {
                    self.remove(cfg, prs, cc.get_node_id());
                }
                ConfChangeType::ConfChangeUpdateNode => info!("execute conf change update node"),
                _ => return Err(format!("unexpected conf type {:?}", cc.get_field_type())),
            }
        }
        if cfg.voters.incoming.is_empty() {
            return Err("removed all voters".to_string());
        }
        Ok(())
    }
// apply a change to the configuration. By convention, changes to voters are
// always made to the incoming majority config voters[0]. Voters[1] is either
// empty or preserves the outgoing majority configuration while in a joint state.
apply a change to the configuration. By convention, changes to voters are
always made to the incoming majority config voters[0]. Voters[1] is either
empty or preserves the outgoing majority configuration while in a joint state.
apply a change to the configuration . By convention changes to voters are always made to the incoming majority config voters [ 0 ] . Voters [ 1 ] is either empty or preserves the outgoing majority configuration while in a joint state .
fn apply(
        &mut self,
        cfg: &mut Config,
        prs: &mut ProgressMap,
        ccs: &mut [ConfChangeSingle],
    ) -> Result<(), String> {
        info!("execute change.apply");
        for cc in ccs {
            if cc.get_node_id() == 0 {
                // etcd replace the nodeID with zero if it decides (downstream of
                // raft) to not apply a change, so we have to have explicit code
                // here to ignore these.
                continue;
            }
            match cc.get_field_type() {
                ConfChangeType::ConfChangeAddNode => {
                    self.make_voter(cfg, prs, cc.get_node_id());
                }
                ConfChangeType::ConfChangeAddLearnerNode => {
                    self.make_learner(cfg, prs, cc.get_node_id());
                }
                ConfChangeType::ConfChangeRemoveNode => {
                    self.remove(cfg, prs, cc.get_node_id());
                }
                ConfChangeType::ConfChangeUpdateNode => info!("execute conf change update node"),
                _ => return Err(format!("unexpected conf type {:?}", cc.get_field_type())),
            }
        }
        if cfg.voters.incoming.is_empty() {
            return Err("removed all voters".to_string());
        }
        Ok(())
    }
fn apply ( & mut self , cfg : & mut Config , prs : & mut ProgressMap , ccs : & mut [ ConfChangeSingle ] , ) -> Result < ( ) , String > { info ! ( " " ) ; for cc in ccs { if cc . get_node_id ( ) == 0 { // etcd replace the nodeID with zero if it decides (downstream of // raft) to not apply a change, so we have to have explicit code // here to ignore these. continue ; } match cc . get_field_type ( ) { ConfChangeType :: ConfChangeAddNode => { self . make_voter ( cfg , prs , cc . get_node_id ( ) ) ; } ConfChangeType :: ConfChangeAddLearnerNode => { self . make_learner ( cfg , prs , cc . get_node_id ( ) ) ; } ConfChangeType :: ConfChangeRemoveNode => { self . remove ( cfg , prs , cc . get_node_id ( ) ) ; } ConfChangeType :: ConfChangeUpdateNode => info ! ( " " ) , _ => return Err ( format ! ( " " cc get_field_type ( ) ) ) , } } if cfg . voters . incoming . is_empty ( ) { return Err ( " " . to_string ( ) ) ; } Ok ( ( ) ) }
apply a change to the configuration.
apply a change to the configuration .
&mut self
cfg
&mut Config
prs
&mut ProgressMap
ccs
&mut [ConfChangeSingle]