MXS-1883 Maintenance is now the only user-modifiable bit for a monitored server

The request to turn maintenance off/on is a separate flag, although the actual
status is still contained in the status bitfield.
This commit is contained in:
Esa Korhonen
2018-05-24 13:47:56 +03:00
parent 2f48d079db
commit c039821467
11 changed files with 182 additions and 40 deletions

View File

@ -121,4 +121,13 @@ static inline void atomic_synchronize()
*/
bool atomic_cas_ptr(void **variable, void** old_value, void *new_value);
/**
* Atomic read-and-write. Writes new value into the given memory address and returns the old value.
*
* @param variable The variable which is overwritten
* @param new_value The value to write
* @return The value before writing
*/
int atomic_exchange_int(int *variable, int new_value);
MXS_END_DECLS

View File

@ -41,6 +41,13 @@ extern const char CN_PERSISTMAXTIME[];
extern const char CN_PERSISTPOOLMAX[];
extern const char CN_PROXY_PROTOCOL[];
/**
* Maintenance mode request constants.
*/
const int MAINTENANCE_OFF = -100;
const int MAINTENANCE_NO_CHANGE = 0;
const int MAINTENANCE_ON = 100;
/**
* The server parameters used for weighting routing decissions
*/
@ -137,9 +144,9 @@ typedef struct server
int last_event; /**< The last event that occurred on this server */
int64_t triggered_at; /**< Time when the last event was triggered */
bool active_event; /**< Was MaxScale active when last event was observed */
// Values updated mainly by monitor
// Status descriptors. Updated automatically by a monitor or manually by the admin
uint64_t status; /**< Current status flag bitmap */
uint64_t status_pending; /**< Temporary status, usually written to current status once ready */
int maint_request; /**< Is admin requesting Maintenance=ON/OFF on the server? */
char version_string[MAX_SERVER_VERSION_LEN]; /**< Server version string as given by backend */
uint64_t version; /**< Server version numeric representation */
server_type_t server_type; /**< Server type (MariaDB or MySQL), deduced from version string */
@ -372,8 +379,6 @@ extern uint64_t server_map_status(const char *str);
extern void server_set_version_string(SERVER* server, const char* version_string);
extern void server_set_version(SERVER* server, const char* version_string, uint64_t version);
extern uint64_t server_get_version(const SERVER* server);
extern void server_set_status(SERVER *server, int bit);
extern void server_clear_status(SERVER *server, int bit);
extern void printServer(const SERVER *);
extern void printAllServers();

View File

@ -0,0 +1,24 @@
#pragma once
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2020-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <maxscale/cppdefs.hh>
#include <string>
#include <maxscale/server.h>
namespace maxscale
{
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);
}