From 9bc7887728761bcdc4d869abee278eac8cb6113f Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 19 Oct 2020 13:47:30 +0300 Subject: [PATCH] MXS-3239 Rename [c|C]clustrix names to [x|X]pand names --- server/modules/monitor/xpandmon/xpand.cc | 42 ++-- server/modules/monitor/xpandmon/xpand.hh | 22 +- .../monitor/xpandmon/xpandmembership.hh | 28 +-- server/modules/monitor/xpandmon/xpandmon.cc | 12 +- .../modules/monitor/xpandmon/xpandmonitor.cc | 228 +++++++++--------- .../modules/monitor/xpandmon/xpandmonitor.hh | 54 ++--- server/modules/monitor/xpandmon/xpandnode.cc | 8 +- server/modules/monitor/xpandmon/xpandnode.hh | 56 ++--- 8 files changed, 225 insertions(+), 225 deletions(-) diff --git a/server/modules/monitor/xpandmon/xpand.cc b/server/modules/monitor/xpandmon/xpand.cc index 9d4cffe7b..0e9f61e38 100644 --- a/server/modules/monitor/xpandmon/xpand.cc +++ b/server/modules/monitor/xpandmon/xpand.cc @@ -27,7 +27,7 @@ const char CN_STATIC[] = "static"; const char CN_UNKNOWN[] = "unknown"; } -std::string Clustrix::to_string(Clustrix::Status status) +std::string xpand::to_string(xpand::Status status) { switch (status) { @@ -48,7 +48,7 @@ std::string Clustrix::to_string(Clustrix::Status status) return CN_UNKNOWN; } -Clustrix::Status Clustrix::status_from_string(const std::string& status) +xpand::Status xpand::status_from_string(const std::string& status) { if (status == CN_QUORUM) { @@ -64,12 +64,12 @@ Clustrix::Status Clustrix::status_from_string(const std::string& status) } else { - MXB_WARNING("'%s' is an unknown status for a Clustrix node.", status.c_str()); + MXB_WARNING("'%s' is an unknown status for a Xpand node.", status.c_str()); return Status::UNKNOWN; } } -std::string Clustrix::to_string(Clustrix::SubState substate) +std::string xpand::to_string(xpand::SubState substate) { switch (substate) { @@ -84,7 +84,7 @@ std::string Clustrix::to_string(Clustrix::SubState substate) return CN_UNKNOWN; } -Clustrix::SubState Clustrix::substate_from_string(const std::string& substate) +xpand::SubState xpand::substate_from_string(const std::string& substate) { if (substate == CN_NORMAL) { @@ -92,12 +92,12 @@ Clustrix::SubState Clustrix::substate_from_string(const std::string& substate) } else { - MXB_WARNING("'%s' is an unknown sub-state for a Clustrix node.", substate.c_str()); + MXB_WARNING("'%s' is an unknown sub-state for a Xpand node.", substate.c_str()); return SubState::UNKNOWN; } } -bool Clustrix::is_part_of_the_quorum(const char* zName, MYSQL* pCon) +bool xpand::is_part_of_the_quorum(const char* zName, MYSQL* pCon) { bool rv = false; @@ -114,27 +114,27 @@ bool Clustrix::is_part_of_the_quorum(const char* zName, MYSQL* pCon) MYSQL_ROW row = mysql_fetch_row(pResult); if (row && row[0]) { - Clustrix::Status status = Clustrix::status_from_string(row[0]); + xpand::Status status = xpand::status_from_string(row[0]); switch (status) { - case Clustrix::Status::QUORUM: + case xpand::Status::QUORUM: rv = true; break; - case Clustrix::Status::STATIC: + case xpand::Status::STATIC: MXS_NOTICE("%s: Node %s is not part of the quorum (static), switching to " "other node for monitoring.", zName, mysql_get_host_info(pCon)); break; - case Clustrix::Status::DYNAMIC: + case xpand::Status::DYNAMIC: MXS_NOTICE("%s: Node %s is not part of the quorum (dynamic), switching to " "other node for monitoring.", zName, mysql_get_host_info(pCon)); break; - case Clustrix::Status::UNKNOWN: + case xpand::Status::UNKNOWN: MXS_WARNING("%s: Do not know how to interpret '%s'. Assuming node %s " "is not part of the quorum.", zName, row[0], mysql_get_host_info(pCon)); @@ -163,7 +163,7 @@ bool Clustrix::is_part_of_the_quorum(const char* zName, MYSQL* pCon) return rv; } -bool Clustrix::is_being_softfailed(const char* zName, MYSQL* pCon) +bool xpand::is_being_softfailed(const char* zName, MYSQL* pCon) { bool rv = false; @@ -201,22 +201,22 @@ bool Clustrix::is_being_softfailed(const char* zName, MYSQL* pCon) return rv; } -bool Clustrix::ping_or_connect_to_hub(const char* zName, - const MonitorServer::ConnectionSettings& settings, - Softfailed softfailed, - SERVER& server, - MYSQL** ppCon) +bool xpand::ping_or_connect_to_hub(const char* zName, + const MonitorServer::ConnectionSettings& settings, + Softfailed softfailed, + SERVER& server, + MYSQL** ppCon) { bool connected = false; MonitorServer::ConnectResult rv = Monitor::ping_or_connect_to_db(settings, server, ppCon); if (Monitor::connection_is_ok(rv)) { - if (Clustrix::is_part_of_the_quorum(zName, *ppCon)) + if (xpand::is_part_of_the_quorum(zName, *ppCon)) { - if ((softfailed == Softfailed::REJECT) && Clustrix::is_being_softfailed(zName, *ppCon)) + if ((softfailed == Softfailed::REJECT) && xpand::is_being_softfailed(zName, *ppCon)) { - MXS_NOTICE("%s: The Clustrix node %s used as hub is part of the quorum, " + MXS_NOTICE("%s: The Xpand node %s used as hub is part of the quorum, " "but it is being softfailed. Switching to another node.", zName, server.address); } diff --git a/server/modules/monitor/xpandmon/xpand.hh b/server/modules/monitor/xpandmon/xpand.hh index 1aa859457..59387c8c8 100644 --- a/server/modules/monitor/xpandmon/xpand.hh +++ b/server/modules/monitor/xpandmon/xpand.hh @@ -17,7 +17,7 @@ #include #include -namespace Clustrix +namespace xpand { enum class Status @@ -47,9 +47,9 @@ enum class Softfailed }; /** - * Is a particular Clustrix node part of the quorum. + * Is a particular Xpand node part of the quorum. * - * @param zName The name of the Clustrix monitor instance. + * @param zName The name of the Xpand monitor instance. * @param pCon Valid MYSQL handle to the server. * * @return True, if the node is part of the quorum, false otherwise. @@ -57,10 +57,10 @@ enum class Softfailed bool is_part_of_the_quorum(const char* zName, MYSQL* pCon); /** - * Is a particular Clustrix node part of the quorum. + * Is a particular Xpand node part of the quorum. * - * @param zName The name of the Clustrix monitor instance. - * @param ms The monitored server object of a Clustrix node. + * @param zName The name of the Xpand monitor instance. + * @param ms The monitored server object of a Xpand node. * * @return True, if the node is part of the quorum, false otherwise. */ @@ -72,9 +72,9 @@ inline bool is_part_of_the_quorum(const char* zName, mxs::MonitorServer& ms) } /** - * Is a particular Clustrix node being softfailed. + * Is a particular Xpand node being softfailed. * - * @param zName The name of the Clustrix monitor instance. + * @param zName The name of the Xpand monitor instance. * @param pCon Valid MYSQL handle to the server. * * @return True, if the node is being softfailed, false otherwise. @@ -85,10 +85,10 @@ bool is_being_softfailed(const char* zName, MYSQL* pCon); * Ping or create connection to server and check whether it can be used * as hub. * - * @param zName The name of the Clustrix monitor instance. + * @param zName The name of the Xpand monitor instance. * @param settings Connection settings * @param softfailed Whether a softfailed node is considered ok or not. - * @param server Server object referring to a Clustrix node. + * @param server Server object referring to a Xpand node. * @param ppCon Address of pointer to MYSQL object referring to @server * (@c *ppCon may also be NULL). * @@ -106,7 +106,7 @@ bool ping_or_connect_to_hub(const char* zName, * Ping or create connection to server and check whether it can be used * as hub. * - * @param zName The name of the Clustrix monitor instance. + * @param zName The name of the Xpand monitor instance. * @param settings Connection settings * @param softfailed Whether a softfailed node is considered ok or not. * @param ms The monitored server. diff --git a/server/modules/monitor/xpandmon/xpandmembership.hh b/server/modules/monitor/xpandmon/xpandmembership.hh index b18d818cf..d1a7866c5 100644 --- a/server/modules/monitor/xpandmon/xpandmembership.hh +++ b/server/modules/monitor/xpandmon/xpandmembership.hh @@ -18,13 +18,13 @@ #include #include "xpand.hh" -class ClustrixMembership +class XpandMembership { public: - ClustrixMembership(int id, - Clustrix::Status status, - Clustrix::SubState substate, - int instance) + XpandMembership(int id, + xpand::Status status, + xpand::SubState substate, + int instance) : m_id(id) , m_status(status) , m_substate(substate) @@ -37,12 +37,12 @@ public: return m_id; } - Clustrix::Status status() const + xpand::Status status() const { return m_status; } - Clustrix::SubState substate() const + xpand::SubState substate() const { return m_substate; } @@ -57,8 +57,8 @@ public: std::stringstream ss; ss << "{" << m_id << ", " - << Clustrix::to_string(m_status) << ", " - << Clustrix::to_string(m_substate) << ", " + << xpand::to_string(m_status) << ", " + << xpand::to_string(m_substate) << ", " << m_instance << "}"; return ss.str(); @@ -70,13 +70,13 @@ public: } private: - int m_id; - Clustrix::Status m_status; - Clustrix::SubState m_substate; - int m_instance; + int m_id; + xpand::Status m_status; + xpand::SubState m_substate; + int m_instance; }; -inline std::ostream& operator<<(std::ostream& out, const ClustrixMembership& x) +inline std::ostream& operator<<(std::ostream& out, const XpandMembership& x) { x.print(out); return out; diff --git a/server/modules/monitor/xpandmon/xpandmon.cc b/server/modules/monitor/xpandmon/xpandmon.cc index 51e12def2..e759f4b60 100644 --- a/server/modules/monitor/xpandmon/xpandmon.cc +++ b/server/modules/monitor/xpandmon/xpandmon.cc @@ -25,7 +25,7 @@ bool handle_softfail(const MODULECMD_ARG* args, json_t** error_out) mxb_assert(MODULECMD_GET_TYPE(&args->argv[0].type) == MODULECMD_ARG_MONITOR); mxb_assert(MODULECMD_GET_TYPE(&args->argv[1].type) == MODULECMD_ARG_SERVER); - ClustrixMonitor* pMon = static_cast(args->argv[0].value.monitor); + XpandMonitor* pMon = static_cast(args->argv[0].value.monitor); SERVER* pServer = args->argv[1].value.server; return pMon->softfail(pServer, error_out); @@ -37,7 +37,7 @@ bool handle_unsoftfail(const MODULECMD_ARG* args, json_t** error_out) mxb_assert(MODULECMD_GET_TYPE(&args->argv[0].type) == MODULECMD_ARG_MONITOR); mxb_assert(MODULECMD_GET_TYPE(&args->argv[1].type) == MODULECMD_ARG_SERVER); - ClustrixMonitor* pMon = static_cast(args->argv[0].value.monitor); + XpandMonitor* pMon = static_cast(args->argv[0].value.monitor); SERVER* pServer = args->argv[1].value.server; return pMon->unsoftfail(pServer, error_out); @@ -54,7 +54,7 @@ bool handle_unsoftfail(const MODULECMD_ARG* args, json_t** error_out) */ extern "C" MXS_MODULE* MXS_CREATE_MODULE() { - MXS_NOTICE("Initialise the MariaDB Clustrix Monitor module."); + MXS_NOTICE("Initialise the MariaDB Xpand Monitor module."); static modulecmd_arg_type_t softfail_argv[] = { @@ -91,17 +91,17 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() MXS_MODULE_API_MONITOR, MXS_MODULE_GA, MXS_MONITOR_VERSION, - "A Clustrix cluster monitor", + "A Xpand cluster monitor", "V1.0.0", MXS_NO_MODULE_CAPABILITIES, - &maxscale::MonitorApi::s_api, + &maxscale::MonitorApi::s_api, NULL, /* Process init. */ NULL, /* Process finish. */ NULL, /* Thread init. */ NULL, /* Thread finish. */ }; - ClustrixMonitor::Config::populate(info); + XpandMonitor::Config::populate(info); return &info; } diff --git a/server/modules/monitor/xpandmon/xpandmonitor.cc b/server/modules/monitor/xpandmon/xpandmonitor.cc index 495587e5a..90a9ecc09 100644 --- a/server/modules/monitor/xpandmon/xpandmonitor.cc +++ b/server/modules/monitor/xpandmon/xpandmonitor.cc @@ -26,19 +26,19 @@ namespace http = mxb::http; using namespace std; using maxscale::MonitorServer; -#define LOG_JSON_ERROR(ppJson, format, ...) \ - do { \ - MXS_ERROR(format, ##__VA_ARGS__); \ - if (ppJson) \ - { \ +#define LOG_JSON_ERROR(ppJson, format, ...) \ + do { \ + MXS_ERROR(format, ##__VA_ARGS__); \ + if (ppJson) \ + { \ *ppJson = mxs_json_error_append(*ppJson, format, ##__VA_ARGS__); \ - } \ + } \ } while (false) namespace { -namespace clustrixmon +namespace xpandmon { config::Specification specification(MXS_MODULE_NAME, config::Specification::MONITOR); @@ -46,7 +46,7 @@ config::Specification specification(MXS_MODULE_NAME, config::Specification::MONI config::ParamDuration cluster_monitor_interval(&specification, "cluster_monitor_interval", - "How frequently the Clustrix monitor should perform a cluster check.", + "How frequently the Xpand monitor should perform a cluster check.", mxs::config::INTERPRET_AS_MILLISECONDS, std::chrono::milliseconds(DEFAULT_CLUSTER_MONITOR_INTERVAL)); @@ -66,7 +66,7 @@ dynamic_node_detection(&specification, config::ParamInteger health_check_port(&specification, "health_check_port", - "Port number for Clustrix health check.", + "Port number for Xpand health check.", DEFAULT_HEALTH_CHECK_PORT, 0, std::numeric_limits::max()); // min, max @@ -186,7 +186,7 @@ sqlite3* open_or_create_db(const std::string& path) path.c_str(), sqlite3_errmsg(pDb)); } MXS_ERROR("Could not open sqlite3 database for storing information " - "about dynamically detected Clustrix nodes. The Clustrix " + "about dynamically detected Xpand nodes. The Xpand " "monitor will remain dependent upon statically defined " "bootstrap nodes."); } @@ -195,40 +195,40 @@ sqlite3* open_or_create_db(const std::string& path) } } -ClustrixMonitor::Config::Config(const std::string& name) - : m_configuration(name, &clustrixmon::specification) - , m_cluster_monitor_interval(&m_configuration, &clustrixmon::cluster_monitor_interval) - , m_health_check_threshold(&m_configuration, &clustrixmon::health_check_threshold) - , m_dynamic_node_detection(&m_configuration, &clustrixmon::dynamic_node_detection) - , m_health_check_port(&m_configuration, &clustrixmon::health_check_port) +XpandMonitor::Config::Config(const std::string& name) + : m_configuration(name, &xpandmon::specification) + , m_cluster_monitor_interval(&m_configuration, &xpandmon::cluster_monitor_interval) + , m_health_check_threshold(&m_configuration, &xpandmon::health_check_threshold) + , m_dynamic_node_detection(&m_configuration, &xpandmon::dynamic_node_detection) + , m_health_check_port(&m_configuration, &xpandmon::health_check_port) { } //static -void ClustrixMonitor::Config::populate(MXS_MODULE& module) +void XpandMonitor::Config::populate(MXS_MODULE& module) { - clustrixmon::specification.populate(module); + xpandmon::specification.populate(module); } -bool ClustrixMonitor::Config::configure(const MXS_CONFIG_PARAMETER& params) +bool XpandMonitor::Config::configure(const MXS_CONFIG_PARAMETER& params) { - return clustrixmon::specification.configure(m_configuration, params); + return xpandmon::specification.configure(m_configuration, params); } -ClustrixMonitor::ClustrixMonitor(const string& name, const string& module, sqlite3* pDb) +XpandMonitor::XpandMonitor(const string& name, const string& module, sqlite3* pDb) : MonitorWorker(name, module) , m_config(name) , m_pDb(pDb) { } -ClustrixMonitor::~ClustrixMonitor() +XpandMonitor::~XpandMonitor() { sqlite3_close_v2(m_pDb); } // static -ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& module) +XpandMonitor* XpandMonitor::create(const string& name, const string& module) { string path = get_datadir(); @@ -239,29 +239,29 @@ ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& modul { MXS_ERROR("Could not create the directory %s, MaxScale will not be " "able to create database for persisting connection " - "information of dynamically detected Clustrix nodes.", + "information of dynamically detected Xpand nodes.", path.c_str()); } - path += "/clustrix_nodes-v"; + path += "/xpand_nodes-v"; path += std::to_string(SCHEMA_VERSION); path += ".db"; sqlite3* pDb = open_or_create_db(path); - ClustrixMonitor* pThis = nullptr; + XpandMonitor* pThis = nullptr; if (pDb) { // Even if the creation/opening of the sqlite3 database fails, we will still // get a valid database handle. - pThis = new ClustrixMonitor(name, module, pDb); + pThis = new XpandMonitor(name, module, pDb); } else { // The handle will be null, *only* if the opening fails due to a memory // allocation error. - MXS_ALERT("sqlite3 memory allocation failed, the Clustrix monitor " + MXS_ALERT("sqlite3 memory allocation failed, the Xpand monitor " "cannot continue."); } @@ -270,9 +270,9 @@ ClustrixMonitor* ClustrixMonitor::create(const string& name, const string& modul using std::chrono::milliseconds; -bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams) +bool XpandMonitor::configure(const MXS_CONFIG_PARAMETER* pParams) { - if (!clustrixmon::specification.validate(*pParams)) + if (!xpandmon::specification.validate(*pParams)) { return false; } @@ -294,25 +294,25 @@ bool ClustrixMonitor::configure(const MXS_CONFIG_PARAMETER* pParams) return true; } -void ClustrixMonitor::populate_services() +void XpandMonitor::populate_services() { mxb_assert(!is_running()); - // The servers that the Clustrix monitor has been configured with are + // The servers that the Xpand monitor has been configured with are // only used for bootstrapping and services will not be populated // with them. } -bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError) +bool XpandMonitor::softfail(SERVER* pServer, json_t** ppError) { bool rv = false; if (is_running()) { call([this, pServer, ppError, &rv]() { - rv = perform_softfail(pServer, ppError); - }, - EXECUTE_QUEUED); + rv = perform_softfail(pServer, ppError); + }, + EXECUTE_QUEUED); } else { @@ -325,16 +325,16 @@ bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError) return true; } -bool ClustrixMonitor::unsoftfail(SERVER* pServer, json_t** ppError) +bool XpandMonitor::unsoftfail(SERVER* pServer, json_t** ppError) { bool rv = false; if (is_running()) { call([this, pServer, ppError, &rv]() { - rv = perform_unsoftfail(pServer, ppError); - }, - EXECUTE_QUEUED); + rv = perform_unsoftfail(pServer, ppError); + }, + EXECUTE_QUEUED); } else { @@ -347,26 +347,26 @@ bool ClustrixMonitor::unsoftfail(SERVER* pServer, json_t** ppError) return true; } -void ClustrixMonitor::server_added(SERVER* pServer) +void XpandMonitor::server_added(SERVER* pServer) { // The servers explicitly added to the Cluster monitor are only used // as bootstrap servers, so they are not added to any services. } -void ClustrixMonitor::server_removed(SERVER* pServer) +void XpandMonitor::server_removed(SERVER* pServer) { // @see server_added(), no action is needed. } -void ClustrixMonitor::pre_loop() +void XpandMonitor::pre_loop() { load_server_journal(nullptr); if (m_config.dynamic_node_detection()) { // At startup we accept softfailed nodes in an attempt to be able to // connect at any cost. It'll be replaced once there is an alternative. - check_cluster(Clustrix::Softfailed::ACCEPT); + check_cluster(xpand::Softfailed::ACCEPT); } else { @@ -376,7 +376,7 @@ void ClustrixMonitor::pre_loop() make_health_check(); } -void ClustrixMonitor::post_loop() +void XpandMonitor::post_loop() { if (m_pHub_con) { @@ -387,12 +387,12 @@ void ClustrixMonitor::post_loop() m_pHub_server = nullptr; } -void ClustrixMonitor::tick() +void XpandMonitor::tick() { check_maintenance_requests(); if (m_config.dynamic_node_detection() && should_check_cluster()) { - check_cluster(Clustrix::Softfailed::REJECT); + check_cluster(xpand::Softfailed::REJECT); } switch (m_http.status()) @@ -418,7 +418,7 @@ void ClustrixMonitor::tick() store_server_journal(nullptr); } -void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed) +void XpandMonitor::choose_hub(xpand::Softfailed softfailed) { mxb_assert(!m_pHub_con); @@ -443,7 +443,7 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed) if (m_pHub_con) { - MXS_NOTICE("%s: Monitoring Clustrix cluster state using node %s:%d.", + MXS_NOTICE("%s: Monitoring Xpand cluster state using node %s:%d.", name(), m_pHub_server->address, m_pHub_server->port); } else @@ -453,11 +453,11 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed) } } -bool ClustrixMonitor::choose_dynamic_hub(Clustrix::Softfailed softfailed, std::set& ips_checked) +bool XpandMonitor::choose_dynamic_hub(xpand::Softfailed softfailed, std::set& ips_checked) { for (auto& kv : m_nodes_by_id) { - ClustrixNode& node = kv.second; + XpandNode& node = kv.second; if (node.can_be_used_as_hub(name(), settings().conn_settings, softfailed)) { @@ -476,13 +476,13 @@ bool ClustrixMonitor::choose_dynamic_hub(Clustrix::Softfailed softfailed, std::s return m_pHub_con != nullptr; } -bool ClustrixMonitor::choose_bootstrap_hub(Clustrix::Softfailed softfailed, std::set& ips_checked) +bool XpandMonitor::choose_bootstrap_hub(xpand::Softfailed softfailed, std::set& ips_checked) { for (auto* pMs : servers()) { if (ips_checked.find(pMs->server->address) == ips_checked.end()) { - if (Clustrix::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed, *pMs)) + if (xpand::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed, *pMs)) { m_pHub_con = pMs->con; m_pHub_server = pMs->server; @@ -504,9 +504,9 @@ bool ClustrixMonitor::choose_bootstrap_hub(Clustrix::Softfailed softfailed, std: return m_pHub_con != nullptr; } -bool ClustrixMonitor::refresh_using_persisted_nodes(std::set& ips_checked) +bool XpandMonitor::refresh_using_persisted_nodes(std::set& ips_checked) { - MXS_NOTICE("Attempting to find a Clustrix bootstrap node from one of the nodes " + MXS_NOTICE("Attempting to find a Xpand bootstrap node from one of the nodes " "used during the previous run of MaxScale."); bool refreshed = false; @@ -543,7 +543,7 @@ bool ClustrixMonitor::refresh_using_persisted_nodes(std::set& ips_checke nullptr, port, nullptr, 0)) { - if (Clustrix::is_part_of_the_quorum(name(), pHub_con)) + if (xpand::is_part_of_the_quorum(name(), pHub_con)) { if (refresh_nodes(pHub_con)) { @@ -577,18 +577,18 @@ bool ClustrixMonitor::refresh_using_persisted_nodes(std::set& ips_checke return refreshed; } -bool ClustrixMonitor::refresh_nodes() +bool XpandMonitor::refresh_nodes() { mxb_assert(m_pHub_con); return refresh_nodes(m_pHub_con); } -bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) +bool XpandMonitor::refresh_nodes(MYSQL* pHub_con) { mxb_assert(pHub_con); - map memberships; + map memberships; bool refreshed = check_cluster_membership(pHub_con, &memberships); @@ -610,7 +610,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) set nids; for (const auto& kv : m_nodes_by_id) { - const ClustrixNode& node = kv.second; + const XpandNode& node = kv.second; nids.insert(node.id()); } @@ -626,7 +626,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) bool softfailed = row[4] ? true : false; // '@@' ensures no clash with user created servers. - // Monitor name ensures no clash with other Clustrix monitor instances. + // Monitor name ensures no clash with other Xpand monitor instances. string server_name = string("@@") + m_name + ":node-" + std::to_string(id); auto nit = m_nodes_by_id.find(id); @@ -637,7 +637,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) // Existing node. mxb_assert(SERVER::find_by_unique_name(server_name)); - ClustrixNode& node = nit->second; + XpandNode& node = nit->second; node.update(ip, mysql_port, health_port); @@ -684,11 +684,11 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) pServer->set_status(SERVER_DRAINING); } - const ClustrixMembership& membership = mit->second; + const XpandMembership& membership = mit->second; int health_check_threshold = m_config.health_check_threshold(); - ClustrixNode node(this, membership, ip, mysql_port, health_port, - health_check_threshold, pServer); + XpandNode node(this, membership, ip, mysql_port, health_port, + health_check_threshold, pServer); m_nodes_by_id.insert(make_pair(id, node)); @@ -735,8 +735,8 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) auto it = m_nodes_by_id.find(nid); mxb_assert(it != m_nodes_by_id.end()); - ClustrixNode& node = it->second; - node.set_running(false, ClustrixNode::APPROACH_OVERRIDE); + XpandNode& node = it->second; + node.set_running(false, XpandNode::APPROACH_OVERRIDE); } cluster_checked(); @@ -762,7 +762,7 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) return refreshed; } -void ClustrixMonitor::check_bootstrap_servers() +void XpandMonitor::check_bootstrap_servers() { HostPortPairs nodes; char* pError = nullptr; @@ -813,7 +813,7 @@ void ClustrixMonitor::check_bootstrap_servers() } } -bool ClustrixMonitor::remove_persisted_information() +bool XpandMonitor::remove_persisted_information() { char* pError = nullptr; int rv; @@ -833,7 +833,7 @@ bool ClustrixMonitor::remove_persisted_information() return rv1 == SQLITE_OK && rv2 == SQLITE_OK; } -void ClustrixMonitor::persist_bootstrap_servers() +void XpandMonitor::persist_bootstrap_servers() { string values; @@ -871,7 +871,7 @@ void ClustrixMonitor::persist_bootstrap_servers() } } -void ClustrixMonitor::check_cluster(Clustrix::Softfailed softfailed) +void XpandMonitor::check_cluster(xpand::Softfailed softfailed) { if (m_pHub_con) { @@ -889,21 +889,21 @@ void ClustrixMonitor::check_cluster(Clustrix::Softfailed softfailed) } } -void ClustrixMonitor::check_hub(Clustrix::Softfailed softfailed) +void XpandMonitor::check_hub(xpand::Softfailed softfailed) { mxb_assert(m_pHub_con); mxb_assert(m_pHub_server); - if (!Clustrix::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed, - *m_pHub_server, &m_pHub_con)) + if (!xpand::ping_or_connect_to_hub(name(), settings().conn_settings, softfailed, + *m_pHub_server, &m_pHub_con)) { mysql_close(m_pHub_con); m_pHub_con = nullptr; } } -bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con, - std::map* pMemberships) +bool XpandMonitor::check_cluster_membership(MYSQL* pHub_con, + std::map* pMemberships) { mxb_assert(pHub_con); mxb_assert(pMemberships); @@ -923,7 +923,7 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con, set nids; for (const auto& kv : m_nodes_by_id) { - const ClustrixNode& node = kv.second; + const XpandNode& node = kv.second; nids.insert(node.id()); } @@ -941,20 +941,20 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con, if (it != m_nodes_by_id.end()) { - ClustrixNode& node = it->second; + XpandNode& node = it->second; - node.update(Clustrix::status_from_string(status), - Clustrix::substate_from_string(substate), + node.update(xpand::status_from_string(status), + xpand::substate_from_string(substate), instance); nids.erase(node.id()); } else { - ClustrixMembership membership(nid, - Clustrix::status_from_string(status), - Clustrix::substate_from_string(substate), - instance); + XpandMembership membership(nid, + xpand::status_from_string(status), + xpand::substate_from_string(substate), + instance); pMemberships->insert(make_pair(nid, membership)); } @@ -974,7 +974,7 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con, auto it = m_nodes_by_id.find(nid); mxb_assert(it != m_nodes_by_id.end()); - ClustrixNode& node = it->second; + XpandNode& node = it->second; node.deactivate_server(); m_nodes_by_id.erase(it); } @@ -995,7 +995,7 @@ bool ClustrixMonitor::check_cluster_membership(MYSQL* pHub_con, return rv; } -void ClustrixMonitor::populate_from_bootstrap_servers() +void XpandMonitor::populate_from_bootstrap_servers() { int id = 1; @@ -1003,17 +1003,17 @@ void ClustrixMonitor::populate_from_bootstrap_servers() { SERVER* pServer = ms->server; - Clustrix::Status status = Clustrix::Status::UNKNOWN; - Clustrix::SubState substate = Clustrix::SubState::UNKNOWN; + xpand::Status status = xpand::Status::UNKNOWN; + xpand::SubState substate = xpand::SubState::UNKNOWN; int instance = 1; - ClustrixMembership membership(id, status, substate, instance); + XpandMembership membership(id, status, substate, instance); std::string ip = pServer->address; int mysql_port = pServer->port; int health_port = m_config.health_check_port(); int health_check_threshold = m_config.health_check_threshold(); - ClustrixNode node(this, membership, ip, mysql_port, health_port, health_check_threshold, pServer); + XpandNode node(this, membership, ip, mysql_port, health_port, health_check_threshold, pServer); m_nodes_by_id.insert(make_pair(id, node)); ++id; @@ -1026,7 +1026,7 @@ void ClustrixMonitor::populate_from_bootstrap_servers() update_http_urls(); } -void ClustrixMonitor::update_server_statuses() +void XpandMonitor::update_server_statuses() { mxb_assert(!servers().empty()); @@ -1035,14 +1035,14 @@ void ClustrixMonitor::update_server_statuses() pMs->stash_current_status(); auto it = find_if(m_nodes_by_id.begin(), m_nodes_by_id.end(), - [pMs](const std::pair& element) -> bool { - const ClustrixNode& info = element.second; + [pMs](const std::pair& element) -> bool { + const XpandNode& info = element.second; return pMs->server->address == info.ip(); }); if (it != m_nodes_by_id.end()) { - const ClustrixNode& info = it->second; + const XpandNode& info = it->second; if (info.is_running()) { @@ -1060,7 +1060,7 @@ void ClustrixMonitor::update_server_statuses() } } -void ClustrixMonitor::make_health_check() +void XpandMonitor::make_health_check() { mxb_assert(m_http.status() != http::Async::PENDING); @@ -1082,7 +1082,7 @@ void ClustrixMonitor::make_health_check() } } -void ClustrixMonitor::initiate_delayed_http_check() +void XpandMonitor::initiate_delayed_http_check() { mxb_assert(m_delayed_http_check_id == 0); @@ -1095,10 +1095,10 @@ void ClustrixMonitor::initiate_delayed_http_check() ms = max_delay_ms; } - m_delayed_http_check_id = delayed_call(ms, &ClustrixMonitor::check_http, this); + m_delayed_http_check_id = delayed_call(ms, &XpandMonitor::check_http, this); } -bool ClustrixMonitor::check_http(Call::action_t action) +bool XpandMonitor::check_http(Call::action_t action) { m_delayed_http_check_id = 0; @@ -1124,7 +1124,7 @@ bool ClustrixMonitor::check_http(Call::action_t action) { bool running = (result.code == 200); // HTTP OK - ClustrixNode& node = it->second; + XpandNode& node = it->second; node.set_running(running); @@ -1153,12 +1153,12 @@ bool ClustrixMonitor::check_http(Call::action_t action) return false; } -void ClustrixMonitor::update_http_urls() +void XpandMonitor::update_http_urls() { vector health_urls; for (const auto& kv : m_nodes_by_id) { - const ClustrixNode& node = kv.second; + const XpandNode& node = kv.second; string url = "http://" + node.ip() + ":" + std::to_string(node.health_port()); health_urls.push_back(url); @@ -1178,7 +1178,7 @@ void ClustrixMonitor::update_http_urls() } } -bool ClustrixMonitor::perform_softfail(SERVER* pServer, json_t** ppError) +bool XpandMonitor::perform_softfail(SERVER* pServer, json_t** ppError) { bool rv = perform_operation(Operation::SOFTFAIL, pServer, ppError); @@ -1189,14 +1189,14 @@ bool ClustrixMonitor::perform_softfail(SERVER* pServer, json_t** ppError) return rv; } -bool ClustrixMonitor::perform_unsoftfail(SERVER* pServer, json_t** ppError) +bool XpandMonitor::perform_unsoftfail(SERVER* pServer, json_t** ppError) { return perform_operation(Operation::UNSOFTFAIL, pServer, ppError); } -bool ClustrixMonitor::perform_operation(Operation operation, - SERVER* pServer, - json_t** ppError) +bool XpandMonitor::perform_operation(Operation operation, + SERVER* pServer, + json_t** ppError) { bool performed = false; @@ -1207,19 +1207,19 @@ bool ClustrixMonitor::perform_operation(Operation operation, if (!m_pHub_con) { - check_cluster(Clustrix::Softfailed::ACCEPT); + check_cluster(xpand::Softfailed::ACCEPT); } if (m_pHub_con) { auto it = find_if(m_nodes_by_id.begin(), m_nodes_by_id.end(), - [pServer](const std::pair& element) { + [pServer](const std::pair& element) { return element.second.server() == pServer; }); if (it != m_nodes_by_id.end()) { - ClustrixNode& node = it->second; + XpandNode& node = it->second; const char ZQUERY_FORMAT[] = "ALTER CLUSTER %s %d"; @@ -1267,7 +1267,7 @@ bool ClustrixMonitor::perform_operation(Operation operation, else { LOG_JSON_ERROR(ppError, - "%s: Could not could not connect to any Clustrix node, " + "%s: Could not could not connect to any Xpand node, " "cannot perform %s of %s.", name(), zOperation, pServer->address); } @@ -1275,7 +1275,7 @@ bool ClustrixMonitor::perform_operation(Operation operation, return performed; } -void ClustrixMonitor::persist(const ClustrixNode& node) +void XpandMonitor::persist(const XpandNode& node) { if (!m_pDb) { @@ -1294,7 +1294,7 @@ void ClustrixMonitor::persist(const ClustrixNode& node) char* pError = nullptr; if (sqlite3_exec(m_pDb, sql_upsert, nullptr, nullptr, &pError) == SQLITE_OK) { - MXS_INFO("Updated Clustrix node in bookkeeping: %d, '%s', %d, %d.", + MXS_INFO("Updated Xpand node in bookkeeping: %d, '%s', %d, %d.", id, zIp, mysql_port, health_port); } else @@ -1304,7 +1304,7 @@ void ClustrixMonitor::persist(const ClustrixNode& node) } } -void ClustrixMonitor::unpersist(const ClustrixNode& node) +void XpandMonitor::unpersist(const XpandNode& node) { if (!m_pDb) { @@ -1320,7 +1320,7 @@ void ClustrixMonitor::unpersist(const ClustrixNode& node) char* pError = nullptr; if (sqlite3_exec(m_pDb, sql_delete, nullptr, nullptr, &pError) == SQLITE_OK) { - MXS_INFO("Deleted Clustrix node %d from bookkeeping.", id); + MXS_INFO("Deleted Xpand node %d from bookkeeping.", id); } else { diff --git a/server/modules/monitor/xpandmon/xpandmonitor.hh b/server/modules/monitor/xpandmon/xpandmonitor.hh index d3c7a2e48..43c9838fb 100644 --- a/server/modules/monitor/xpandmon/xpandmonitor.hh +++ b/server/modules/monitor/xpandmon/xpandmonitor.hh @@ -22,11 +22,11 @@ #include "xpandmembership.hh" #include "xpandnode.hh" -class ClustrixMonitor : public maxscale::MonitorWorker - , private ClustrixNode::Persister +class XpandMonitor : public maxscale::MonitorWorker + , private XpandNode::Persister { - ClustrixMonitor(const ClustrixMonitor&) = delete; - ClustrixMonitor& operator=(const ClustrixMonitor&) = delete; + XpandMonitor(const XpandMonitor&) = delete; + XpandMonitor& operator=(const XpandMonitor&) = delete; public: class Config { @@ -65,9 +65,9 @@ public: config::Integer m_health_check_port; }; - ~ClustrixMonitor(); + ~XpandMonitor(); - static ClustrixMonitor* create(const std::string& name, const std::string& module); + static XpandMonitor* create(const std::string& name, const std::string& module); bool configure(const MXS_CONFIG_PARAMETER* pParams) override; @@ -81,9 +81,9 @@ protected: void server_removed(SERVER* pServer) override; private: - ClustrixMonitor(const std::string& name, - const std::string& module, - sqlite3* pDb); + XpandMonitor(const std::string& name, + const std::string& module, + sqlite3* pDb); void pre_loop() override; void post_loop() override; @@ -94,18 +94,18 @@ private: bool remove_persisted_information(); void persist_bootstrap_servers(); - void check_cluster(Clustrix::Softfailed softfailed); - void check_hub(Clustrix::Softfailed softfailed); - void choose_hub(Clustrix::Softfailed softfailed); + void check_cluster(xpand::Softfailed softfailed); + void check_hub(xpand::Softfailed softfailed); + void choose_hub(xpand::Softfailed softfailed); - bool choose_dynamic_hub(Clustrix::Softfailed softfailed, std::set& ips_checked); - bool choose_bootstrap_hub(Clustrix::Softfailed softfailed, std::set& ips_checked); + bool choose_dynamic_hub(xpand::Softfailed softfailed, std::set& ips_checked); + bool choose_bootstrap_hub(xpand::Softfailed softfailed, std::set& ips_checked); bool refresh_using_persisted_nodes(std::set& ips_checked); bool refresh_nodes(); bool refresh_nodes(MYSQL* pHub_con); bool check_cluster_membership(MYSQL* pHub_con, - std::map* pMemberships); + std::map* pMemberships); void populate_from_bootstrap_servers(); @@ -150,18 +150,18 @@ private: return mxb::WorkerLoad::get_time_ms(); } - // ClustrixNode::Persister - void persist(const ClustrixNode& node); - void unpersist(const ClustrixNode& node); + // XpandNode::Persister + void persist(const XpandNode& node); + void unpersist(const XpandNode& node); private: - Config m_config; - std::map m_nodes_by_id; - std::vector m_health_urls; - mxb::http::Async m_http; - uint32_t m_delayed_http_check_id {0}; - long m_last_cluster_check {0}; - SERVER* m_pHub_server {nullptr}; - MYSQL* m_pHub_con {nullptr}; - sqlite3* m_pDb {nullptr}; + Config m_config; + std::map m_nodes_by_id; + std::vector m_health_urls; + mxb::http::Async m_http; + uint32_t m_delayed_http_check_id {0}; + long m_last_cluster_check {0}; + SERVER* m_pHub_server {nullptr}; + MYSQL* m_pHub_con {nullptr}; + sqlite3* m_pDb {nullptr}; }; diff --git a/server/modules/monitor/xpandmon/xpandnode.cc b/server/modules/monitor/xpandmon/xpandnode.cc index 9741b5783..5d1b909fa 100644 --- a/server/modules/monitor/xpandmon/xpandnode.cc +++ b/server/modules/monitor/xpandmon/xpandnode.cc @@ -14,12 +14,12 @@ #include "xpandnode.hh" #include "xpand.hh" -bool ClustrixNode::can_be_used_as_hub(const char* zName, - const mxs::MonitorServer::ConnectionSettings& settings, - Clustrix::Softfailed softfailed) +bool XpandNode::can_be_used_as_hub(const char* zName, + const mxs::MonitorServer::ConnectionSettings& settings, + xpand::Softfailed softfailed) { mxb_assert(m_pServer); - bool rv = Clustrix::ping_or_connect_to_hub(zName, settings, softfailed, *m_pServer, &m_pCon); + bool rv = xpand::ping_or_connect_to_hub(zName, settings, softfailed, *m_pServer, &m_pCon); if (!rv) { diff --git a/server/modules/monitor/xpandmon/xpandnode.hh b/server/modules/monitor/xpandmon/xpandnode.hh index d22f32faa..e977a4df1 100644 --- a/server/modules/monitor/xpandmon/xpandnode.hh +++ b/server/modules/monitor/xpandmon/xpandnode.hh @@ -19,14 +19,14 @@ #include "xpand.hh" #include "xpandmembership.hh" -class ClustrixNode +class XpandNode { public: class Persister { public: - virtual void persist(const ClustrixNode& node) = 0; - virtual void unpersist(const ClustrixNode& node) = 0; + virtual void persist(const XpandNode& node) = 0; + virtual void unpersist(const XpandNode& node) = 0; }; enum @@ -41,13 +41,13 @@ public: APPROACH_DEFAULT }; - ClustrixNode(Persister* pPersister, - const ClustrixMembership& membership, - const std::string& ip, - int mysql_port, - int health_port, - int health_check_threshold, - SERVER* pServer) + XpandNode(Persister* pPersister, + const XpandMembership& membership, + const std::string& ip, + int mysql_port, + int health_port, + int health_check_threshold, + SERVER* pServer) : m_persister(*pPersister) , m_id(membership.id()) , m_status(membership.status()) @@ -65,7 +65,7 @@ public: m_persister.persist(*this); } - ~ClustrixNode() + ~XpandNode() { if (m_pCon) { @@ -78,12 +78,12 @@ public: return m_id; } - Clustrix::Status status() const + xpand::Status status() const { return m_status; } - Clustrix::SubState substate() const + xpand::SubState substate() const { return m_substate; } @@ -178,7 +178,7 @@ public: } } - void update(Clustrix::Status status, Clustrix::SubState substate, int instance) + void update(xpand::Status status, xpand::SubState substate, int instance) { m_status = status; m_substate = substate; @@ -193,7 +193,7 @@ public: bool can_be_used_as_hub(const char* zName, const mxs::MonitorServer::ConnectionSettings& settings, - Clustrix::Softfailed softfailed); + xpand::Softfailed softfailed); SERVER* server() const { @@ -225,21 +225,21 @@ public: } private: - Persister& m_persister; - int m_id; - Clustrix::Status m_status; - Clustrix::SubState m_substate; - int m_instance; - std::string m_ip; - int m_mysql_port {DEFAULT_MYSQL_PORT}; - int m_health_port {DEFAULT_HEALTH_PORT}; - int m_health_check_threshold {DEFAULT_HEALTH_CHECK_THRESHOLD}; - int m_nRunning {0}; - SERVER* m_pServer {nullptr}; - MYSQL* m_pCon {nullptr}; + Persister& m_persister; + int m_id; + xpand::Status m_status; + xpand::SubState m_substate; + int m_instance; + std::string m_ip; + int m_mysql_port {DEFAULT_MYSQL_PORT}; + int m_health_port {DEFAULT_HEALTH_PORT}; + int m_health_check_threshold {DEFAULT_HEALTH_CHECK_THRESHOLD}; + int m_nRunning {0}; + SERVER* m_pServer {nullptr}; + MYSQL* m_pCon {nullptr}; }; -inline std::ostream& operator<<(std::ostream& out, const ClustrixNode& x) +inline std::ostream& operator<<(std::ostream& out, const XpandNode& x) { x.print(out); return out;