134 Commits

Author SHA1 Message Date
Johan Wikman
ab9a9f92cb MXS-2020 Remove maxscale/debug.h
- Removed from all files.
- maxbase/assert.h included where necessary.
2018-08-22 11:35:35 +03:00
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +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
Johan Wikman
88f1795412 MXS-2008 Move Worker and MessageQueue to maxbase 2018-08-21 10:02:39 +03:00
Markus Mäkelä
02ed338afa
Remove mxs::Closer<json_t*>
As std::unique_ptr can now be used with a json_t, there's no need for the
closer.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
e5c2b1a8c4
Create JSON serialization from object parameters
The services, monitors and filters now construct the JSON format
parameters from the configuration parameters. This reduces the need for
the amount of explicit operations and makes adding new parameters easier.
2018-08-20 13:56:59 +03:00
Markus Mäkelä
a9ff2a7056
MXS-1929: Serialize objects using parameters
The main "non-static" objects are now serialized using their
parameters. This makes it possible to use common code for most modules.
2018-08-20 13:56:59 +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ä
3c20b47a8d
Change parameters in dump_param
Putting the file descriptor first keeps it in line with dprintf.

Making the parameter set an initializer list allows matching against
multiple sets of parameters in one function call. This will compact the
parameter serialization by using the same code for the common service
parameters and the module parameters.
2018-08-20 13:56:59 +03:00
Johan Wikman
40a5ae81c7 MXS-2008 Store worker as MXB_WORKER* and not void* 2018-08-20 11:15:14 +03:00
Johan Wikman
932956d5f6 MXS-2008 Add maxbase/poll.[h|hh]
Remove maxscale/poll_core.h
2018-08-20 11:15:14 +03:00
Markus Mäkelä
af70dc3973
Fix build failures
Fixed build failures caused by merges and rebases.
2018-08-17 18:23:04 +03:00
Johan Wikman
d8255d0cac MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:53:54 +03:00
Johan Wikman
17418572f9 MXS-2014 Move maxscale/jansson.h to maxbase/jansson.h 2018-08-16 09:58:00 +03:00
Johan Wikman
8e624f48de MXS-2008 Remove Worker dependency on internal/poll.h 2018-08-15 08:41:45 +03:00
Johan Wikman
363750a07c MXS-2008 Slightly cleanup includes
Remove headers that are not actually needed by the including
header.
2018-08-15 08:41:45 +03:00
Markus Mäkelä
0c2bec9fba
MXS-1929: Add config dump helper functions
The functions dump of parameters only if they differ from the
defaults. The check for equality is rather coarse but it should work as
long as all core objects use C++ types correctly e.g. integer are not used
to store boolean values (I'm looking at you, enable_root and
localhost_match_wildcard_host). The boolean type has a specialization to
convert the value to the string format used for all defaults in the core.

This also adds the missing return value checks to the dprintf calls and
reports errors if any are encountered.
2018-08-14 21:51:58 +03:00
Markus Mäkelä
419aefb173
Update basic monitor parameters
All of the monitor parameters are now kept up to date when they are
altered. This simplifies the parameter list generation for the REST API.
2018-08-14 15:08:51 +03:00
Markus Mäkelä
c543525c1b
MXS-2005: Move Logger into maxutils
Moved the logger into the maxutils library as it is a generic
utility. Also moved mxs_strerror into it as it depends on it.
2018-08-14 14:57:34 +03:00
Markus Mäkelä
39ce6c624f
MXS-2005: Remove unused code
Removed skygw_utils and relate files along with the old log manager
code. Also removed file flushing due to it being redundant; messages are
written to the file immediately. Adjusted tests to accommodate this
change.
2018-08-14 14:57:33 +03:00
Markus Mäkelä
1326b3a950
MXS-2005: Add Logger class
The interface defines a very simple logging API. The main logger,
FileLogger, implements a very basic logger that writes to a file. The
StdoutLogger implements a logger that simply writes to stdout.

