Move RWSplitSession into rwsplitsession.cc
Moved the class method definitions into the correct file.
This commit is contained in:
parent
d5643bc14d
commit
14e399dd68
@ -620,68 +620,6 @@ bool RWSplit::have_enough_servers() const
|
||||
return succp;
|
||||
}
|
||||
|
||||
RWSplitSession::RWSplitSession(RWSplit* instance, MXS_SESSION* session,
|
||||
const SRWBackendList& backends,
|
||||
const SRWBackend& master):
|
||||
rses_chk_top(CHK_NUM_ROUTER_SES),
|
||||
rses_closed(false),
|
||||
backends(backends),
|
||||
current_master(master),
|
||||
large_query(false),
|
||||
rses_config(instance->config()),
|
||||
rses_nbackends(instance->service()->n_dbref),
|
||||
load_data_state(LOAD_DATA_INACTIVE),
|
||||
have_tmp_tables(false),
|
||||
rses_load_data_sent(0),
|
||||
client_dcb(session->client_dcb),
|
||||
sescmd_count(1), // Needs to be a positive number to work
|
||||
expected_responses(0),
|
||||
query_queue(NULL),
|
||||
router(instance),
|
||||
sent_sescmd(0),
|
||||
recv_sescmd(0),
|
||||
gtid_pos(""),
|
||||
wait_gtid_state(EXPECTING_NOTHING),
|
||||
next_seq(0),
|
||||
rses_chk_tail(CHK_NUM_ROUTER_SES)
|
||||
{
|
||||
if (rses_config.rw_max_slave_conn_percent)
|
||||
{
|
||||
int n_conn = 0;
|
||||
double pct = (double)rses_config.rw_max_slave_conn_percent / 100.0;
|
||||
n_conn = MXS_MAX(floor((double)rses_nbackends * pct), 1);
|
||||
rses_config.max_slave_connections = n_conn;
|
||||
}
|
||||
}
|
||||
|
||||
RWSplitSession* RWSplitSession::create(RWSplit* router, MXS_SESSION* session)
|
||||
{
|
||||
RWSplitSession* rses = NULL;
|
||||
|
||||
if (router->have_enough_servers())
|
||||
{
|
||||
SRWBackendList backends = RWBackend::from_servers(router->service()->dbref);
|
||||
|
||||
/**
|
||||
* At least the master must be found if the router is in the strict mode.
|
||||
* If sessions without master are allowed, only a slave must be found.
|
||||
*/
|
||||
|
||||
SRWBackend master;
|
||||
|
||||
if (select_connect_backend_servers(router, session, backends, master,
|
||||
NULL, NULL, connection_type::ALL))
|
||||
{
|
||||
if ((rses = new RWSplitSession(router, session, backends, master)))
|
||||
{
|
||||
router->stats().n_sessions += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rses;
|
||||
}
|
||||
|
||||
/**
|
||||
* API function definitions
|
||||
*/
|
||||
|
@ -15,6 +15,72 @@
|
||||
#include "rwsplit_internal.hh"
|
||||
#include "routeinfo.hh"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace maxscale;
|
||||
|
||||
RWSplitSession::RWSplitSession(RWSplit* instance, MXS_SESSION* session,
|
||||
const SRWBackendList& backends,
|
||||
const SRWBackend& master):
|
||||
rses_chk_top(CHK_NUM_ROUTER_SES),
|
||||
rses_closed(false),
|
||||
backends(backends),
|
||||
current_master(master),
|
||||
large_query(false),
|
||||
rses_config(instance->config()),
|
||||
rses_nbackends(instance->service()->n_dbref),
|
||||
load_data_state(LOAD_DATA_INACTIVE),
|
||||
have_tmp_tables(false),
|
||||
rses_load_data_sent(0),
|
||||
client_dcb(session->client_dcb),
|
||||
sescmd_count(1), // Needs to be a positive number to work
|
||||
expected_responses(0),
|
||||
query_queue(NULL),
|
||||
router(instance),
|
||||
sent_sescmd(0),
|
||||
recv_sescmd(0),
|
||||
gtid_pos(""),
|
||||
wait_gtid_state(EXPECTING_NOTHING),
|
||||
next_seq(0),
|
||||
rses_chk_tail(CHK_NUM_ROUTER_SES)
|
||||
{
|
||||
if (rses_config.rw_max_slave_conn_percent)
|
||||
{
|
||||
int n_conn = 0;
|
||||
double pct = (double)rses_config.rw_max_slave_conn_percent / 100.0;
|
||||
n_conn = MXS_MAX(floor((double)rses_nbackends * pct), 1);
|
||||
rses_config.max_slave_connections = n_conn;
|
||||
}
|
||||
}
|
||||
|
||||
RWSplitSession* RWSplitSession::create(RWSplit* router, MXS_SESSION* session)
|
||||
{
|
||||
RWSplitSession* rses = NULL;
|
||||
|
||||
if (router->have_enough_servers())
|
||||
{
|
||||
SRWBackendList backends = RWBackend::from_servers(router->service()->dbref);
|
||||
|
||||
/**
|
||||
* At least the master must be found if the router is in the strict mode.
|
||||
* If sessions without master are allowed, only a slave must be found.
|
||||
*/
|
||||
|
||||
SRWBackend master;
|
||||
|
||||
if (select_connect_backend_servers(router, session, backends, master,
|
||||
NULL, NULL, connection_type::ALL))
|
||||
{
|
||||
if ((rses = new RWSplitSession(router, session, backends, master)))
|
||||
{
|
||||
router->stats().n_sessions += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rses;
|
||||
}
|
||||
|
||||
uint32_t get_internal_ps_id(RWSplitSession* rses, GWBUF* buffer)
|
||||
{
|
||||
uint32_t rval = 0;
|
||||
|
@ -43,8 +43,8 @@ typedef std::tr1::unordered_map<uint32_t, mxs::SRWBackend> ExecMap;
|
||||
*/
|
||||
class RWSplitSession
|
||||
{
|
||||
RWSplitSession(const RWSplitSession&);
|
||||
RWSplitSession& operator=(const RWSplitSession&);
|
||||
RWSplitSession(const RWSplitSession&) = delete;
|
||||
RWSplitSession& operator=(const RWSplitSession&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user