Divide ClusterOperation to two types
The main class was getting unwieldly and too general. Dividing the fields helps adding support for other operation types. This commit leaves most data duplicated, later commits clean up the affected code.
This commit is contained in:
@ -217,6 +217,21 @@ enum class OperationType
|
||||
FAILOVER
|
||||
};
|
||||
|
||||
class ServerOperation;
|
||||
class GeneralOpData
|
||||
{
|
||||
public:
|
||||
const OperationType type;
|
||||
const std::string replication_user; // User for CHANGE MASTER TO ...
|
||||
const std::string replication_password; // Password for CHANGE MASTER TO ...
|
||||
json_t** const error_out; // Json error output
|
||||
maxbase::Duration time_remaining; // How much time remains to complete the operation
|
||||
|
||||
GeneralOpData(OperationType type,
|
||||
const std::string& replication_user, const std::string& replication_password,
|
||||
json_t** error, maxbase::Duration time_remaining);
|
||||
};
|
||||
|
||||
/**
|
||||
* Class which encapsulates many settings and status descriptors for a failover/switchover.
|
||||
* Is more convenient to pass around than the separate elements. Most fields are constants or constant
|
||||
@ -229,7 +244,11 @@ private:
|
||||
ClusterOperation& operator=(const ClusterOperation&) = delete;
|
||||
|
||||
public:
|
||||
const OperationType type; // Failover or switchover
|
||||
const OperationType type; // Failover or switchover
|
||||
ServerOperation* const demotion; // Required by MariaDBServer->demote()
|
||||
ServerOperation* const promotion; // Required by MariaDBServer->promote()
|
||||
GeneralOpData general; // General operation data
|
||||
|
||||
MariaDBServer* const promotion_target; // Which server will be promoted
|
||||
MariaDBServer* const demotion_target; // Which server will be demoted
|
||||
const bool demotion_target_is_master; // Was the demotion target the master?
|
||||
@ -248,13 +267,28 @@ public:
|
||||
/* Similar copy for promotion target connections. */
|
||||
SlaveStatusArray promotion_target_conns;
|
||||
|
||||
ClusterOperation(OperationType type,
|
||||
ClusterOperation(OperationType type, ServerOperation* dem_op, ServerOperation* prom_op,
|
||||
MariaDBServer* promotion_target, MariaDBServer* demotion_target,
|
||||
const SlaveStatusArray& promo_target_conns, const SlaveStatusArray& demo_target_conns,
|
||||
bool demo_target_is_master, bool handle_events,
|
||||
std::string& promotion_sql_file, std::string& demotion_sql_file,
|
||||
std::string& replication_user, std::string& replication_password,
|
||||
json_t** error, maxbase::Duration time_remaining);
|
||||
~ClusterOperation();
|
||||
};
|
||||
|
||||
// Operation data which concerns a single server
|
||||
class ServerOperation
|
||||
{
|
||||
public:
|
||||
MariaDBServer* const target; // Target server
|
||||
const bool was_is_master; // Was the target a master / should it become one
|
||||
const bool handle_events; // Should scheduled server events be disabled/enabled?
|
||||
const std::string sql_file; // Path to file with SQL commands to run during op
|
||||
const SlaveStatusArray conns_to_copy; // Slave connections the target should copy/merge
|
||||
|
||||
ServerOperation(MariaDBServer* target, bool was_is_master, bool handle_events,
|
||||
const std::string& sql_file, const SlaveStatusArray& conns_to_copy);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user