The logging to shm could be implemented quite easily but the usefulness of
it is very questionable and it has the problem of losing log files on a
server shutdown. A ring buffer of INFO messages would be more useful and
would provide a way to limit the amount of memory used for it.
2018-08-14 14:57:33 +03:00
Johan Wikman
f9ba8824d4 MXS-2004 Remove additional dependencies on maxscale/thread.h 2018-08-13 13:38:39 +03:00
Esa Korhonen
eab0a22518 Use parameters list when converting monitor parameters to json
The json conversion now processes the general monitor parameters similarly
to the module-specific settings.
2018-08-13 11:18:04 +03:00
Johan Wikman
6335d3776c MXS-2002 Replace auto_ptr with unique_ptr
Given 'Derived : public Base', a unique_ptr<Derived> converts
implictly to a unique_ptr<Base>.
2018-08-13 08:30:05 +03:00
Johan Wikman
9cfd451a1d MXS-2002 Make Worker excecution mode explicit
This is the first step in some cleanup of the Worker interface.
The execution mode must now be explicitly specified, but that is
just a temporary step. Further down the road, _posting_ will
*always* mean via the message loop while _executing_ will optionally
and by default mean direct execution if the calling thread is that
of the worker.
2018-08-13 08:30:05 +03:00
Esa Korhonen
b9ec3f5130 Monitor json diagnostics printing cleanup
The 'events' and 'script' config values were defined for every monitor.
Removed the extra definitions and moved the variables to MXS_MONITOR.

MariaDBMonitor was printing config values a second time, they are
already printed by the caller.

Moved the events enum definition to the internal header since it's no longer
required by modules.

Added a default config setting "all" to 'events' to clarify that it enables
all events.
2018-08-10 11:19:09 +03:00
Markus Mäkelä
6661680c4e
MXS-1929: Add direct filter relationship updates
The filters of a service can now be directly updated via the relationships
endpoint.
2018-08-10 09:53:33 +03:00
Markus Mäkelä
7c627144fb
Fix basic parameters
The ssl parameters were defined as strings even thought they were actually
enums. The events parameter was also a string even though it was an enum.

Also added the missing "all" value to the events enum. This fixes the
regression of scripts not being launched on all events by default.

Moved the definition of the default version string where it should be and
removed the empty value check.
2018-08-10 09:50:56 +03:00
Markus Mäkelä
ac098c4a02
Check validity of size types
The get_suffixed_size function is now exposed in the internal config
header and it also checks for the validity of the size types.

Took the new function into use and added the appropriate error messages.
2018-08-10 09:44:44 +03:00
Johan Wikman
f14380243b Rename cppdefs.hh to ccdefs.hh
For obvious reasons; the c++ suffix is .cc and not .cpp
2018-08-10 07:50:18 +03:00
Johan Wikman
326bb88f70 MXS-1992 Expose config.cc:runtime_error as config_runtime_error 2018-08-08 09:17:58 +03:00
Johan Wikman
1b521b16a9 MXS-1992 Move QC json "parsing" to query_classifier.cc 2018-08-08 09:17:15 +03:00
Johan Wikman
2188090742 MXS-1992 Expose type checking functions of config_runtime.cc
The functions

bool runtime_is_string_or_null(json_t* json, const char* path);
bool runtime_is_bool_or_null(json_t* json, const char* path);
bool runtime_is_count_or_null(json_t* json, const char* path);

can now be called from anywhere inside MaxScale.
2018-08-08 09:17:15 +03:00
Johan Wikman
185758ef06 MXS-1992 Allow changing the QC cache size 2018-08-08 09:17:15 +03:00
Johan Wikman
bb77ae7b95 MXS-1992 Rename internal/query_classifier.h to .hh 2018-08-08 09:16:19 +03:00
Johan Wikman
fbd3b08c1e MXS-1992 Make preparations for REST-API 2018-08-08 09:16:19 +03:00
Markus Mäkelä
9d30c524e3
MXS-1929: Fix mock testing framework
The testing framework extended the public struct, not the private
one. Also moved the internal Session class inside the mxs namespace to
prevent conflicts with the mock testing Session class.
2018-08-06 21:20:29 +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ä
2e60d5fd71
MXS-1929: Store filters inside Session
The Session now holds a reference to the filters it uses. This makes the
use of filters safe even if they are destroyed mid-session.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
7e64d6b3df
MXS-1929: Move use of C++ inside the Session
The Session class now handles the work involved in dealing with the
private member variables.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
945510e735
MXS-1929: Add Session class
The Session class now contains all of the C++ objects that were previously
in the MXS_SESSION struct. It is also allocated with new but all
initialization is still done outside of the Session in session_alloc_body.

This commit will not compile as it is a part of a set of commits that make
parts of the session private.
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