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

Method GetMaster

phxsqlproxy/group_status_cache.cpp:157–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157int GroupStatusCache::GetMaster(std::string & master_ip) {
158 if (std::string(config_->GetSpecifiedMasterIP()) != "") {
159 master_ip = config_->GetSpecifiedMasterIP();
160 LogVerbose("master is specified to [%s]", master_ip.c_str());
161 return 0;
162 }
163
164 RWLockManager lock(&master_mutex_, RWLockManager::READ);
165
166 if (IsMasterValid(master_status_.master_ip_, master_status_.expired_time_)) {
167 master_ip = master_status_.master_ip_;
168 return 0;
169 }
170
171 MonitorPluginEntry::GetDefault()->GetMonitorPlugin()->CheckMasterInvalid();
172 LogError("get master [%s] expiretime [%u] current [%u]", master_status_.master_ip_.c_str(),
173 master_status_.expired_time_, (uint32_t)time(NULL));
174 return -__LINE__;
175}
176
177bool GroupStatusCache::IsMember(const std::string & ip) {
178 RWLockManager lock(&membership_mutex_, RWLockManager::READ);

Callers 3

UpdateMasterStatusMethod · 0.45
GetDestEndpointMethod · 0.45
CanExecuteMethod · 0.45

Calls 5

LogVerboseFunction · 0.85
LogErrorFunction · 0.85
CheckMasterInvalidMethod · 0.80
GetMonitorPluginMethod · 0.80
GetSpecifiedMasterIPMethod · 0.45

Tested by

no test coverage detected