diff --git a/include/maxscale/config2.hh b/include/maxscale/config2.hh index 85abc2fad..c84940290 100644 --- a/include/maxscale/config2.hh +++ b/include/maxscale/config2.hh @@ -815,9 +815,15 @@ public: /** * Constructor * + * @param name The object (i.e. section name) of this configuration. * @param pSpecification The specification this instance is a configuration of. */ - Configuration(const Specification* pSpecification); + Configuration(const std::string& name, const Specification* pSpecification); + + /** + * @return The The object (i.e. section name) of this configuration. + */ + const std::string& name() const; /** * @return The specification of this configuration. @@ -880,6 +886,7 @@ private: void remove(Type* pValue); private: + std::string m_name; const Specification& m_specification; ValuesByName m_values; }; diff --git a/server/core/config2.cc b/server/core/config2.cc index 6ee0b0a15..023655a09 100644 --- a/server/core/config2.cc +++ b/server/core/config2.cc @@ -385,11 +385,17 @@ void Param::populate(MXS_MODULE_PARAM& param) const /** * class Configuration */ -Configuration::Configuration(const config::Specification* pSpecification) - : m_specification(*pSpecification) +Configuration::Configuration(const std::string& name, const config::Specification* pSpecification) + : m_name(name) + , m_specification(*pSpecification) { } +const std::string& Configuration::name() const +{ + return m_name; +} + const config::Specification& Configuration::specification() const { return m_specification; diff --git a/server/core/test/test_config2.cc b/server/core/test/test_config2.cc index 06c48fbfe..9fdca79f0 100644 --- a/server/core/test/test_config2.cc +++ b/server/core/test/test_config2.cc @@ -338,7 +338,7 @@ int main() specification.document(cout); - config::Configuration configuration(&specification); + config::Configuration configuration("test", &specification); int nErrors = 0; diff --git a/server/modules/filter/cache/cacheconfig.cc b/server/modules/filter/cache/cacheconfig.cc index 9a65c8f8c..3a0d48b4b 100644 --- a/server/modules/filter/cache/cacheconfig.cc +++ b/server/modules/filter/cache/cacheconfig.cc @@ -146,8 +146,8 @@ config::ParamBool CacheConfig::s_enabled( true ); -CacheConfig::CacheConfig() - : config::Configuration(&s_specification) +CacheConfig::CacheConfig(const std::string& name) + : config::Configuration(name, &s_specification) , storage(this, &s_storage) , storage_options(this, &s_storage_options) , hard_ttl(this, &s_hard_ttl) diff --git a/server/modules/filter/cache/cacheconfig.hh b/server/modules/filter/cache/cacheconfig.hh index 25d2c1d79..6437b8a20 100644 --- a/server/modules/filter/cache/cacheconfig.hh +++ b/server/modules/filter/cache/cacheconfig.hh @@ -38,7 +38,7 @@ const cache_thread_model CACHE_DEFAULT_THREAD_MODEL = CACHE_THREAD_MODEL_ST; class CacheConfig : public config::Configuration { public: - CacheConfig(); + CacheConfig(const std::string& name); ~CacheConfig(); CacheConfig(const CacheConfig&) = delete; diff --git a/server/modules/filter/cache/cachefilter.cc b/server/modules/filter/cache/cachefilter.cc index cab2d4187..f1452ee0d 100644 --- a/server/modules/filter/cache/cachefilter.cc +++ b/server/modules/filter/cache/cachefilter.cc @@ -144,7 +144,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() // CacheFilter // -CacheFilter::CacheFilter() +CacheFilter::CacheFilter(const std::string& name) + : m_config(name) { } @@ -155,7 +156,7 @@ CacheFilter::~CacheFilter() // static CacheFilter* CacheFilter::create(const char* zName, MXS_CONFIG_PARAMETER* ppParams) { - CacheFilter* pFilter = new CacheFilter; + CacheFilter* pFilter = new CacheFilter(zName); if (pFilter) { diff --git a/server/modules/filter/cache/cachefilter.hh b/server/modules/filter/cache/cachefilter.hh index 2f90e39d4..5315ac201 100644 --- a/server/modules/filter/cache/cachefilter.hh +++ b/server/modules/filter/cache/cachefilter.hh @@ -49,7 +49,7 @@ public: private: - CacheFilter(); + CacheFilter(const std::string& name); CacheFilter(const CacheFilter&); CacheFilter& operator=(const CacheFilter&); diff --git a/server/modules/monitor/clustrixmon/clustrixmonitor.cc b/server/modules/monitor/clustrixmon/clustrixmonitor.cc index 67e409f5f..bdf1aa753 100644 --- a/server/modules/monitor/clustrixmon/clustrixmonitor.cc +++ b/server/modules/monitor/clustrixmon/clustrixmonitor.cc @@ -190,8 +190,8 @@ sqlite3* open_or_create_db(const std::string& path) } } -ClustrixMonitor::Config::Config() - : m_configuration(&clustrixmon::specification) +ClustrixMonitor::Config::Config(const std::string& name) + : m_configuration(name, &clustrixmon::specification) , m_cluster_monitor_interval(&m_configuration, &clustrixmon::cluster_monitor_interval) , m_health_check_threshold(&m_configuration, &clustrixmon::health_check_threshold) , m_dynamic_node_detection(&m_configuration, &clustrixmon::dynamic_node_detection) @@ -212,6 +212,7 @@ bool ClustrixMonitor::Config::configure(const MXS_CONFIG_PARAMETER& params) ClustrixMonitor::ClustrixMonitor(const string& name, const string& module, sqlite3* pDb) : MonitorWorker(name, module) + , m_config(name) , m_pDb(pDb) { } diff --git a/server/modules/monitor/clustrixmon/clustrixmonitor.hh b/server/modules/monitor/clustrixmon/clustrixmonitor.hh index 6e4387fdb..fd2e1f4ed 100644 --- a/server/modules/monitor/clustrixmon/clustrixmonitor.hh +++ b/server/modules/monitor/clustrixmon/clustrixmonitor.hh @@ -31,7 +31,7 @@ public: class Config { public: - Config(); + Config(const std::string& name); static void populate(MXS_MODULE& module); diff --git a/server/modules/routing/smartrouter/smartrouter.cc b/server/modules/routing/smartrouter/smartrouter.cc index 2c2d2e56f..81af59ae5 100644 --- a/server/modules/routing/smartrouter/smartrouter.cc +++ b/server/modules/routing/smartrouter/smartrouter.cc @@ -65,8 +65,8 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() return &info; } -SmartRouter::Config::Config() - : config::Configuration(&smartquery::specification) +SmartRouter::Config::Config(const std::string& name) + : config::Configuration(name, &smartquery::specification) , m_master(this, &smartquery::master) { } @@ -100,10 +100,10 @@ bool SmartRouter::Config::post_configure(const MXS_CONFIG_PARAMETER& params) { if (strcmp(pServer->address, "127.0.0.1") == 0 || strcmp(pServer->address, "localhost")) { - MXS_WARNING("The server %s, used by the smartrouter, is currently accessed " + MXS_WARNING("The server %s, used by the smartrouter %s, is currently accessed " "using a TCP/IP socket (%s:%d). For better performance, a Unix " "domain socket should be used. See the 'socket' argument.", - pServer->name(), pServer->address, pServer->port); + pServer->name(), name().c_str(), pServer->address, pServer->port); } } } @@ -124,8 +124,9 @@ bool SmartRouter::Config::post_configure(const MXS_CONFIG_PARAMETER& params) s += server->name(); } - MXS_ERROR("The master server %s, is not one of the servers (%s) of the service.", - m_master.get()->name(), s.c_str()); + MXS_ERROR("The master server %s of the smartrouter %s, is not one of the " + "servers (%s) of the service.", + m_master.get()->name(), name().c_str(), s.c_str()); } return rv; @@ -149,6 +150,7 @@ SERVICE* SmartRouter::service() const SmartRouter::SmartRouter(SERVICE* service) : mxs::Router(service) + , m_config(service->name()) { } diff --git a/server/modules/routing/smartrouter/smartrouter.hh b/server/modules/routing/smartrouter/smartrouter.hh index e582c4e48..26ca0f812 100644 --- a/server/modules/routing/smartrouter/smartrouter.hh +++ b/server/modules/routing/smartrouter/smartrouter.hh @@ -32,7 +32,7 @@ public: class Config : public config::Configuration { public: - Config(); + Config(const std::string& name); Config(const Config&) = delete; Config& operator=(const Config&) = delete;