MXS-2546 Add DNS-resolving to topology detection
When matching hostnames between MaxScale server configuration and the SHOW SLAVE STATUS-output, use DNS-resolution if a simple string comparison doesn't find an answer. Results of the resolution are saved to avoid repeating the operation for the same address.
This commit is contained in:
@ -169,6 +169,21 @@ private:
|
||||
bool result_waiting = false; /* Guard variable for has_result */
|
||||
};
|
||||
|
||||
class DNSResolver
|
||||
{
|
||||
public:
|
||||
std::string resolve_server(const std::string& host);
|
||||
|
||||
private:
|
||||
struct MapElement
|
||||
{
|
||||
std::string address;
|
||||
mxb::TimePoint timestamp;
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, MapElement> m_mapping; // hostname -> address cache
|
||||
};
|
||||
|
||||
ManualCommand m_manual_cmd; /* Communicates manual commands and results */
|
||||
|
||||
// Server containers, mostly constant.
|
||||
@ -185,6 +200,8 @@ private:
|
||||
bool m_cluster_modified = false; /* Has a cluster operation been performed this loop? Prevents
|
||||
* other operations during this tick. */
|
||||
|
||||
DNSResolver m_resolver; /* DNS-resolver with cache */
|
||||
|
||||
/* Counter for temporary automatic cluster operation disabling. */
|
||||
int cluster_operation_disable_timer = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user