MXS-1775 Move monitor loop to MonitorInstance

This commit is contained in:
Johan Wikman
2018-05-17 14:07:12 +03:00
parent db30ea96f2
commit 650a739c92
12 changed files with 61 additions and 236 deletions

View File

@ -238,48 +238,6 @@ monitorDatabase(MXS_MONITORED_SERVER *database, char *defaultUser, char *default
}
}
/**
* The entry point for the monitoring module thread
*
* @param arg The handle of the monitor
*/
void NDBCMonitor::main()
{
load_server_journal(m_monitor, NULL);
while (!m_shutdown)
{
lock_monitor_servers(m_monitor);
servers_status_pending_to_current(m_monitor);
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);
mon_hangup_failed_servers(m_monitor);
servers_status_current_to_pending(m_monitor);
store_server_journal(m_monitor, NULL);
release_monitor_servers(m_monitor);
/** Sleep until the next monitoring interval */
unsigned int ms = 0;
while (ms < m_monitor->interval && !m_shutdown)
{
if (m_monitor->server_pending_changes)
{
// Admin has changed something, skip sleep
break;
}
thread_millisleep(MXS_MON_BASE_INTERVAL_MS);
ms += MXS_MON_BASE_INTERVAL_MS;
}
}
}
void NDBCMonitor::tick()
{
MXS_MONITORED_SERVER *ptr = m_monitor->monitored_servers;

View File

@ -40,6 +40,4 @@ private:
bool has_sufficient_permissions() const;
void configure(const MXS_CONFIG_PARAMETER* params);
void tick();
void main();
};