MXS-1775 Factor out post-processing
Further adjustments for being able to move MariaDBMonitor on top of MonitorInstance::main().
This commit is contained in:
@ -200,6 +200,13 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual void post_loop();
|
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_MONITOR* m_monitor; /**< The generic monitor structure. */
|
||||||
MXS_MONITORED_SERVER* m_master; /**< Master server */
|
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()
|
void MonitorInstance::main()
|
||||||
{
|
{
|
||||||
pre_loop();
|
pre_loop();
|
||||||
@ -2916,11 +2921,7 @@ void MonitorInstance::main()
|
|||||||
|
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
/**
|
process_state_changes();
|
||||||
* 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);
|
|
||||||
|
|
||||||
mon_hangup_failed_servers(m_monitor);
|
mon_hangup_failed_servers(m_monitor);
|
||||||
store_server_journal(m_monitor, m_master);
|
store_server_journal(m_monitor, m_master);
|
||||||
|
|||||||
@ -305,6 +305,38 @@ void MariaDBMonitor::pre_loop()
|
|||||||
m_log_no_master = true;
|
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()
|
void MariaDBMonitor::main()
|
||||||
{
|
{
|
||||||
pre_loop();
|
pre_loop();
|
||||||
@ -423,33 +455,11 @@ void MariaDBMonitor::main()
|
|||||||
mon_srv->server->status = mon_srv->pending_status;
|
mon_srv->server->status = mon_srv->pending_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if monitor events need to be launched. */
|
/* log master detection failure of first master becomes available after failure */
|
||||||
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_changes(root_master);
|
log_master_changes(root_master);
|
||||||
|
|
||||||
// Do not auto-join servers on this monitor loop if a failover (or any other cluster modification)
|
/* Check if monitor events need to be launched. */
|
||||||
// has been performed, as server states have not been updated yet. It will happen next iteration.
|
process_state_changes();
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
mon_hangup_failed_servers(m_monitor);
|
mon_hangup_failed_servers(m_monitor);
|
||||||
store_server_journal(m_monitor, m_master ? m_master->m_server_base : NULL);
|
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 update_server_status(MXS_MONITORED_SERVER* pMonitored_server);
|
||||||
void pre_loop();
|
void pre_loop();
|
||||||
void main();
|
void main();
|
||||||
|
void tick();
|
||||||
|
void process_state_changes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned long m_id; /**< Monitor ID */
|
unsigned long m_id; /**< Monitor ID */
|
||||||
|
|||||||
Reference in New Issue
Block a user