MXS-1587 Rename mysqlmon to mariadbmon
'mysqlmon' is still accepted but 'mariadbmon' is loaded instead. This is done at runtime instead of e.g. by using a symbolic link, so that a warning can be logged. The warning is logged and the translation of the module name is made by the code that loads the modules so that it's easy to do the same thing for other modules as well. In a subsequent commit the documentation is updated.
This commit is contained in:
@ -35,6 +35,9 @@
|
||||
#include "internal/modules.h"
|
||||
#include "internal/config.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
typedef struct loaded_module
|
||||
{
|
||||
char *module; /**< The name of the module */
|
||||
@ -46,6 +49,54 @@ typedef struct loaded_module
|
||||
struct loaded_module *next; /**< Next module in the linked list */
|
||||
} LOADED_MODULE;
|
||||
|
||||
struct NAME_MAPPING
|
||||
{
|
||||
const char* type; // The type of the module.
|
||||
const char* from; // Old module name.
|
||||
const char* to; // What should be loaded instead.
|
||||
bool warned; // Whether a warning has been logged.
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static NAME_MAPPING name_mappings[] =
|
||||
{
|
||||
{ MODULE_MONITOR, "mysqlmon", "mariadbmon", false }
|
||||
};
|
||||
|
||||
static const size_t N_NAME_MAPPINGS = sizeof(name_mappings) / sizeof(name_mappings[0]);
|
||||
|
||||
static const char* get_effective_name(const char* name)
|
||||
{
|
||||
const char* effective_name = NULL;
|
||||
size_t i = 0;
|
||||
|
||||
while (!effective_name && (i < N_NAME_MAPPINGS))
|
||||
{
|
||||
NAME_MAPPING& nm = name_mappings[i];
|
||||
|
||||
if (strcasecmp(name, nm.from) == 0)
|
||||
{
|
||||
if (!nm.warned)
|
||||
{
|
||||
MXS_WARNING("%s module '%s' has been deprecated, use '%s' instead.",
|
||||
nm.type, nm.from, nm.to);
|
||||
nm.warned = true;
|
||||
}
|
||||
effective_name = nm.to;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
if (!effective_name)
|
||||
{
|
||||
effective_name = name;
|
||||
}
|
||||
|
||||
return effective_name;
|
||||
}
|
||||
|
||||
static LOADED_MODULE *registered = NULL;
|
||||
|
||||
static LOADED_MODULE *find_module(const char *module);
|
||||
@ -115,6 +166,8 @@ void *load_module(const char *module, const char *type)
|
||||
ss_dassert(module && type);
|
||||
LOADED_MODULE *mod;
|
||||
|
||||
module = get_effective_name(module);
|
||||
|
||||
if ((mod = find_module(module)) == NULL)
|
||||
{
|
||||
/** The module is not already loaded, search for the shared object */
|
||||
@ -169,6 +222,8 @@ void *load_module(const char *module, const char *type)
|
||||
|
||||
void unload_module(const char *module)
|
||||
{
|
||||
module = get_effective_name(module);
|
||||
|
||||
LOADED_MODULE *mod = find_module(module);
|
||||
|
||||
if (mod)
|
||||
@ -561,6 +616,8 @@ RESULTSET *moduleGetList()
|
||||
|
||||
const MXS_MODULE *get_module(const char *name, const char *type)
|
||||
{
|
||||
name = get_effective_name(name);
|
||||
|
||||
LOADED_MODULE *mod = find_module(name);
|
||||
|
||||
if (mod == NULL && type && load_module(name, type))
|
||||
|
@ -1,6 +1,6 @@
|
||||
add_subdirectory(galeramon)
|
||||
add_subdirectory(mmmon)
|
||||
add_subdirectory(mysqlmon)
|
||||
add_subdirectory(mariadbmon)
|
||||
add_subdirectory(ndbclustermon)
|
||||
add_subdirectory(auroramon)
|
||||
add_subdirectory(grmon)
|
||||
|
5
server/modules/monitor/mariadbmon/CMakeLists.txt
Normal file
5
server/modules/monitor/mariadbmon/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
add_library(mariadbmon SHARED mysql_mon.cc)
|
||||
target_link_libraries(mariadbmon maxscale-common)
|
||||
add_dependencies(mariadbmon pcre2)
|
||||
set_target_properties(mariadbmon PROPERTIES VERSION "1.4.0")
|
||||
install_module(mariadbmon core)
|
@ -1,5 +0,0 @@
|
||||
add_library(mysqlmon SHARED mysql_mon.cc)
|
||||
target_link_libraries(mysqlmon maxscale-common)
|
||||
add_dependencies(mysqlmon pcre2)
|
||||
set_target_properties(mysqlmon PROPERTIES VERSION "1.4.0")
|
||||
install_module(mysqlmon core)
|
Reference in New Issue
Block a user