25 Commits

Author SHA1 Message Date
Esa Korhonen
5fc2c1f49c MXS-2220 Store server ports as integers and modify them in methods 2019-01-03 12:13:15 +02:00
Markus Mäkelä
7aa60b4a24
MXS-2196: Start listeners after worker threads
If the startup of the listeners requires communication with all of the
workers, the workers must be up and running for that to happen.

Due to the fact that the main thread is still a worker thread, the
initialization code is not extra straightforward. By queuing an event to
the main worker, the startup of all listeners is done at a fully
operational state with all workers fully functional.

The service initialization code was also flawed in the sense that it would
cause a deadlock if any of the threads would have to check for the user
permissions. This is mainly a problem with the authenticator modules but
the benefits of the per service pre-loading of users is most likely
superficial. In theory startup will be faster as each thread now queries
the users in parallel.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
015c581a5b
MXS-2196: Remove unnecessary functions
The functions for starting listeners aren't needed as the listen method
can be called directly.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
45827dd433
MXS-2196: Store listener reference in DCB
By storing the reference in the DCB, the two-way dependency between the
listeners and services is severed. Now the services have no direct link to
listeners and after the destruction of a listener it will be freed once
all connections through it have closed.

Due to the fact that a listener itself has a DCB that must point to a
valid listener, a self-reference is stored in the listener DCB. This is
extremely confusing and is only here to keep the code functional until the
DCB part of the listener can be factored out.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
a10b6c2e89
MXS-2196: Take Listener into use 2018-12-04 11:39:52 +02:00
Markus Mäkelä
330719c8f9
MXS-2196: Store listener references in Service
By storing a shared pointer to the listeners in the services, they will be
available as long as the service using them exists. This enables clean
destruction of listeners that still have open sessions.

The listener creation code now separately creates the listener and links
it to the service. Also replaced relevant parts of the related code with
the listener implemented versions of it.
2018-12-04 11:39:52 +02:00
Markus Mäkelä
bb295b5cbe
MXS-2196: Remove listeners from services
All access to the listeners of a service are done via the listener
functions.
2018-12-04 11:39:51 +02:00
Markus Mäkelä
77585bdb8c
MXS-2197: Make config.h and service.h C++ headers
This is the first step into converting the other headers into C++.
2018-11-30 12:15:57 +02:00
Niclas Antti
c447e5cf15 Uncrustify maxscale
See script directory for method. The script to run in the top level
MaxScale directory is called maxscale-uncrustify.sh, which uses
another script, list-src, from the same directory (so you need to set
your PATH). The uncrustify version was 0.66.
2018-09-09 22:26:19 +03:00
Niclas Antti
24ab3c099c Move top of the file "#pragma once" to after the following comment (swap them). If the comment is a BPL update it to the latest one 2018-08-21 13:13:15 +03:00
Markus Mäkelä
e2ace578d2
Validate parameters before storing them
The runtime modification of servers, services and monitors now validates
the parameters before starting the update process. This guarantees that
the set of parameters is valid before it is processed.

After the validation, the parameters are now also stored in the list of
configuration parameters. This will simplify the serialization process by
removing the need to explicitly serialize all common object parameters.
2018-08-20 13:56:59 +03:00
Markus Mäkelä
56ede5bbf4
MXS-1929: Remove string parsing from Service
As the filters are only passed as a pipe separated list when the
configuration is being processed, there's no need to have the interface
conform to that. Passing a list of filter names makes it more flexible and
will make it's use in the runtime configuration easier.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
47176d9bf1
MXS-1929: Take local filter lists into use
The session creation function now uses the local filter list of the
worker. This also removes the need for the has_filters function.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
f59fda0d9f
MXS-1929: Move configuration dumping into Service
The service now generates the configuration file that represents the
serialized form of it. Also removed the unused service_serialize_servers
function.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
478d07efc0
MXS-1929: Cache filter lists in workers
The services will now store a local copy of the filter lists in the worker
local data associated with the service. This removes the instance level
lock and removes the performance penalty that was previously imposed by
it.

The only remaining performance "regression" compared to 2.2 is the extra
two atomic operations per filter that a session does when it is being
created. This is quite hard to get rid of without significant amounts code
and will hopefully be just a drop in the ocean.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
3038eb3326
MXS-1929: Move user reloading to Service
The Service class now handles the reloading of users. This removes the
need to expose the rate limits.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
373fb89dca
MXS-1929: Initialize service like a class
The most relevant string variables of a service are now duplicated as C++
strings. This should ease the eventual transition to a fully C++ internal
representation of the service. The array of refresh rates was also wrapped
inside a std::vector to remove the need to manually manage memory.

Separated the SERVICE_USER struct into its individual components as there
was no real need to have them inside a struct.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
7d6338d65b
MXS-1929: Make filters configurable at runtime
The filters can now be altered at runtime. Currently, the filter usage
uses a service level lock. The next is to allocate a per-service key to
the worker local data and use that to orchestrate the storage of the
filter lists.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
5d085f5cdf
MXS-1929: Remove service parameter setters
Removed the explicit setters for the service parameters. Not all of them
were implemented and they were only used internally. Moved the parameter
validation and update processing inside the Service class to reduce the
load on the other parts of the core.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
dc8414db9f
MXS-1929: Remove SPINLOCK from service
The service now has a private std::mutex that is used for
synchronization.

Renamed the vector of services to use snake_case.

Use lock guards with mutexes to make usage easier and safer. This makes
the code smaller as well as slightly easier to read.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
4d3dbb2040
MXS-1929: Take SFilterDef into use
The service now uses a std::vector<SFilterDef> to store the filters it
uses. Most internal parts deal with the SFilterDef but debugcmd.cc still
moves raw pointers around (needs to be changed).
2018-08-06 21:20:29 +03:00
Markus Mäkelä
be6a404c0b
Fix crash on failure to create service
The service would not be in the list if it failed before it was placed
there. Moving the actual freeing of memory into the Service destructor
allows it to be called directly when we know the service is not in the
list. This also only allows valid services to be placed into the global
list of services.

To prevent freeing a partially constructed service, the memory allocation
checks were replaced with a runtime assertion. This can be changed when
the creation of the service is done only at a point where we know it can't
fail. Currently, the createInstance call expects the service as a
parameter which prevents this.
2018-08-02 18:56:36 +03:00
Markus Mäkelä
ec420332ea
MXS-1929: Take ResultSet into use
Replaced the previous RESULTSET with the new implementation. As the new
ResultSet doesn't have a JSON streaming capability, the MaxInfo JSON
interface has been removed. This should not be a big problem as the REST
API offers the same information in a more secure and structured way.
2018-07-31 22:50:08 +03:00
Markus Mäkelä
8ababa1d39
MXS-1929: Make core ResultSet functions private
The functions in the core that generate a ResultSet are now private.
2018-07-31 22:32:32 +03:00
Markus Mäkelä
b0e74ac4ae
MXS-1929: Move internal functions to internal header
Converted the internal service header to a C++ header and moved all
functions there that are for internal use only.

Added the new Service type that inherits the SERVICE struct. This is to
distinct the opaque external C interface from the C++ internals.
2018-07-31 09:41:13 +03:00