90 Commits

Author SHA1 Message Date
Johan Wikman
809d3549ae MXS-2149 Add REST-API watchdog
This will simply cause a task to be posted to each worker.
If the workers are running normally, the task will reach the
workers and the associated semaphore posted, and the REST-API
call will return. If any worker is not running normally, the
task will not be processed and the REST-API call will hang.
2018-11-08 12:13:02 +02:00
Johan Wikman
3631388f75 MXS-1779 Add initial support for classification URL
This commit introduces the plumbing support for obtaining
classification information of a statement using the REST-API.
It introduces a URL like

    /v1/maxscale/query_classifier/classify?sql=SELECT+1

that in the response will return a JSON object with the
information. Subsequent commits will provide the actual
information.
2018-10-31 10:19:40 +02:00
Markus Mäkelä
50451166bb
MXS-2067: Remove spinlock.hh
Replaced the C++ versions with standard library mutexes.
2018-09-28 12:18:23 +03: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
Markus Mäkelä
26dfb19ea4
Make routingworker.hh public
Given that worker.hh was public, it made sense to make routingworker.hh
public as well. This removes the need to include private headers in
modules and allows C++ constructs to be used in C++ code when previously
only the C API was available.
2018-09-04 13:04:08 +03:00
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +03:00
Johan Wikman
88f1795412 MXS-2008 Move Worker and MessageQueue to maxbase 2018-08-21 10:02:39 +03:00
Johan Wikman
d8255d0cac MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:53:54 +03:00
Markus Mäkelä
fd5a2305e4
MXS-2005: Take Logger into use in log_manager
The log manager now uses the logger type for logging. Removed some of the
code that depended on the renamed functions to make it compile. The next
step is to remove all unused code in the log manager.
2018-08-14 14:57:33 +03:00
Markus Mäkelä
f9e5d3135d
Allow null parameter values
If a resource parameter is defined as a null JSON value, it is ignored.
2018-08-13 10:28:01 +03:00
Johan Wikman
43b53fda7a MXS-2002 Replace task with std::function 2018-08-13 08:30:05 +03:00
Johan Wikman
e9758ebaf1 MXS-2002 Rename Worker::post() to Worker::execute()
The main point is that tasks/functions are executed, not that
they are posted.
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
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
Johan Wikman
185758ef06 MXS-1992 Allow changing the QC cache size 2018-08-08 09:17:15 +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ä
cca7757090
MXS-1929: Take internal Service struct into use
The internals now mostly refer to the Service struct instead of the public
SERVICE struct.
2018-07-31 09:41:13 +03:00
Markus Mäkelä
829fdcff83
MXS-1929: Make filters fully opaque
The filter implementation is now fully hidden. Also converted it to a C++
struct allocated with new and stored the filters in a global list instead
of embedding the list in the object itself.
2018-07-31 09:41:13 +03:00
Markus Mäkelä
e39242d6e5
MXS-1929: Add filter deletion entry points
Added the code required to delete a filter via the REST API. The actual
deleting of the filters is still to be implemented.
2018-07-31 09:41:11 +03:00
Markus Mäkelä
037cedf70e
MXS-1929: Allow service creation at runtime
Services can now be created at runtime. The command to create services is
exposed in the REST API.
2018-07-31 09:41:07 +03:00
Markus Mäkelä
5a40064826
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.
2018-07-31 09:41:07 +03:00
Markus Mäkelä
2c1f79c5d1
MXS-1929: Add runtime creation of filters
Filters can now be created at runtime. This is not yet a usable feature
since the filters can't be added to services at runtime.
2018-07-31 09:41:05 +03:00
Johan Wikman
8ea7d8898a MXS-1915 Remove id from mxs::Worker
The id has now been moved from mxs::Worker to mxs::RoutingWorker
and the implications are felt in many places.

The primary need for the id was to be able to access worker specfic
data, maintained outside of a routing worker, when given a worker
(the id is used to index into an array). Slightly related to that
was the need to be able to iterate over all workers. That obviously
implies some kind of collection.

That causes all sorts of issues if there is a need for being able
to create and destroy a worker at runtime. With the id removed from
mxs::Worker all those issues are gone, and its perfectly ok to create
and destory mxs::Workers as needed.

Further, while there is a need to broadcast a particular message to
all _routing_ workers, it hardly makes sense to broadcast a particular
message too _all_ workers. Consequently, only routing workers are kept
in a collection and all static member functions dealing with all
workers (e.g. broadcast) have now been moved to mxs::RoutingWorker.

Now, instead of passing the id around we instead deal directly
with the worker pointer. Later the data in all those external arrays
will be moved into mxs::[Worker|RoutingWorker] so that worker related
data is maintained in exactly one place.
2018-06-26 09:19:46 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Esa Korhonen
c039821467 MXS-1883 Maintenance is now the only user-modifiable bit for a monitored server
The request to turn maintenance off/on is a separate flag, although the actual
status is still contained in the status bitfield.
2018-05-30 10:09:15 +03:00
Johan Wikman
510eb7ec7c MXS-1848 Change monitorCamelCase to monitor_snake_case 2018-05-07 14:08:36 +03:00
Johan Wikman
b36f6faa7e MXS-1754 Reintroduce maxscale::Worker
Worker is now the base class of all workers. It has a message
queue and can be run in a thread of its own, or in the calling
thread. Worker can not be used as such, but a concrete worker
class must be derived from it. Currently there is only one
concrete class RoutingWorker.

There is some overlapping in functionality between Worker and
RoutingWorker, as there is e.g. a need for broadcasting a
message to all routing workers, but not to other workers.

Currently other workers can not be created as the array for
holding the pointers to the workers is exactly as large as
there will be RoutingWorkers. That will be changed so that
the maximum number of threads is hardwired to some ridiculous
value such as 128. That's the first step in the path towards
a situation where the number of worker threads can be changed
at runtime.
2018-04-16 14:53:08 +03:00
Johan Wikman
230876cd69 MXS-1754 Rename mxs::Worker to mxs::RoutingWorker
A new class mxs::Worker will be introduced and mxs::RoutingWorker
will be inherited from that. mxs::Worker will basically only be a
thread with a message-loop.

Once available, all current non-worker threads (but the one
implicitly created by microhttpd) can be creating by inheriting
from that; in practice that means the housekeeping thread, all
monitor threads and possibly the logging thread.

The benefit of this arrangement is that there then will be a general
mechanism for cross thread communication without having to use any
shared data structures.
2018-04-16 14:53:08 +03:00
Markus Mäkelä
f54038f378 Process module command output even on errors
The output generated by a failed call to a module command was previously
overwritten with the error messages stored in the module command
subsystem.

In the case of a failure, the proper procedure is to check if the output
generated by the module command conforms to the JSON API error
specification and if it does, combine it with any system generated error
messages. If the output does not conform, it is stored in the "meta" field
of the returned object. This allows all of the generated output to be
saved.
2018-01-10 15:08:06 +02:00
Markus Mäkelä
ba02ffb0db Move resource.cc internals into a anonymous namespace
All internal code is now inside an anonymous namespace to prevent their
use outside of the compilation unit.

Also fixed the wrong return type of ResourceWatcher::etag.
2017-12-05 09:43:06 +02:00
Markus Mäkelä
08689d3bb2 MXS-1539: Execute all REST API commands in a worker thread
Executing the commands inside a worker thread allows further improvements
to job queuing but mainly it fixes the problem of loading users when
listeners are allocated at runtime.

When a runtime listener was being created, it was allocated in the admin
thread whereas the listeners created at startup were allocated in the
"main" thread. This caused a minor difference in how administrative
functions were handled by the REST API and MaxAdmin. The only real problem
is that listener allocation depends on being done inside a worker thread
as it lazily initializes some resources.
2017-12-05 09:43:06 +02:00
Markus Mäkelä
396b81f336 Fix in-source builds
The internal header directory conflicted with in-source builds causing a
build failure. This is fixed by renaming the internal header directory to
something other than maxscale.

The renaming pointed out a few problems in a couple of source files that
appeared to include internal headers when the headers were in fact public
headers.

Fixed maxctrl in-source builds by making the copying of the sources
optional.
2017-11-22 18:40:18 +02:00
Markus Mäkelä
6918842585 Add direct relationship updating to REST API
The JSON API specification states that all resources must support direct
modification of resource relationships by providing only the definition
for a particular relationship type to a /:type/:id/relationships/:type
endpoint.

The relevant part of the JSON API specification:

    http://jsonapi.org/format/#crud-updating-to-many-relationships
2017-10-23 19:37:24 +03:00
Markus Mäkelä
14d8b6a0df Remove MODULECMD_ARG_OUTPUT argument type
Since the module command interface was expanded to include a JSON output
parameter, there is no longer a need for an output DCB. As the JSON can be
printed by both maxadmin and the REST API, this allows the removal of
explicit output formatting in module commands.
2017-09-28 13:59:28 +03:00
Markus Mäkelä
3ca172f380 MXS-1390: Clean up services resource documentation
Cleaned up the documentation and reformatted the parameter list of
listener creation to be made out of links.

Added some comments to the resource declarations in resource.cc to prevent
the order of them from being altered.
2017-09-11 12:49:11 +03:00
Markus Mäkelä
5abb30c357 MXS-1390: Add missing self-link to module command output
The module commands now produce functional self-links. The links most
often require parameters so they are not of great use.
2017-09-11 12:49:11 +03:00
Markus Mäkelä
1308e7a304 Fix resource collection modification times
The resource collection modification times weren't updated when an
individual resource was updated. By tracking back the path of a resource
and updating the modification times, all nodes in the path will get the
correct modification time.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
7e18e49eec MXS-1220: Move request body checks to a higher level
The checks whether a request body is present are now done at a higher
level. This removes the need to do the checks at the resource handler
callback, removing duplicated code.

The checks are done by adding constraints to resources that must be
fulfilled by each request.

Added debug assertions to make sure that the core logic of the REST API
resource system works.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
d2543c4841 Fix refactoring errors
The monitor deletion would mistakenly label all monitors as not being
created at runtime. Due to this, the deletion of monitors would fail.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
090de1a0f7 MXS-1220: Make individual listeners resources
The listeners are now a proper sub-resource of the service resource. This
means that it acts like a normal resource and can be queried both as a
collection of resources and as an individual resource.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
35745ee925 MXS-1220: Add deletion of listeners
The listeners can now be deleted via the REST API. Documented the added
endpoint in the REST API documentation.
2017-07-10 22:23:46 +03:00
Markus Mäkelä
c7b9b7ac4a MXS-1220: Unify resource member naming
All resoures now use the `state` member to describe their internal
state. This includes servers, services and monitors. This means that the
`status` keyword can be reserved for something else and it can be removed
until it is needed again.

Changed the module maturity field to `maturity` to better describe its
purpose.
2017-07-10 22:23:45 +03:00
Markus Mäkelä
a8bfdac49c MXS-1220: Use PUT to set/clear server
The correct method for set/clear endpoints is PUT, not POST, as the
resource always ends up in the desired state, regardless of its current
state.
2017-07-10 22:23:45 +03:00
Markus Mäkelä
63d2eee0e3 MXS-1220: Add endpoint for set/clear of server status
The server status can now be manipulated via the REST API. Added tests for
the state manipulation. Fixed minor issues in related code.
2017-07-10 22:23:44 +03:00
Markus Mäkelä
53d7c57982 MXS-1220: Add error descriptions to REST API module commands
The module command calls that fail can now display additional information
in the form of an error object.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
b3c1e15f22 MXS-1220: Add output for module commands
The module commands can now produce JSON formatted output which is passed
to the caller. The output should conform to the JSON API as closely as
possible.

Currently, the REST API wraps all JSON produced by module commands inside
a meta-object of the following type:

  {
    "meta": <output of module command>
  }

This allows the output to be JSON API conformant without modifying the
modules and allows incremental updates to code.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
e4a004097e MXS-1220: Add support for PATCH
The PATCH method should now be used instead the PUT method to update
resources.  As PUT request bodies should represent complete resources, the
use of PUT to update resources is no longer supported.

Altered tests to use PATCH instead of PUT for updating resources.
2017-06-05 13:37:08 +03:00
Markus Mäkelä
ba546fcd21 MXS-1220: Add execution of module commands to REST API
The module command self links now point to an endpoint that executes the
module command. Depending on the type of the module command, either a GET
or a POST request must be made.
2017-06-02 12:52:33 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
6b8b19b439 MXS-1220: Add PUT support for /maxscale/ resource
The /maxscale/ resource now supports PUT requests which modify core
parameters. As not all parameters can be changed at runtime, only
modifications to parameters that support runtime configuration are
allowed.
2017-05-24 15:05:11 +03:00