MXS-2275 Fix breakage due to rebasing

This commit is contained in:
Johan Wikman
2019-02-01 09:12:39 +02:00
parent 6d60714a17
commit 55b1e031d6
5 changed files with 29 additions and 19 deletions

View File

@ -156,15 +156,17 @@ bool Clustrix::is_part_of_the_quorum(const char* zName, const SERVER& server, MY
return rv; return rv;
} }
bool Clustrix::ping_or_connect_to_hub(const MXS_MONITORED_SERVER::ConnectionSettings& sett, SERVER& server, bool Clustrix::ping_or_connect_to_hub(const char* zName,
const MXS_MONITORED_SERVER::ConnectionSettings& settings,
SERVER& server,
MYSQL** ppCon) MYSQL** ppCon)
{ {
bool connected = false; bool connected = false;
mxs_connect_result_t rv = mon_ping_or_connect_to_db(sett, server, ppCon); mxs_connect_result_t rv = mon_ping_or_connect_to_db(settings, server, ppCon);
if (mon_connection_is_ok(rv)) if (mon_connection_is_ok(rv))
{ {
if (Clustrix::is_part_of_the_quorum(mon.m_name, server, *ppCon)) if (Clustrix::is_part_of_the_quorum(zName, server, *ppCon))
{ {
connected = true; connected = true;
} }
@ -172,7 +174,7 @@ bool Clustrix::ping_or_connect_to_hub(const MXS_MONITORED_SERVER::ConnectionSett
else else
{ {
MXS_ERROR("%s: Could either not ping or create connection to %s:%d: %s", MXS_ERROR("%s: Could either not ping or create connection to %s:%d: %s",
mon.m_name, server.address, server.port, mysql_error(*ppCon)); zName, server.address, server.port, mysql_error(*ppCon));
} }
return connected; return connected;

View File

@ -70,30 +70,36 @@ inline bool is_part_of_the_quorum(const char* zName, MXS_MONITORED_SERVER& ms)
* Ping or create connection to server and check whether it can be used * Ping or create connection to server and check whether it can be used
* as hub. * as hub.
* *
* @param sett Connection settings * @param zName The name of the Clustrix monitor instance.
* @param server Server object referring to a Clustrix node. * @param settings Connection settings
* @param ppCon Address of pointer to MYSQL object referring to @server * @param server Server object referring to a Clustrix node.
* (@c *ppCon may also be NULL). * @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. * @return True, if the server can be used as hub, false otherwise.
* *
* @note Upon return @c *ppCon will be non-NULL. * @note Upon return @c *ppCon will be non-NULL.
*/ */
bool ping_or_connect_to_hub(const MXS_MONITORED_SERVER::ConnectionSettings& sett, SERVER& server, bool ping_or_connect_to_hub(const char* zName,
const MXS_MONITORED_SERVER::ConnectionSettings& settings,
SERVER& server,
MYSQL** ppCon); MYSQL** ppCon);
/** /**
* Ping or create connection to server and check whether it can be used * Ping or create connection to server and check whether it can be used
* as hub. * as hub.
* *
* @param ms Monitored server object referring to a Clustrix node. * @param zName The name of the Clustrix monitor instance.
* @param sett Connection settings * @param settings Connection settings
* @param ms The monitored server.
*
* @return True, if the server can be used as hub, false otherwise. * @return True, if the server can be used as hub, false otherwise.
*/ */
inline bool ping_or_connect_to_hub(const MXS_MONITORED_SERVER::ConnectionSettings& sett, inline bool ping_or_connect_to_hub(const char* zName,
const MXS_MONITORED_SERVER::ConnectionSettings& settings,
MXS_MONITORED_SERVER& ms) MXS_MONITORED_SERVER& ms)
{ {
return ping_or_connect_to_hub(sett, *ms.server, &ms.con); return ping_or_connect_to_hub(zName, settings, *ms.server, &ms.con);
} }
} }

View File

@ -169,7 +169,7 @@ void ClustrixMonitor::choose_hub()
auto& element = *it; auto& element = *it;
ClustrixNode& node = element.second; ClustrixNode& node = element.second;
if (node.can_be_used_as_hub(m_settings.conn_settings)) if (node.can_be_used_as_hub(m_name, m_settings.conn_settings))
{ {
pHub_con = node.release_connection(); pHub_con = node.release_connection();
pHub_server = node.server(); pHub_server = node.server();
@ -189,7 +189,7 @@ void ClustrixMonitor::choose_hub()
if (ips.find(ms.server->address) == ips.end()) if (ips.find(ms.server->address) == ips.end())
{ {
if (Clustrix::ping_or_connect_to_hub(m_settings.conn_settings, ms)) if (Clustrix::ping_or_connect_to_hub(m_name, m_settings.conn_settings, ms))
{ {
pHub_con = ms.con; pHub_con = ms.con;
pHub_server = ms.server; pHub_server = ms.server;
@ -395,7 +395,7 @@ void ClustrixMonitor::check_hub()
mxb_assert(m_pHub_con); mxb_assert(m_pHub_con);
mxb_assert(m_pHub_server); mxb_assert(m_pHub_server);
if (!Clustrix::ping_or_connect_to_hub(m_settings.conn_settings, *m_pHub_server, &m_pHub_con)) if (!Clustrix::ping_or_connect_to_hub(m_name, m_settings.conn_settings, *m_pHub_server, &m_pHub_con))
{ {
mysql_close(m_pHub_con); mysql_close(m_pHub_con);
m_pHub_con = nullptr; m_pHub_con = nullptr;

View File

@ -14,10 +14,11 @@
#include "clustrixnode.hh" #include "clustrixnode.hh"
#include "clustrix.hh" #include "clustrix.hh"
bool ClustrixNode::can_be_used_as_hub(const MXS_MONITORED_SERVER::ConnectionSettings& sett) bool ClustrixNode::can_be_used_as_hub(const char* zName,
const MXS_MONITORED_SERVER::ConnectionSettings& settings)
{ {
mxb_assert(m_pServer); mxb_assert(m_pServer);
bool rv = Clustrix::ping_or_connect_to_hub(sett, *m_pServer, &m_pCon); bool rv = Clustrix::ping_or_connect_to_hub(zName, settings, *m_pServer, &m_pCon);
if (!rv) if (!rv)
{ {

View File

@ -160,7 +160,8 @@ public:
m_pServer->is_active = false; m_pServer->is_active = false;
} }
bool can_be_used_as_hub(const MXS_MONITORED_SERVER::ConnectionSettings& sett); bool can_be_used_as_hub(const char* zName,
const MXS_MONITORED_SERVER::ConnectionSettings& settings);
SERVER* server() const SERVER* server() const
{ {