MXS-1625 Add QueryClassifier instance to RWSplitSession

The readwritesplit session now has a mxs::QueryClassifier instance
as member.
This commit is contained in:
Johan Wikman
2018-04-03 17:58:34 +03:00
parent 0771701d94
commit 563fa2c840
3 changed files with 13 additions and 12 deletions

View File

@ -25,8 +25,7 @@ namespace
* Examine the query type, transaction state and routing hints. Find out the
* target for query routing.
*
* @param session The MaxScale session.
* @param use_sql_variables_in Where statements using SQL variables should be sent.
* @param qc The query classifier.
* @param load_active Whether LOAD DATA is on going.
* @param command The current command.
* @param qtype Type of query
@ -35,15 +34,12 @@ namespace
* @return bitfield including the routing target, or the target server name
* if the query would otherwise be routed to slave.
*/
route_target_t get_route_target(MXS_SESSION* session,
mxs_target_t use_sql_variables_in,
route_target_t get_route_target(mxs::QueryClassifier& qc,
bool load_active,
uint8_t command,
uint32_t qtype,
HINT *query_hints)
{
maxscale::QueryClassifier qc(session, use_sql_variables_in);
qc.set_load_active(load_active);
int target = qc.get_route_target(command, qtype);
@ -625,12 +621,9 @@ route_target_t get_target_type(RWSplitSession *rses, GWBUF *buffer,
*type = rses->m_ps_manager.get_type(*stmt_id);
}
MXS_SESSION* session = rses->m_client->session;
mxs_target_t use_sql_variables_in = rses->m_config.use_sql_variables_in;
bool load_active = (rses->m_load_data_state != LOAD_DATA_INACTIVE);
bool load_active = (rses->load_data_state != LOAD_DATA_INACTIVE);
route_target = get_route_target(session,
use_sql_variables_in,
route_target = get_route_target(rses->qc(),
load_active,
*command, *type, buffer->hint);
}

View File

@ -39,7 +39,8 @@ RWSplitSession::RWSplitSession(RWSplit* instance, MXS_SESSION* session,
m_recv_sescmd(0),
m_gtid_pos(""),
m_wait_gtid_state(EXPECTING_NOTHING),
m_next_seq(0)
m_next_seq(0),
m_qc(session, instance->config().use_sql_variables_in)
{
if (m_config.rw_max_slave_conn_percent)
{

View File

@ -20,6 +20,7 @@
#include <string>
#include <maxscale/modutil.h>
#include <maxscale/queryclassifier.hh>
typedef enum
{
@ -93,6 +94,11 @@ public:
mxs_error_action_t action,
bool* pSuccess);
mxs::QueryClassifier& qc()
{
return m_qc;
}
// TODO: Make member variables private
mxs::SRWBackendList m_backends; /**< List of backend servers */
mxs::SRWBackend m_current_master; /**< Current master server */
@ -121,6 +127,7 @@ public:
std::string m_gtid_pos; /**< Gtid position for causal read */
wait_gtid_state_t m_wait_gtid_state; /**< Determine boundray of wait gtid result and client query result */
uint32_t m_next_seq; /**< Next packet'ssequence number */
mxs::QueryClassifier m_qc; /**< The query classifier. */
private:
RWSplitSession(RWSplit* instance, MXS_SESSION* session,