diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index ca66d573d..16ebcf8d7 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -39,6 +39,7 @@ Running | The server is running. Master | The server is the master. Slave | The server is a slave. Being Drained | The server is being drained. Existing connections can continue to be used, but no new connections will be created to the server. Typically this status bit is turned on manually using _maxctrl_, but a monitor may also turn it on. +Drained | The server has been drained. The server was being drained and now the number of connections to the server has dropped to 0. Maintenance | The server is under maintenance. Typically this status bit is turned on manually using _maxctrl_, but it will also be turned on for a server that for some reason is blocking connections from MaxScale. When a server is in maintenace mode, no connections will be created to it and existing connections will be closed. Slave of External Master | The server is a slave of a master that is not being monitored. diff --git a/include/maxscale/server.hh b/include/maxscale/server.hh index 66a64866a..1e35a7577 100644 --- a/include/maxscale/server.hh +++ b/include/maxscale/server.hh @@ -468,10 +468,15 @@ public: /** * Convert a set of server status flags to a string. * - * @param flags Status flags + * @param flags Status flags + * @param nConnections Number of current connections. Only affects the output + * if the @c SERVER_BEING_DRAINED bit is on. In that case, if + * the number of connections is 0 the state will be reported + * as 'Drained', otherwise as 'Being Drained'. + * * @return A string representation of the status flags */ - static std::string status_to_string(uint64_t flags); + static std::string status_to_string(uint64_t flags, int nConnections = -1); /** * Convert a status string to a status bit. Only converts one status element. diff --git a/server/core/server.cc b/server/core/server.cc index fdae6e279..ce0aa5474 100644 --- a/server/core/server.cc +++ b/server/core/server.cc @@ -611,7 +611,7 @@ void Server::dListServers(DCB* dcb) } } -string SERVER::status_to_string(uint64_t flags) +string SERVER::status_to_string(uint64_t flags, int nConnections) { string result; string separator; @@ -630,6 +630,7 @@ string SERVER::status_to_string(uint64_t flags) // should not change, but this is more dependant on the monitors and have already changed. // Also, system tests compare to these strings so the output must stay constant for now. const string maintenance = "Maintenance"; + const string drained = "Drained"; const string being_drained = "Being Drained"; const string master = "Master"; const string relay = "Relay Master"; @@ -651,7 +652,14 @@ string SERVER::status_to_string(uint64_t flags) } else if (status_is_being_drained(flags)) { - concatenate_if(true, being_drained); + if (nConnections == 0) + { + concatenate_if(true, drained); + } + else + { + concatenate_if(true, being_drained); + } } // Master cannot be a relay or a slave. @@ -684,7 +692,7 @@ string SERVER::status_to_string(uint64_t flags) string SERVER::status_string() const { - return status_to_string(status); + return status_to_string(status, stats.n_current); } void SERVER::set_status(uint64_t bit)