Format all sources with Uncrustify
Formatted all sources and manually tuned some files to make the code look neater.
This commit is contained in:
@ -26,7 +26,7 @@ using maxscale::string_printf;
|
||||
|
||||
namespace
|
||||
{
|
||||
using VisitorFunc = std::function<bool (MariaDBServer*)>; // Used by graph search
|
||||
using VisitorFunc = std::function<bool(MariaDBServer*)>; // Used by graph search
|
||||
|
||||
/**
|
||||
* Generic depth-first search. Iterates through the root and its child nodes (slaves) and runs
|
||||
|
@ -1014,51 +1014,125 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /* Thread init. */
|
||||
NULL, /* Thread finish. */
|
||||
{
|
||||
{"detect_replication_lag", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{"detect_stale_master", MXS_MODULE_PARAM_BOOL,
|
||||
"true" },
|
||||
{"detect_stale_slave", MXS_MODULE_PARAM_BOOL,
|
||||
"true" },
|
||||
{"mysql51_replication", MXS_MODULE_PARAM_BOOL,
|
||||
"false",
|
||||
MXS_MODULE_OPT_DEPRECATED },
|
||||
{"multimaster", MXS_MODULE_PARAM_BOOL,
|
||||
"false",
|
||||
MXS_MODULE_OPT_DEPRECATED },
|
||||
{CN_DETECT_STANDALONE_MASTER, MXS_MODULE_PARAM_BOOL,
|
||||
"true" },
|
||||
{CN_FAILCOUNT, MXS_MODULE_PARAM_COUNT,
|
||||
"5" },
|
||||
{"allow_cluster_recovery", MXS_MODULE_PARAM_BOOL, "true",
|
||||
MXS_MODULE_OPT_DEPRECATED },
|
||||
{"ignore_external_masters", MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{CN_AUTO_FAILOVER, MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{CN_FAILOVER_TIMEOUT, MXS_MODULE_PARAM_COUNT,
|
||||
"90" },
|
||||
{CN_SWITCHOVER_TIMEOUT, MXS_MODULE_PARAM_COUNT,
|
||||
"90" },
|
||||
{CN_REPLICATION_USER, MXS_MODULE_PARAM_STRING},
|
||||
{CN_REPLICATION_PASSWORD, MXS_MODULE_PARAM_STRING},
|
||||
{CN_VERIFY_MASTER_FAILURE, MXS_MODULE_PARAM_BOOL,
|
||||
"true" },
|
||||
{CN_MASTER_FAILURE_TIMEOUT, MXS_MODULE_PARAM_COUNT,
|
||||
"10" },
|
||||
{CN_AUTO_REJOIN, MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{CN_ENFORCE_READONLY, MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{CN_NO_PROMOTE_SERVERS, MXS_MODULE_PARAM_SERVERLIST},
|
||||
{CN_PROMOTION_SQL_FILE, MXS_MODULE_PARAM_PATH},
|
||||
{CN_DEMOTION_SQL_FILE, MXS_MODULE_PARAM_PATH},
|
||||
{CN_SWITCHOVER_ON_LOW_DISK_SPACE, MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{CN_MAINTENANCE_ON_LOW_DISK_SPACE, MXS_MODULE_PARAM_BOOL,
|
||||
"true" },
|
||||
{CN_HANDLE_EVENTS, MXS_MODULE_PARAM_BOOL,
|
||||
"false" },
|
||||
{
|
||||
"detect_replication_lag",
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false"
|
||||
},
|
||||
{
|
||||
"detect_stale_master",
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"true"
|
||||
},
|
||||
{
|
||||
"detect_stale_slave",
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"true"
|
||||
},
|
||||
{
|
||||
"mysql51_replication",
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false",
|
||||
MXS_MODULE_OPT_DEPRECATED
|
||||
},
|
||||
{
|
||||
"multimaster",
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false",
|
||||
MXS_MODULE_OPT_DEPRECATED
|
||||
},
|
||||
{
|
||||
CN_DETECT_STANDALONE_MASTER,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"true"
|
||||
},
|
||||
{
|
||||
CN_FAILCOUNT,
|
||||
MXS_MODULE_PARAM_COUNT,
|
||||
"5"
|
||||
},
|
||||
{
|
||||
"allow_cluster_recovery",
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"true",
|
||||
MXS_MODULE_OPT_DEPRECATED
|
||||
},
|
||||
{
|
||||
"ignore_external_masters",
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false"
|
||||
},
|
||||
{
|
||||
CN_AUTO_FAILOVER,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false"
|
||||
},
|
||||
{
|
||||
CN_FAILOVER_TIMEOUT,
|
||||
MXS_MODULE_PARAM_COUNT,
|
||||
|
||||
"90"
|
||||
},
|
||||
{
|
||||
CN_SWITCHOVER_TIMEOUT,
|
||||
MXS_MODULE_PARAM_COUNT,
|
||||
"90"
|
||||
},
|
||||
{
|
||||
CN_REPLICATION_USER,
|
||||
MXS_MODULE_PARAM_STRING
|
||||
},
|
||||
{
|
||||
CN_REPLICATION_PASSWORD,
|
||||
MXS_MODULE_PARAM_STRING
|
||||
},
|
||||
{
|
||||
CN_VERIFY_MASTER_FAILURE,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"true"
|
||||
},
|
||||
{
|
||||
CN_MASTER_FAILURE_TIMEOUT,
|
||||
MXS_MODULE_PARAM_COUNT,
|
||||
"10"
|
||||
},
|
||||
{
|
||||
CN_AUTO_REJOIN,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false"
|
||||
},
|
||||
{
|
||||
CN_ENFORCE_READONLY,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false"
|
||||
},
|
||||
{
|
||||
CN_NO_PROMOTE_SERVERS,
|
||||
MXS_MODULE_PARAM_SERVERLIST
|
||||
},
|
||||
{
|
||||
CN_PROMOTION_SQL_FILE,
|
||||
MXS_MODULE_PARAM_PATH
|
||||
},
|
||||
{
|
||||
CN_DEMOTION_SQL_FILE,
|
||||
MXS_MODULE_PARAM_PATH
|
||||
},
|
||||
{
|
||||
CN_SWITCHOVER_ON_LOW_DISK_SPACE,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false"
|
||||
},
|
||||
{
|
||||
CN_MAINTENANCE_ON_LOW_DISK_SPACE,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"true"
|
||||
},
|
||||
{
|
||||
CN_HANDLE_EVENTS,
|
||||
MXS_MODULE_PARAM_BOOL,
|
||||
"false"
|
||||
},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
};
|
||||
|
@ -118,14 +118,14 @@ private:
|
||||
struct ManualCommand
|
||||
{
|
||||
public:
|
||||
std::mutex mutex; /**< Mutex used by the condition variables */
|
||||
std::condition_variable has_command; /**< Notified when a command is waiting
|
||||
std::mutex mutex; /**< Mutex used by the condition variables */
|
||||
std::condition_variable has_command; /**< Notified when a command is waiting
|
||||
* execution */
|
||||
bool command_waiting_exec = false; /**< Guard variable for the above */
|
||||
std::function<void(void)> method; /**< The method to run when executing the
|
||||
* command */
|
||||
std::condition_variable has_result; /**< Notified when the command has ran */
|
||||
bool result_waiting = false; /**< Guard variable for the above */
|
||||
std::condition_variable has_result; /**< Notified when the command has ran */
|
||||
bool result_waiting = false; /**< Guard variable for the above */
|
||||
};
|
||||
|
||||
ServerArray m_servers; /**< Servers of the monitor */
|
||||
@ -135,9 +135,9 @@ private:
|
||||
// Values updated by monitor
|
||||
MariaDBServer* m_master; /**< Master server for Master/Slave replication */
|
||||
MariaDBServer* m_next_master; /**< When master changes because of a failover/switchover, the
|
||||
* new
|
||||
* master is written here so the next monitor loop picks it
|
||||
*up. */
|
||||
* new
|
||||
* master is written here so the next monitor loop picks it
|
||||
* up. */
|
||||
IdToServerMap m_servers_by_id; /**< Map from server id:s to MariaDBServer */
|
||||
int64_t m_master_gtid_domain; /**< gtid_domain_id most recently seen on the master */
|
||||
std::string m_external_master_host; /**< External master host, for fail/switchover */
|
||||
@ -145,8 +145,8 @@ private:
|
||||
bool m_cluster_topology_changed; /**< Has cluster topology changed since last monitor loop? */
|
||||
bool m_cluster_modified; /**< Has a failover/switchover/rejoin been performed this
|
||||
* loop? */
|
||||
CycleMap m_cycles; /**< Map from cycle number to cycle member servers */
|
||||
CycleInfo m_master_cycle_status; /**< Info about master server cycle from previous round */
|
||||
CycleMap m_cycles; /**< Map from cycle number to cycle member servers */
|
||||
CycleInfo m_master_cycle_status; /**< Info about master server cycle from previous round */
|
||||
|
||||
// Replication topology detection settings
|
||||
bool m_detect_stale_master; /**< Monitor flag for MySQL replication Stale Master detection */
|
||||
@ -155,32 +155,32 @@ private:
|
||||
bool m_ignore_external_masters; /**< Ignore masters outside of the monitor configuration */
|
||||
|
||||
// Failover, switchover and rejoin settings
|
||||
bool m_auto_failover; /**< Is automatic master failover is enabled? */
|
||||
bool m_auto_rejoin; /**< Is automatic rejoin enabled? */
|
||||
int m_failcount; /**< Numer of cycles master must be down before auto-failover
|
||||
* begins */
|
||||
std::string m_replication_user; /**< Replication user for CHANGE MASTER TO-commands */
|
||||
std::string m_replication_password; /**< Replication password for CHANGE MASTER TO-commands */
|
||||
uint32_t m_failover_timeout; /**< Time limit in seconds for master failover */
|
||||
uint32_t m_switchover_timeout; /**< Time limit in seconds for master switchover */
|
||||
bool m_verify_master_failure; /**< Is master failure is verified via slaves? */
|
||||
int m_master_failure_timeout; /**< Master failure verification (via slaves) time in seconds
|
||||
* */
|
||||
ServerArray m_excluded_servers; /**< Servers banned for master promotion during auto-failover
|
||||
* or
|
||||
* autoselect switchover. */
|
||||
std::string m_promote_sql_file; /**< File with sql commands which are ran to a server being
|
||||
* promoted. */
|
||||
std::string m_demote_sql_file; /**< File with sql commands which are ran to a server being
|
||||
* demoted. */
|
||||
bool m_enforce_read_only_slaves; /**< Should the monitor set read-only=1 on any slave servers.
|
||||
* */
|
||||
bool m_switchover_on_low_disk_space; /**< Should the monitor do a switchover on low disk space. */
|
||||
bool m_maintenance_on_low_disk_space;/**< Set slave and unreplicating servers with low disk space
|
||||
* to
|
||||
* maintenance. */
|
||||
bool m_handle_event_scheduler; /**< Should failover/switchover handle any scheduled events on
|
||||
* the servers */
|
||||
bool m_auto_failover; /**< Is automatic master failover is enabled? */
|
||||
bool m_auto_rejoin; /**< Is automatic rejoin enabled? */
|
||||
int m_failcount; /**< Numer of cycles master must be down before auto-failover
|
||||
* begins */
|
||||
std::string m_replication_user; /**< Replication user for CHANGE MASTER TO-commands */
|
||||
std::string m_replication_password; /**< Replication password for CHANGE MASTER TO-commands */
|
||||
uint32_t m_failover_timeout; /**< Time limit in seconds for master failover */
|
||||
uint32_t m_switchover_timeout; /**< Time limit in seconds for master switchover */
|
||||
bool m_verify_master_failure; /**< Is master failure is verified via slaves? */
|
||||
int m_master_failure_timeout; /**< Master failure verification (via slaves) time in seconds
|
||||
* */
|
||||
ServerArray m_excluded_servers; /**< Servers banned for master promotion during auto-failover
|
||||
* or
|
||||
* autoselect switchover. */
|
||||
std::string m_promote_sql_file; /**< File with sql commands which are ran to a server being
|
||||
* promoted. */
|
||||
std::string m_demote_sql_file; /**< File with sql commands which are ran to a server being
|
||||
* demoted. */
|
||||
bool m_enforce_read_only_slaves; /**< Should the monitor set read-only=1 on any slave servers.
|
||||
* */
|
||||
bool m_switchover_on_low_disk_space; /**< Should the monitor do a switchover on low disk space. */
|
||||
bool m_maintenance_on_low_disk_space; /**< Set slave and unreplicating servers with low disk space
|
||||
* to
|
||||
* maintenance. */
|
||||
bool m_handle_event_scheduler; /**< Should failover/switchover handle any scheduled events on
|
||||
* the servers */
|
||||
|
||||
// Other settings
|
||||
bool m_log_no_master; /**< Should it be logged that there is no master */
|
||||
|
@ -1267,12 +1267,12 @@ string SlaveStatus::to_string() const
|
||||
slave_sql_running ? "Yes" : "No");
|
||||
|
||||
string rval = string_printf(
|
||||
" Host: %22s, IO/SQL running: %7s, Master ID: %4" PRId64 ", Gtid_IO_Pos: %s, R.Lag: %d",
|
||||
host_port.c_str(),
|
||||
running_states.c_str(),
|
||||
master_server_id,
|
||||
gtid_io_pos.to_string().c_str(),
|
||||
seconds_behind_master);
|
||||
" Host: %22s, IO/SQL running: %7s, Master ID: %4" PRId64 ", Gtid_IO_Pos: %s, R.Lag: %d",
|
||||
host_port.c_str(),
|
||||
running_states.c_str(),
|
||||
master_server_id,
|
||||
gtid_io_pos.to_string().c_str(),
|
||||
seconds_behind_master);
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
int master_port = PORT_UNKNOWN; /* Master server port. */
|
||||
slave_io_running_t slave_io_running = SLAVE_IO_NO; /* Slave I/O thread running state: * "Yes",
|
||||
* "Connecting" or "No" */
|
||||
bool slave_sql_running = false; /* Slave SQL thread running state, true if "Yes"
|
||||
bool slave_sql_running = false; /* Slave SQL thread running state, true if "Yes"
|
||||
* */
|
||||
GtidList gtid_io_pos; /* Gtid I/O position of the slave thread. */
|
||||
std::string last_error; /* Last IO or SQL error encountered. */
|
||||
@ -100,9 +100,9 @@ struct NodeData
|
||||
bool in_stack; /* Is this node currently is the search stack. */
|
||||
|
||||
// Results from algorithm runs. Should only be overwritten when server data has been queried.
|
||||
int cycle; /* Which cycle is this node part of, if any. */
|
||||
int reach; /* How many servers replicate from this server or its children. */
|
||||
ServerArray parents; /* Which nodes is this node replicating from. External masters
|
||||
int cycle; /* Which cycle is this node part of, if any. */
|
||||
int reach; /* How many servers replicate from this server or its children. */
|
||||
ServerArray parents; /* Which nodes is this node replicating from. External masters
|
||||
* excluded. */
|
||||
ServerArray children; /* Which nodes are replicating from this node. */
|
||||
std::vector<int64_t> external_masters; /* Server id:s of external masters. */
|
||||
@ -172,7 +172,7 @@ public:
|
||||
|
||||
/**
|
||||
* Update information which changes rarely. This method should be called after (re)connecting to a
|
||||
*backend.
|
||||
* backend.
|
||||
* Calling this every monitoring loop is overkill.
|
||||
*/
|
||||
void update_server_version();
|
||||
|
@ -103,26 +103,26 @@ int MariaDBMonitor::Test::run_tests()
|
||||
|
||||
// Test 2: 4 servers, two cycles with a connection between them
|
||||
init_servers(4);
|
||||
EdgeArray edges2 = {{{1, 2}, {2, 1}, {3, 2}, {3, 4}, {4, 3}}};
|
||||
EdgeArray edges2 = { { {1, 2}, {2, 1}, {3, 2}, {3, 4}, {4, 3}}};
|
||||
add_replication(edges2);
|
||||
CycleArray expected_cycles2 = {{{{1, 2}}, {{3, 4}}}};
|
||||
CycleArray expected_cycles2 = { { { {1, 2}}, { {3, 4}}}};
|
||||
results.push_back(check_result_cycles(expected_cycles2));
|
||||
|
||||
// Test 3: 6 servers, with one cycle
|
||||
init_servers(6);
|
||||
EdgeArray edges3 = {{{2, 1}, {3, 2}, {4, 3}, {2, 4}, {5, 1}, {6, 5}, {6, 4}}};
|
||||
EdgeArray edges3 = { { {2, 1}, {3, 2}, {4, 3}, {2, 4}, {5, 1}, {6, 5}, {6, 4}}};
|
||||
add_replication(edges3);
|
||||
CycleArray expected_cycles3 = {{{{2, 3, 4}}}};
|
||||
CycleArray expected_cycles3 = { { { {2, 3, 4}}}};
|
||||
results.push_back(check_result_cycles(expected_cycles3));
|
||||
|
||||
// Test 4: 10 servers, with a big cycle composed of two smaller ones plus non-cycle servers
|
||||
init_servers(10);
|
||||
EdgeArray edges4
|
||||
= { {{1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 4}, {3, 10}, {4, 1}, {5, 6}, {6, 7}, {6, 4}, {7, 8},
|
||||
{8, 6},
|
||||
{9, 8}}};
|
||||
= { { {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 4}, {3, 10}, {4, 1}, {5, 6}, {6, 7}, {6, 4}, {7, 8},
|
||||
{8, 6},
|
||||
{9, 8}}};
|
||||
add_replication(edges4);
|
||||
CycleArray expected_cycles4 = {{{{1, 5, 6, 7, 8, 4}}}};
|
||||
CycleArray expected_cycles4 = { { { {1, 5, 6, 7, 8, 4}}}};
|
||||
results.push_back(check_result_cycles(expected_cycles4));
|
||||
|
||||
clear_servers();
|
||||
|
Reference in New Issue
Block a user