| 182 | |
| 183 | |
| 184 | comm::RetCode FreqMan::UpdateLimitInfo() { |
| 185 | QLVerb("start"); |
| 186 | |
| 187 | comm::RetCode ret; |
| 188 | |
| 189 | uint64_t now = comm::utils::Time::GetSteadyClockMS(); |
| 190 | uint64_t diff_time_ms = now - impl_->last_update_time; |
| 191 | impl_->last_update_time = now; |
| 192 | |
| 193 | auto &&opt(impl_->consumer->GetConsumerOption()); |
| 194 | |
| 195 | shared_ptr<const config::TopicConfig> topic_config; |
| 196 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetTopicConfigByTopicID(impl_->topic_id, topic_config))) { |
| 197 | QLErr("GetTopicConfigByTopicID ret %d", as_integer(ret)); |
| 198 | return ret; |
| 199 | } |
| 200 | const int batch_limit = topic_config->GetProto().topic().batch_limit(); |
| 201 | |
| 202 | shared_ptr<const config::StoreConfig> store_config; |
| 203 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetStoreConfig(impl_->topic_id, store_config))) { |
| 204 | QLErr("GetStoreConfig ret %d", as_integer(ret)); |
| 205 | return ret; |
| 206 | } |
| 207 | |
| 208 | set<int> store_ids; |
| 209 | if (comm::RetCode::RET_OK != (ret = store_config->GetAllStoreID(store_ids))) { |
| 210 | QLErr("GetAllStoreID ret %d", as_integer(ret)); |
| 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | vector<shared_ptr<config::proto::FreqInfo> > freq_infos; |
| 215 | if (comm::RetCode::RET_OK != (ret = topic_config->GetAllFreqInfo(freq_infos))) { |
| 216 | QLErr("GetAllFreqInfo ret %d", as_integer(ret)); |
| 217 | return ret; |
| 218 | } |
| 219 | |
| 220 | vector<Queue_t> queues; |
| 221 | if (comm::RetCode::RET_OK != (ret = impl_->consumer->GetQueuesDistribute(queues))) { |
| 222 | QLErr("GetQueuesDistribute ret %d", as_integer(ret)); |
| 223 | return ret; |
| 224 | } |
| 225 | |
| 226 | if (queues.size() != opt->nprocs) { |
| 227 | QLErr("queues.size(%d) != opt->nprocs(%d)", queues.size(), opt->nprocs); |
| 228 | return comm::RetCode::RET_ERR_UNEXPECTED; |
| 229 | } |
| 230 | |
| 231 | unique_ptr<bool[]> updated(new bool[opt->nprocs]); |
| 232 | memset(updated.get(), 0, sizeof(bool) * opt->nprocs); |
| 233 | |
| 234 | map<tuple<int, int, int>, double> pub_sub_queue_info_id2max_handle_pct; |
| 235 | for (auto &&freq_info : freq_infos) { |
| 236 | auto pub_id = freq_info->pub_id(); |
| 237 | auto sub_id = freq_info->sub_id(); |
| 238 | auto handle_id = freq_info->handle_id(); |
| 239 | auto limit_per_min = freq_info->limit_per_min(); |
| 240 | auto queue_info_id = freq_info->queue_info_id(); |
| 241 |
nothing calls this directly
no test coverage detected