Persist server changes to services

When a service is added or removed from a service, a supplementary
configuration file is created. This allows MaxScale to survive restars and
unexpected downtime even if runtime changes to the servers of a service
have been made.

With these changes, it is possible to start MaxScale without any servers,
create servers, add the created servers to services and monitors and
restart Maxscale without losing the runtime configuration changes.
This commit is contained in:
Markus Makela
2016-11-12 22:49:27 +02:00
parent a17aa28eed
commit 878d01e276
3 changed files with 136 additions and 32 deletions

View File

@ -200,7 +200,7 @@ extern int serviceHasProtocol(SERVICE *service, const char *protocol,
const char* address, unsigned short port);
extern void serviceAddBackend(SERVICE *, SERVER *);
extern void serviceRemoveBackend(SERVICE *, const SERVER *);
extern int serviceHasBackend(SERVICE *, SERVER *);
extern bool serviceHasBackend(SERVICE *, SERVER *);
extern void serviceAddRouterOption(SERVICE *, char *);
extern void serviceClearRouterOptions(SERVICE *);
extern int serviceStart(SERVICE *);
@ -264,4 +264,20 @@ static inline uint64_t service_get_capabilities(const SERVICE *service)
*/
bool service_server_in_use(const SERVER *server);
/**
* @brief Serialize a service to a file
*
* This partially converts @c service into an INI format file. Only the servers
* of the service are serialized. This allows the service to keep using the servers
* added at runtime even after a restart.
*
* NOTE: This does not persist the complete service configuration and requires
* that an existing service configuration is in the main configuration file.
* Changes to service parameters are not persisted.
*
* @param service Service to serialize
* @return False if the serialization of the service fails, true if it was successful
*/
bool service_serialize_servers(const SERVICE *service);
MXS_END_DECLS