MXS-1703 Remove MariaDBServer value array type

Having two types of arrays was more trouble than worth. Clearer to just
use the array of pointers. Renamed ServerRefArray to ServerArray.
This commit is contained in:
Esa Korhonen
2018-04-12 15:52:24 +03:00
parent 9fe57bfb9b
commit f7cc2aed5a
4 changed files with 64 additions and 62 deletions

View File

@ -1100,7 +1100,7 @@ MariaDBServer* MariaDBMonitor::find_root_master()
/* if only one server is configured, that's is Master */ /* if only one server is configured, that's is Master */
if (num_servers == 1) if (num_servers == 1)
{ {
auto mon_server = m_servers[0].server_base; auto mon_server = m_servers[0]->server_base;
if (SERVER_IS_RUNNING(mon_server->server)) if (SERVER_IS_RUNNING(mon_server->server))
{ {
mon_server->server->depth = 0; mon_server->server->depth = 0;
@ -1110,7 +1110,7 @@ MariaDBServer* MariaDBMonitor::find_root_master()
monitor_set_pending_status(mon_server, SERVER_MASTER); monitor_set_pending_status(mon_server, SERVER_MASTER);
mon_server->server->depth = 0; mon_server->server->depth = 0;
m_master = &m_servers[0]; m_master = m_servers[0];
found_root_master = mon_server; found_root_master = mon_server;
} }
} }

View File

