MXS-1775 Rename m_monitor_base to m_monitor
To make it compatible with how the variable is named in maxscale::MonitorInstance.
This commit is contained in:
@ -39,7 +39,7 @@ MXS_MONITORED_SERVER* MariaDBMonitor::get_replication_tree()
|
|||||||
long node_id;
|
long node_id;
|
||||||
int root_level;
|
int root_level;
|
||||||
|
|
||||||
ptr = m_monitor_base->monitored_servers;
|
ptr = m_monitor->monitored_servers;
|
||||||
root_level = num_servers;
|
root_level = num_servers;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
@ -182,7 +182,7 @@ MXS_MONITORED_SERVER* MariaDBMonitor::get_replication_tree()
|
|||||||
MXS_MONITORED_SERVER* MariaDBMonitor::getServerByNodeId(long node_id)
|
MXS_MONITORED_SERVER* MariaDBMonitor::getServerByNodeId(long node_id)
|
||||||
{
|
{
|
||||||
SERVER *current;
|
SERVER *current;
|
||||||
MXS_MONITORED_SERVER *ptr = m_monitor_base->monitored_servers;
|
MXS_MONITORED_SERVER *ptr = m_monitor->monitored_servers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
current = ptr->server;
|
current = ptr->server;
|
||||||
@ -204,7 +204,7 @@ MXS_MONITORED_SERVER* MariaDBMonitor::getServerByNodeId(long node_id)
|
|||||||
*/
|
*/
|
||||||
MXS_MONITORED_SERVER* MariaDBMonitor::getSlaveOfNodeId(long node_id, slave_down_setting_t slave_down_setting)
|
MXS_MONITORED_SERVER* MariaDBMonitor::getSlaveOfNodeId(long node_id, slave_down_setting_t slave_down_setting)
|
||||||
{
|
{
|
||||||
MXS_MONITORED_SERVER *ptr = m_monitor_base->monitored_servers;
|
MXS_MONITORED_SERVER *ptr = m_monitor->monitored_servers;
|
||||||
SERVER *current;
|
SERVER *current;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -447,12 +447,12 @@ void MariaDBMonitor::find_graph_cycles()
|
|||||||
*/
|
*/
|
||||||
void MariaDBMonitor::check_maxscale_schema_replication()
|
void MariaDBMonitor::check_maxscale_schema_replication()
|
||||||
{
|
{
|
||||||
MXS_MONITORED_SERVER* database = m_monitor_base->monitored_servers;
|
MXS_MONITORED_SERVER* database = m_monitor->monitored_servers;
|
||||||
bool err = false;
|
bool err = false;
|
||||||
|
|
||||||
while (database)
|
while (database)
|
||||||
{
|
{
|
||||||
mxs_connect_result_t rval = mon_ping_or_connect_to_db(m_monitor_base, database);
|
mxs_connect_result_t rval = mon_ping_or_connect_to_db(m_monitor, database);
|
||||||
if (mon_connection_is_ok(rval))
|
if (mon_connection_is_ok(rval))
|
||||||
{
|
{
|
||||||
if (!check_replicate_ignore_table(database) ||
|
if (!check_replicate_ignore_table(database) ||
|
||||||
|
@ -29,11 +29,11 @@ bool MariaDBMonitor::manual_switchover(SERVER* new_master, SERVER* current_maste
|
|||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
MXS_NOTICE("Stopped the monitor %s for the duration of switchover.", m_monitor_base->name);
|
MXS_NOTICE("Stopped the monitor %s for the duration of switchover.", m_monitor->name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Monitor %s already stopped, switchover can proceed.", m_monitor_base->name);
|
MXS_NOTICE("Monitor %s already stopped, switchover can proceed.", m_monitor->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It's possible for either current_master, or both new_master & current_master to be NULL, which means
|
/* It's possible for either current_master, or both new_master & current_master to be NULL, which means
|
||||||
@ -59,7 +59,7 @@ bool MariaDBMonitor::manual_switchover(SERVER* new_master, SERVER* current_maste
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string format = "Switchover %s -> %s failed";
|
string format = "Switchover %s -> %s failed";
|
||||||
bool failover_setting = config_get_bool(m_monitor_base->parameters, CN_AUTO_FAILOVER);
|
bool failover_setting = config_get_bool(m_monitor->parameters, CN_AUTO_FAILOVER);
|
||||||
if (failover_setting)
|
if (failover_setting)
|
||||||
{
|
{
|
||||||
disable_setting(CN_AUTO_FAILOVER);
|
disable_setting(CN_AUTO_FAILOVER);
|
||||||
@ -73,7 +73,7 @@ bool MariaDBMonitor::manual_switchover(SERVER* new_master, SERVER* current_maste
|
|||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
// TODO: What if this fails?
|
// TODO: What if this fails?
|
||||||
start(m_monitor_base->parameters);
|
start(m_monitor->parameters);
|
||||||
}
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
@ -84,11 +84,11 @@ bool MariaDBMonitor::manual_failover(json_t** output)
|
|||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
MXS_NOTICE("Stopped monitor %s for the duration of failover.", m_monitor_base->name);
|
MXS_NOTICE("Stopped monitor %s for the duration of failover.", m_monitor->name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Monitor %s already stopped, failover can proceed.", m_monitor_base->name);
|
MXS_NOTICE("Monitor %s already stopped, failover can proceed.", m_monitor->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rv = true;
|
bool rv = true;
|
||||||
@ -109,7 +109,7 @@ bool MariaDBMonitor::manual_failover(json_t** output)
|
|||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
// TODO: What if this fails?
|
// TODO: What if this fails?
|
||||||
start(m_monitor_base->parameters);
|
start(m_monitor->parameters);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -120,18 +120,18 @@ bool MariaDBMonitor::manual_rejoin(SERVER* rejoin_server, json_t** output)
|
|||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
MXS_NOTICE("Stopped monitor %s for the duration of rejoin.", m_monitor_base->name);
|
MXS_NOTICE("Stopped monitor %s for the duration of rejoin.", m_monitor->name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Monitor %s already stopped, rejoin can proceed.", m_monitor_base->name);
|
MXS_NOTICE("Monitor %s already stopped, rejoin can proceed.", m_monitor->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rval = false;
|
bool rval = false;
|
||||||
if (cluster_can_be_joined())
|
if (cluster_can_be_joined())
|
||||||
{
|
{
|
||||||
const char* rejoin_serv_name = rejoin_server->name;
|
const char* rejoin_serv_name = rejoin_server->name;
|
||||||
MXS_MONITORED_SERVER* mon_slave_cand = mon_get_monitored_server(m_monitor_base, rejoin_server);
|
MXS_MONITORED_SERVER* mon_slave_cand = mon_get_monitored_server(m_monitor, rejoin_server);
|
||||||
if (mon_slave_cand)
|
if (mon_slave_cand)
|
||||||
{
|
{
|
||||||
MariaDBServer* slave_cand = get_server_info(mon_slave_cand);
|
MariaDBServer* slave_cand = get_server_info(mon_slave_cand);
|
||||||
@ -178,13 +178,13 @@ bool MariaDBMonitor::manual_rejoin(SERVER* rejoin_server, json_t** output)
|
|||||||
{
|
{
|
||||||
const char BAD_CLUSTER[] = "The server cluster of monitor '%s' is not in a state valid for joining. "
|
const char BAD_CLUSTER[] = "The server cluster of monitor '%s' is not in a state valid for joining. "
|
||||||
"Either it has no master or its gtid domain is unknown.";
|
"Either it has no master or its gtid domain is unknown.";
|
||||||
PRINT_MXS_JSON_ERROR(output, BAD_CLUSTER, m_monitor_base->name);
|
PRINT_MXS_JSON_ERROR(output, BAD_CLUSTER, m_monitor->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
// TODO: What if this fails?
|
// TODO: What if this fails?
|
||||||
start(m_monitor_base->parameters);
|
start(m_monitor->parameters);
|
||||||
}
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
@ -1202,7 +1202,7 @@ bool MariaDBMonitor::switchover_check_current(const MXS_MONITORED_SERVER* sugges
|
|||||||
ss_dassert(suggested_curr_master);
|
ss_dassert(suggested_curr_master);
|
||||||
bool server_is_master = false;
|
bool server_is_master = false;
|
||||||
MXS_MONITORED_SERVER* extra_master = NULL; // A master server which is not the suggested one
|
MXS_MONITORED_SERVER* extra_master = NULL; // A master server which is not the suggested one
|
||||||
for (MXS_MONITORED_SERVER* mon_serv = m_monitor_base->monitored_servers;
|
for (MXS_MONITORED_SERVER* mon_serv = m_monitor->monitored_servers;
|
||||||
mon_serv != NULL && extra_master == NULL;
|
mon_serv != NULL && extra_master == NULL;
|
||||||
mon_serv = mon_serv->next)
|
mon_serv = mon_serv->next)
|
||||||
{
|
{
|
||||||
@ -1337,7 +1337,7 @@ bool MariaDBMonitor::handle_auto_failover()
|
|||||||
"replication configuration, disabling automatic failover. Failover "
|
"replication configuration, disabling automatic failover. Failover "
|
||||||
"should only be enabled after the replication configuration has been "
|
"should only be enabled after the replication configuration has been "
|
||||||
"fixed.";
|
"fixed.";
|
||||||
MXS_ERROR(RE_ENABLE_FMT, PROBLEMS, CN_AUTO_FAILOVER, m_monitor_base->name);
|
MXS_ERROR(RE_ENABLE_FMT, PROBLEMS, CN_AUTO_FAILOVER, m_monitor->name);
|
||||||
m_auto_failover = false;
|
m_auto_failover = false;
|
||||||
disable_setting(CN_AUTO_FAILOVER);
|
disable_setting(CN_AUTO_FAILOVER);
|
||||||
return cluster_modified;
|
return cluster_modified;
|
||||||
@ -1395,7 +1395,7 @@ bool MariaDBMonitor::handle_auto_failover()
|
|||||||
if (!do_failover(NULL))
|
if (!do_failover(NULL))
|
||||||
{
|
{
|
||||||
const char FAILED[] = "Failed to perform failover, disabling automatic failover.";
|
const char FAILED[] = "Failed to perform failover, disabling automatic failover.";
|
||||||
MXS_ERROR(RE_ENABLE_FMT, FAILED, CN_AUTO_FAILOVER, m_monitor_base->name);
|
MXS_ERROR(RE_ENABLE_FMT, FAILED, CN_AUTO_FAILOVER, m_monitor->name);
|
||||||
m_auto_failover = false;
|
m_auto_failover = false;
|
||||||
disable_setting(CN_AUTO_FAILOVER);
|
disable_setting(CN_AUTO_FAILOVER);
|
||||||
}
|
}
|
||||||
@ -1504,11 +1504,11 @@ bool MariaDBMonitor::switchover_check(SERVER* new_master, SERVER* current_master
|
|||||||
// Check that both servers are ok if specified. Null is a valid value.
|
// Check that both servers are ok if specified. Null is a valid value.
|
||||||
if (new_master)
|
if (new_master)
|
||||||
{
|
{
|
||||||
auto mon_new_master = mon_get_monitored_server(m_monitor_base, new_master);
|
auto mon_new_master = mon_get_monitored_server(m_monitor, new_master);
|
||||||
if (mon_new_master == NULL)
|
if (mon_new_master == NULL)
|
||||||
{
|
{
|
||||||
new_master_ok = false;
|
new_master_ok = false;
|
||||||
PRINT_MXS_JSON_ERROR(error_out, NO_SERVER, new_master->name, m_monitor_base->name);
|
PRINT_MXS_JSON_ERROR(error_out, NO_SERVER, new_master->name, m_monitor->name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1526,11 +1526,11 @@ bool MariaDBMonitor::switchover_check(SERVER* new_master, SERVER* current_master
|
|||||||
|
|
||||||
if (current_master)
|
if (current_master)
|
||||||
{
|
{
|
||||||
auto mon_curr_master = mon_get_monitored_server(m_monitor_base, current_master);
|
auto mon_curr_master = mon_get_monitored_server(m_monitor, current_master);
|
||||||
if (mon_curr_master == NULL)
|
if (mon_curr_master == NULL)
|
||||||
{
|
{
|
||||||
current_master_ok = false;
|
current_master_ok = false;
|
||||||
PRINT_MXS_JSON_ERROR(error_out, NO_SERVER, current_master->name, m_monitor_base->name);
|
PRINT_MXS_JSON_ERROR(error_out, NO_SERVER, current_master->name, m_monitor->name);
|
||||||
}
|
}
|
||||||
else if (!switchover_check_current(mon_curr_master, error_out))
|
else if (!switchover_check_current(mon_curr_master, error_out))
|
||||||
{
|
{
|
||||||
|
@ -51,8 +51,8 @@ static const char CN_MASTER_FAILURE_TIMEOUT[] = "master_failure_timeout";
|
|||||||
static const char CN_REPLICATION_USER[] = "replication_user";
|
static const char CN_REPLICATION_USER[] = "replication_user";
|
||||||
static const char CN_REPLICATION_PASSWORD[] = "replication_password";
|
static const char CN_REPLICATION_PASSWORD[] = "replication_password";
|
||||||
|
|
||||||
MariaDBMonitor::MariaDBMonitor(MXS_MONITOR* monitor_base)
|
MariaDBMonitor::MariaDBMonitor(MXS_MONITOR* monitor)
|
||||||
: m_monitor_base(monitor_base)
|
: m_monitor(monitor)
|
||||||
, m_id(config_get_global_options()->id)
|
, m_id(config_get_global_options()->id)
|
||||||
, m_shutdown(false)
|
, m_shutdown(false)
|
||||||
, m_state(MXS_MONITOR_STOPPED)
|
, m_state(MXS_MONITOR_STOPPED)
|
||||||
@ -81,7 +81,7 @@ void MariaDBMonitor::reset_server_info()
|
|||||||
clear_server_info();
|
clear_server_info();
|
||||||
|
|
||||||
// Next, initialize the data.
|
// Next, initialize the data.
|
||||||
for (auto mon_server = m_monitor_base->monitored_servers; mon_server; mon_server = mon_server->next)
|
for (auto mon_server = m_monitor->monitored_servers; mon_server; mon_server = mon_server->next)
|
||||||
{
|
{
|
||||||
m_servers.push_back(new MariaDBServer(mon_server));
|
m_servers.push_back(new MariaDBServer(mon_server));
|
||||||
}
|
}
|
||||||
@ -132,8 +132,8 @@ bool MariaDBMonitor::set_replication_credentials(const MXS_CONFIG_PARAMETER* par
|
|||||||
if (repl_user.empty() && repl_pw.empty())
|
if (repl_user.empty() && repl_pw.empty())
|
||||||
{
|
{
|
||||||
// No replication credentials defined, use monitor credentials
|
// No replication credentials defined, use monitor credentials
|
||||||
repl_user = m_monitor_base->user;
|
repl_user = m_monitor->user;
|
||||||
repl_pw = m_monitor_base->password;
|
repl_pw = m_monitor->password;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!repl_user.empty() && !repl_pw.empty())
|
if (!repl_user.empty() && !repl_pw.empty())
|
||||||
@ -168,7 +168,7 @@ bool MariaDBMonitor::start(const MXS_CONFIG_PARAMETER* params)
|
|||||||
|
|
||||||
if (!error && (thread_start(&m_thread, monitorMain, this, 0) == NULL))
|
if (!error && (thread_start(&m_thread, monitorMain, this, 0) == NULL))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor_base->name);
|
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor->name);
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ bool MariaDBMonitor::configure(const MXS_CONFIG_PARAMETER* params)
|
|||||||
|
|
||||||
m_excluded_servers.clear();
|
m_excluded_servers.clear();
|
||||||
MXS_MONITORED_SERVER** excluded_array = NULL;
|
MXS_MONITORED_SERVER** excluded_array = NULL;
|
||||||
int n_excluded = mon_config_get_servers(params, CN_NO_PROMOTE_SERVERS, m_monitor_base, &excluded_array);
|
int n_excluded = mon_config_get_servers(params, CN_NO_PROMOTE_SERVERS, m_monitor, &excluded_array);
|
||||||
for (int i = 0; i < n_excluded; i++)
|
for (int i = 0; i < n_excluded; i++)
|
||||||
{
|
{
|
||||||
m_excluded_servers.push_back(get_server_info(excluded_array[i]));
|
m_excluded_servers.push_back(get_server_info(excluded_array[i]));
|
||||||
@ -339,7 +339,7 @@ void MariaDBMonitor::main_loop()
|
|||||||
/* Check monitor permissions. Failure won't cause the monitor to stop. Afterwards, close connections so
|
/* Check monitor permissions. Failure won't cause the monitor to stop. Afterwards, close connections so
|
||||||
* that update_server() reconnects and checks server version. TODO: check permissions when checking
|
* that update_server() reconnects and checks server version. TODO: check permissions when checking
|
||||||
* server version. */
|
* server version. */
|
||||||
check_monitor_permissions(m_monitor_base, "SHOW SLAVE STATUS");
|
check_monitor_permissions(m_monitor, "SHOW SLAVE STATUS");
|
||||||
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
|
for (auto iter = m_servers.begin(); iter != m_servers.end(); iter++)
|
||||||
{
|
{
|
||||||
mysql_close((*iter)->m_server_base->con);
|
mysql_close((*iter)->m_server_base->con);
|
||||||
@ -352,15 +352,15 @@ void MariaDBMonitor::main_loop()
|
|||||||
/* Coarse time has resolution ~1ms (as opposed to 1ns) but this is enough. */
|
/* Coarse time has resolution ~1ms (as opposed to 1ns) but this is enough. */
|
||||||
clock_gettime(CLOCK_MONOTONIC_COARSE, &loop_start);
|
clock_gettime(CLOCK_MONOTONIC_COARSE, &loop_start);
|
||||||
|
|
||||||
lock_monitor_servers(m_monitor_base);
|
lock_monitor_servers(m_monitor);
|
||||||
/* Read any admin status changes from SERVER->status_pending. */
|
/* Read any admin status changes from SERVER->status_pending. */
|
||||||
if (m_monitor_base->server_pending_changes)
|
if (m_monitor->server_pending_changes)
|
||||||
{
|
{
|
||||||
servers_status_pending_to_current(m_monitor_base);
|
servers_status_pending_to_current(m_monitor);
|
||||||
}
|
}
|
||||||
/* Update MXS_MONITORED_SERVER->pending_status. This is where the monitor loop writes it's findings.
|
/* Update MXS_MONITORED_SERVER->pending_status. This is where the monitor loop writes it's findings.
|
||||||
* Also, backup current status so that it can be compared to any deduced state. */
|
* Also, backup current status so that it can be compared to any deduced state. */
|
||||||
for (auto mon_srv = m_monitor_base->monitored_servers; mon_srv; mon_srv = mon_srv->next)
|
for (auto mon_srv = m_monitor->monitored_servers; mon_srv; mon_srv = mon_srv->next)
|
||||||
{
|
{
|
||||||
auto status = mon_srv->server->status;
|
auto status = mon_srv->server->status;
|
||||||
mon_srv->pending_status = status;
|
mon_srv->pending_status = status;
|
||||||
@ -368,13 +368,13 @@ void MariaDBMonitor::main_loop()
|
|||||||
}
|
}
|
||||||
/* Avoid reading/writing SERVER->status while servers are not locked. Routers read the state
|
/* Avoid reading/writing SERVER->status while servers are not locked. Routers read the state
|
||||||
* all the time. */
|
* all the time. */
|
||||||
release_monitor_servers(m_monitor_base);
|
release_monitor_servers(m_monitor);
|
||||||
|
|
||||||
// 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++)
|
||||||
{
|
{
|
||||||
MariaDBServer* server = *iter;
|
MariaDBServer* server = *iter;
|
||||||
server->update_server(m_monitor_base);
|
server->update_server(m_monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the information to find the so far best master server.
|
// Use the information to find the so far best master server.
|
||||||
@ -462,18 +462,18 @@ void MariaDBMonitor::main_loop()
|
|||||||
* rewritten next loop. TODO: make versions of log_master_changes() and mon_process_state_changes()
|
* rewritten next loop. TODO: make versions of log_master_changes() and mon_process_state_changes()
|
||||||
* which read from MXS_MONITORED_SERVER->pending_status instead of SERVER->status. Then this locking
|
* which read from MXS_MONITORED_SERVER->pending_status instead of SERVER->status. Then this locking
|
||||||
* and releasing can be moved after failover etc and the user changes can be applied gracefully. */
|
* and releasing can be moved after failover etc and the user changes can be applied gracefully. */
|
||||||
lock_monitor_servers(m_monitor_base);
|
lock_monitor_servers(m_monitor);
|
||||||
if (m_monitor_base->server_pending_changes)
|
if (m_monitor->server_pending_changes)
|
||||||
{
|
{
|
||||||
MXS_WARNING("MaxAdmin or REST API modified the state of a server monitored by '%s' during a "
|
MXS_WARNING("MaxAdmin or REST API modified the state of a server monitored by '%s' during a "
|
||||||
"monitor iteration. Discarding the monitor results and retrying.",
|
"monitor iteration. Discarding the monitor results and retrying.",
|
||||||
m_monitor_base->name);
|
m_monitor->name);
|
||||||
release_monitor_servers(m_monitor_base);
|
release_monitor_servers(m_monitor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Update shared status.
|
// Update shared status.
|
||||||
for (auto mon_srv = m_monitor_base->monitored_servers; mon_srv; mon_srv = mon_srv->next)
|
for (auto mon_srv = m_monitor->monitored_servers; mon_srv; mon_srv = mon_srv->next)
|
||||||
{
|
{
|
||||||
auto new_status = mon_srv->pending_status;
|
auto new_status = mon_srv->pending_status;
|
||||||
auto srv = mon_srv->server;
|
auto srv = mon_srv->server;
|
||||||
@ -481,7 +481,7 @@ void MariaDBMonitor::main_loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if monitor events need to be launched. */
|
/* Check if monitor events need to be launched. */
|
||||||
mon_process_state_changes(m_monitor_base, m_script.c_str(), m_events);
|
mon_process_state_changes(m_monitor, m_script.c_str(), m_events);
|
||||||
m_cluster_modified = false;
|
m_cluster_modified = false;
|
||||||
if (m_auto_failover)
|
if (m_auto_failover)
|
||||||
{
|
{
|
||||||
@ -508,9 +508,9 @@ void MariaDBMonitor::main_loop()
|
|||||||
enforce_read_only_on_slaves();
|
enforce_read_only_on_slaves();
|
||||||
}
|
}
|
||||||
|
|
||||||
mon_hangup_failed_servers(m_monitor_base);
|
mon_hangup_failed_servers(m_monitor);
|
||||||
store_server_journal(m_monitor_base, m_master ? m_master->m_server_base : NULL);
|
store_server_journal(m_monitor, m_master ? m_master->m_server_base : NULL);
|
||||||
release_monitor_servers(m_monitor_base);
|
release_monitor_servers(m_monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check how much the monitor should sleep to get one full monitor interval.
|
// Check how much the monitor should sleep to get one full monitor interval.
|
||||||
@ -518,12 +518,12 @@ void MariaDBMonitor::main_loop()
|
|||||||
clock_gettime(CLOCK_MONOTONIC_COARSE, &loop_end);
|
clock_gettime(CLOCK_MONOTONIC_COARSE, &loop_end);
|
||||||
int64_t time_elapsed_ms = (loop_end.tv_sec - loop_start.tv_sec) * 1000 +
|
int64_t time_elapsed_ms = (loop_end.tv_sec - loop_start.tv_sec) * 1000 +
|
||||||
(loop_end.tv_nsec - loop_start.tv_nsec) / 1000000;
|
(loop_end.tv_nsec - loop_start.tv_nsec) / 1000000;
|
||||||
int64_t sleep_time_remaining = m_monitor_base->interval - time_elapsed_ms;
|
int64_t sleep_time_remaining = m_monitor->interval - time_elapsed_ms;
|
||||||
// Sleep at least one full interval.
|
// Sleep at least one full interval.
|
||||||
sleep_time_remaining = MXS_MAX(MXS_MON_BASE_INTERVAL_MS, sleep_time_remaining);
|
sleep_time_remaining = MXS_MAX(MXS_MON_BASE_INTERVAL_MS, sleep_time_remaining);
|
||||||
/* Sleep in small increments to react faster to some events. This should ideally use some type of
|
/* Sleep in small increments to react faster to some events. This should ideally use some type of
|
||||||
* notification mechanism. */
|
* notification mechanism. */
|
||||||
while (sleep_time_remaining > 0 && !m_shutdown && !m_monitor_base->server_pending_changes)
|
while (sleep_time_remaining > 0 && !m_shutdown && !m_monitor->server_pending_changes)
|
||||||
{
|
{
|
||||||
int small_sleep_ms = (sleep_time_remaining >= MXS_MON_BASE_INTERVAL_MS) ?
|
int small_sleep_ms = (sleep_time_remaining >= MXS_MON_BASE_INTERVAL_MS) ?
|
||||||
MXS_MON_BASE_INTERVAL_MS : sleep_time_remaining;
|
MXS_MON_BASE_INTERVAL_MS : sleep_time_remaining;
|
||||||
@ -655,7 +655,7 @@ void MariaDBMonitor::handle_auto_rejoin()
|
|||||||
{
|
{
|
||||||
MXS_ERROR("A cluster join operation failed, disabling automatic rejoining. "
|
MXS_ERROR("A cluster join operation failed, disabling automatic rejoining. "
|
||||||
"To re-enable, manually set '%s' to 'true' for monitor '%s' via MaxAdmin or "
|
"To re-enable, manually set '%s' to 'true' for monitor '%s' via MaxAdmin or "
|
||||||
"the REST API.", CN_AUTO_REJOIN, m_monitor_base->name);
|
"the REST API.", CN_AUTO_REJOIN, m_monitor->name);
|
||||||
m_auto_rejoin = false;
|
m_auto_rejoin = false;
|
||||||
disable_setting(CN_AUTO_REJOIN);
|
disable_setting(CN_AUTO_REJOIN);
|
||||||
}
|
}
|
||||||
@ -879,7 +879,7 @@ void MariaDBMonitor::set_slave_heartbeat(MariaDBServer* server)
|
|||||||
if (rlag >= 0)
|
if (rlag >= 0)
|
||||||
{
|
{
|
||||||
/* store rlag only if greater than monitor sampling interval */
|
/* store rlag only if greater than monitor sampling interval */
|
||||||
database->server->rlag = ((unsigned int)rlag > (m_monitor_base->interval / 1000)) ? rlag : 0;
|
database->server->rlag = ((unsigned int)rlag > (m_monitor->interval / 1000)) ? rlag : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -934,7 +934,7 @@ void MariaDBMonitor::disable_setting(const char* setting)
|
|||||||
MXS_CONFIG_PARAMETER p = {};
|
MXS_CONFIG_PARAMETER p = {};
|
||||||
p.name = const_cast<char*>(setting);
|
p.name = const_cast<char*>(setting);
|
||||||
p.value = const_cast<char*>("false");
|
p.value = const_cast<char*>("false");
|
||||||
monitor_add_parameters(m_monitor_base, &p);
|
monitor_add_parameters(m_monitor, &p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -944,7 +944,7 @@ void MariaDBMonitor::disable_setting(const char* setting)
|
|||||||
void MariaDBMonitor::load_journal()
|
void MariaDBMonitor::load_journal()
|
||||||
{
|
{
|
||||||
MXS_MONITORED_SERVER* master_output = NULL;
|
MXS_MONITORED_SERVER* master_output = NULL;
|
||||||
load_server_journal(m_monitor_base, &master_output);
|
load_server_journal(m_monitor, &master_output);
|
||||||
m_master = master_output ? get_server_info(master_output) : NULL;
|
m_master = master_output ? get_server_info(master_output) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ public:
|
|||||||
bool manual_rejoin(SERVER* rejoin_server, json_t** output);
|
bool manual_rejoin(SERVER* rejoin_server, json_t** output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MXS_MONITOR* m_monitor_base; /**< Generic monitor object */
|
MXS_MONITOR* m_monitor; /**< Generic monitor object */
|
||||||
THREAD m_thread; /**< Monitor thread */
|
THREAD m_thread; /**< Monitor thread */
|
||||||
unsigned long m_id; /**< Monitor ID */
|
unsigned long m_id; /**< Monitor ID */
|
||||||
volatile bool m_shutdown; /**< Should the monitor shut down? */
|
volatile bool m_shutdown; /**< Should the monitor shut down? */
|
||||||
|
Reference in New Issue
Block a user