MXS-1775 MariaDBMonitor::main() removed

Now uses MonitorInstance::main() as all other monitors.
This commit is contained in:
Johan Wikman 2018-06-05 15:53:41 +03:00
parent 44b1e805a3
commit 18ece193bb
3 changed files with 1 additions and 49 deletions

View File

@ -181,11 +181,6 @@ protected:
*/
virtual void tick();
/**
* TODO: Temporarily virtual so that MariaDBMonitor can override.
*/
virtual void main();
/**
* @brief Called before the monitor loop is started
*
@ -219,6 +214,7 @@ private:
uint64_t m_events; /**< Enabled monitor events. */
Semaphore m_semaphore; /**< Semaphore for synchronizing with monitor thread. */
void main();
static void main(void* pArg);
};

View File

@ -444,49 +444,6 @@ void MariaDBMonitor::process_state_changes()
}
}
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. */
process_state_changes();
mon_hangup_failed_servers(m_monitor);
store_server_journal(m_monitor, m_master ? m_master->m_server_base : NULL);
// Check how much the monitor should sleep to get one full monitor interval.
timespec loop_end;
clock_gettime(CLOCK_MONOTONIC_COARSE, &loop_end);
int64_t time_elapsed_ms = (loop_end.tv_sec - loop_start.tv_sec) * 1000 +
(loop_end.tv_nsec - loop_start.tv_nsec) / 1000000;
int64_t sleep_time_remaining = m_monitor->interval - time_elapsed_ms;
// Sleep at least one full interval.
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
* notification mechanism. */
while (sleep_time_remaining > 0 && !should_shutdown() &&
atomic_load_int(&m_monitor->check_maintenance_flag) == MAINTENANCE_FLAG_NOCHECK)
{
int small_sleep_ms = (sleep_time_remaining >= MXS_MON_BASE_INTERVAL_MS) ?
MXS_MON_BASE_INTERVAL_MS : sleep_time_remaining;
thread_millisleep(small_sleep_ms);
sleep_time_remaining -= small_sleep_ms;
}
}
}
void MariaDBMonitor::update_gtid_domain()
{
int64_t domain = m_master->m_gtid_domain_id;

View File

@ -101,7 +101,6 @@ public:
protected:
void update_server_status(MXS_MONITORED_SERVER* pMonitored_server);
void pre_loop();
void main();
void tick();
void process_state_changes();