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

@ -14,6 +14,8 @@
#include "clustrixmon.hh"
#include <string>
#include <maxscale/monitor.hh>
#include <maxscale/server.hh>
namespace Clustrix
{
@ -37,4 +39,58 @@ enum class SubState
SubState substate_from_string(const std::string& substate);
std::string to_string(SubState sub_state);
/**
* Is a particular Clustrix node part of the quorum.
*
* @param server The server object of a Clustrix node.
* @param pCon Valid MYSQL handle to the server.
*
* @return True, if the node is part of the quorum, false otherwise.
*/
bool is_part_of_the_quorum(const SERVER& server, MYSQL* pCon);
/**
* Is a particular Clustrix node part of the quorum.
*
* @param ms The monitored server object of a Clustrix node.
*
* @return True, if the node is part of the quorum, false otherwise.
*/
inline bool is_part_of_the_quorum(MXS_MONITORED_SERVER& ms)
{
mxb_assert(ms.server);
mxb_assert(ms.con);
return is_part_of_the_quorum(*ms.server, ms.con);
}
/**
* Ping or create connection to server and check whether it can be used
* as hub.
*
* @param mon The monitor.
* @param server Server object referring to a Clustrix node.
* @param ppCon Address of pointer to MYSQL object referring to @server
* (@c *ppCon may also be NULL).
*
* @return True, if the server can be used as hub, false otherwise.
*
* @note Upon return @c *ppCon will be non-NULL.
*/
bool ping_or_connect_to_hub(const MXS_MONITOR& mon, SERVER& server, MYSQL** ppCon);
/**
* Ping or create connection to server and check whether it can be used
* as hub.
*
* @param mon The monitor.
* @param ms Monitored server object referring to a Clustrix node.
*
* @return True, if the server can be used as hub, false otherwise.
*/
inline bool ping_or_connect_to_hub(const MXS_MONITOR& mon, MXS_MONITORED_SERVER& ms)
{
return ping_or_connect_to_hub(mon, *ms.server, &ms.con);
}
}