MCPcopy Create free account
hub / github.com/Tencent/phxsql / GetSlave

Method GetSlave

phxsqlproxy/group_status_cache.cpp:187–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187int GroupStatusCache::GetSlave(const std::string & master_ip, std::string & slave_ip) {
188 RWLockManager lock(&membership_mutex_, RWLockManager::READ);
189 slave_ip = "";
190 uint64_t t_last_failure = 0;
191 for (auto & itr : membership_) {
192 if (itr != master_ip) {
193 if (slave_ip == "" || last_failure_[itr] < t_last_failure) {
194 slave_ip = itr;
195 t_last_failure = last_failure_[itr];
196 }
197 }
198 }
199 return slave_ip != "" ? 0 : -1;
200}
201
202void GroupStatusCache::MarkFailure(const std::string & ip) {
203 RWLockManager lock(&membership_mutex_, RWLockManager::WRITE);

Callers 1

GetDestEndpointMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected