MXS-1929: Make services destroyable

Services can now be destroyed if they have no active listeners and they
are not linked to servers. When these conditions are met, the service will
be destroyed when the last session for the service is closed.

The closing of a service will close all listeners that were once assigned
to the service. This allows closing of the ports at runtime which
previously was done only on shutdown.

Exposed the command through the REST API but not through MaxAdmin as it is
deprecated.
This commit is contained in:
Markus Mäkelä
2018-07-18 10:03:54 +03:00
parent 18c1ec2678
commit 5a40064826
7 changed files with 163 additions and 4 deletions

View File

@ -979,8 +979,8 @@ bool runtime_destroy_listener(SERVICE *service, const char *name)
{
rval = true;
MXS_NOTICE("Destroyed listener '%s' for service '%s'. The listener "
"will be removed after the next restart of MaxScale.",
name, service->name);
"will be removed after the next restart of MaxScale or "
"when the associated service is destroyed.", name, service->name);
}
return rval;
@ -1078,6 +1078,26 @@ bool runtime_create_filter(const char *name, const char *module, MXS_CONFIG_PARA
return rval;
}
bool runtime_destroy_service(SERVICE* service)
{
bool rval = false;
mxs::SpinLockGuard guard(crt_lock);
ss_dassert(service && service->active);
if (service_can_be_destroyed(service))
{
service_destroy(service);
rval = true;
}
else
{
runtime_error("Service '%s' cannot be destroyed: Remove all servers and "
"destroy all listeners first", service->name);
}
return rval;
}
bool runtime_destroy_monitor(MXS_MONITOR *monitor)
{
bool rval = false;