MXS-1775 Move MariaDBMonitor functionality to tick
Now all is set for moving MariaDBMonitor on top of MonitorInstance::main.
This commit is contained in:
@ -307,49 +307,6 @@ void MariaDBMonitor::pre_loop()
|
|||||||
|
|
||||||
void MariaDBMonitor::tick()
|
void MariaDBMonitor::tick()
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
void MariaDBMonitor::process_state_changes()
|
|
||||||
{
|
|
||||||
MonitorInstance::process_state_changes();
|
|
||||||
|
|
||||||
m_cluster_modified = false;
|
|
||||||
if (m_auto_failover)
|
|
||||||
{
|
|
||||||
m_cluster_modified = handle_auto_failover();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not auto-join servers on this monitor loop if a failover (or any other cluster modification)
|
|
||||||
// has been performed, as server states have not been updated yet. It will happen next iteration.
|
|
||||||
if (!config_get_global_options()->passive && m_auto_rejoin && !m_cluster_modified &&
|
|
||||||
cluster_can_be_joined())
|
|
||||||
{
|
|
||||||
// Check if any servers should be autojoined to the cluster and try to join them.
|
|
||||||
handle_auto_rejoin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if any slave servers have read-only off and turn it on if user so wishes. Again, do not
|
|
||||||
* perform this if cluster has been modified this loop since it may not be clear which server
|
|
||||||
* should be a slave. */
|
|
||||||
if (!config_get_global_options()->passive && m_enforce_read_only_slaves && !m_cluster_modified)
|
|
||||||
{
|
|
||||||
enforce_read_only_on_slaves();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MariaDBMonitor::main()
|
|
||||||
{
|
|
||||||
pre_loop();
|
|
||||||
|
|
||||||
while (!should_shutdown())
|
|
||||||
{
|
|
||||||
atomic_add_uint64(&m_monitor->ticks, 1);
|
|
||||||
timespec loop_start;
|
|
||||||
/* Coarse time has resolution ~1ms (as opposed to 1ns) but this is enough. */
|
|
||||||
clock_gettime(CLOCK_MONOTONIC_COARSE, &loop_start);
|
|
||||||
|
|
||||||
/* Read any admin status changes from SERVER->status_pending. */
|
|
||||||
monitor_check_maintenance_requests(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->monitored_servers; mon_srv; mon_srv = mon_srv->next)
|
for (auto mon_srv = m_monitor->monitored_servers; mon_srv; mon_srv = mon_srv->next)
|
||||||
@ -457,6 +414,51 @@ void MariaDBMonitor::main()
|
|||||||
|
|
||||||
/* log master detection failure of first master becomes available after failure */
|
/* log master detection failure of first master becomes available after failure */
|
||||||
log_master_changes(root_master);
|
log_master_changes(root_master);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MariaDBMonitor::process_state_changes()
|
||||||
|
{
|
||||||
|
MonitorInstance::process_state_changes();
|
||||||
|
|
||||||
|
m_cluster_modified = false;
|
||||||
|
if (m_auto_failover)
|
||||||
|
{
|
||||||
|
m_cluster_modified = handle_auto_failover();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not auto-join servers on this monitor loop if a failover (or any other cluster modification)
|
||||||
|
// has been performed, as server states have not been updated yet. It will happen next iteration.
|
||||||
|
if (!config_get_global_options()->passive && m_auto_rejoin && !m_cluster_modified &&
|
||||||
|
cluster_can_be_joined())
|
||||||
|
{
|
||||||
|
// Check if any servers should be autojoined to the cluster and try to join them.
|
||||||
|
handle_auto_rejoin();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if any slave servers have read-only off and turn it on if user so wishes. Again, do not
|
||||||
|
* perform this if cluster has been modified this loop since it may not be clear which server
|
||||||
|
* should be a slave. */
|
||||||
|
if (!config_get_global_options()->passive && m_enforce_read_only_slaves && !m_cluster_modified)
|
||||||
|
{
|
||||||
|
enforce_read_only_on_slaves();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MariaDBMonitor::main()
|
||||||
|
{
|
||||||
|
pre_loop();
|
||||||
|
|
||||||
|
while (!should_shutdown())
|
||||||
|
{
|
||||||
|
atomic_add_uint64(&m_monitor->ticks, 1);
|
||||||
|
timespec loop_start;
|
||||||
|
/* Coarse time has resolution ~1ms (as opposed to 1ns) but this is enough. */
|
||||||
|
clock_gettime(CLOCK_MONOTONIC_COARSE, &loop_start);
|
||||||
|
|
||||||
|
/* Read any admin status changes from SERVER->status_pending. */
|
||||||
|
monitor_check_maintenance_requests(m_monitor);
|
||||||
|
|
||||||
|
tick();
|
||||||
|
|
||||||
/* Check if monitor events need to be launched. */
|
/* Check if monitor events need to be launched. */
|
||||||
process_state_changes();
|
process_state_changes();
|
||||||
|
|||||||
Reference in New Issue
Block a user