@ -20,7 +20,7 @@
using std::string; using std::string;
static void print_redirect_errors(MariaDBServer* first_server, const ServerRefArray& servers, static void print_redirect_errors(MariaDBServer* first_server, const ServerArray& servers,
json_t** err_out); json_t** err_out);
bool MariaDBMonitor::manual_switchover(SERVER* new_master, SERVER* current_master, json_t** error_out) bool MariaDBMonitor::manual_switchover(SERVER* new_master, SERVER* current_master, json_t** error_out)
@ -140,7 +140,7 @@ bool MariaDBMonitor::manual_rejoin(SERVER* rejoin_server, json_t** output)
{ {
if (can_replicate_from(slave_cand, m_master)) if (can_replicate_from(slave_cand, m_master))
{ {
ServerRefArray joinable_server; ServerArray joinable_server;
joinable_server.push_back(slave_cand); joinable_server.push_back(slave_cand);
if (do_rejoin(joinable_server) == 1) if (do_rejoin(joinable_server) == 1)
{ {
@ -219,8 +219,8 @@ string MariaDBMonitor::generate_change_master_cmd(const string& master_host, int
* @param redirected_slaves A vector where to insert successfully redirected slaves. * @param redirected_slaves A vector where to insert successfully redirected slaves.
* @return The number of slaves successfully redirected. * @return The number of slaves successfully redirected.
*/ */
int MariaDBMonitor::redirect_slaves(MariaDBServer* new_master, const ServerRefArray& slaves, int MariaDBMonitor::redirect_slaves(MariaDBServer* new_master, const ServerArray& slaves,
ServerRefArray* redirected_slaves) ServerArray* redirected_slaves)
{ {
ss_dassert(redirected_slaves != NULL); ss_dassert(redirected_slaves != NULL);
MXS_NOTICE("Redirecting slaves to new master."); MXS_NOTICE("Redirecting slaves to new master.");
@ -335,7 +335,7 @@ bool MariaDBMonitor::redirect_one_slave(MXS_MONITORED_SERVER* slave, const char*
* @param joinable_servers Which servers to rejoin * @param joinable_servers Which servers to rejoin
* @return The number of servers successfully rejoined * @return The number of servers successfully rejoined
*/ */
uint32_t MariaDBMonitor::do_rejoin(const ServerRefArray& joinable_servers) uint32_t MariaDBMonitor::do_rejoin(const ServerArray& joinable_servers)
{ {
SERVER* master_server = m_master->server_base->server; SERVER* master_server = m_master->server_base->server;
const char* master_name = master_server->unique_name; const char* master_name = master_server->unique_name;
@ -389,18 +389,18 @@ bool MariaDBMonitor::cluster_can_be_joined()
* @return False, if there were possible rejoinable servers but communications error to master server * @return False, if there were possible rejoinable servers but communications error to master server
* prevented final checks. * prevented final checks.
*/ */
bool MariaDBMonitor::get_joinable_servers(ServerRefArray* output) bool MariaDBMonitor::get_joinable_servers(ServerArray* output)
{ {
ss_dassert(output); ss_dassert(output);
// Whether a join operation should be attempted or not depends on several criteria. Start with the ones // Whether a join operation should be attempted or not depends on several criteria. Start with the ones
// easiest to test. Go though all slaves and construct a preliminary list. // easiest to test. Go though all slaves and construct a preliminary list.
ServerRefArray suspects; ServerArray suspects;
for (size_t i = 0; i < m_servers.size(); i++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
if (server_is_rejoin_suspect(&m_servers[i], m_master, NULL)) if (server_is_rejoin_suspect(*iter, m_master, NULL))
{ {
suspects.push_back(&m_servers[i]); suspects.push_back(*iter);
} }
} }
@ -572,7 +572,7 @@ bool MariaDBMonitor::do_switchover(MariaDBServer** current_master, MariaDBServer
// Step 1: Save all slaves except promotion target to an array. If we have a // Step 1: Save all slaves except promotion target to an array. If we have a
// user-defined master candidate, check it. Otherwise, autoselect. // user-defined master candidate, check it. Otherwise, autoselect.
MariaDBServer* promotion_target = NULL; MariaDBServer* promotion_target = NULL;
ServerRefArray redirectable_slaves; ServerArray redirectable_slaves;
if (*new_master == NULL) if (*new_master == NULL)
{ {
// Autoselect new master. // Autoselect new master.
@ -600,14 +600,14 @@ bool MariaDBMonitor::do_switchover(MariaDBServer** current_master, MariaDBServer
* updated by update_slave_info() but not added to array. */ * updated by update_slave_info() but not added to array. */
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
MariaDBServer& server = *iter; MariaDBServer* server = *iter;
if (&server != promotion_target) if (server != promotion_target)
{ {
MariaDBServer* slave_info = update_slave_info(server.server_base); MariaDBServer* slave_info = update_slave_info(server->server_base);
// If master is replicating from external master, it is updated but not added to array. // If master is replicating from external master, it is updated but not added to array.
if (slave_info && &server != demotion_target) if (slave_info && server != demotion_target)
{ {
redirectable_slaves.push_back(&server); redirectable_slaves.push_back(server);
} }
} }
} }
@ -628,7 +628,7 @@ bool MariaDBMonitor::do_switchover(MariaDBServer** current_master, MariaDBServer
seconds_remaining -= difftime(step2_time, start_time); seconds_remaining -= difftime(step2_time, start_time);
// Step 3: Wait for the slaves (including promotion target) to catch up with master. // Step 3: Wait for the slaves (including promotion target) to catch up with master.
ServerRefArray catchup_slaves = redirectable_slaves; ServerArray catchup_slaves = redirectable_slaves;
catchup_slaves.push_back(promotion_target); catchup_slaves.push_back(promotion_target);
if (switchover_wait_slaves_catchup(catchup_slaves, demotion_target->gtid_binlog_pos, if (switchover_wait_slaves_catchup(catchup_slaves, demotion_target->gtid_binlog_pos,
seconds_remaining, m_monitor_base->read_timeout, err_out)) seconds_remaining, m_monitor_base->read_timeout, err_out))
@ -643,7 +643,7 @@ bool MariaDBMonitor::do_switchover(MariaDBServer** current_master, MariaDBServer
{ {
catchup_and_promote_success = true; catchup_and_promote_success = true;
// Step 5: Redirect slaves and start replication on old master. // Step 5: Redirect slaves and start replication on old master.
ServerRefArray redirected_slaves; ServerArray redirected_slaves;
bool start_ok = switchover_start_slave(demotion_target->server_base, bool start_ok = switchover_start_slave(demotion_target->server_base,
promotion_target->server_base->server); promotion_target->server_base->server);
if (start_ok) if (start_ok)
@ -729,7 +729,7 @@ bool MariaDBMonitor::do_failover(json_t** err_out)
int seconds_remaining = m_failover_timeout; int seconds_remaining = m_failover_timeout;
time_t start_time = time(NULL); time_t start_time = time(NULL);
// Step 1: Select new master. Also populate a vector with all slaves not the selected master. // Step 1: Select new master. Also populate a vector with all slaves not the selected master.
ServerRefArray redirectable_slaves; ServerArray redirectable_slaves;
MariaDBServer* new_master = select_new_master(&redirectable_slaves, err_out); MariaDBServer* new_master = select_new_master(&redirectable_slaves, err_out);
if (new_master == NULL) if (new_master == NULL)
{ {
@ -751,7 +751,7 @@ bool MariaDBMonitor::do_failover(json_t** err_out)
if (promote_new_master(new_master->server_base, err_out)) if (promote_new_master(new_master->server_base, err_out))
{ {
// Step 4: Redirect slaves. // Step 4: Redirect slaves.
ServerRefArray redirected_slaves; ServerArray redirected_slaves;
int redirects = redirect_slaves(new_master, redirectable_slaves, &redirected_slaves); int redirects = redirect_slaves(new_master, redirectable_slaves, &redirected_slaves);
bool success = redirectable_slaves.empty() ? true : redirects > 0; bool success = redirectable_slaves.empty() ? true : redirects > 0;
if (success) if (success)
@ -968,7 +968,7 @@ bool MariaDBMonitor::switchover_demote_master(MXS_MONITORED_SERVER* current_mast
* @param err_out json object for error printing. Can be NULL. * @param err_out json object for error printing. Can be NULL.
* @return True, if target gtid was reached within allotted time for all servers * @return True, if target gtid was reached within allotted time for all servers
*/ */
bool MariaDBMonitor::switchover_wait_slaves_catchup(const ServerRefArray& slaves, const GtidList& gtid, bool MariaDBMonitor::switchover_wait_slaves_catchup(const ServerArray& slaves, const GtidList& gtid,
int total_timeout, int read_timeout, json_t** err_out) int total_timeout, int read_timeout, json_t** err_out)
{ {
bool success = true; bool success = true;
@ -1005,7 +1005,7 @@ bool MariaDBMonitor::switchover_wait_slaves_catchup(const ServerRefArray& slaves
* @param seconds_remaining How long can we wait * @param seconds_remaining How long can we wait
* @return True, if at least one slave got the new event within the time limit * @return True, if at least one slave got the new event within the time limit
*/ */
bool MariaDBMonitor::wait_cluster_stabilization(MariaDBServer* new_master, const ServerRefArray& slaves, bool MariaDBMonitor::wait_cluster_stabilization(MariaDBServer* new_master, const ServerArray& slaves,
int seconds_remaining) int seconds_remaining)
{ {
ss_dassert(!slaves.empty()); ss_dassert(!slaves.empty());
@ -1019,7 +1019,7 @@ bool MariaDBMonitor::wait_cluster_stabilization(MariaDBServer* new_master, const
int repl_fails = 0; int repl_fails = 0;
int successes = 0; int successes = 0;
const GtidList& target = new_master->gtid_current_pos; const GtidList& target = new_master->gtid_current_pos;
ServerRefArray wait_list = slaves; // Check all the servers in the list ServerArray wait_list = slaves; // Check all the servers in the list
bool first_round = true; bool first_round = true;
bool time_is_up = false; bool time_is_up = false;
@ -1155,7 +1155,7 @@ bool MariaDBMonitor::promote_new_master(MXS_MONITORED_SERVER* new_master, json_t
* @param err_out json object for error printing. Can be NULL. * @param err_out json object for error printing. Can be NULL.
* @return The found master, or NULL if not found * @return The found master, or NULL if not found
*/ */
MariaDBServer* MariaDBMonitor::select_new_master(ServerRefArray* slaves_out, json_t** err_out) MariaDBServer* MariaDBMonitor::select_new_master(ServerArray* slaves_out, json_t** err_out)
{ {
ss_dassert(slaves_out && slaves_out->size() == 0); ss_dassert(slaves_out && slaves_out->size() == 0);
/* Select a new master candidate. Selects the one with the latest event in relay log. /* Select a new master candidate. Selects the one with the latest event in relay log.
@ -1163,7 +1163,7 @@ MariaDBServer* MariaDBMonitor::select_new_master(ServerRefArray* slaves_out, jso
MXS_MONITORED_SERVER* current_best = NULL; MXS_MONITORED_SERVER* current_best = NULL;
MariaDBServer* current_best_info = NULL; MariaDBServer* current_best_info = NULL;
// Servers that cannot be selected because of exclusion, but seem otherwise ok. // Servers that cannot be selected because of exclusion, but seem otherwise ok.
ServerRefArray valid_but_excluded; ServerArray valid_but_excluded;
// Index of the current best candidate in slaves_out // Index of the current best candidate in slaves_out
int master_vector_index = -1; int master_vector_index = -1;
@ -1173,7 +1173,7 @@ MariaDBServer* MariaDBMonitor::select_new_master(ServerRefArray* slaves_out, jso
* Do not worry about the exclusion list yet, querying the excluded servers is ok. * Do not worry about the exclusion list yet, querying the excluded servers is ok.
* If master is replicating from external master, it is updated by update_slave_info() * If master is replicating from external master, it is updated by update_slave_info()
* but not added to array. */ * but not added to array. */
MariaDBServer* cand = update_slave_info(iter->server_base); MariaDBServer* cand = update_slave_info((*iter)->server_base);
if (cand && cand != m_master) if (cand && cand != m_master)
{ {
slaves_out->push_back(cand); slaves_out->push_back(cand);
@ -1610,7 +1610,7 @@ bool MariaDBMonitor::slave_receiving_events()
* @param redirectable_slaves Other servers to query for errors. * @param redirectable_slaves Other servers to query for errors.
* @param err_out If not null, the error output object. * @param err_out If not null, the error output object.
*/ */
static void print_redirect_errors(MariaDBServer* first_server, const ServerRefArray& servers, static void print_redirect_errors(MariaDBServer* first_server, const ServerArray& servers,
json_t** err_out) json_t** err_out)
{ {
// Individual server errors have already been printed to the log. // Individual server errors have already been printed to the log.
@ -1619,7 +1619,7 @@ static void print_redirect_errors(MariaDBServer* first_server, const ServerRefAr
MXS_ERROR(MSG); MXS_ERROR(MSG);
if (err_out) if (err_out)
{ {
ServerRefArray failed_slaves; ServerArray failed_slaves;
if (first_server) if (first_server)
{ {
failed_slaves.push_back(first_server); failed_slaves.push_back(first_server);
@ -1692,7 +1692,7 @@ bool MariaDBMonitor::switchover_check(SERVER* new_master, SERVER* current_master
bool gtid_ok = true; bool gtid_ok = true;
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
if (SERVER_IS_SLAVE(iter->server_base->server) && !uses_gtid(iter->server_base, error_out)) if (SERVER_IS_SLAVE((*iter)->server_base->server) && !uses_gtid((*iter)->server_base, error_out))
{ {
gtid_ok = false; gtid_ok = false;
} }

View File

@ -65,19 +65,23 @@ MariaDBMonitor::~MariaDBMonitor()
*/ */
void MariaDBMonitor::init_server_info() void MariaDBMonitor::init_server_info()
{ {
m_servers.clear(); // If this monitor is being restarted, the server data needs to be freed.
for (auto server = m_monitor_base->monitored_servers; server; server = server->next) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
m_servers.push_back(MariaDBServer(server)); delete *iter;
}
m_servers.clear();
for (auto mon_server = m_monitor_base->monitored_servers; mon_server; mon_server = mon_server->next)
{
m_servers.push_back(new MariaDBServer(mon_server));
} }
// All servers have been inserted into the vector. The data in the vector should no longer move so it's
// safe to take addresses.
m_server_info.clear(); m_server_info.clear();
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
ss_dassert(m_server_info.count(iter->server_base) == 0); auto mon_server = (*iter)->server_base;
ServerInfoMap::value_type new_val(iter->server_base, &*iter); ss_dassert(m_server_info.count(mon_server) == 0);
ServerInfoMap::value_type new_val(mon_server, *iter);
m_server_info.insert(new_val); m_server_info.insert(new_val);
} }
} }
@ -397,7 +401,7 @@ void MariaDBMonitor::main_loop()
// Query all servers for their status. // Query all servers for their status.
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
monitor_one_server(*iter); monitor_one_server(**iter);
} }
// Use the information to find the so far best master server. // Use the information to find the so far best master server.
@ -413,19 +417,19 @@ void MariaDBMonitor::main_loop()
// Assign relay masters, clear SERVER_SLAVE from binlog relays // Assign relay masters, clear SERVER_SLAVE from binlog relays
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
assign_relay_master(*iter); assign_relay_master(**iter);
/* Remove SLAVE status if this server is a Binlog Server relay */ /* Remove SLAVE status if this server is a Binlog Server relay */
if (iter->binlog_relay) if ((*iter)->binlog_relay)
{ {
monitor_clear_pending_status(iter->server_base, SERVER_SLAVE); monitor_clear_pending_status((*iter)->server_base, SERVER_SLAVE);
} }
} }
/* Update server status from monitor pending status on that server*/ /* Update server status from monitor pending status on that server*/
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
update_server_states(*iter, root_master); update_server_states(**iter, root_master);
} }
/** Now that all servers have their status correctly set, we can check /** Now that all servers have their status correctly set, we can check
@ -585,13 +589,13 @@ void MariaDBMonitor::measure_replication_lag(MariaDBServer* root_master_server)
set_master_heartbeat(root_master); set_master_heartbeat(root_master);
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++) for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
{ {
MXS_MONITORED_SERVER* ptr = iter->server_base; MXS_MONITORED_SERVER* ptr = (*iter)->server_base;
if ((!SERVER_IN_MAINT(ptr->server)) && SERVER_IS_RUNNING(ptr->server)) if ((!SERVER_IN_MAINT(ptr->server)) && SERVER_IS_RUNNING(ptr->server))
{ {
if (ptr->server->node_id != root_master->server->node_id && if (ptr->server->node_id != root_master->server->node_id &&
(SERVER_IS_SLAVE(ptr->server) || (SERVER_IS_SLAVE(ptr->server) ||
SERVER_IS_RELAY_SERVER(ptr->server)) && SERVER_IS_RELAY_SERVER(ptr->server)) &&
!iter->binlog_relay) // No select lag for Binlog Server !(*iter)->binlog_relay) // No select lag for Binlog Server
{ {
set_slave_heartbeat(ptr); set_slave_heartbeat(ptr);
} }
@ -665,7 +669,7 @@ void MariaDBMonitor::log_master_changes(MariaDBServer* root_master_server, int*
void MariaDBMonitor::handle_auto_rejoin() void MariaDBMonitor::handle_auto_rejoin()
{ {
ServerRefArray joinable_servers; ServerArray joinable_servers;
if (get_joinable_servers(&joinable_servers)) if (get_joinable_servers(&joinable_servers))
{ {
uint32_t joins = do_rejoin(joinable_servers); uint32_t joins = do_rejoin(joinable_servers);
@ -1102,7 +1106,7 @@ bool handle_manual_rejoin(const MODULECMD_ARG* args, json_t** output)
return rv; return rv;
} }
string monitored_servers_to_string(const ServerRefArray& servers) string monitored_servers_to_string(const ServerArray& servers)
{ {
string rval; string rval;
size_t array_size = servers.size(); size_t array_size = servers.size();
@ -1119,7 +1123,7 @@ string monitored_servers_to_string(const ServerRefArray& servers)
return rval; return rval;
} }
string get_connection_errors(const ServerRefArray& servers) string get_connection_errors(const ServerArray& servers)
{ {
// Get errors from all connections, form a string. // Get errors from all connections, form a string.
string rval; string rval;

View File

@ -29,10 +29,8 @@ class MariaDBMonitor;
// Map of base struct to MariaDBServer. Does not own the server objects. May not be needed at the end. // Map of base struct to MariaDBServer. Does not own the server objects. May not be needed at the end.
typedef std::tr1::unordered_map<MXS_MONITORED_SERVER*, MariaDBServer*> ServerInfoMap; typedef std::tr1::unordered_map<MXS_MONITORED_SERVER*, MariaDBServer*> ServerInfoMap;
// Server container, owns the server objects. // Server pointer array
typedef std::vector<MariaDBServer> ServerArray; // TODO: Rename/get rid of ServerVector typedef! typedef std::vector<MariaDBServer*> ServerArray;
// Server pointer array, used for temporary server collections
typedef std::vector<MariaDBServer*> ServerRefArray;
// MariaDB Monitor instance data // MariaDB Monitor instance data
class MariaDBMonitor class MariaDBMonitor
@ -142,7 +140,7 @@ private:
bool m_auto_failover; /**< If automatic master failover is enabled */ bool m_auto_failover; /**< If automatic master failover is enabled */
bool m_auto_rejoin; /**< Attempt to start slave replication on standalone servers or servers bool m_auto_rejoin; /**< Attempt to start slave replication on standalone servers or servers
* replicating from the wrong master automatically. */ * replicating from the wrong master automatically. */
ServerRefArray m_excluded_servers; /**< Servers banned for master promotion during auto-failover. */ ServerArray m_excluded_servers; /**< Servers banned for master promotion during auto-failover. */
// Other settings // Other settings
std::string m_script; /**< Script to call when state changes occur on servers */ std::string m_script; /**< Script to call when state changes occur on servers */
@ -197,7 +195,7 @@ private:
bool switchover_check_preferred_master(MXS_MONITORED_SERVER* preferred, json_t** err_out); bool switchover_check_preferred_master(MXS_MONITORED_SERVER* preferred, json_t** err_out);
bool switchover_demote_master(MXS_MONITORED_SERVER* current_master, MariaDBServer* info, bool switchover_demote_master(MXS_MONITORED_SERVER* current_master, MariaDBServer* info,
json_t** err_out); json_t** err_out);
bool switchover_wait_slaves_catchup(const ServerRefArray& slaves, const GtidList& gtid, int total_timeout, bool switchover_wait_slaves_catchup(const ServerArray& slaves, const GtidList& gtid, int total_timeout,
int read_timeout, json_t** err_out); int read_timeout, json_t** err_out);
bool switchover_start_slave(MXS_MONITORED_SERVER* old_master, SERVER* new_master); bool switchover_start_slave(MXS_MONITORED_SERVER* old_master, SERVER* new_master);
@ -213,26 +211,26 @@ private:
// Rejoin methods // Rejoin methods
bool cluster_can_be_joined(); bool cluster_can_be_joined();
void handle_auto_rejoin(); void handle_auto_rejoin();
bool get_joinable_servers(ServerRefArray* output); bool get_joinable_servers(ServerArray* output);
bool server_is_rejoin_suspect(MariaDBServer* rejoin_cand, MariaDBServer* master, json_t** output); bool server_is_rejoin_suspect(MariaDBServer* rejoin_cand, MariaDBServer* master, json_t** output);
bool can_replicate_from(MariaDBServer* slave_cand, MariaDBServer* master); bool can_replicate_from(MariaDBServer* slave_cand, MariaDBServer* master);
uint32_t do_rejoin(const ServerRefArray& joinable_servers); uint32_t do_rejoin(const ServerArray& joinable_servers);
bool join_cluster(MXS_MONITORED_SERVER* server, const char* change_cmd); bool join_cluster(MXS_MONITORED_SERVER* server, const char* change_cmd);
// Methods common to failover/switchover/rejoin // Methods common to failover/switchover/rejoin
bool uses_gtid(MXS_MONITORED_SERVER* mon_server, json_t** error_out); bool uses_gtid(MXS_MONITORED_SERVER* mon_server, json_t** error_out);
MariaDBServer* select_new_master(ServerRefArray* slaves_out, json_t** err_out); MariaDBServer* select_new_master(ServerArray* slaves_out, json_t** err_out);
MariaDBServer* update_slave_info(MXS_MONITORED_SERVER* server); MariaDBServer* update_slave_info(MXS_MONITORED_SERVER* server);
bool server_is_excluded(const MXS_MONITORED_SERVER* server); bool server_is_excluded(const MXS_MONITORED_SERVER* server);
bool is_candidate_better(const MariaDBServer* current_best_info, const MariaDBServer* candidate_info, bool is_candidate_better(const MariaDBServer* current_best_info, const MariaDBServer* candidate_info,
uint32_t gtid_domain); uint32_t gtid_domain);
bool promote_new_master(MXS_MONITORED_SERVER* new_master, json_t** err_out); bool promote_new_master(MXS_MONITORED_SERVER* new_master, json_t** err_out);
int redirect_slaves(MariaDBServer* new_master, const ServerRefArray& slaves, int redirect_slaves(MariaDBServer* new_master, const ServerArray& slaves,
ServerRefArray* redirected_slaves); ServerArray* redirected_slaves);
bool redirect_one_slave(MXS_MONITORED_SERVER* slave, const char* change_cmd); bool redirect_one_slave(MXS_MONITORED_SERVER* slave, const char* change_cmd);
std::string generate_change_master_cmd(const std::string& master_host, int master_port); std::string generate_change_master_cmd(const std::string& master_host, int master_port);
bool start_external_replication(MXS_MONITORED_SERVER* new_master, json_t** err_out); bool start_external_replication(MXS_MONITORED_SERVER* new_master, json_t** err_out);
bool wait_cluster_stabilization(MariaDBServer* new_master, const ServerRefArray& slaves, bool wait_cluster_stabilization(MariaDBServer* new_master, const ServerArray& slaves,
int seconds_remaining); int seconds_remaining);
void disable_setting(const char* setting); void disable_setting(const char* setting);
void load_journal(); void load_journal();
@ -244,7 +242,7 @@ private:
* @param servers The servers * @param servers The servers
* @return Server names * @return Server names
*/ */
std::string monitored_servers_to_string(const ServerRefArray& servers); std::string monitored_servers_to_string(const ServerArray& servers);
/** /**
* Get MariaDB connection error strings from all the given servers, form one string. * Get MariaDB connection error strings from all the given servers, form one string.
@ -252,4 +250,4 @@ std::string monitored_servers_to_string(const ServerRefArray& servers);
* @param servers Servers with errors * @param servers Servers with errors
* @return Concatenated string. * @return Concatenated string.
*/ */
std::string get_connection_errors(const ServerRefArray& servers); std::string get_connection_errors(const ServerArray& servers);