MXS-1944 Cleanup function parameters

The naming and ordering is now a bit more consistent between promote() and demote().
This commit is contained in:
Esa Korhonen 2018-11-06 17:54:17 +02:00
parent e4e2235297
commit fb3ccc94d6
3 changed files with 12 additions and 12 deletions

View File

@ -595,7 +595,7 @@ uint32_t MariaDBMonitor::do_rejoin(const ServerArray& joinable_servers, json_t**
// Rejoin doesn't have its own time limit setting. Use switchover time limit for now since
// the first phase of standalone rejoin is similar to switchover.
maxbase::Duration time_limit((double)m_switchover_timeout);
GeneralOpData op(m_replication_user, m_replication_password, output, time_limit);
GeneralOpData general(m_replication_user, m_replication_password, output, time_limit);
if (joinable->m_slave_status.empty())
{
@ -603,7 +603,7 @@ uint32_t MariaDBMonitor::do_rejoin(const ServerArray& joinable_servers, json_t**
// the case, the following is unlikely to do damage.
ServerOperation demotion(joinable, true, /* treat as old master */
m_handle_event_scheduler, m_demote_sql_file, {} /* unused */);
if (joinable->demote(demotion, op))
if (joinable->demote(general, demotion))
{
MXS_NOTICE("Directing standalone server '%s' to replicate from '%s'.", name, master_name);
// A slave connection description is required. As this is the only connection, no name
@ -611,7 +611,7 @@ uint32_t MariaDBMonitor::do_rejoin(const ServerArray& joinable_servers, json_t**
SlaveStatus new_conn;
new_conn.master_host = master_server->address;
new_conn.master_port = master_server->port;
op_success = joinable->create_start_slave(op, new_conn);
op_success = joinable->create_start_slave(general, new_conn);
}
else
{
@ -626,7 +626,7 @@ uint32_t MariaDBMonitor::do_rejoin(const ServerArray& joinable_servers, json_t**
name, master_name, master_name);
// Multisource replication does not get to this point.
mxb_assert(joinable->m_slave_status.size() == 1);
op_success = joinable->redirect_existing_slave_conn(op, joinable->m_slave_status[0],
op_success = joinable->redirect_existing_slave_conn(general, joinable->m_slave_status[0],
m_master);
}
@ -791,7 +791,7 @@ bool MariaDBMonitor::switchover_perform(SwitchoverParams& op)
bool rval = false;
// Step 1: Set read-only to on, flush logs, update gtid:s.
if (demotion_target->demote(op.demotion, op.general))
if (demotion_target->demote(op.general, op.demotion))
{
m_cluster_modified = true;
bool catchup_and_promote_success = false;

View File

@ -1523,9 +1523,9 @@ bool MariaDBServer::promote(GeneralOpData& general, ServerOperation& promotion,
return success;
}
bool MariaDBServer::demote(ServerOperation& demo_op, GeneralOpData& general)
bool MariaDBServer::demote(GeneralOpData& general, ServerOperation& demotion)
{
mxb_assert(demo_op.target == this);
mxb_assert(demotion.target == this);
json_t** const error_out = general.error_out;
bool success = false;
@ -1541,7 +1541,7 @@ bool MariaDBServer::demote(ServerOperation& demo_op, GeneralOpData& general)
// likely part to fail, setting read_only=1, first to make undoing easier. Setting
// read_only may fail if another session has table locks or is doing long writes.
bool demotion_error = false;
if (demo_op.to_from_master)
if (demotion.to_from_master)
{
// The server should either be the master or be a standalone being rejoined.
mxb_assert(is_master() || m_slave_status.empty());
@ -1556,7 +1556,7 @@ bool MariaDBServer::demote(ServerOperation& demo_op, GeneralOpData& general)
}
else
{
if (demo_op.handle_events)
if (demotion.handle_events)
{
// TODO: Add query replying to enable_events
// Step 2b: Using BINLOG_OFF to avoid adding any gtid events,
@ -1571,7 +1571,7 @@ bool MariaDBServer::demote(ServerOperation& demo_op, GeneralOpData& general)
}
// Step 2c: Run demotion_sql_file if no errors so far.
const string& sql_file = demo_op.sql_file;
const string& sql_file = demotion.sql_file;
if (!demotion_error && !sql_file.empty())
{
bool file_ran_ok = run_sql_from_file(sql_file, error_out);
@ -1620,7 +1620,7 @@ bool MariaDBServer::demote(ServerOperation& demo_op, GeneralOpData& general)
}
}
if (demotion_error && demo_op.to_from_master)
if (demotion_error && demotion.to_from_master)
{
// Read_only was enabled (or tried to be enabled) but a later step failed.
// Disable read_only. Connection is likely broken so use a short time limit.

View File

@ -357,7 +357,7 @@ public:
* @param op Cluster operation descriptor
* @return True if successful
*/
bool demote(ServerOperation& op, GeneralOpData& general);
bool demote(GeneralOpData& general, ServerOperation& op);
/**
* Redirect the slave connection going to old master to replicate from new master.