diff --git a/server/core/load_utils.cc b/server/core/load_utils.cc index 3ef9f0761..517498320 100644 --- a/server/core/load_utils.cc +++ b/server/core/load_utils.cc @@ -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)) diff --git a/server/modules/monitor/CMakeLists.txt b/server/modules/monitor/CMakeLists.txt index 829b1c9d6..9c86696b2 100644 --- a/server/modules/monitor/CMakeLists.txt +++ b/server/modules/monitor/CMakeLists.txt @@ -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) diff --git a/server/modules/monitor/mariadbmon/CMakeLists.txt b/server/modules/monitor/mariadbmon/CMakeLists.txt new file mode 100644 index 000000000..af152bf4e --- /dev/null +++ b/server/modules/monitor/mariadbmon/CMakeLists.txt @@ -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) diff --git a/server/modules/monitor/mysqlmon/mysql_mon.cc b/server/modules/monitor/mariadbmon/mysql_mon.cc similarity index 100% rename from server/modules/monitor/mysqlmon/mysql_mon.cc rename to server/modules/monitor/mariadbmon/mysql_mon.cc diff --git a/server/modules/monitor/mysqlmon/CMakeLists.txt b/server/modules/monitor/mysqlmon/CMakeLists.txt deleted file mode 100644 index 3ae09f874..000000000 --- a/server/modules/monitor/mysqlmon/CMakeLists.txt +++ /dev/null @@ -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)