18 Commits

Author SHA1 Message Date
Markus Mäkelä
bbfd9ce136 Move Backend and SessionCommand classes to the core
Using the same implementation of the Backend and SessionCommand classes in
both schemarouter and readwritesplit will prevent duplication of code.

This commit only splits the generic parts of the class to a Backend class
which the schemarouter then extends. The session commands for both routers
are similar so they require no special handling.
2017-06-22 10:40:16 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
ce6b52ab39 Rename schemarouter internal functions
Renamed the functions to better describe what they do.
2017-04-06 09:22:21 +03:00
Markus Mäkelä
c59ed30da1 Simplify error handling
The error handlers are now simpler as the Backend class handles the
closing of the connections.
2017-03-31 14:12:02 +03:00
Markus Mäkelä
6e218adc1d Make connections and command queues internal to Backends
The SERVER_REF and DCB members of the Backend class are now
private. Access to the stored SERVER_REF is provided with the backend()
function. No accompanying setter function is provided as the backend
server should not change during the lifetime of the session.

The creation of the internal DCB is hidden behind the connect()
function. It simplifies the process of connecting to a server by removing
the need to manually do the bookkeeping of the server reference connection
counts. Access to the DCB is provided by the dcb() function.

The closing of the backend is done with the close() function which
contains the code that was previously in closeSession. If the backend
isn't closed when the destructor is called, it will be done
automatically. This should prevent connection leakage.

The pending command queues and the methods used to write them are now also
internal to the backends. They are simple wrappers around dcb->func.write
and the interfaces provided by the Buffer class. The mapping command queue
is still public. It needs to be combined with the generic command queue.
2017-03-31 14:12:02 +03:00
Markus Mäkelä
66fa4fbc7d Use shared pointers to Backend classes
The schemarouter now uses shared pointers. This removes the need to copy
the class.

Following changes move the member variables inside the Backend class.
2017-03-31 14:12:02 +03:00
Markus Mäkelä
94ac2d89d0 MXS-1160: Add support for LOAD DATA LOCAL INFILE
Schemarouter now supports the LOAD DATA LOCAL INFILE command.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
f6470c580a Fix minor problems
Use correct value in initialization, return correct return value on
success, do a equals comparison on route target.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
34b0b07cd1 Ignore duplicate shards in a subfunction
The ignoring of duplicate shards is now done inside a subfunction.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
5ba9de6f42 Move Backend functions inside the class
The functions that handle Backend classes are now methods of the class
itself.

Prefix all member variables with `m_` to distinct them from other
variables.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
d1aa2a4b8a Use a list of backends instead of an array
Changed the backend_ref_t struct into a Backend class. Replaced static
arrays with lists. Altered functions to make the code compile.

Further refactoring is needed, a part of the functions should be moved
into this new class.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
c4638666cf Remove typedefs from schemarouter enums
The enum typedefs weren't really useful in most cases.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
f5a259ba57 Do configuration outside of constructors
Configuration errors can be resolved before the instance is created. This
avoids the unnecessary throws that were generated when an error occured.

As the configuration is stored in the router, the router sessions can use
a pointer to it instead of copying it locally. This should avoid some
unnecessary copying if more complex configuration parameters are added.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
b9fae58891 Favor pointers over references
The use of a pointer instead of a reference conveys the message that the
lifetime of the object being pointed can, and most likely will, exceed the
lifetime of the function.

Also shuffled the member variables and internal functions around and
removed unneeded function declarations.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
02796e7304 Move #pragma to first line in each header
The `#pragma once` is now on the first line of each header.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
a10aa85736 Clean up routeQuery and clientReply
Moved parts of the functionality into subfunctions. Reordered code to
remove redundant logic.
2017-03-31 14:12:01 +03:00
Markus Mäkelä
39903e40b7 Rename member variables
Renamed and cleaned up schemarouter member variables. Removed unused
variables.
2017-03-31 14:12:00 +03:00
Markus Mäkelä
ac641e0f22 Use router template in schemarouter
The schemarouter now uses the router template.
2017-03-31 14:12:00 +03:00