| 49 | |
| 50 | template <typename Req, typename Resp> |
| 51 | comm::RetCode LockMasterClient<Req, Resp>::GetCandidateAddrs(const Req &req, |
| 52 | std::vector<comm::proto::Addr> &addrs) { |
| 53 | addrs.clear(); |
| 54 | |
| 55 | std::shared_ptr<const config::LockConfig> lock_config; |
| 56 | comm::RetCode ret{config::GlobalConfig::GetThreadInstance()-> |
| 57 | GetLockConfig(req.topic_id(), lock_config)}; |
| 58 | if (comm::RetCode::RET_OK != ret) { |
| 59 | QLErr("GetLockConfig ret %d topic_id %d", as_integer(ret), req.topic_id()); |
| 60 | |
| 61 | return ret; |
| 62 | } |
| 63 | |
| 64 | std::shared_ptr<const config::proto::Lock> lock; |
| 65 | ret = lock_config->GetLockByLockID(req.lock_id(), lock); |
| 66 | if (comm::RetCode::RET_OK != ret) { |
| 67 | QLErr("GetLockByLockID ret %d topic_id %d lock_id %d", |
| 68 | as_integer(ret), req.topic_id(), req.lock_id()); |
| 69 | |
| 70 | return ret; |
| 71 | } |
| 72 | |
| 73 | std::string addrs_str; |
| 74 | for (int i{0}; lock->addrs_size() > i; ++i) { |
| 75 | addrs.push_back(lock->addrs(i)); |
| 76 | addrs_str += lock->addrs(i).ip() + ";"; |
| 77 | } |
| 78 | QLVerb("addrs {%s}", addrs_str.c_str()); |
| 79 | |
| 80 | return comm::RetCode::RET_OK; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | } // namespace lock |
nothing calls this directly
no test coverage detected