| 75 | } |
| 76 | |
| 77 | void 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 | |
| 117 | comm::RetCode KeepMasterThread::InitMasterRate() { |
| 118 | impl_->master_rate = 100; |
nothing calls this directly
no test coverage detected