7427 Commits

Author SHA1 Message Date
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
Markus Mäkelä
601976dede Use __atomic builtins only where they are supported
Use the newer __atomic builtins only with GCC >= 4.7. The older __sync
builtins are used elsewhere.
2017-04-28 14:53:37 +03:00
Johan Wikman
6a3d99afe5 Prevent adding DCBs on non-worker threads 2017-04-28 12:56:38 +03:00
MassimilianoPinto
1203a8211a MXS-1209: blr_master.c cleanup
blr_master.c cleanup continues
2017-04-28 11:40:11 +02:00
MassimilianoPinto
07e95d03ec Merge branch 'develop' into MXS-1209 2017-04-27 18:08:04 +02:00
Johan Wikman
fae4b2d99a MXS-1209: Ensure master is connected to in main worker 2017-04-27 18:05:22 +02:00
MassimilianoPinto
4ab1156cef Merge branch 'develop' into MXS-1209 2017-04-27 18:04:18 +02:00
MassimilianoPinto
9a34aa5c7f Fprintf removed
Fprintf removed
2017-04-27 18:03:34 +02:00
Esa Korhonen
8f50269338 Add proxy protocol support
Adds a server-specific parameter, "use_proxy_protocol". If enabled,
a header string is sent to the backend when a routing session connection
changes state to MXS_AUTH_STATE_CONNECTED. The string contains the real
client IP and port.
2017-04-27 12:29:46 +03:00
Johan Wikman
a4f9beb1ad MXS-1209: Ensure master is connected to in main worker 2017-04-27 11:00:07 +03:00
MassimilianoPinto
1e98de7b15 Added extra debug fprintf
Added extra debug fprintf
2017-04-27 09:15:32 +02:00
Johan Wikman
deb11ae6eb Merge branch '2.1' into develop 2017-04-27 09:11:02 +03:00
MassimilianoPinto
de8febf9a9 Binlogrouter: set poll.thread.id from mxs_worker_get_current_id()
As 'client' is the fake DCB that emulates a client session,
poll.thread.id for the "dummy client" must be set to the current
thread_id that calls blr_start_master()

This affects both startup and START SLAVE (via mysql client)
2017-04-26 17:38:22 +02:00
MassimilianoPinto
e10dd1329d Merge branch 'develop' into MXS-1209 2017-04-26 16:21:39 +02:00
MassimilianoPinto
2428468f47 MXS-1209: blr_master.c cleanup
blr_master.c cleanup continues
2017-04-26 16:06:42 +02:00
MassimilianoPinto
656cb3c517 Added depth and SERVER_SLAVE_OF_EXTERNAL_MASTER for build_mysql51_replication_tree
Now build_mysql51_replication_tree assigns depth and handles
SERVER_SLAVE_OF_EXTERNAL_MASTER status
2017-04-26 13:40:28 +03:00
MassimilianoPinto
57700215ac MXS-1244: MySQL monitor "detect_replication_lag=true" doesn't work with "mysql51_replication=true"
Added the missing handle->master assignment
2017-04-26 13:39:55 +03:00
Johan Wikman
728c780187 Expose current worker id to c-files 2017-04-26 13:17:23 +03:00
Johan Wikman
c8c2822c7b Link storage_rocksdb with lz4 2017-04-26 13:15:23 +03:00