MXS-2271 Change Monitor->m_name to std::string
Also, monitor address is no longer printed.
This commit is contained in:
parent
d7971fa44d
commit
d89f0c062b
@ -312,6 +312,8 @@ public:
|
||||
|
||||
virtual monitor_state_t state() const = 0;
|
||||
|
||||
const char* name() const;
|
||||
|
||||
/**
|
||||
* Configure the monitor. Called by monitor creation and altering code. Any inheriting classes
|
||||
* should override this with their own configuration processing function. The overriding function
|
||||
@ -385,7 +387,7 @@ public:
|
||||
|
||||
void show(DCB* dcb);
|
||||
|
||||
const char* const m_name; /**< Monitor instance name. TODO: change to string */
|
||||
const std::string m_name; /**< Monitor instance name. */
|
||||
const std::string m_module; /**< Name of the monitor module */
|
||||
bool m_active {true}; /**< True if monitor exists and has not been "destroyed". */
|
||||
|
||||
|
@ -198,7 +198,7 @@ bool runtime_remove_server(Monitor* mon, Server* server)
|
||||
|
||||
if (MonitorManager::server_is_monitored(server) != mon)
|
||||
{
|
||||
config_runtime_error("Server '%s' is not monitored by '%s'.", server->name(), mon->m_name);
|
||||
config_runtime_error("Server '%s' is not monitored by '%s'.", server->name(), mon->name());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -249,7 +249,7 @@ bool runtime_link_server(Server* server, const char* target)
|
||||
config_runtime_error("The servers of the service '%s' are defined by the monitor '%s'. "
|
||||
"Servers cannot explicitly be added to the service.",
|
||||
service->name(),
|
||||
service->m_monitor->m_name);
|
||||
service->m_monitor->name());
|
||||
}
|
||||
}
|
||||
else if (monitor)
|
||||
@ -297,7 +297,7 @@ bool runtime_unlink_server(Server* server, const char* target)
|
||||
config_runtime_error("The servers of the service '%s' are defined by the monitor '%s'. "
|
||||
"Servers cannot explicitly be removed from the service.",
|
||||
service->name(),
|
||||
service->m_monitor->m_name);
|
||||
service->m_monitor->name());
|
||||
}
|
||||
}
|
||||
else if (monitor)
|
||||
@ -741,7 +741,7 @@ bool do_alter_monitor(Monitor* monitor, const char* key, const char* value)
|
||||
|
||||
if (success)
|
||||
{
|
||||
MXS_NOTICE("Updated monitor '%s': %s=%s", monitor->m_name, key, value);
|
||||
MXS_NOTICE("Updated monitor '%s': %s=%s", monitor->name(), key, value);
|
||||
}
|
||||
|
||||
return success;
|
||||
@ -1461,12 +1461,12 @@ bool runtime_destroy_monitor(Monitor* monitor)
|
||||
if (Service* s = service_uses_monitor(monitor))
|
||||
{
|
||||
config_runtime_error("Monitor '%s' cannot be destroyed as it is used by service '%s'",
|
||||
monitor->m_name, s->name());
|
||||
monitor->name(), s->name());
|
||||
}
|
||||
else
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
snprintf(filename, sizeof(filename), "%s/%s.cnf", get_config_persistdir(), monitor->m_name);
|
||||
snprintf(filename, sizeof(filename), "%s/%s.cnf", get_config_persistdir(), monitor->name());
|
||||
|
||||
std::lock_guard<std::mutex> guard(crt_lock);
|
||||
|
||||
@ -1486,7 +1486,7 @@ bool runtime_destroy_monitor(Monitor* monitor)
|
||||
if (rval)
|
||||
{
|
||||
MonitorManager::deactivate_monitor(monitor);
|
||||
MXS_NOTICE("Destroyed monitor '%s'", monitor->m_name);
|
||||
MXS_NOTICE("Destroyed monitor '%s'", monitor->name());
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
@ -174,7 +174,7 @@ bool rename_tmp_file(Monitor* monitor, const char* src)
|
||||
{
|
||||
bool rval = true;
|
||||
char dest[PATH_MAX + 1];
|
||||
snprintf(dest, sizeof(dest), journal_template, get_datadir(), monitor->m_name, journal_name);
|
||||
snprintf(dest, sizeof(dest), journal_template, get_datadir(), monitor->name(), journal_name);
|
||||
|
||||
if (rename(src, dest) == -1)
|
||||
{
|
||||
@ -198,7 +198,7 @@ bool rename_tmp_file(Monitor* monitor, const char* src)
|
||||
*/
|
||||
FILE* open_tmp_file(Monitor* monitor, char* path)
|
||||
{
|
||||
int nbytes = snprintf(path, PATH_MAX, journal_template, get_datadir(), monitor->m_name, "");
|
||||
int nbytes = snprintf(path, PATH_MAX, journal_template, get_datadir(), monitor->name(), "");
|
||||
int max_bytes = PATH_MAX - (int)sizeof(journal_name);
|
||||
FILE* rval = NULL;
|
||||
|
||||
@ -419,7 +419,7 @@ json_t* monitor_json_data(const Monitor* monitor, const char* host)
|
||||
|
||||
{
|
||||
Guard guard(monitor->m_lock);
|
||||
json_object_set_new(rval, CN_ID, json_string(monitor->m_name));
|
||||
json_object_set_new(rval, CN_ID, json_string(monitor->name()));
|
||||
json_object_set_new(rval, CN_TYPE, json_string(CN_MONITORS));
|
||||
|
||||
json_object_set_new(attr, CN_MODULE, json_string(monitor->m_module.c_str()));
|
||||
@ -451,7 +451,7 @@ json_t* monitor_json_data(const Monitor* monitor, const char* host)
|
||||
|
||||
json_object_set_new(rval, CN_RELATIONSHIPS, rel);
|
||||
json_object_set_new(rval, CN_ATTRIBUTES, attr);
|
||||
json_object_set_new(rval, CN_LINKS, mxs_json_self_link(host, CN_MONITORS, monitor->m_name));
|
||||
json_object_set_new(rval, CN_LINKS, mxs_json_self_link(host, CN_MONITORS, monitor->name()));
|
||||
return rval;
|
||||
}
|
||||
|
||||
@ -539,7 +539,7 @@ void MonitorManager::start_monitor(Monitor* monitor)
|
||||
{
|
||||
if (!monitor->start())
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor '%s'.", monitor->m_name);
|
||||
MXS_ERROR("Failed to start monitor '%s'.", monitor->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -651,7 +651,7 @@ void MonitorManager::monitor_list(DCB* dcb)
|
||||
{
|
||||
dcb_printf(dcb,
|
||||
"%-20s | %s\n",
|
||||
ptr->m_name,
|
||||
ptr->name(),
|
||||
ptr->state() == MONITOR_STATE_RUNNING ?
|
||||
"Running" : "Stopped");
|
||||
}
|
||||
@ -671,7 +671,7 @@ Monitor* MonitorManager::find_monitor(const char* name)
|
||||
{
|
||||
Monitor* rval = nullptr;
|
||||
this_unit.foreach_monitor([&rval, name](Monitor* ptr) {
|
||||
if (!strcmp(ptr->m_name, name) && ptr->m_active)
|
||||
if (ptr->m_name == name && ptr->m_active)
|
||||
{
|
||||
rval = ptr;
|
||||
}
|
||||
@ -724,7 +724,7 @@ bool MonitorManager::create_monitor_config(const Monitor* monitor, const char* f
|
||||
{
|
||||
MXS_ERROR("Failed to open file '%s' when serializing monitor '%s': %d, %s",
|
||||
filename,
|
||||
monitor->m_name,
|
||||
monitor->name(),
|
||||
errno,
|
||||
mxs_strerror(errno));
|
||||
return false;
|
||||
@ -758,7 +758,7 @@ bool MonitorManager::monitor_serialize(const Monitor* monitor)
|
||||
sizeof(filename),
|
||||
"%s/%s.cnf.tmp",
|
||||
get_config_persistdir(),
|
||||
monitor->m_name);
|
||||
monitor->name());
|
||||
|
||||
if (unlink(filename) == -1 && errno != ENOENT)
|
||||
{
|
||||
@ -875,7 +875,7 @@ namespace maxscale
|
||||
{
|
||||
|
||||
Monitor::Monitor(const string& name, const string& module)
|
||||
: m_name(MXS_STRDUP_A(name.c_str()))
|
||||
: m_name(name)
|
||||
, m_module(module)
|
||||
{
|
||||
memset(m_journal_hash, 0, sizeof(m_journal_hash));
|
||||
@ -893,10 +893,13 @@ void Monitor::stop()
|
||||
}
|
||||
}
|
||||
|
||||
const char* Monitor::name() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
bool Monitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
|
||||
|
||||
m_settings.interval = params->get_integer(CN_MONITOR_INTERVAL);
|
||||
m_settings.journal_max_age = params->get_integer(CN_JOURNAL_MAX_AGE);
|
||||
m_settings.script_timeout = params->get_integer(CN_SCRIPT_TIMEOUT);
|
||||
@ -934,7 +937,7 @@ bool Monitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
{
|
||||
mxb_assert(srv_monitored_by != this);
|
||||
MXS_ERROR("Server '%s' is already monitored by '%s', cannot add it to another monitor.",
|
||||
elem->name(), srv_monitored_by->m_name);
|
||||
elem->name(), srv_monitored_by->name());
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
@ -950,7 +953,7 @@ bool Monitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||
if (!set_disk_space_threshold(threshold_string))
|
||||
{
|
||||
MXS_ERROR("Invalid value for '%s' for monitor %s: %s",
|
||||
CN_DISK_SPACE_THRESHOLD, m_name, threshold_string.c_str());
|
||||
CN_DISK_SPACE_THRESHOLD, name(), threshold_string.c_str());
|
||||
error = true;
|
||||
}
|
||||
|
||||
@ -972,7 +975,6 @@ Monitor::~Monitor()
|
||||
delete server;
|
||||
}
|
||||
m_servers.clear();
|
||||
MXS_FREE((const_cast<char*>(m_name)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1045,9 +1047,7 @@ void Monitor::remove_server(SERVER* server)
|
||||
|
||||
void Monitor::show(DCB* dcb)
|
||||
{
|
||||
Monitor* monitor = this;
|
||||
dcb_printf(dcb, "Monitor: %p\n", monitor);
|
||||
dcb_printf(dcb, "Name: %s\n", m_name);
|
||||
dcb_printf(dcb, "Name: %s\n", name());
|
||||
dcb_printf(dcb, "State: %s\n", monitor_state_to_string(state()));
|
||||
dcb_printf(dcb, "Times monitored: %lu\n", m_ticks);
|
||||
dcb_printf(dcb, "Sampling interval: %lu milliseconds\n", m_settings.interval);
|
||||
@ -1059,7 +1059,7 @@ void Monitor::show(DCB* dcb)
|
||||
|
||||
const char* sep = "";
|
||||
|
||||
for (MonitorServer* db : monitor->m_servers)
|
||||
for (const auto& db : m_servers)
|
||||
{
|
||||
dcb_printf(dcb, "%s[%s]:%d", sep, db->server->address, db->server->port);
|
||||
sep = ", ";
|
||||
@ -1069,7 +1069,7 @@ void Monitor::show(DCB* dcb)
|
||||
|
||||
if (state() == MONITOR_STATE_RUNNING)
|
||||
{
|
||||
monitor->diagnostics(dcb);
|
||||
diagnostics(dcb);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1095,7 +1095,7 @@ bool Monitor::test_permissions(const string& query)
|
||||
{
|
||||
MXS_ERROR("[%s] Failed to connect to server '%s' ([%s]:%d) when"
|
||||
" checking monitor user credentials and permissions: %s",
|
||||
monitor->m_name,
|
||||
monitor->name(),
|
||||
mondb->server->name(),
|
||||
mondb->server->address,
|
||||
mondb->server->port,
|
||||
@ -1130,7 +1130,7 @@ bool Monitor::test_permissions(const string& query)
|
||||
}
|
||||
|
||||
MXS_ERROR("[%s] Failed to execute query '%s' with user '%s'. MySQL error message: %s",
|
||||
m_name, query.c_str(), m_settings.conn_settings.username.c_str(),
|
||||
name(), query.c_str(), m_settings.conn_settings.username.c_str(),
|
||||
mysql_error(mondb->con));
|
||||
}
|
||||
else
|
||||
@ -1140,7 +1140,7 @@ bool Monitor::test_permissions(const string& query)
|
||||
if (res == NULL)
|
||||
{
|
||||
MXS_ERROR("[%s] Result retrieval failed when checking monitor permissions: %s",
|
||||
monitor->m_name,
|
||||
monitor->name(),
|
||||
mysql_error(mondb->con));
|
||||
}
|
||||
else
|
||||
@ -1843,7 +1843,7 @@ void Monitor::detect_handle_state_changes()
|
||||
|
||||
int Monitor::get_data_file_path(char* path) const
|
||||
{
|
||||
int rv = snprintf(path, PATH_MAX, journal_template, get_datadir(), m_name, journal_name);
|
||||
int rv = snprintf(path, PATH_MAX, journal_template, get_datadir(), name(), journal_name);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -2114,7 +2114,7 @@ std::vector<MonitorServer*> Monitor::get_monitored_serverlist(const string& key,
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Server '%s' is not monitored by monitor '%s'.", elem->name(), m_name);
|
||||
MXS_ERROR("Server '%s' is not monitored by monitor '%s'.", elem->name(), name());
|
||||
*error_out = true;
|
||||
}
|
||||
}
|
||||
@ -2164,7 +2164,7 @@ bool Monitor::set_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
if (!msrv)
|
||||
{
|
||||
MXS_ERROR("Monitor %s requested to set status of server %s that it does not monitor.",
|
||||
m_name, srv->address);
|
||||
name(), srv->address);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2227,7 +2227,7 @@ bool Monitor::clear_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
if (!msrv)
|
||||
{
|
||||
MXS_ERROR("Monitor %s requested to clear status of server %s that it does not monitor.",
|
||||
m_name, srv->address);
|
||||
name(), srv->address);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2359,7 +2359,7 @@ bool MonitorWorker::start()
|
||||
|
||||
if (journal_is_stale())
|
||||
{
|
||||
MXS_WARNING("Removing stale journal file for monitor '%s'.", m_name);
|
||||
MXS_WARNING("Removing stale journal file for monitor '%s'.", name());
|
||||
remove_server_journal();
|
||||
}
|
||||
|
||||
@ -2382,7 +2382,7 @@ bool MonitorWorker::start()
|
||||
m_loop_called = get_time_ms() - m_settings.interval; // Next tick should happen immediately.
|
||||
if (!Worker::start())
|
||||
{
|
||||
MXS_ERROR("Failed to start worker for monitor '%s'.", m_name);
|
||||
MXS_ERROR("Failed to start worker for monitor '%s'.", name());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2684,7 +2684,7 @@ bool MonitorWorker::pre_run()
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("mysql_thread_init() failed for %s. The monitor cannot start.", m_name);
|
||||
MXS_ERROR("mysql_thread_init() failed for %s. The monitor cannot start.", name());
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ bool ClustrixMonitor::softfail(SERVER* pServer, json_t** ppError)
|
||||
LOG_JSON_ERROR(ppError,
|
||||
"%s: The monitor is not running and hence "
|
||||
"SOFTFAIL cannot be performed for %s.",
|
||||
m_name, pServer->address);
|
||||
name(), pServer->address);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -117,7 +117,7 @@ bool ClustrixMonitor::unsoftfail(SERVER* pServer, json_t** ppError)
|
||||
LOG_JSON_ERROR(ppError,
|
||||
"%s: The monitor is not running and hence "
|
||||
"UNSOFTFAIL cannot be performed for %s.",
|
||||
m_name, pServer->address);
|
||||
name(), pServer->address);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -165,11 +165,11 @@ void ClustrixMonitor::tick()
|
||||
switch (m_http.status())
|
||||
{
|
||||
case http::Async::PENDING:
|
||||
MXS_WARNING("%s: Health check round had not completed when next tick arrived.", m_name);
|
||||
MXS_WARNING("%s: Health check round had not completed when next tick arrived.", name());
|
||||
break;
|
||||
|
||||
case http::Async::ERROR:
|
||||
MXS_WARNING("%s: Health check round ended with general error.", m_name);
|
||||
MXS_WARNING("%s: Health check round ended with general error.", name());
|
||||
make_health_check();
|
||||
break;
|
||||
|
||||
@ -199,7 +199,7 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
auto& element = *it;
|
||||
ClustrixNode& node = element.second;
|
||||
|
||||
if (node.can_be_used_as_hub(m_name, m_settings.conn_settings))
|
||||
if (node.can_be_used_as_hub(name(), m_settings.conn_settings))
|
||||
{
|
||||
pHub_con = node.release_connection();
|
||||
pHub_server = node.server();
|
||||
@ -219,7 +219,7 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
|
||||
if (ips.find(ms.server->address) == ips.end())
|
||||
{
|
||||
if (Clustrix::ping_or_connect_to_hub(m_name, m_settings.conn_settings, softfailed, ms))
|
||||
if (Clustrix::ping_or_connect_to_hub(name(), m_settings.conn_settings, softfailed, ms))
|
||||
{
|
||||
pHub_con = ms.con;
|
||||
pHub_server = ms.server;
|
||||
@ -237,7 +237,7 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
if (pHub_con)
|
||||
{
|
||||
MXS_NOTICE("%s: Monitoring Clustrix cluster state using node %s:%d.",
|
||||
m_name, pHub_server->address, pHub_server->port);
|
||||
name(), pHub_server->address, pHub_server->port);
|
||||
|
||||
m_pHub_con = pHub_con;
|
||||
m_pHub_server = pHub_server;
|
||||
@ -248,7 +248,7 @@ void ClustrixMonitor::choose_hub(Clustrix::Softfailed softfailed)
|
||||
else
|
||||
{
|
||||
MXS_ERROR("%s: Could not connect to any server or no server that could "
|
||||
"be connected to was part of the quorum.", m_name);
|
||||
"be connected to was part of the quorum.", name());
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ void ClustrixMonitor::refresh_nodes()
|
||||
|
||||
// '@@' ensures no clash with user created servers.
|
||||
// Monitor name ensures no clash with other Clustrix monitor instances.
|
||||
string name = string("@@") + m_name + ":node-" + std::to_string(id);
|
||||
string server_name = string("@@") + m_name + ":node-" + std::to_string(id);
|
||||
|
||||
auto nit = m_nodes.find(id);
|
||||
auto mit = memberships.find(id);
|
||||
@ -301,7 +301,7 @@ void ClustrixMonitor::refresh_nodes()
|
||||
if (nit != m_nodes.end())
|
||||
{
|
||||
// Existing node.
|
||||
mxb_assert(SERVER::find_by_unique_name(name));
|
||||
mxb_assert(SERVER::find_by_unique_name(server_name));
|
||||
|
||||
ClustrixNode& node = nit->second;
|
||||
|
||||
@ -326,7 +326,7 @@ void ClustrixMonitor::refresh_nodes()
|
||||
{
|
||||
MXS_NOTICE("%s: Node %d (%s) has been SOFTFAILed. "
|
||||
"Turning ON 'Being Drained'.",
|
||||
m_name, node.id(), node.server()->address);
|
||||
name(), node.id(), node.server()->address);
|
||||
|
||||
node.server()->set_status(SERVER_DRAINING);
|
||||
}
|
||||
@ -334,7 +334,7 @@ void ClustrixMonitor::refresh_nodes()
|
||||
{
|
||||
MXS_NOTICE("%s: Node %d (%s) is no longer being SOFTFAILed. "
|
||||
"Turning OFF 'Being Drained'.",
|
||||
m_name, node.id(), node.server()->address);
|
||||
name(), node.id(), node.server()->address);
|
||||
|
||||
node.server()->clear_status(SERVER_DRAINING);
|
||||
}
|
||||
@ -344,16 +344,16 @@ void ClustrixMonitor::refresh_nodes()
|
||||
else if (mit != memberships.end())
|
||||
{
|
||||
// New node.
|
||||
mxb_assert(!SERVER::find_by_unique_name(name));
|
||||
mxb_assert(!SERVER::find_by_unique_name(server_name));
|
||||
|
||||
if (runtime_create_server(name.c_str(),
|
||||
if (runtime_create_server(server_name.c_str(),
|
||||
ip.c_str(),
|
||||
std::to_string(mysql_port).c_str(),
|
||||
"mariadbbackend",
|
||||
"mysqlbackendauth",
|
||||
false))
|
||||
{
|
||||
SERVER* pServer = SERVER::find_by_unique_name(name);
|
||||
SERVER* pServer = SERVER::find_by_unique_name(server_name);
|
||||
mxb_assert(pServer);
|
||||
|
||||
if (softfailed)
|
||||
@ -376,7 +376,7 @@ void ClustrixMonitor::refresh_nodes()
|
||||
else
|
||||
{
|
||||
MXS_ERROR("%s: Could not create server %s at %s:%d.",
|
||||
m_name, name.c_str(), ip.c_str(), mysql_port);
|
||||
name(), server_name.c_str(), ip.c_str(), mysql_port);
|
||||
}
|
||||
|
||||
memberships.erase(mit);
|
||||
@ -386,13 +386,13 @@ void ClustrixMonitor::refresh_nodes()
|
||||
// Node found in system.node_info but not in system.membership
|
||||
MXS_ERROR("%s: Node %d at %s:%d,%d found in system.node_info "
|
||||
"but not in system.membership.",
|
||||
m_name, id, ip.c_str(), mysql_port, health_port);
|
||||
name(), id, ip.c_str(), mysql_port, health_port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_WARNING("%s: Either nodeid and/or iface_ip is missing, ignoring node.",
|
||||
m_name);
|
||||
name());
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,13 +425,13 @@ void ClustrixMonitor::refresh_nodes()
|
||||
else
|
||||
{
|
||||
MXS_WARNING("%s: No result returned for '%s' on %s.",
|
||||
m_name, ZQUERY, m_pHub_server->address);
|
||||
name(), ZQUERY, m_pHub_server->address);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("%s: Could not execute '%s' on %s: %s",
|
||||
m_name, ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con));
|
||||
name(), ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -459,7 +459,7 @@ void ClustrixMonitor::check_hub(Clustrix::Softfailed softfailed)
|
||||
mxb_assert(m_pHub_con);
|
||||
mxb_assert(m_pHub_server);
|
||||
|
||||
if (!Clustrix::ping_or_connect_to_hub(m_name, m_settings.conn_settings, softfailed,
|
||||
if (!Clustrix::ping_or_connect_to_hub(name(), m_settings.conn_settings, softfailed,
|
||||
*m_pHub_server, &m_pHub_con))
|
||||
{
|
||||
mysql_close(m_pHub_con);
|
||||
@ -528,7 +528,7 @@ bool ClustrixMonitor::check_cluster_membership(std::map<int, ClustrixMembership>
|
||||
else
|
||||
{
|
||||
MXS_WARNING("%s: No node id returned in row for '%s'.",
|
||||
m_name, ZQUERY);
|
||||
name(), ZQUERY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,13 +549,13 @@ bool ClustrixMonitor::check_cluster_membership(std::map<int, ClustrixMembership>
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_WARNING("%s: No result returned for '%s'.", m_name, ZQUERY);
|
||||
MXS_WARNING("%s: No result returned for '%s'.", name(), ZQUERY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("%s: Could not execute '%s' on %s: %s",
|
||||
m_name, ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con));
|
||||
name(), ZQUERY, m_pHub_server->address, mysql_error(m_pHub_con));
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -608,11 +608,11 @@ void ClustrixMonitor::make_health_check()
|
||||
break;
|
||||
|
||||
case http::Async::ERROR:
|
||||
MXS_ERROR("%s: Could not initiate health check.", m_name);
|
||||
MXS_ERROR("%s: Could not initiate health check.", name());
|
||||
break;
|
||||
|
||||
case http::Async::READY:
|
||||
MXS_INFO("%s: Health check available immediately.", m_name);
|
||||
MXS_INFO("%s: Health check available immediately.", name());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -680,7 +680,7 @@ bool ClustrixMonitor::check_http(Call::action_t action)
|
||||
break;
|
||||
|
||||
case http::Async::ERROR:
|
||||
MXS_ERROR("%s: Health check waiting ended with general error.", m_name);
|
||||
MXS_ERROR("%s: Health check waiting ended with general error.", name());
|
||||
}
|
||||
}
|
||||
|
||||
@ -740,12 +740,12 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
if (mysql_query(m_pHub_con, zQuery) == 0)
|
||||
{
|
||||
MXS_NOTICE("%s: %s performed on node %d (%s).",
|
||||
m_name, zOperation, id, pServer->address);
|
||||
name(), zOperation, id, pServer->address);
|
||||
|
||||
if (operation == Operation::SOFTFAIL)
|
||||
{
|
||||
MXS_NOTICE("%s: Turning on 'Being Drained' on server %s.",
|
||||
m_name, pServer->address);
|
||||
name(), pServer->address);
|
||||
pServer->set_status(SERVER_DRAINING);
|
||||
}
|
||||
else
|
||||
@ -753,7 +753,7 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
mxb_assert(operation == Operation::UNSOFTFAIL);
|
||||
|
||||
MXS_NOTICE("%s: Turning off 'Being Drained' on server %s.",
|
||||
m_name, pServer->address);
|
||||
name(), pServer->address);
|
||||
pServer->clear_status(SERVER_DRAINING);
|
||||
}
|
||||
}
|
||||
@ -761,7 +761,7 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
{
|
||||
LOG_JSON_ERROR(ppError,
|
||||
"%s: The execution of '%s' failed: %s",
|
||||
m_name, zQuery, mysql_error(m_pHub_con));
|
||||
name(), zQuery, mysql_error(m_pHub_con));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -769,7 +769,7 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
LOG_JSON_ERROR(ppError,
|
||||
"%s: The server %s is not being monitored, "
|
||||
"cannot perform %s.",
|
||||
m_name, pServer->address, zOperation);
|
||||
name(), pServer->address, zOperation);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -777,7 +777,7 @@ bool ClustrixMonitor::perform_operation(Operation operation,
|
||||
LOG_JSON_ERROR(ppError,
|
||||
"%s: Could not could not connect to any Clustrix node, "
|
||||
"cannot perform %s of %s.",
|
||||
m_name, zOperation, pServer->address);
|
||||
name(), zOperation, pServer->address);
|
||||
}
|
||||
|
||||
return performed;
|
||||
|
@ -171,14 +171,14 @@ bool MariaDBMonitor::manual_rejoin(SERVER* rejoin_cand_srv, json_t** output)
|
||||
else
|
||||
{
|
||||
PRINT_MXS_JSON_ERROR(output, "%s is not monitored by %s, cannot rejoin.",
|
||||
rejoin_cand_srv->name(), m_name);
|
||||
rejoin_cand_srv->name(), name());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const char BAD_CLUSTER[] = "The server cluster of monitor %s is not in a valid state for joining. "
|
||||
"Either it has no master or its gtid domain is unknown.";
|
||||
PRINT_MXS_JSON_ERROR(output, BAD_CLUSTER, m_name);
|
||||
PRINT_MXS_JSON_ERROR(output, BAD_CLUSTER, name());
|
||||
}
|
||||
|
||||
return rval;
|
||||
@ -204,7 +204,7 @@ bool MariaDBMonitor::manual_reset_replication(SERVER* master_server, json_t** er
|
||||
MariaDBServer* new_master_cand = get_server(master_server);
|
||||
if (new_master_cand == NULL)
|
||||
{
|
||||
PRINT_MXS_JSON_ERROR(error_out, NO_SERVER, master_server->name(), m_name);
|
||||
PRINT_MXS_JSON_ERROR(error_out, NO_SERVER, master_server->name(), name());
|
||||
}
|
||||
else if (!new_master_cand->is_usable())
|
||||
{
|
||||
@ -1534,8 +1534,8 @@ void MariaDBMonitor::check_cluster_operations_support()
|
||||
"Automatic failover/switchover has been disabled. They should only be enabled "
|
||||
"after the above issues have been resolved.";
|
||||
string p1 = string_printf(PROBLEMS, all_reasons.c_str());
|
||||
string p2 = string_printf(RE_ENABLE_FMT, "failover", CN_AUTO_FAILOVER, m_name);
|
||||
string p3 = string_printf(RE_ENABLE_FMT, "switchover", CN_SWITCHOVER_ON_LOW_DISK_SPACE, m_name);
|
||||
string p2 = string_printf(RE_ENABLE_FMT, "failover", CN_AUTO_FAILOVER, name());
|
||||
string p3 = string_printf(RE_ENABLE_FMT, "switchover", CN_SWITCHOVER_ON_LOW_DISK_SPACE, name());
|
||||
string total_msg = p1 + " " + p2 + " " + p3;
|
||||
MXS_ERROR("%s", total_msg.c_str());
|
||||
|
||||
@ -1612,7 +1612,7 @@ MariaDBMonitor::switchover_prepare(SERVER* promotion_server, SERVER* demotion_se
|
||||
MariaDBServer* demotion_candidate = get_server(demotion_server);
|
||||
if (demotion_candidate == NULL)
|
||||
{
|
||||
PRINT_ERROR_IF(log_mode, error_out, NO_SERVER, demotion_server->name(), m_name);
|
||||
PRINT_ERROR_IF(log_mode, error_out, NO_SERVER, demotion_server->name(), name());
|
||||
}
|
||||
else if (!demotion_candidate->can_be_demoted_switchover(&demotion_msg))
|
||||
{
|
||||
@ -1656,7 +1656,7 @@ MariaDBMonitor::switchover_prepare(SERVER* promotion_server, SERVER* demotion_se
|
||||
MariaDBServer* promotion_candidate = get_server(promotion_server);
|
||||
if (promotion_candidate == NULL)
|
||||
{
|
||||
PRINT_ERROR_IF(log_mode, error_out, NO_SERVER, promotion_server->name(), m_name);
|
||||
PRINT_ERROR_IF(log_mode, error_out, NO_SERVER, promotion_server->name(), name());
|
||||
}
|
||||
else if (!promotion_candidate->can_be_promoted(op_type, demotion_target, &promotion_msg))
|
||||
{
|
||||
@ -1797,7 +1797,7 @@ void MariaDBMonitor::report_and_disable(const string& operation, const string& s
|
||||
string p1 = string_printf("Automatic %s failed, disabling automatic %s.",
|
||||
operation.c_str(),
|
||||
operation.c_str());
|
||||
string p2 = string_printf(RE_ENABLE_FMT, operation.c_str(), setting_name.c_str(), m_name);
|
||||
string p2 = string_printf(RE_ENABLE_FMT, operation.c_str(), setting_name.c_str(), name());
|
||||
string error_msg = p1 + " " + p2;
|
||||
MXS_ERROR("%s", error_msg.c_str());
|
||||
*setting_var = false;
|
||||
|
@ -1418,16 +1418,14 @@ static void destroyListener(DCB* dcb, SERVICE* service, const char* name)
|
||||
|
||||
static void destroyMonitor(DCB* dcb, Monitor* monitor)
|
||||
{
|
||||
char name[strlen(monitor->m_name) + 1];
|
||||
strcpy(name, monitor->m_name);
|
||||
|
||||
std::string name = monitor->name();
|
||||
if (runtime_destroy_monitor(monitor))
|
||||
{
|
||||
dcb_printf(dcb, "Destroyed monitor '%s'\n", name);
|
||||
dcb_printf(dcb, "Destroyed monitor '%s'\n", name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb_printf(dcb, "Failed to destroy monitor '%s', see log file for more details\n", name);
|
||||
dcb_printf(dcb, "Failed to destroy monitor '%s', see log file for more details\n", name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user