diff options
8 files changed, 32 insertions, 31 deletions
diff --git a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp index 7a8247c8944..712ac681f30 100644 --- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp +++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp @@ -210,6 +210,8 @@ struct MyDocumentDBConfigOwner : public IDocumentDBConfigOwner virtual ~MyDocumentDBConfigOwner() { } virtual void reconfigure(const DocumentDBConfig::SP & config) override; + virtual bool getDelayedConfig() const override { return false; } + virtual int64_t getActiveGeneration() const override { return 0; } }; struct MyProtonConfigurerOwner : public IProtonConfigurerOwner diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 307707b7c6a..c3c2f95b059 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -827,6 +827,12 @@ DocumentDB::reconfigure(const DocumentDBConfig::SP & snapshot) } } +bool +DocumentDB::getDelayedConfig() const +{ + return _state.getDelayedConfig(); +} + void DocumentDB::enterRedoReprocessState() { diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index da933faeeb0..61c683ccf08 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -397,7 +397,6 @@ public: void retain() { _refCount.retain(); } void release() { _refCount.release(); } - bool getDelayedConfig() const { return _state.getDelayedConfig(); } /** * Implements IReplayConfig API. @@ -416,8 +415,8 @@ public: // Implements DocumentDBConfigOwner void reconfigure(const DocumentDBConfig::SP & snapshot) override; - - int64_t getActiveGeneration() const; + virtual bool getDelayedConfig() const override; + virtual int64_t getActiveGeneration() const override; // Implements IDocumentSubDBOwner void syncFeedView() override; diff --git a/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h index fd64dc6253f..60b5da3cbd4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_document_db_config_owner.h @@ -16,6 +16,8 @@ class IDocumentDBConfigOwner public: virtual ~IDocumentDBConfigOwner() { } virtual void reconfigure(const std::shared_ptr<DocumentDBConfig> & config) = 0; + virtual bool getDelayedConfig() const = 0; + virtual int64_t getActiveGeneration() const = 0; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index ae9aa130b72..2c9231a40ff 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -178,7 +178,6 @@ Proton::Proton(const config::ConfigUri & configUri, _flushEngine(), _rpcHooks(), _healthAdapter(*this), - _componentConfig(), _genericStateHandler(CUSTOM_COMPONENT_API_PATH, *this), _customComponentBindToken(), _customComponentRootToken(), @@ -251,10 +250,6 @@ Proton::init(const BootstrapConfig::SP & configSnapshot) (protonConfig.basedir, diskMemUsageSamplerConfig(protonConfig)); - _componentConfig.addConfig(vespalib::ComponentConfigProducer::Config("proton", - configSnapshot->getGeneration(), - "config obtained at startup")); - _metricsEngine.reset(new MetricsEngine()); _metricsEngine->addMetricsHook(_metricsHook); _fileHeaderContext.setClusterName(protonConfig.clustername, @@ -425,8 +420,6 @@ Proton::applyConfig(const BootstrapConfig::SP & configSnapshot) if (_persistenceProxy.get() != NULL) { _persistenceProxy->setRepo(*repo); } - _componentConfig.addConfig(vespalib::ComponentConfigProducer::Config("proton.documentdbs", - configSnapshot->getGeneration())); _diskMemUsageSampler-> setConfig(diskMemUsageSamplerConfig(protonConfig)); if (_memoryFlushConfigUpdater) { @@ -883,24 +876,7 @@ Proton::waitForOnlineState() void Proton::getComponentConfig(Consumer &consumer) { - _componentConfig.getComponentConfig(consumer); - std::vector<DocumentDB::SP> dbs; - { - std::shared_lock<std::shared_timed_mutex> guard(_mutex); - for (const auto &kv : _documentDBMap) { - dbs.push_back(kv.second); - } - } - for (const auto &docDb : dbs) { - vespalib::string name("proton.documentdb."); - name.append(docDb->getDocTypeName().getName()); - int64_t gen = docDb->getActiveGeneration(); - if (docDb->getDelayedConfig()) { - consumer.add(Config(name, gen, "has delayed attribute aspect change in config")); - } else { - consumer.add(Config(name, gen)); - } - } + _protonConfigurer.getComponentConfig().getComponentConfig(consumer); } int64_t diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index 68f6f4efc6a..9c107d92c3c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -32,7 +32,6 @@ #include <vespa/vespalib/net/component_config_producer.h> #include <vespa/vespalib/net/generic_state_handler.h> #include <vespa/vespalib/net/json_get_handler.h> -#include <vespa/vespalib/net/simple_component_config_producer.h> #include <vespa/vespalib/net/state_explorer.h> #include <vespa/vespalib/net/state_server.h> #include <vespa/vespalib/util/varholder.h> @@ -118,7 +117,6 @@ private: FlushEngine::UP _flushEngine; RPCHooks::UP _rpcHooks; HealthAdapter _healthAdapter; - vespalib::SimpleComponentConfigProducer _componentConfig; vespalib::GenericStateHandler _genericStateHandler; vespalib::JsonHandlerRepo::Token::UP _customComponentBindToken; vespalib::JsonHandlerRepo::Token::UP _customComponentRootToken; diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp index c7009754899..18ac1cf2ed5 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.cpp @@ -23,7 +23,8 @@ ProtonConfigurer::ProtonConfigurer(vespalib::ThreadStackExecutorBase &executor, _pendingConfigSnapshot(), _activeConfigSnapshot(), _mutex(), - _allowReconfig(false) + _allowReconfig(false), + _componentConfig() { } @@ -116,6 +117,8 @@ ProtonConfigurer::applyConfig(std::shared_ptr<ProtonConfigSnapshot> configSnapsh configureDocumentDB(*configSnapshot, docTypeName, ddbConfig.configid, initializeThreads); } pruneDocumentDBs(*configSnapshot); + size_t gen = bootstrapConfig->getGeneration(); + _componentConfig.addConfig({"proton", gen}); std::lock_guard<std::mutex> guard(_mutex); _activeConfigSnapshot = configSnapshot; } @@ -135,10 +138,20 @@ ProtonConfigurer::configureDocumentDB(const ProtonConfigSnapshot &configSnapshot if (newdb != nullptr) { auto insres = _documentDBs.insert(std::make_pair(docTypeName, newdb)); assert(insres.second); + dbitr = insres.first; + } else { + return; } } else { dbitr->second->reconfigure(documentDBConfig); } + vespalib::string componentName("proton.documentdb." + docTypeName.getName()); + size_t gen = dbitr->second->getActiveGeneration(); + if (dbitr->second->getDelayedConfig()) { + _componentConfig.addConfig({componentName, gen, "has delayed attribute aspect change in config"}); + } else { + _componentConfig.addConfig({componentName, gen}); + } } void @@ -157,8 +170,10 @@ ProtonConfigurer::pruneDocumentDBs(const ProtonConfigSnapshot &configSnapshot) while (dbitr != _documentDBs.end()) { auto found(newDocTypes.find(dbitr->first)); if (found == newDocTypes.end()) { + vespalib::string componentName("proton.documentdb." + dbitr->first.getName()); _owner.removeDocumentDB(dbitr->first); dbitr = _documentDBs.erase(dbitr); + _componentConfig.removeConfig(componentName); } else { ++dbitr; } diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h index 17f25274876..b8c80602691 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton_configurer.h @@ -4,6 +4,7 @@ #include "i_proton_configurer.h" #include <vespa/searchcore/proton/common/doctypename.h> +#include <vespa/vespalib/net/simple_component_config_producer.h> #include <map> #include <mutex> #include "executor_thread_service.h" @@ -30,6 +31,7 @@ class ProtonConfigurer : public IProtonConfigurer std::shared_ptr<ProtonConfigSnapshot> _activeConfigSnapshot; mutable std::mutex _mutex; bool _allowReconfig; + vespalib::SimpleComponentConfigProducer _componentConfig; void performReconfigure(); bool skipConfig(const ProtonConfigSnapshot *configSnapshot, bool initialConfig); @@ -52,6 +54,7 @@ public: virtual void reconfigure(std::shared_ptr<ProtonConfigSnapshot> configSnapshot) override; void applyInitialConfig(InitializeThreads initializeThreads); + vespalib::SimpleComponentConfigProducer &getComponentConfig() { return _componentConfig; } }; } // namespace proton |