11464 Commits

Author SHA1 Message Date
Johan Wikman
3576780f78 MXS-2008 Update gateway and tests to initialize maxbase
Update gateway and tests to initialize maxbase using

  maxbase::init();

instead of initializing individual components.
2018-08-21 10:02:39 +03:00
Johan Wikman
e852dcacdd MXS-2008 Provide single entrypoint for initializing maxbase
Everything of maxbase can now be initialized by a call to

    maxbase_init();

(from a C-program) or

    maxbase::init();

from a C++-program and finalized with calls to either
maxbase_finish() or maxbase::finish(). Creating an instance
maxbase::MaxBase will take care of both operations.
2018-08-21 10:02:39 +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ä
0a0623003e
MXS-1929: Factor out parameter validation
The parameter validation for all module types follows roughly the same
path: first check whether it's a known parameter and then whether the
value is valid. This can be moved into common functions that removes
duplicated code.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
20994351ef
MXS-1929: Fix SSL JSON detection
The SSL initialization should only be attempted if `ssl_key`, `ssl_cert`
or `ssl_ca_cert` is defined. In addition to this, the SSL parameters
requirements for servers and listeners are different: servers require only
`ssl_ca_cert` but listeners require all three.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
eddae78b42
Remove repurposing of servers
This was not very safe or correct. For example statistics and parameters
were reused by a new server.
2018-08-20 13:57:00 +03:00
Markus Mäkelä
6a06654ee9
Serialize servers from parameters
The config and JSON serialization of servers is now from the
parameters. As the server's use a different parameter type, a temporary
adapter was required. Eventually, a lock-free and globally safe way to
"disable" parameters is needed.
2018-08-20 13:56:59 +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
Markus Mäkelä
355768c564
Add overloads to dump_stacktrace
Using a function while debugging helps to see where various functions are
called from.
2018-08-20 13:56:59 +03:00
Markus Mäkelä
fe7a73e5c3
Register atexit functions in the correct place
The atexit functions should be registered after there is a need for
them. This fixes the problem where cleanup functions were called before
the initialization for them was done. Also removed the header and footer
printint to stdout.
2018-08-20 13:56:59 +03:00
Markus Mäkelä
930be8d77a
Fix CMake problems in system test
The paths were wrong in the scripts used to run tests. The same problem
was in the CMake files that used CMAKE_SOURCE_DIR instead of
CMAKE_CURRENT_SOURCE_DIR.

Added missing check for BUILD_SYSTEM_TESTS in avrorouter for the
workaround to building without all dependencies present.
2018-08-20 13:56:58 +03:00
Markus Mäkelä
d428292ec0
Add workaround to building tests without all dependencies
The system tests can be build even if not all of the dependencies for
MaxScale are met.
2018-08-20 13:56:58 +03:00
Markus Mäkelä
67df3ad4f0
Use option() CMake command
This is the appropriate command for ON/OFF options controlled by the
user. Also removed the useless C99 option which must always be on (using
C11 would be another option).
2018-08-20 13:56:58 +03:00
Markus Mäkelä
0685276764
Use correct functions in maxutils CMake files
The headers and the static library were installed unconditionally.
2018-08-20 13:56:58 +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
e0cb11151f MXS-2008 Move maxscale/worker.h to maxbase/worker.h 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
Johan Wikman
8f257a51fe MXS-2008 Remove unused headers from worker.hh
Add corresponding headers to files that depended on those headers.
2018-08-20 11:15:14 +03:00
Johan Wikman
aaad63ee5e MXS-2008 Move content of maxscale/platform.h to maxbase/cdefs.h
No good reason for keeping that platform adjustments anywhere
else but in cdefs.h.
2018-08-20 11:15:14 +03:00
Markus Mäkelä
90960ec07f
Make Worker::run(mxb::Semaphore*) private
The semaphore is only used when Worker::start() is called to synchronize
the startup of the two threads. Also asserted that the state is what we
expected it to be.
2018-08-20 10:10:23 +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
Markus Mäkelä
667e9df97c
Merge branch '2.2' into develop 2018-08-17 18:10:44 +03:00
Markus Mäkelä
208949f1cb
Synchronize the worker thread with the starting thread
This guarantees that the caller of the start function will know whether
the worker is running by looking at its state.

