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

Method InitMasterRate

phxqueue/store/keepmasterthread.cpp:105–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void KeepMasterThread::InitMasterRate() {
106 comm::RetCode ret;
107
108 const int topic_id{impl_->store->GetTopicID()};
109
110 impl_->master_rate = 0;
111
112 auto opt(impl_->store->GetStoreOption());
113
114 phxpaxos::Node *node{impl_->store->GetNode()};
115
116 shared_ptr<const config::TopicConfig> topic_config;
117 if (comm::RetCode::RET_OK !=
118 (ret = config::GlobalConfig::GetThreadInstance()->
119 GetTopicConfigByTopicID(topic_id, topic_config))) {
120 QLErr("GetTopicConfigByTopicID ret %d topic_id %d", ret, topic_id);
121 return;
122 }
123
124 for (int paxos_group_id{0}; paxos_group_id < opt->ngroup; ++paxos_group_id) {
125 if (node->IsIMMaster(paxos_group_id)) {
126 impl_->master_rate = paxos_group_id * 100 / opt->ngroup + (paxos_group_id * 100 % opt->ngroup ? 1 : 0);
127 }
128 }
129
130 if (impl_->master_rate < topic_config->GetProto().topic().store_adjust_min_master_rate()) {
131 impl_->master_rate = topic_config->GetProto().topic().store_adjust_min_master_rate();
132 } else if (impl_->master_rate > topic_config->GetProto().topic().store_adjust_max_master_rate()) {
133 impl_->master_rate = topic_config->GetProto().topic().store_adjust_max_master_rate();
134 }
135}
136
137void KeepMasterThread::AdjustMasterRate() {
138 comm::RetCode ret;

Callers

nothing calls this directly

Calls 4

GetStoreOptionMethod · 0.80
GetTopicIDMethod · 0.45
GetNodeMethod · 0.45

Tested by

no test coverage detected