MXS-2276 Use dynamic servers also for cluster check

Once the monitor has been able to connect to a clustrix node
and obtain the clustrix nodes, it'll primarily use those nodes
when looking for a Clustrix node to be used as the "hub".
With this change it is sufficient (but perhaps unwise) to provide
a single node boostrap node in the configuration file.

Some other rearrangements and renamings of functions has also been
made.
This commit is contained in:
Johan Wikman
2019-01-23 10:07:48 +02:00
parent 0fe5b0bec9
commit 42b3402a71
7 changed files with 404 additions and 238 deletions

View File

@ -17,6 +17,7 @@
#include <sstream>
#include <string>
#include "clustrix.hh"
#include "clustrixmembership.hh"
class ClustrixNode
{
@ -49,9 +50,18 @@ public:
, m_health_check_threshold(health_check_threshold)
, m_nRunning(m_health_check_threshold)
, m_pServer(pServer)
, m_pCon(nullptr)
{
}
~ClustrixNode()
{
if (m_pCon)
{
mysql_close(m_pCon);
}
}
int id() const
{
return m_id;
@ -150,6 +160,25 @@ public:
m_pServer->is_active = false;
}
bool can_be_used_as_hub(const MXS_MONITOR& mon);
SERVER* server() const
{
return m_pServer;
}
MYSQL* connection() const
{
return m_pCon;
}
MYSQL* release_connection()
{
MYSQL* pCon = m_pCon;
m_pCon = nullptr;
return pCon;
}
std::string to_string() const
{
std::stringstream ss;
@ -173,6 +202,7 @@ private:
int m_health_check_threshold { DEFAULT_HEALTH_CHECK_THRESHOLD_VALUE };
int m_nRunning { 0 };
SERVER* m_pServer { nullptr };
MYSQL* m_pCon { nullptr };
};
inline std::ostream& operator << (std::ostream& out, const ClustrixNode& x)