/// based on our current state, compute what should be next state
based on our current state, compute what should be next state
based on our current state compute what should be next state
pub fn compute_next_state(&self,
        spu_store: &SpuLocalStore,
        partition_store: &PartitionLocalStore
    ) -> TopicNextState {
        match self.spec() {
            // Computed Topic
            TopicSpec::Computed(ref param) => {
                match self.status.resolution {
                    TopicResolution::Init | TopicResolution::InvalidConfig => {
                        self.validate_computed_topic_parameters(param)
                    },
                    TopicResolution::Pending | TopicResolution::InsufficientResources => {
                        let mut next_state = self.generate_replica_map(spu_store,param);
                        if next_state.resolution == TopicResolution::Provisioned {
                            debug!("Topic: {} replica generate successfull, status is provisioned",self.key());
                            next_state.partitions = self.create_new_partitions(partition_store);
                            next_state
                        } else {
                            next_state
                        }
                    },
                    _ => {
                        debug!("topic: {} resolution: {:#?} ignoring",self.key,self.status.resolution);
                        let mut next_state = self.same_next_state();
                        if next_state.resolution == TopicResolution::Provisioned {
                            next_state.partitions = self.create_new_partitions(partition_store);
                            next_state
                        } else {
                            next_state
                        }
                    }
                }
            }
            // Assign Topic
            TopicSpec::Assigned(ref partition_map) => {
                match self.status.resolution {
                    TopicResolution::Init | TopicResolution::InvalidConfig  => {
                        self.validate_assigned_topic_parameters(partition_map)
                    },
                    TopicResolution::Pending | TopicResolution::InsufficientResources => {
                        let mut next_state = self.update_replica_map_for_assigned_topic(partition_map,spu_store);
                        if next_state.resolution == TopicResolution::Provisioned {
                            next_state.partitions = self.create_new_partitions(partition_store);
                            next_state
                        } else {
                            next_state
                        }
                    },
                    _ => {
                        debug!("assigned topic: {} resolution: {:#?} ignoring",self.key,self.status.resolution);
                        let mut next_state = self.same_next_state();
                        if next_state.resolution == TopicResolution::Provisioned {
                            next_state.partitions = self.create_new_partitions(partition_store);
                            next_state
                        } else {
                            next_state
                        }
                    }
                }
            }
        }
    }
pub fn compute_next_state ( & self , spu_store : & SpuLocalStore , partition_store : & PartitionLocalStore ) -> TopicNextState { match self . spec ( ) { // Computed Topic TopicSpec :: Computed ( ref param ) => { match self . status . resolution { TopicResolution :: Init | TopicResolution :: InvalidConfig => { self . validate_computed_topic_parameters ( param ) } , TopicResolution :: Pending | TopicResolution :: InsufficientResources => { let mut next_state = self . generate_replica_map ( spu_store , param ) ; if next_state . resolution == TopicResolution :: Provisioned { debug ! ( " " self key ( ) ) ; next_state . partitions = self . create_new_partitions ( partition_store ) ; next_state } else { next_state } } , _ => { debug ! ( " " self key self status resolution ) ; let mut next_state = self . same_next_state ( ) ; if next_state . resolution == TopicResolution :: Provisioned { next_state . partitions = self . create_new_partitions ( partition_store ) ; next_state } else { next_state } } } } // Assign Topic TopicSpec :: Assigned ( ref partition_map ) => { match self . status . resolution { TopicResolution :: Init | TopicResolution :: InvalidConfig => { self . validate_assigned_topic_parameters ( partition_map ) } , TopicResolution :: Pending | TopicResolution :: InsufficientResources => { let mut next_state = self . update_replica_map_for_assigned_topic ( partition_map , spu_store ) ; if next_state . resolution == TopicResolution :: Provisioned { next_state . partitions = self . create_new_partitions ( partition_store ) ; next_state } else { next_state } } , _ => { debug ! ( " " self key self status resolution ) ; let mut next_state = self . same_next_state ( ) ; if next_state . resolution == TopicResolution :: Provisioned { next_state . partitions = self . create_new_partitions ( partition_store ) ; next_state } else { next_state } } } } } }
based on our current state, compute what should be next state
based on our current state compute what should be next state
&self
spu_store
&SpuLocalStore
partition_store
&PartitionLocalStore