| 155 | } |
| 156 | |
| 157 | int 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 | |
| 177 | bool GroupStatusCache::IsMember(const std::string & ip) { |
| 178 | RWLockManager lock(&membership_mutex_, RWLockManager::READ); |
no test coverage detected