MXS-2220 Add server version and type information struct
The old fields are still used.
This commit is contained in:
@ -51,36 +51,13 @@ struct SERVER_STATS
|
||||
uint64_t packets = 0; /**< Number of packets routed to this server */
|
||||
};
|
||||
|
||||
/* Server version */
|
||||
struct SERVER_VERSION
|
||||
{
|
||||
uint32_t major;
|
||||
uint32_t minor;
|
||||
uint32_t patch;
|
||||
};
|
||||
|
||||
// TODO: Add clustrix etc types
|
||||
enum server_type_t
|
||||
{
|
||||
SERVER_TYPE_MARIADB,
|
||||
SERVER_TYPE_MYSQL
|
||||
};
|
||||
|
||||
static inline void server_decode_version(uint64_t version, SERVER_VERSION* server_version)
|
||||
{
|
||||
uint32_t major = version / 10000;
|
||||
uint32_t minor = (version - major * 10000) / 100;
|
||||
uint32_t patch = version - major * 10000 - minor * 100;
|
||||
|
||||
server_version->major = major;
|
||||
server_version->minor = minor;
|
||||
server_version->patch = patch;
|
||||
}
|
||||
|
||||
static uint64_t server_encode_version(const SERVER_VERSION* server_version)
|
||||
{
|
||||
return server_version->major * 10000 + server_version->minor * 100 + server_version->patch;
|
||||
}
|
||||
|
||||
/**
|
||||
* The SERVER structure defines a backend server. Each server has a name
|
||||
* or IP address for the server, a port that the server listens on and
|
||||
@ -96,6 +73,13 @@ public:
|
||||
static const int MAX_VERSION_LEN = 256;
|
||||
static const int RLAG_UNDEFINED = -1; // Default replication lag value
|
||||
|
||||
struct Version
|
||||
{
|
||||
uint32_t major = 0;
|
||||
uint32_t minor = 0;
|
||||
uint32_t patch = 0;
|
||||
};
|
||||
|
||||
// Base settings
|
||||
char* name = nullptr; /**< Server config name */
|
||||
char* protocol = nullptr; /**< Backend protocol module name */
|
||||
@ -180,6 +164,21 @@ public:
|
||||
*/
|
||||
virtual std::string get_custom_parameter(const std::string& name) const = 0;
|
||||
|
||||
/**
|
||||
* Update server version.
|
||||
*
|
||||
* @param version_num New numeric version
|
||||
* @param version_str New version string
|
||||
*/
|
||||
virtual void set_version(uint64_t version_num, const std::string& version_str) = 0;
|
||||
|
||||
/**
|
||||
* Get numeric version information. TODO: Rename to "version" once cleanup is done.
|
||||
*
|
||||
* @return Major, minor and patch numbers
|
||||
*/
|
||||
virtual Version get_version() const = 0;
|
||||
|
||||
protected:
|
||||
SERVER()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user