diff --git a/include/maxscale/server.hh b/include/maxscale/server.hh index 9e9c25b46..87de25a29 100644 --- a/include/maxscale/server.hh +++ b/include/maxscale/server.hh @@ -19,6 +19,7 @@ #include #include #include +#include /** * Server configuration parameters names @@ -30,6 +31,12 @@ extern const char CN_PERSISTPOOLMAX[]; extern const char CN_PROXY_PROTOCOL[]; extern const char CN_RANK[]; +// The enum values for `rank` +extern const MXS_ENUM_VALUE rank_values[]; + +// Default value for `rank` +extern const char* DEFAULT_RANK; + /** * Status bits in the SERVER->status member, which describes the general state of a server. Although the * individual bits are independent, not all combinations make sense or are used. The bitfield is 64bits wide. diff --git a/server/core/config.cc b/server/core/config.cc index 4f254f9f0..e21f6ffd5 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -425,7 +425,8 @@ const MXS_MODULE_PARAM config_server_params[] = {CN_SSL_CERT_VERIFY_DEPTH, MXS_MODULE_PARAM_COUNT, "9"}, {CN_SSL_VERIFY_PEER_CERTIFICATE, MXS_MODULE_PARAM_BOOL, "true"}, {CN_DISK_SPACE_THRESHOLD, MXS_MODULE_PARAM_STRING}, - {CN_RANK, MXS_MODULE_PARAM_COUNT, "2147483647"}, + {CN_RANK, MXS_MODULE_PARAM_ENUM, DEFAULT_RANK, + MXS_MODULE_OPT_ENUM_UNIQUE, rank_values}, {NULL} }; diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 369ed9a1e..c4be67836 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -621,9 +621,11 @@ bool runtime_alter_server(Server* server, const char* key, const char* value) } if (strcmp(key, CN_RANK) == 0) { - if (auto i = get_positive_int(value)) + auto v = config_enum_to_value(value, rank_values); + + if (v != MXS_UNKNOWN_ENUM_VALUE) { - server->set_rank(i); + server->set_rank(v); } else { diff --git a/server/core/server.cc b/server/core/server.cc index 154037209..c87e8a63f 100644 --- a/server/core/server.cc +++ b/server/core/server.cc @@ -65,6 +65,15 @@ const char CN_PERSISTPOOLMAX[] = "persistpoolmax"; const char CN_PROXY_PROTOCOL[] = "proxy_protocol"; const char CN_RANK[] = "rank"; +const MXS_ENUM_VALUE rank_values[] = +{ + {"primary", 1}, + {"secondary", 2}, + {NULL} +}; + +const char* DEFAULT_RANK = "primary"; + namespace { @@ -252,7 +261,7 @@ Server* Server::server_alloc(const char* name, MXS_CONFIG_PARAMETER* params) server->persistent = persistent; server->last_event = SERVER_UP_EVENT; server->status = SERVER_RUNNING; - server->m_settings.rank = params->get_integer(CN_RANK); + server->m_settings.rank = params->get_enum(CN_RANK, rank_values); mxb_assert(server->m_settings.rank > 0); if (!monuser.empty())