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

Method GetMeanLoad

phxqueue/scheduler/schedulermgr.cpp:610–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

608}
609
610comm::RetCode SchedulerMgr::GetMeanLoad(const int topic_id, const TopicData &topic_data,
611 float &mean_load) {
612 mean_load = 0;
613 int nr_live{0};
614 int sum_load{0};
615
616 for (const auto &cosumer_addr2info_kv : topic_data.consumer_addr2info_map) {
617 const auto &consumer_info(cosumer_addr2info_kv.second);
618 if (!consumer_info.live)
619 continue;
620
621 sum_load += consumer_info.sticky_load;
622 ++nr_live;
623 }
624
625 if (0 >= nr_live) {
626 QLInfo("topic_id %d no live consumer", topic_id);
627 return comm::RetCode::RET_NO_LIVE_CONSUMER;
628 }
629
630 if (0 >= sum_load) {
631 QLErr("topic %d sum_load", topic_id, sum_load, sum_load);
632
633 return comm::RetCode::RET_ERR_LOGIC;
634 }
635
636 mean_load = sum_load / nr_live;
637 QLInfo("topic %d mean_load %.1f sum_load %d nr_live %d", topic_id, mean_load, sum_load, nr_live);
638
639 return comm::RetCode::RET_OK;
640}
641
642comm::RetCode SchedulerMgr::UpdateLive(const int topic_id, TopicData &topic_data,
643 TopicLock &topic_lock, const uint64_t now, bool &modified) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected