7445 Commits

Author SHA1 Message Date
Markus Mäkelä
5e679aa167 MXS-1220: Implement JSON diagnostics entry point in monitors
All monitors now implement the JSON version of the diagnostics function.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
9d108a58de MXS-1220: Use new diagnostics in avrorouter
The avrorouter now implements the new diagnostics API entry point.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
bbe0620944 MXS-1220: Add JSON return value to diagnostics entry points
The modules that implement a diagnostics entry point now return a JSON
type object. This removes the need to format data inside the modules.

The module implementations of these are not yet complete which means that
MaxScale will fail to compile.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
94ebef0703 MXS-1220: Expand nested service and monitor resources
As a service is a collection of other resources, it makes sense to expand
those resources that were previously expressed as relative paths. This way
the API can be readily consumed without altering the pathnames to
links. The downside to this is the increased bandwidth consumption and
possible excess data.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
47c1e9d533 MXS-1220: Deprecate whitespace in object names
All whitespace in object names is now converted to a compacted format with
whitespace replaced with hyphens. If a conversion takes place, a warning
is logged.

Converted some of the tests into C++ as they directly include .cc files.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
aa16980cec MXS-1220: Fix date formatting
Some of the dates were printed with a trailing newline. This was added by
asctime_r.

Fixed `/services` resource returning an empty array.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
75b44198ba MXS-1220: Add monitor to JSON conversion
Monitors can now be printed in JSON format. The REST API resource
`/monitors` accepts GET requests and returns a JSON representation of the
monitors as a response.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
d2e4d9cc64 MXS-1220: Make filter to JSON functions const correct
The functions don't modify the filters when the JSON is generated. This
means that the parameters can be const.

Minor formatting fixes to service sources.
2017-05-04 09:12:14 +03:00
Markus Mäkelä
b656f2b300 MXS-1220: Add JSON formatting for servers and filters
Both the filters and services can be queried via the REST API now that
these resources can be expressed in JSON format.

As with the other resources, these directly call the functions that
generate the data. This will be done via the inter-thread messaging system
once it's in place.
2017-05-04 09:12:14 +03:00
Markus Mäkelä
9468893048 MXS-1220: Add server and session printing to REST API
The REST API now prints individual sessions and servers. It also lists all
servers if no specific server is given.

The functions directly call the printing functions when they should be
using the inter-thread messaging system. When the messaging system is
ready, these functions should be updated.
2017-05-04 09:12:14 +03:00
Markus Mäkelä
fd680544d6 MXS-1220: Add session JSON output
Sessions can now be printed in JSON.
2017-05-04 09:12:12 +03:00
Markus Mäkelä
13cba2cb75 MXS-1220: Make server JSON functions const correct
The functions now take const parameters.

Also fixed a memory leak.
2017-05-04 09:11:18 +03:00
Markus Mäkelä
caf2172677 MXS-1220: Fix minor problems with admin thread
The admin thread now uses blocking IO. This is not optimal but it
simplifies the code by some amount.

Fixed option processing removing one extra character from key name.

Use correct member variable when checking for the option map end.
2017-05-04 09:11:18 +03:00
Markus Mäkelä
c4a8f8c8a6 MXS-1220: Add JSON functions for servers
The servers can now be printed in JSON format.
2017-05-04 09:11:17 +03:00
Markus Mäkelä
b975518996 MXS-1220: Add simple functionality to resources
The resources now properly process parts of the uri. This allows, for
example, certain sessions to be inspected. The current functionality is
only intended for testing and provides no useful functionality.

The actions taken by the resource manager are not done via the
inter-thread messaging system. When the implementation of the messages and
the JSON representation of the resources is done, the REST API resource
can actually be used.
2017-05-04 09:11:15 +03:00
Markus Mäkelä
900bf2db5a MXS-1220: Take the resource handler into use
The resource handler system is now usable but it doesn't perform anything
useful. Although, this will allows it to be tested for correctness.

Minor fixes to HttpResponse output and renaming of functions.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
8b1c0cd1a1 MXS-1220: Add REST resource handler class
The Resource class is intended to be an abstraction of a resource
tree. Each node in the tree can perform actions. The tree is traversed
depth first so that deeper command paths resolve to the correct nodes.

Currently all the base resources defined in the REST API documents are
implemented in a way that they return a 200 OK response to all
requests. When the internal data can be represented as JSON, the resources
can be hooked up to functions that generate JSON.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
e248178349 MXS-1220: Split requested resource into parts
When a client requests a resource, the HttpRequest class now splits the
requested resource into parts. This should help with the resource
validation and navigation.

Added test that checks that the resources are correctly split into the
correct number of arguments and that the argument contents are correct.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
4b4a87fb41 MXS-1220: Clean up requested resource paths
Remove trailing slashes in requested resource paths.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
34ee4a1997 MXS-1220: Add option parsing
The options of a request are now parsed and exposed by the HttpRequest
class.

Added tests for the request options.

Also added missing error handling of invalid requests.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
9d0d394361 MXS-1220: Expand HttpResponse class
The class now generates default headers. The ETag and Last-Modified tags
do not represent any actual modification time or resource hash.

The basic functionality of the HTTP responses is tested by the core test
suite. More advanced testing of the whole REST API is still required.

Removed the static `create` functions as only the JSON parsing version
could generated errors and even then the errors were unlikely. By
replacing the static creator function with a normal constructor, the
HttpResponse class can now also be created on the stack making its use
easier.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
a73d3e9276 MXS-1220: Create HTTP response class
The HTTP response class simplifies the response creation. The next step is
to add generation of all the default headers that are needed by the REST
API.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
55b52b8ab1 MXS-1220: Add HEAD method support
The HEAD method was not in the list of supported methods.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
c937457738 MXS-1220: Add request body parsing
The HTTP request body is expected to be a valid JSON object. All other
requests are considered malformed requests and result in a HTTP 400 error.

Added the Jansson license to the LICENSE-THIRDPARTY.TXT file. Imported
some of the tests from the Jansson test suite to the HttpParser test.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
4eb121ce35 MXS-1220: Rename and reorganize HttpParser
The HttpParser class was renamed to HttpRequest as it parses and processes
only HTTP requests. A second class that creates a HTTP response needs to
be created to handle the response generation.

Moved some of the HTTP constants and helper functions to a separate
http.hh header.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
e34b65658e MXS-1220: Simplify admin request handling
The admin requests are now processed in blocking mode. The timing out of
connecttions is handled by a specific timeout thread that checks the state
of each admin request.

The simplification will help with the JSON parsing with PUT/POST
commands. If non-blocking IO is used, the network reading code and JSON
parsing needs a lot more work to handle partial reads.

If the administrative interface requires higher performance and
concurrency, a multi-threaded solution could be created.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
439d67d129 MXS-1220: Add test for HttpParser
The test simulates various HTTP requests and checks that they are parsed
properly.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
605fed7839 MXS-1220: Add HTTP parser
The HTTP parser parses HTTP/1.1 messages into easily manageable data
structures. This should make it easier to map the HTTP requests into
actual commands in MaxScale.
2017-05-04 09:10:31 +03:00
Markus Mäkelä
23b6fb3e6d MXS-1220: Create separate admin thread
When MaxScale is started, a separate thread for the administrative
interface is started. This allows the worker threads to handle client
requests while the administrative thread handles the lower priority
administrative requests.

The administrative interface responds to all request with a 200 OK HTTP
response. This allows the administrative interface itself to be tested.
2017-05-04 09:10:31 +03:00
Markus Mäkelä
5c0429466c Always include Jansson header directory
The directory is always included even if we are not building the Jansson
library ourselves.
2017-05-03 14:16:37 +03:00
Markus Mäkelä
dd8a10f466 Remove old polling message system
The old polling message system is obsolete now that the worker messages
are implemented. The old system was only used to clean up the persistent
connection pool of a server.
2017-05-03 14:16:35 +03:00
Markus Mäkelä
4c6e0c75a5 Allow execution of tasks from within worker threads
It is now possible to define whether tasks are executed immediately or put
on the event queue of the worker thread. If task execution is in automatic
mode and the current executing thread is a worker thread, the
Task->execute method is called immediately.

This allows tasks to be posted from within worker threads. This is
intended to be used when purging of stale persistent connections and
printing diagnostic output via MaxAdmin. All of these actions are done
from within a worker thread.
2017-05-03 14:03:23 +03:00
Markus Mäkelä
6f24c04a4f Compile core unit tests as C++
Since the core source is C++, the tests should also be C++.
2017-05-03 14:02:25 +03:00
MassimilianoPinto
758dc72f06 Merge branch 'MXS-1209' into develop 2017-05-03 12:56:12 +02:00
MassimilianoPinto
c07350e710 Merge branch 'develop' into MXS-1209 2017-05-03 12:54:19 +02:00
Johan Wikman
ab31cd4b1a Use O_DIRECT, but only if available.
TODO: The kernel version should be looked up at startup and made
      generally available so that it is readily available for
      anybody interested.
2017-05-03 13:39:26 +03:00
MassimilianoPinto
6c7013ab00 MXS-1209: blr_start_master_registration() handles the replication protocol registration
New routine blr_start_master_registration() handles the replication
protocol registration
2017-05-03 08:40:49 +02:00
MassimilianoPinto
b0837dc635 MXS-1209: added blr_register_cache_response
New routine blr_register_cache_response() in use.
2017-05-03 08:30:05 +02:00
MassimilianoPinto
1b5bf65260 MXS-1209: blr_register_send_command() in use for all registration phases
blr_register_send_command() in use for all registration phases
2017-05-02 11:10:55 +02:00
Johan Wikman
00b6c10089 Adjust Worker terminology
- Posting a task to a worker for execution (without implicit wait)
  is called "post".
- Posting a task to every worker for execution (without implicit wait)
  is called "broadcast".

In these cases the task must be provided as a pointer or auto_ptr, to
indicate that the provided pointer must remain alive for longer than
the duration of the function call.

- Posting a task to a worker for execution *and* waiting for all workers
  to have executed the task is called "execute" and the two variants are
  now called "execute_concurrently" and "execute_serially".

In these cases the task is provided as a reference, since the functions
will return only when all workers have (in concurrent or serial fashion)
executed the task. That is, it need not remain alive for longer than the
duration of the function call.
2017-05-02 11:32:08 +03:00
Johan Wikman
1b58a75f42 Add concurrent execution helper to Worker
Concurrently executing a task on all workers *and* waiting until
all workers have executed the task seems to be common enough to
warrant a helper function for that purpose.
2017-05-02 10:54:29 +03:00
Esa Korhonen
bfd94c2b31 KILL [CONNECTION | QUERY] support, part1
Preparation for adding KILL syntax support.
Session id changed to uint32 everywhere. Added atomic op.
Session id can be acquired before session_alloc().
Added session_alloc_with_id(), which is given a session id number.
Worker object has a session_id->SESSION* mapping, not used yet.
2017-05-02 10:29:55 +03:00
MassimilianoPinto
3c6006a010 MXS-1209: added blr_register_send_command()
MXS-1209: added blr_register_send_command()
2017-05-02 09:11:15 +02:00
Esa Korhonen
46da2d3ad2 Add entry on proxy protocol to release notes 2017-05-02 10:07:30 +03:00
MassimilianoPinto
5cef78b7d4 MXS-1209: blr_master.c cleanup
Further optimisations will come with new registration phases
2017-04-28 18:08:33 +02:00
MassimilianoPinto
23c166ba37 Merge branch 'develop' into MXS-1209 2017-04-28 16:43:49 +02:00
MassimilianoPinto
2c6d08325a MXS-1209: blr_master.c cleanup
blr_master.c cleanup continues
2017-04-28 16:22:26 +02:00
Markus Mäkelä
ab33f05f7a Use correct __atomic builtins for atomic_add
The atomic_add function should return the old value.
2017-04-28 16:27:20 +03:00
Esa Korhonen
c90c870727 Add proxy protocol setting documentation 2017-04-28 15:28:51 +03:00
Markus Mäkelä
97e57d92ff Check GCC version instead of C++ standard
The C++11 standard in pre-4.8 GCC versions lacks the thread_local
implementation. For those versions, the __thread qualifier should be used.
2017-04-28 14:53:37 +03:00