MXS-2314 Server added to monitor should be added to service
If the servers of a service are defined by a monitor (the config has 'cluster=SomeMonitor'), then the addition of a server to a a monitor should lead to that server being added to the service.
This commit is contained in:
parent
0e3ec06c5b
commit
ab93216064
@ -417,5 +417,13 @@ json_t* service_relations_to_filter(const SFilterDef& filter, const char* host);
|
||||
*/
|
||||
void service_add_server(Monitor* pMonitor, SERVER* pServer);
|
||||
|
||||
/**
|
||||
* @brief Remove server from all services associated with a monitor
|
||||
*
|
||||
* @param monitor A monitor.
|
||||
* @param server A server.
|
||||
*/
|
||||
void service_remove_server(Monitor* pMonitor, SERVER* pServer);
|
||||
|
||||
std::unique_ptr<ResultSet> serviceGetList(void);
|
||||
std::unique_ptr<ResultSet> serviceGetListenerList(void);
|
||||
|
@ -384,6 +384,8 @@ bool monitor_add_server(Monitor* mon, SERVER* server)
|
||||
mon->m_servers.push_back(db);
|
||||
}
|
||||
|
||||
service_add_server(mon, server);
|
||||
|
||||
if (old_state == MONITOR_STATE_RUNNING)
|
||||
{
|
||||
MonitorManager::monitor_start(mon, mon->parameters);
|
||||
@ -450,6 +452,8 @@ void monitor_remove_server(Monitor* mon, SERVER* server)
|
||||
if (ptr)
|
||||
{
|
||||
monitor_server_free(ptr);
|
||||
|
||||
service_remove_server(mon, server);
|
||||
}
|
||||
|
||||
if (old_state == MONITOR_STATE_RUNNING)
|
||||
|
@ -161,6 +161,19 @@ void service_add_server(Monitor* pMonitor, SERVER* pServer)
|
||||
}
|
||||
}
|
||||
|
||||
void service_remove_server(Monitor* pMonitor, SERVER* pServer)
|
||||
{
|
||||
LockGuard guard(this_unit.lock);
|
||||
|
||||
for (Service* pService : this_unit.services)
|
||||
{
|
||||
if (pService->m_monitor == pMonitor)
|
||||
{
|
||||
serviceRemoveBackend(pService, pServer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Service::Service(const std::string& service_name,
|
||||
const std::string& router_name,
|
||||
MXS_CONFIG_PARAMETER* params)
|
||||
|
Loading…
x
Reference in New Issue
Block a user