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

Method DoRun

phxqueue/lock/keepmasterthread.cpp:77–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77void KeepMasterThread::DoRun() {
78 if (nullptr == impl_->lock || nullptr == impl_->lock->GetNode()) {
79 QLErr("lock %p", impl_->lock);
80
81 return;
82 }
83
84 comm::RetCode ret{InitMasterRate()};
85 if (comm::RetCode::RET_OK != ret) {
86 QLErr("InitMasterRate ret %d", ret);
87
88 exit(-1);
89 }
90
91 const int topic_id{impl_->lock->GetTopicID()};
92 shared_ptr<const config::TopicConfig> topic_config;
93 ret = config::GlobalConfig::GetThreadInstance()->GetTopicConfigByTopicID(topic_id, topic_config);
94 if (comm::RetCode::RET_OK != ret) {
95 QLErr("ERR: GetTopicConfigByTopicID ret %d topic_id %d", ret, topic_id);
96 exit(-1);
97 }
98
99 while (true) {
100 if (impl_->stop) return;
101
102 sleep(topic_config->GetProto().topic().lock_adjust_master_rate_time_interval_s());
103
104 if (comm::RetCode::RET_OK != (ret = UpdatePaxosArgs())) {
105 QLErr("UpdatePaxosArgs ret %d", ret);
106 }
107
108 if (comm::RetCode::RET_OK != (ret = AdjustMasterRate())) {
109 QLErr("AdjustMasterRate ret %d", ret);
110 }
111 if (comm::RetCode::RET_OK != (ret = KeepMaster())) {
112 QLErr("KeepMaster ret %d", ret);
113 }
114 }
115}
116
117comm::RetCode KeepMasterThread::InitMasterRate() {
118 impl_->master_rate = 100;

Callers

nothing calls this directly

Calls 3

GetNodeMethod · 0.45
GetTopicIDMethod · 0.45

Tested by

no test coverage detected