| 67 | } |
| 68 | |
| 69 | void LoadBalanceThread::DoRun() { |
| 70 | comm::RetCode ret; |
| 71 | const int topic_id{impl_->scheduler->GetTopicID()}; |
| 72 | |
| 73 | while (true) { |
| 74 | |
| 75 | shared_ptr<const config::TopicConfig> topic_config; |
| 76 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetTopicConfigByTopicID(topic_id, topic_config))) { |
| 77 | QLErr("GetTopicConfigByTopicID ret %d", as_integer(ret)); |
| 78 | sleep(1); |
| 79 | continue; |
| 80 | } |
| 81 | |
| 82 | const uint64_t now{comm::utils::Time::GetSteadyClockMS()}; |
| 83 | |
| 84 | if (!impl_->scheduler->GetSchedulerMgr()->IsMaster(now)) { |
| 85 | QLInfo("not master"); |
| 86 | sleep(topic_config->GetProto().topic().scheduler_load_balance_interval_s()); |
| 87 | |
| 88 | continue; |
| 89 | } |
| 90 | |
| 91 | ret = impl_->scheduler->GetSchedulerMgr()->LoadBalance(now); |
| 92 | if (comm::RetCode::RET_OK != ret) { |
| 93 | QLErr("LoadBalance err %d", ret); |
| 94 | } |
| 95 | |
| 96 | sleep(topic_config->GetProto().topic().scheduler_load_balance_interval_s()); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | |
| 101 | } // namespace scheduler |
nothing calls this directly
no test coverage detected