MXS-1775 Factor out post-processing
Further adjustments for being able to move MariaDBMonitor on top of MonitorInstance::main().
This commit is contained in:
parent
71194d83d3
commit
329a6df662
@ -200,6 +200,13 @@ protected:
|
||||
*/
|
||||
virtual void post_loop();
|
||||
|
||||
/**
|
||||
* @brief Called after tick returns
|
||||
*
|
||||
* The default implementation will call @mon_process_state_changes.
|
||||
*/
|
||||
virtual void process_state_changes();
|
||||
|
||||
MXS_MONITOR* m_monitor; /**< The generic monitor structure. */
|
||||
MXS_MONITORED_SERVER* m_master; /**< Master server */
|
||||
|
||||
|
@ -2906,6 +2906,11 @@ void MonitorInstance::post_loop()
|
||||
{
|
||||
}
|
||||
|
||||
void MonitorInstance::process_state_changes()
|
||||
{
|
||||
mon_process_state_changes(m_monitor, m_script.empty() ? NULL : m_script.c_str(), m_events);
|
||||
}
|
||||
|
||||
void MonitorInstance::main()
|
||||
{
|
||||
pre_loop();
|
||||
@ -2916,11 +2921,7 @@ void MonitorInstance::main()
|
||||
|
||||
tick();
|
||||
|
||||
/**
|
||||
* After updating the status of all servers, check if monitor events
|
||||
* need to be launched.
|
||||
*/
|
||||
mon_process_state_changes(m_monitor, m_script.empty() ? NULL : m_script.c_str(), m_events);
|
||||
process_state_changes();
|
||||
|
||||
mon_hangup_failed_servers(m_monitor);
|
||||
store_server_journal(m_monitor, m_master);
|
||||
|
@ -305,6 +305,38 @@ void MariaDBMonitor::pre_loop()
|
||||
m_log_no_master = true;
|
||||
}
|
||||
|
||||
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();
|
||||
@ -423,33 +455,11 @@ void MariaDBMonitor::main()
|
||||
mon_srv->server->status = mon_srv->pending_status;
|
||||
}
|
||||
|
||||
/* Check if monitor events need to be launched. */
|
||||
mon_process_state_changes(m_monitor, m_script.c_str(), m_events);
|
||||
m_cluster_modified = false;
|
||||
if (m_auto_failover)
|
||||
{
|
||||
m_cluster_modified = handle_auto_failover();
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
// 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();
|
||||
}
|
||||
/* Check if monitor events need to be launched. */
|
||||
process_state_changes();
|
||||
|
||||
mon_hangup_failed_servers(m_monitor);
|
||||
store_server_journal(m_monitor, m_master ? m_master->m_server_base : NULL);
|
||||
|
@ -102,6 +102,8 @@ protected:
|
||||
void update_server_status(MXS_MONITORED_SERVER* pMonitored_server);
|
||||
void pre_loop();
|
||||
void main();
|
||||
void tick();
|
||||
void process_state_changes();
|
||||
|
||||
private:
|
||||
unsigned long m_id; /**< Monitor ID */
|
||||
|
Loading…
x
Reference in New Issue
Block a user