| 26 | } |
| 27 | |
| 28 | int PhxSQLClientSvrkitConfig::Read(Comm::CConfig * poConfig, bool isReload) { |
| 29 | ResetEndPoints(); |
| 30 | |
| 31 | std::vector<MySQLEndPoint_t> vecEndPoints; |
| 32 | bool bFound = false; |
| 33 | |
| 34 | int iSetCount = 0; |
| 35 | poConfig->ReadItem("Phxsql", "SetCount", 0, iSetCount); |
| 36 | poConfig->ReadItem("Phxsql", "ConnTimeout", 0, m_iConnTimeout); |
| 37 | poConfig->ReadItem("Phxsql", "ReadTimeout", 0, m_iReadTimeout); |
| 38 | for (int i = 0; i < iSetCount; ++i) { |
| 39 | vecEndPoints.clear(); |
| 40 | |
| 41 | char pcSect[16] = { 0 }; |
| 42 | int iServerCount = 0; |
| 43 | |
| 44 | snprintf(pcSect, sizeof(pcSect), "Server%d", i); |
| 45 | poConfig->ReadItem(pcSect, "ServerCount", 0, iServerCount); |
| 46 | |
| 47 | for (int j = 0; j < iServerCount; ++j) { |
| 48 | MySQLEndPoint_t tEndPoint; |
| 49 | |
| 50 | char pcKey[16] = { 0 }; |
| 51 | |
| 52 | snprintf(pcKey, sizeof(pcKey), "SVR_IP%d", j); |
| 53 | poConfig->ReadItem(pcSect, pcKey, "", tEndPoint.m_sMySQLIP); |
| 54 | |
| 55 | snprintf(pcKey, sizeof(pcKey), "SVR_PORT%d", j); |
| 56 | poConfig->ReadItem(pcSect, pcKey, 0, tEndPoint.m_iPort); |
| 57 | |
| 58 | if (tEndPoint.m_sMySQLIP != "" && tEndPoint.m_iPort) { |
| 59 | vecEndPoints.push_back(tEndPoint); |
| 60 | } |
| 61 | |
| 62 | if (tEndPoint.m_sMySQLIP == LOGID_BASE::GetInnerIP()) { |
| 63 | bFound = true; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | if (bFound) { |
| 68 | SetMySQLEndPoints(vecEndPoints); |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | return phxsql::OK; |
| 73 | } |
| 74 | |
| 75 | const std::vector<MySQLEndPoint_t> & PhxSQLClientSvrkitConfig::GetEndPoints() { |
| 76 | LoadIfModified(); |
nothing calls this directly
no outgoing calls
no test coverage detected