Rename and overload adding of session commands

As the session commands are always appended to the end of the list, the
name should reflect that action. For this reason, the function was renamed
to append_session_command.

Readwritesplit supports replacement of slave servers by storing all
executed session commands in a list. To make the copying of this list a
bit cleaner, an overload for a list of session commands was added. This
will allow relatively smooth addition of server replacement to all router
modules that use the Backend class.
This commit is contained in:
Markus Mäkelä
2017-06-16 01:32:04 +03:00
parent 869325e00a
commit 0c8e68fd05
5 changed files with 27 additions and 10 deletions

View File

@ -248,7 +248,7 @@ bool route_session_write(ROUTER_CLIENT_SES *rses, GWBUF *querybuf, uint8_t comma
if (bref->in_use())
{
bref->add_session_command(sescmd);
bref->append_session_command(sescmd);
uint64_t current_pos = bref->next_session_command()->get_position();

View File

@ -214,11 +214,22 @@ bool select_connect_backend_servers(int router_nservers,
bref && slaves_connected < max_nslaves;
bref = get_slave_candidate(rses, master_host, cmpfun))
{
if (bref->connect(session) &&
(bref->session_command_count() == 0 ||
bref->execute_session_command()))
if (bref->can_connect() && bref->connect(session))
{
slaves_connected += 1;
if (rses->sescmd_list.size())
{
bref->append_session_command(rses->sescmd_list);
if (bref->execute_session_command())
{
rses->expected_responses++;
slaves_connected++;
}
}
else
{
slaves_connected++;
}
}
}

View File

@ -726,7 +726,7 @@ bool SchemaRouterSession::route_session_write(GWBUF* querybuf, uint8_t command)
{
GWBUF *buffer = gwbuf_clone(querybuf);
(*it)->add_session_command(buffer, m_sent_sescmd);
(*it)->append_session_command(buffer, m_sent_sescmd);
if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO))
{