Rename server_is_running() to server_is_usable()

The previous name was misleading. The new server_is_running() only
checks for the running bit so that a server is always either running
or down.
This commit is contained in:
Esa Korhonen
2018-07-27 13:20:47 +03:00
parent 89dfc80f86
commit 1e33ab69f2
11 changed files with 51 additions and 23 deletions

View File

@ -539,7 +539,7 @@ MariaDBServer* MariaDBMonitor::find_topology_master_server(string* msg_out)
MariaDBServer* server = *iter;
if (server->m_node.parents.empty())
{
if (server->is_running() && !server->is_read_only())
if (server->is_usable() && !server->is_read_only())
{
master_candidates.push_back(server);
}
@ -624,7 +624,7 @@ MariaDBServer* MariaDBMonitor::find_master_inside_cycle(ServerArray& cycle_membe
{
MariaDBServer* server = *iter;
ss_dassert(server->m_node.cycle != NodeData::CYCLE_NONE);
if (server->is_running() && !server->is_read_only())
if (server->is_usable() && !server->is_read_only())
{
return server;
}
@ -798,7 +798,7 @@ void MariaDBMonitor::assign_slave_and_relay_master(MariaDBServer* start_node)
// The slave only gets the slave flags if it's running.
// TODO: If slaves with broken links should be given different flags, add that here.
slave->clear_status(MASTER_BITS);
if (slave->has_status(SERVER_RUNNING))
if (slave->is_running())
{
slave->set_status(SLAVE_BITS);
}

View File

@ -392,7 +392,7 @@ bool MariaDBMonitor::get_joinable_servers(ServerArray* output)
bool MariaDBMonitor::server_is_rejoin_suspect(MariaDBServer* rejoin_cand, json_t** output)
{
bool is_suspect = false;
if (rejoin_cand->is_running() && !rejoin_cand->is_master())
if (rejoin_cand->is_usable() && !rejoin_cand->is_master())
{
// Has no slave connection, yet is not a master.
if (rejoin_cand->m_slave_status.empty())
@ -1673,7 +1673,7 @@ void MariaDBMonitor::set_low_disk_slaves_maintenance()
// Only set pure slave and standalone servers to maintenance.
for (MariaDBServer* server : m_servers)
{
if (server->has_status(SERVER_DISK_SPACE_EXHAUSTED) && server->is_running() &&
if (server->has_status(SERVER_DISK_SPACE_EXHAUSTED) && server->is_usable() &&
!server->is_master() && !server->is_relay_master())
{
server->set_status(SERVER_MAINT);

View File

@ -443,6 +443,11 @@ bool MariaDBServer::is_slave() const
return status_is_slave(m_server_base->pending_status);
}
bool MariaDBServer::is_usable() const
{
return status_is_usable(m_server_base->pending_status);
}
bool MariaDBServer::is_running() const
{
return status_is_running(m_server_base->pending_status);

View File

@ -229,35 +229,42 @@ public:
bool wait_until_gtid(const GtidList& target, int timeout, json_t** err_out);
/**
* Convenience method for SERVER_IS_MASTER
* Check if server is a running master.
*
* @return True if server is a master
*/
bool is_master() const;
/**
* Convenience method for SERVER_IS_SLAVE
* Check if server is a running slave.
*
* @return True if server is a slave
*/
bool is_slave() const;
/**
* Convenience method for SERVER_IS_RUNNING
* Check if server is running and not in maintenance.
*
* @return True if server is usable
*/
bool is_usable() const;
/**
* Check if server is running.
*
* @return True if server is running
*/
bool is_running() const;
/**
* Convenience method for SERVER_IS_DOWN
* Check if server is down.
*
* @return True if server is down
*/
bool is_down() const;
/**
* Convenience method for SERVER_IN_MAINT
* Check if server is in maintenance.
*/
bool is_in_maintenance() const;