/// perform election when spu become online
perform election when spu become online
perform election when spu become online
fn force_election_spu_on(&self, online_spu: SpuKV, actions: &mut PartitionActions) {
        debug!("start election spu went online: {}", online_spu.key());
        let online_leader_spu_id = online_spu.spec.id;
        let policy = SimplePolicy::new();
        // go thru each partitions which are not online and try to promote given online spu
        self.partition_store.visit_values(|partition_kv| {
            if partition_kv.status.is_offline() {
                // we only care about partition who is follower since, leader will set partition status when it start up
                if partition_kv.spec.leader != online_leader_spu_id {
                    for replica_status in partition_kv.status.replica_iter() {
                        if replica_status.spu == online_leader_spu_id
                            && policy
                                .potential_leader_score(
                                    &replica_status,
                                    &partition_kv.status.leader,
                                )
                                .is_suitable()
                        {
                            debug!(
                                "suitable leader has found: {} leader: {}",
                                partition_kv.key(),
                                online_leader_spu_id
                            );
                            let mut part_kv_change = partition_kv.clone();
                            part_kv_change.spec.leader = online_leader_spu_id;
                            actions
                                .partitions
                                .push(PartitionWSAction::UpdateSpec(part_kv_change));
                        }
                    }
                }
            }
        });
    }
fn force_election_spu_on ( & self , online_spu : SpuKV , actions : & mut PartitionActions ) { debug ! ( " " online_spu key ( ) ) ; let online_leader_spu_id = online_spu . spec . id ; let policy = SimplePolicy :: new ( ) ; // go thru each partitions which are not online and try to promote given online spu self . partition_store . visit_values ( | partition_kv | { if partition_kv . status . is_offline ( ) { // we only care about partition who is follower since, leader will set partition status when it start up if partition_kv . spec . leader != online_leader_spu_id { for replica_status in partition_kv . status . replica_iter ( ) { if replica_status . spu == online_leader_spu_id && policy . potential_leader_score ( & replica_status , & partition_kv . status . leader , ) . is_suitable ( ) { debug ! ( " " partition_kv key ( ) online_leader_spu_id ) ; let mut part_kv_change = partition_kv . clone ( ) ; part_kv_change . spec . leader = online_leader_spu_id ; actions . partitions . push ( PartitionWSAction :: UpdateSpec ( part_kv_change ) ) ; } } } } } ) ; }
perform election when spu become online
perform election when spu become online
&self
online_spu
SpuKV
actions
&mut PartitionActions