| 28 | } MasterStatus_t; |
| 29 | |
| 30 | class GroupStatusCache : public PhxThread { |
| 31 | public: |
| 32 | GroupStatusCache(PHXSqlProxyConfig * config, WorkerConfig_t * worker_config); |
| 33 | |
| 34 | virtual ~GroupStatusCache(); |
| 35 | |
| 36 | void run(); |
| 37 | |
| 38 | int GetMaster(std::string & master_ip); |
| 39 | |
| 40 | bool IsMember(const std::string & ip); |
| 41 | |
| 42 | // use by MasterEnableReadPort=0 |
| 43 | |
| 44 | int GetSlave(const std::string & master_ip, std::string & slave_ip); |
| 45 | |
| 46 | void MarkFailure(const std::string & ip); |
| 47 | |
| 48 | private: |
| 49 | int UpdateMasterStatus(); |
| 50 | |
| 51 | int UpdateMembership(); |
| 52 | |
| 53 | bool IsMasterValid(const std::string & master_ip, uint32_t expired_time); |
| 54 | |
| 55 | private: |
| 56 | PHXSqlProxyConfig * config_; |
| 57 | WorkerConfig_t * worker_config_; |
| 58 | |
| 59 | MasterStatus_t master_status_; |
| 60 | pthread_rwlock_t master_mutex_; |
| 61 | |
| 62 | std::vector<std::string> membership_; |
| 63 | std::unordered_map<std::string, uint64_t> last_failure_; // use by MasterEnableReadPort=0 |
| 64 | pthread_rwlock_t membership_mutex_; |
| 65 | }; |
| 66 | |
| 67 | } |
nothing calls this directly
no outgoing calls
no test coverage detected