MXS-2314 Populate services with servers
The services whose servers are defined using a monitor, will now be populated from the monitor. Note, no consideration has yet been given to runtime changes.
This commit is contained in:
@ -1692,7 +1692,11 @@ static bool process_config_context(CONFIG_CONTEXT* context)
|
||||
}
|
||||
}
|
||||
|
||||
if (error_count)
|
||||
if (error_count == 0)
|
||||
{
|
||||
MonitorManager::populate_services();
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("%d errors were encountered while processing the configuration "
|
||||
"file '%s'.",
|
||||
|
@ -107,6 +107,11 @@ public:
|
||||
static void destroy_all_monitors();
|
||||
|
||||
static void monitor_start(Monitor*, const MXS_CONFIG_PARAMETER*);
|
||||
|
||||
/**
|
||||
* @brief Populate services with the servers of the monitors.
|
||||
*/
|
||||
static void populate_services();
|
||||
};
|
||||
|
||||
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "internal/monitor.hh"
|
||||
#include "internal/modules.hh"
|
||||
#include "internal/server.hh"
|
||||
#include "internal/service.hh"
|
||||
|
||||
/** Schema version, journals must have a matching version */
|
||||
#define MMB_SCHEMA_VERSION 2
|
||||
@ -278,6 +279,14 @@ void MonitorManager::monitor_start(Monitor* monitor, const MXS_CONFIG_PARAMETER*
|
||||
}
|
||||
}
|
||||
|
||||
void MonitorManager::populate_services()
|
||||
{
|
||||
this_unit.foreach_monitor([](Monitor* pMonitor) -> bool {
|
||||
pMonitor->populate_services();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Start all monitors
|
||||
*/
|
||||
@ -2364,8 +2373,16 @@ bool Monitor::clear_server_status(SERVER* srv, int bit, string* errmsg_out)
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
void Monitor::populate_services()
|
||||
{
|
||||
mxb_assert(m_state == MONITOR_STATE_STOPPED);
|
||||
|
||||
for (MXS_MONITORED_SERVER* pMs : m_servers)
|
||||
{
|
||||
service_add_server(this, pMs->server);
|
||||
}
|
||||
}
|
||||
|
||||
void monitor_debug_wait()
|
||||
|
Reference in New Issue
Block a user