MXS-2220 mxs::server_status() accepts status flags
The overload is required to get rid of dummy SERVER objects.
This commit is contained in:
@ -482,6 +482,7 @@ double server_response_time_average(const SERVER* server);
|
|||||||
|
|
||||||
namespace maxscale
|
namespace maxscale
|
||||||
{
|
{
|
||||||
|
std::string server_status(uint64_t flags);
|
||||||
std::string server_status(const SERVER*);
|
std::string server_status(const SERVER*);
|
||||||
bool server_set_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
bool server_set_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||||
bool server_clear_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
bool server_clear_status(SERVER* server, int bit, std::string* errmsg_out = NULL);
|
||||||
|
@ -1542,17 +1542,12 @@ void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t
|
|||||||
|
|
||||||
static void mon_log_state_change(MXS_MONITORED_SERVER* ptr)
|
static void mon_log_state_change(MXS_MONITORED_SERVER* ptr)
|
||||||
{
|
{
|
||||||
SERVER srv;
|
string prev = mxs::server_status(ptr->mon_prev_status);
|
||||||
srv.status = ptr->mon_prev_status;
|
|
||||||
string prev = mxs::server_status(&srv);
|
|
||||||
string next = mxs::server_status(ptr->server);
|
string next = mxs::server_status(ptr->server);
|
||||||
MXS_NOTICE("Server changed state: %s[%s:%u]: %s. [%s] -> [%s]",
|
MXS_NOTICE("Server changed state: %s[%s:%u]: %s. [%s] -> [%s]",
|
||||||
ptr->server->name,
|
ptr->server->name, ptr->server->address, ptr->server->port,
|
||||||
ptr->server->address,
|
|
||||||
ptr->server->port,
|
|
||||||
mon_get_event_name(ptr),
|
mon_get_event_name(ptr),
|
||||||
prev.c_str(),
|
prev.c_str(), next.c_str());
|
||||||
next.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_MONITOR* monitor_server_in_use(const SERVER* server)
|
MXS_MONITOR* monitor_server_in_use(const SERVER* server)
|
||||||
@ -2858,12 +2853,9 @@ void MonitorInstanceSimple::tick()
|
|||||||
if (mon_status_changed(pMs) || mon_print_fail_status(pMs))
|
if (mon_status_changed(pMs) || mon_print_fail_status(pMs))
|
||||||
{
|
{
|
||||||
// The current status is still in pMs->pending_status.
|
// The current status is still in pMs->pending_status.
|
||||||
SERVER server = {};
|
|
||||||
server.status = pMs->pending_status;
|
|
||||||
MXS_DEBUG("Backend server [%s]:%d state : %s",
|
MXS_DEBUG("Backend server [%s]:%d state : %s",
|
||||||
pMs->server->address,
|
pMs->server->address, pMs->server->port,
|
||||||
pMs->server->port,
|
mxs::server_status(pMs->pending_status).c_str());
|
||||||
mxs::server_status(&server).c_str());
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -654,16 +654,13 @@ void dListServers(DCB* dcb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a set of server status flags to a string.
|
* Convert a set of server status flags to a string.
|
||||||
*
|
*
|
||||||
* @param server The server to return the status of
|
* @param flags Status flags
|
||||||
* @return A string representation of the status flags
|
* @return A string representation of the status flags
|
||||||
*/
|
*/
|
||||||
string mxs::server_status(const SERVER* server)
|
string mxs::server_status(uint64_t flags)
|
||||||
{
|
{
|
||||||
mxb_assert(server);
|
|
||||||
uint64_t server_status = server->status;
|
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
string separator;
|
string separator;
|
||||||
|
|
||||||
@ -693,35 +690,46 @@ string mxs::server_status(const SERVER* server)
|
|||||||
const string down = "Down";
|
const string down = "Down";
|
||||||
|
|
||||||
// Maintenance is usually set by user so is printed first.
|
// Maintenance is usually set by user so is printed first.
|
||||||
concatenate_if(status_is_in_maint(server_status), maintenance);
|
concatenate_if(status_is_in_maint(flags), maintenance);
|
||||||
// Master cannot be a relay or a slave.
|
// Master cannot be a relay or a slave.
|
||||||
if (status_is_master(server_status))
|
if (status_is_master(flags))
|
||||||
{
|
{
|
||||||
concatenate_if(true, master);
|
concatenate_if(true, master);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Relays are typically slaves as well. The binlog server may be an exception.
|
// Relays are typically slaves as well. The binlog server may be an exception.
|
||||||
concatenate_if(status_is_relay(server_status), relay);
|
concatenate_if(status_is_relay(flags), relay);
|
||||||
concatenate_if(status_is_slave(server_status), slave);
|
concatenate_if(status_is_slave(flags), slave);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following Galera and Cluster bits may be combined with master/slave.
|
// The following Galera and Cluster bits may be combined with master/slave.
|
||||||
concatenate_if(status_is_joined(server_status), synced);
|
concatenate_if(status_is_joined(flags), synced);
|
||||||
concatenate_if(status_is_ndb(server_status), ndb);
|
concatenate_if(status_is_ndb(flags), ndb);
|
||||||
// May be combined with other MariaDB monitor flags.
|
// May be combined with other MariaDB monitor flags.
|
||||||
concatenate_if(server_status & SERVER_SLAVE_OF_EXT_MASTER, slave_ext);
|
concatenate_if(flags & SERVER_SLAVE_OF_EXT_MASTER, slave_ext);
|
||||||
|
|
||||||
// Should this be printed only if server is master?
|
// Should this be printed only if server is master?
|
||||||
concatenate_if(server_status & SERVER_MASTER_STICKINESS, sticky);
|
concatenate_if(flags & SERVER_MASTER_STICKINESS, sticky);
|
||||||
|
|
||||||
concatenate_if(server_status & SERVER_AUTH_ERROR, auth_err);
|
concatenate_if(flags & SERVER_AUTH_ERROR, auth_err);
|
||||||
concatenate_if(status_is_running(server_status), running);
|
concatenate_if(status_is_running(flags), running);
|
||||||
concatenate_if(status_is_down(server_status), down);
|
concatenate_if(status_is_down(flags), down);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the current server status flags to a string.
|
||||||
|
*
|
||||||
|
* @param server The server to return the status for
|
||||||
|
* @return A string representation of the status
|
||||||
|
*/
|
||||||
|
string mxs::server_status(const SERVER* server)
|
||||||
|
{
|
||||||
|
mxb_assert(server);
|
||||||
|
return mxs::server_status(server->status);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Set a status bit in the server without locking
|
* Set a status bit in the server without locking
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user