MCPcopy Create free account
hub / github.com/Tencent/phxqueue / Rebuild

Method Rebuild

phxqueue/config/globalconfig.cpp:71–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71comm::RetCode GlobalConfig::Rebuild() {
72 impl_->topic_name2topic_id.clear();
73 impl_->topic_id2topic_config.clear();
74 impl_->topic_id2consumer_config.clear();
75 impl_->topic_id2store_config.clear();
76 impl_->topic_id2scheduler_config.clear();
77 impl_->topic_id2lock_config.clear();
78 impl_->handle_id2topic_id.clear();
79
80 comm::RetCode ret;
81
82 auto &&proto = GetProto();
83 for (int i{0}; i < proto.topic_infos_size(); ++i) {
84 auto &&topic_info = proto.topic_infos(i);
85
86 impl_->topic_name2topic_id.emplace(topic_info.topic_name(), topic_info.topic_id());
87
88 shared_ptr<TopicConfig> topic_config = plugin::ConfigFactory::GetInstance()->NewTopicConfig(topic_info.topic_id(), topic_info.topic_config_path());
89 if (topic_config) {
90 topic_config->Load();
91 impl_->topic_id2topic_config.emplace(topic_info.topic_id(), topic_config);
92 }
93
94 for (int j{0}; j < topic_config->GetProto().topic().handle_ids_size(); ++j) {
95 impl_->handle_id2topic_id[topic_config->GetProto().topic().handle_ids(j)] = topic_info.topic_id();
96 }
97
98 auto &&consumer_config = plugin::ConfigFactory::GetInstance()->NewConsumerConfig(topic_info.topic_id(), topic_info.consumer_config_path());
99 if (consumer_config) {
100 consumer_config->Load();
101 impl_->topic_id2consumer_config.emplace(topic_info.topic_id(), move(consumer_config));
102 }
103
104 auto &&store_config = plugin::ConfigFactory::GetInstance()->NewStoreConfig(topic_info.topic_id(), topic_info.store_config_path());
105 if (store_config) {
106 store_config->Load();
107 impl_->topic_id2store_config.emplace(topic_info.topic_id(), move(store_config));
108 }
109
110 auto &&scheduler_config = plugin::ConfigFactory::GetInstance()->NewSchedulerConfig(topic_info.topic_id(), topic_info.scheduler_config_path());
111 if (scheduler_config) {
112 scheduler_config->Load();
113 impl_->topic_id2scheduler_config.emplace(topic_info.topic_id(), move(scheduler_config));
114 }
115
116 auto &&lock_config = plugin::ConfigFactory::GetInstance()->NewLockConfig(topic_info.topic_id(), topic_info.lock_config_path());
117 if (lock_config) {
118 lock_config->Load();
119 impl_->topic_id2lock_config.emplace(topic_info.topic_id(), move(lock_config));
120 }
121 }
122
123 return comm::RetCode::RET_OK;
124}
125
126comm::RetCode GlobalConfig::GetTopicIDByTopicName(const string &topic_name, int &topic_id) const {
127 auto &&it = impl_->topic_name2topic_id.find(topic_name);

Callers

nothing calls this directly

Calls 6

LoadMethod · 0.80
NewTopicConfigMethod · 0.45
NewConsumerConfigMethod · 0.45
NewStoreConfigMethod · 0.45
NewSchedulerConfigMethod · 0.45
NewLockConfigMethod · 0.45

Tested by

no test coverage detected