MXS-1267: Use local client in tee

The tee filter now uses the local client class to clone the queries. This
imposes some restrictions on how the filter can be used but also makes
MaxScale as a whole more robust.
This commit is contained in:
Markus Mäkelä
2017-05-23 13:51:29 +03:00
parent c67b76b486
commit 7fab3f5d1d
5 changed files with 365 additions and 862 deletions

View File

@ -6,12 +6,15 @@ The tee filter is a "plumbing" fitting in the MariaDB MaxScale filter toolkit.
It can be used in a filter pipeline of a service to make copies of requests from It can be used in a filter pipeline of a service to make copies of requests from
the client and send the copies to another service within MariaDB MaxScale. the client and send the copies to another service within MariaDB MaxScale.
**Please Note:** Starting with MaxScale 2.2.0, any client that connects to a
service which uses a tee filter will require a grant for the loopback address,
i.e. `127.0.0.1`.
## Configuration ## Configuration
The configuration block for the TEE filter requires the minimal filter The configuration block for the TEE filter requires the minimal filter
parameters in its section within the MaxScale configuration file. The service to parameters in its section within the MaxScale configuration file. The service to
send the duplicates to must be defined. Currently the tee filter does not send the duplicates to must be defined.
support multi-statements.
``` ```
[DataMartFilter] [DataMartFilter]

View File

@ -1,4 +1,4 @@
add_library(tee SHARED tee.cc) add_library(tee SHARED tee.cc local_client.cc)
target_link_libraries(tee maxscale-common) target_link_libraries(tee maxscale-common MySQLCommon)
set_target_properties(tee PROPERTIES VERSION "1.0.0") set_target_properties(tee PROPERTIES VERSION "1.0.0")
install_module(tee core) install_module(tee core)

View File

@ -34,10 +34,10 @@ LocalClient::LocalClient(MXS_SESSION* session, int fd):
{ {
MXS_POLL_DATA::handler = LocalClient::poll_handler; MXS_POLL_DATA::handler = LocalClient::poll_handler;
MySQLProtocol* client = (MySQLProtocol*)m_session->client_dcb->protocol; MySQLProtocol* client = (MySQLProtocol*)m_session->client_dcb->protocol;
m_proto = {}; m_protocol = {};
m_proto.charset = client->charset; m_protocol.charset = client->charset;
m_proto.client_capabilities = client->client_capabilities; m_protocol.client_capabilities = client->client_capabilities;
m_proto.extra_capabilities = client->extra_capabilities; m_protocol.extra_capabilities = client->extra_capabilities;
} }
LocalClient::~LocalClient() LocalClient::~LocalClient()
@ -48,7 +48,7 @@ LocalClient::~LocalClient()
} }
} }
bool LocalClient::query(GWBUF* buffer) bool LocalClient::queue_query(GWBUF* buffer)
{ {
GWBUF* my_buf = gwbuf_clone(buffer); GWBUF* my_buf = gwbuf_clone(buffer);
@ -82,9 +82,9 @@ void LocalClient::process(uint32_t events)
{ {
if (m_state == VC_WAITING_HANDSHAKE) if (m_state == VC_WAITING_HANDSHAKE)
{ {
if (gw_decode_mysql_server_handshake(&m_proto, GWBUF_DATA(buf) + MYSQL_HEADER_LEN) == 0) if (gw_decode_mysql_server_handshake(&m_protocol, GWBUF_DATA(buf) + MYSQL_HEADER_LEN) == 0)
{ {
GWBUF* response = gw_generate_auth_response(m_session, &m_proto, false, false); GWBUF* response = gw_generate_auth_response(m_session, &m_protocol, false, false);
m_queue.push_front(response); m_queue.push_front(response);
m_state = VC_RESPONSE_SENT; m_state = VC_RESPONSE_SENT;
} }

View File

@ -46,7 +46,7 @@ public:
* *
* @return True if query was successfully queued * @return True if query was successfully queued
*/ */
bool query(GWBUF* buffer); bool queue_query(GWBUF* buffer);
private: private:
LocalClient(MXS_SESSION* session, int fd); LocalClient(MXS_SESSION* session, int fd);
@ -71,5 +71,5 @@ private:
size_t m_expected_bytes; size_t m_expected_bytes;
std::deque<mxs::Buffer> m_queue; std::deque<mxs::Buffer> m_queue;
MXS_SESSION* m_session; MXS_SESSION* m_session;
MySQLProtocol m_proto; MySQLProtocol m_protocol;
}; };

File diff suppressed because it is too large Load Diff