MXS-2220 Change server name to constant string

This commit is contained in:
Esa Korhonen
2018-12-19 15:15:02 +02:00
parent 5fc2c1f49c
commit 40485d746c
37 changed files with 194 additions and 173 deletions

View File

@ -170,7 +170,7 @@ void GaleraMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
if (warn_erange_on_local_index)
{
MXS_WARNING("Invalid 'wsrep_local_index' on server '%s': %s",
monitored_server->server->name,
monitored_server->server->name(),
row[1]);
warn_erange_on_local_index = false;
}
@ -655,20 +655,20 @@ static int compare_node_priority(const void* a, const void* b)
if (!have_a && have_b)
{
MXS_DEBUG("Server %s has no given priority. It will be at the beginning of the list",
s_a->server->name);
s_a->server->name());
return -(INT_MAX - 1);
}
else if (have_a && !have_b)
{
MXS_DEBUG("Server %s has no given priority. It will be at the beginning of the list",
s_b->server->name);
s_b->server->name());
return INT_MAX - 1;
}
else if (!have_a && !have_b)
{
MXS_DEBUG("Servers %s and %s have no given priority. They be at the beginning of the list",
s_a->server->name,
s_b->server->name);
s_a->server->name(),
s_b->server->name());
return 0;
}

View File

@ -171,7 +171,7 @@ 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_monitor->name);
rejoin_cand_srv->name(), m_monitor->name);
}
}
else
@ -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_monitor->name);
PRINT_MXS_JSON_ERROR(error_out, NO_SERVER, master_server->name(), m_monitor->name);
}
else if (!new_master_cand->is_usable())
{
@ -608,7 +608,7 @@ bool MariaDBMonitor::start_external_replication(MariaDBServer* new_master, json_
uint32_t MariaDBMonitor::do_rejoin(const ServerArray& joinable_servers, json_t** output)
{
SERVER* master_server = m_master->m_server_base->server;
const char* master_name = master_server->name;
const char* master_name = master_server->name();
uint32_t servers_joined = 0;
if (!joinable_servers.empty())
{
@ -1602,7 +1602,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_monitor->name);
PRINT_ERROR_IF(log_mode, error_out, NO_SERVER, demotion_server->name(), m_monitor->name);
}
else if (!demotion_candidate->can_be_demoted_switchover(&demotion_msg))
{
@ -1646,7 +1646,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_monitor->name);
PRINT_ERROR_IF(log_mode, error_out, NO_SERVER, promotion_server->name(), m_monitor->name);
}
else if (!promotion_candidate->can_be_promoted(op_type, demotion_target, &promotion_msg))
{

View File

@ -647,7 +647,7 @@ bool MariaDBServer::is_read_only() const
const char* MariaDBServer::name() const
{
return m_server_base->server->name;
return m_server_base->server->name();
}
string MariaDBServer::diagnostics() const

View File

@ -156,9 +156,7 @@ void MariaDBMonitor::Test::init_servers(int count)
for (int i = 1; i < count + 1; i++)
{
auto base_server = new Server; // Contents mostly undefined
string server_name = create_servername(i);
base_server->name = MXS_STRDUP(server_name.c_str());
auto base_server = Server::create_test_server(); // Contents mostly undefined
MXS_MONITORED_SERVER* mon_server = new MXS_MONITORED_SERVER; // Contents mostly undefined
mon_server->server = base_server;
@ -193,7 +191,6 @@ void MariaDBMonitor::Test::clear_servers()
m_monitor->m_servers_by_id.clear();
for (MariaDBServer* server : m_monitor->m_servers)
{
MXS_FREE(server->m_server_base->server->name);
delete server->m_server_base->server;
delete server->m_server_base;
delete server;

View File

@ -208,7 +208,7 @@ void MMMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
" for versions less than 5.5 does not have master_server_id, "
"replication tree cannot be resolved for server %s."
" MySQL Version: %s",
monitored_server->server->name,
monitored_server->server->name(),
server_string.c_str());
monitored_server->log_version_err = false;
}