This will prevent multiple successive stop calls to a worker which
happened when the monitors were altered via the REST API.
2018-08-17 18:09:51 +03:00
Markus Mäkelä
9510a3ae1a
Use normal asserts in log.cc
The logger can't use the asserts that log messages as it introduces a
cyclical dependency on the logger itself.
2018-08-17 18:09:51 +03:00
Markus Mäkelä
0fbd789572
MXS-2019: Fix atexit handlers
The code now registers all functions once instead of one function multiple
times.
2018-08-17 17:35:41 +03:00
Johan Wikman
9b199cfb50 Remove duplicate CMakeLists.txt entry
maxutils/maxbase/src/test/CMakeLists.txt
2018-08-17 16:21:58 +03:00
Johan Wikman
b82822a4b0 MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:57:44 +03:00
Johan Wikman
d8255d0cac MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:53:54 +03:00
Markus Mäkelä
25c81b118d
Rename conflicting test 2018-08-17 15:02:03 +03:00
Markus Mäkelä
81853d8d6b
Fix binlogrouter unit test
The test called mxs_log_finish multiple times.
2018-08-17 14:29:28 +03:00
Markus Mäkelä
f09afa2967
Combine regression test suite and main CMake projects
Combining the projects makes it easier to use common components. This
fixes the build failure of maxutils due to missing jansson definitions.
2018-08-17 14:29:28 +03:00
Johan Wikman
c7a6d75ab9 MXS-2014 Address review issues 2018-08-17 10:59:37 +03:00
Johan Wikman
cf0aeed516 MXS-2014 Rename log_manager.h to log.h
There's nothing resembling a manager anymore.
2018-08-17 10:59:37 +03:00
Johan Wikman
894d4eb034 MXS-2014 Explicitly set the MaxScale log identification 2018-08-17 10:59:37 +03:00
Johan Wikman
15bf481120 MXS-2014 Allow the header and footer to be adjusted 2018-08-17 10:59:37 +03:00
Johan Wikman
4388b8517e MXS-2014 Use standard assert in Logger 2018-08-17 10:59:37 +03:00
Johan Wikman
cfdfff46ae MXS-2014 Add skeleton test for mxb::Log 2018-08-17 10:59:37 +03:00
Johan Wikman
12e8f28907 MXS-2014 Add mxb::Log class for convenience
In tests, the log can now be setup as

    int main()
    {
        mxb::Log log;
        ...
    }

That will initialize the log so that it logs to a file called
<program-name>.log in the current directory and finalize it
when the program exits.
2018-08-17 10:59:37 +03:00
Johan Wikman
be986d366a MXS-2014 Handle default OOM message properly 2018-08-17 10:59:37 +03:00
Esa Korhonen
57706e7758 Hide the MonitorInstance m_state field
The field had the same purpose as MXS_MONITOR->state. Now the field
is only used for checking if the MonitorInstance thread is running.
2018-08-17 09:47:32 +03:00
Esa Korhonen
fe5df6d379 Remove duplicate monitor state definitions
The state is still stored in two different variables. Also, removed the
ALLOC and FREED states.
2018-08-17 09:47:32 +03:00
Johan Wikman
876cf7c86f MXS-2014 Temporarily fix broken token pasting 2018-08-16 11:24:01 +03:00
Johan Wikman
19684deb69 MXS-2014 Init and finish properly
If any part of initalization fails, no resources are held.
At finalization, release all resources.

Also re-implement recent changes made to log_manager.cc that
did not automatically move over to log.cc.
2018-08-16 11:09:30 +03:00
Johan Wikman
a586aa13c4 MXS-2014 Add proper OOM support
Not that I think it ever will be needed...
2018-08-16 09:59:43 +03:00
Johan Wikman
85b68c439a MXS-2014 Still more cleanup of maxbase/log.h 2018-08-16 09:59:43 +03:00
Johan Wikman
9a8bb95be6 MXS-2014 Rename mxs_log_priority_is_enabled
- Renamed to mxs_log_is_priority_enabled
- That function instead of the macro is now consistently used
2018-08-16 09:59:43 +03:00