MXS-2314 Move journal checking inside Monitor
This commit is contained in:
@ -337,6 +337,13 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void detect_handle_state_changes();
|
void detect_handle_state_changes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the journal stale?
|
||||||
|
*
|
||||||
|
* @return True, if the journal is stale, false otherwise.
|
||||||
|
*/
|
||||||
|
bool journal_is_stale() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when a server has been added to the monitor.
|
* @brief Called when a server has been added to the monitor.
|
||||||
*
|
*
|
||||||
@ -450,8 +457,6 @@ private:
|
|||||||
* @brief The monitor should populate associated services.
|
* @brief The monitor should populate associated services.
|
||||||
*/
|
*/
|
||||||
virtual void populate_services();
|
virtual void populate_services();
|
||||||
|
|
||||||
bool journal_is_stale();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,12 +261,6 @@ void MonitorManager::monitor_start(Monitor* monitor, const MXS_CONFIG_PARAMETER*
|
|||||||
// Only start the monitor if it's stopped.
|
// Only start the monitor if it's stopped.
|
||||||
if (monitor->m_state == MONITOR_STATE_STOPPED)
|
if (monitor->m_state == MONITOR_STATE_STOPPED)
|
||||||
{
|
{
|
||||||
if (monitor->journal_is_stale())
|
|
||||||
{
|
|
||||||
MXS_WARNING("Removing stale journal file for monitor '%s'.", monitor->m_name);
|
|
||||||
remove_server_journal(monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitor->start(params))
|
if (monitor->start(params))
|
||||||
{
|
{
|
||||||
monitor->m_state = MONITOR_STATE_RUNNING;
|
monitor->m_state = MONITOR_STATE_RUNNING;
|
||||||
@ -1861,7 +1855,7 @@ static void store_data(Monitor* monitor, MXS_MONITORED_SERVER* master, uint8_t*
|
|||||||
mxb_assert(ptr - data == size + MMB_LEN_BYTES);
|
mxb_assert(ptr - data == size + MMB_LEN_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_data_file_path(Monitor* monitor, char* path)
|
static int get_data_file_path(const Monitor* monitor, char* path)
|
||||||
{
|
{
|
||||||
int rv = snprintf(path, PATH_MAX, journal_template, get_datadir(), monitor->m_name, journal_name);
|
int rv = snprintf(path, PATH_MAX, journal_template, get_datadir(), monitor->m_name, journal_name);
|
||||||
return rv;
|
return rv;
|
||||||
@ -2183,7 +2177,7 @@ static void remove_server_journal(Monitor* monitor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Monitor::journal_is_stale()
|
bool Monitor::journal_is_stale() const
|
||||||
{
|
{
|
||||||
bool is_stale = true;
|
bool is_stale = true;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
@ -2519,6 +2513,12 @@ bool MonitorWorker::start(const MXS_CONFIG_PARAMETER* pParams)
|
|||||||
mxb_assert(monitor_state() == MONITOR_STATE_STOPPED);
|
mxb_assert(monitor_state() == MONITOR_STATE_STOPPED);
|
||||||
mxb_assert(m_thread_running.load() == false);
|
mxb_assert(m_thread_running.load() == false);
|
||||||
|
|
||||||
|
if (journal_is_stale())
|
||||||
|
{
|
||||||
|
MXS_WARNING("Removing stale journal file for monitor '%s'.", m_name);
|
||||||
|
remove_server_journal(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_checked)
|
if (!m_checked)
|
||||||
{
|
{
|
||||||
if (!has_sufficient_permissions())
|
if (!has_sufficient_permissions())
|
||||||
|
Reference in New Issue
Block a user