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

Method DoRun

phxqueue/scheduler/loadbalancethread.cpp:69–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69void 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

Callers

nothing calls this directly

Calls 6

as_integerFunction · 0.85
IsMasterMethod · 0.80
GetSchedulerMgrMethod · 0.80
LoadBalanceMethod · 0.80
GetTopicIDMethod · 0.45

Tested by

no test coverage detected