MXS-2271 Refactor disk space checking

The functions are now in MonitorServer. Disk space can only be checked
during specific ticks. If a server misses a tick (e.g. is down) it will
be checked after disk_space_check_interval has passed.
This commit is contained in:
Esa Korhonen
2019-03-13 13:05:50 +02:00
parent cc3891a43c
commit 3ac1b40b63
5 changed files with 96 additions and 68 deletions

View File

@ -334,7 +334,7 @@ json_t* MariaDBMonitor::to_json() const
*
* @param server The server to update
*/
void MariaDBMonitor::update_server(MariaDBServer* server)
void MariaDBMonitor::update_server(MariaDBServer* server, bool time_to_update_disk_space)
{
MonitorServer* mon_srv = server->m_server_base;
mxs_connect_result_t conn_status = mon_srv->ping_or_connect(m_settings.conn_settings);
@ -361,9 +361,9 @@ void MariaDBMonitor::update_server(MariaDBServer* server)
// If permissions are ok, continue.
if (!server->has_status(SERVER_AUTH_ERROR))
{
if (should_update_disk_space_status(mon_srv))
if (time_to_update_disk_space && mon_srv->can_update_disk_space_status())
{
update_disk_space_status(mon_srv);
mon_srv->update_disk_space_status();
}
// Query MariaDBServer specific data
@ -433,10 +433,12 @@ void MariaDBMonitor::tick()
mon_srv->mon_prev_status = status;
}
bool should_update_disk_space = check_disk_space_this_tick();
// Query all servers for their status.
for (MariaDBServer* server : m_servers)
{
update_server(server);
update_server(server, should_update_disk_space);
if (server->m_topology_changed)
{
m_cluster_topology_changed = true;