diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-05-23 13:35:00 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-05-23 13:35:00 +0000 |
commit | 9ddb444e4c1c9f2ead5e2d0693ead348cc30059a (patch) | |
tree | 916e82d9e3c1be6143385e67148c660ef4ca8a26 | |
parent | 892d4c41216a44ed704855239336316fe8f35293 (diff) |
- Avoid using shared_ptr for simpe AllocConfig and ThreadingServiceConfig.
- Reduce exposure of DocumentDBConfig and DocumentDBConfigManager classes.
31 files changed, 141 insertions, 151 deletions
diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp index ec48d8ebc65..64db35b7acb 100644 --- a/searchcore/src/apps/tests/persistenceconformance_test.cpp +++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp @@ -149,8 +149,8 @@ public: schema, std::make_shared<DocumentDBMaintenanceConfig>(), search::LogDocumentStore::Config(), - std::make_shared<const ThreadingServiceConfig>(ThreadingServiceConfig::make()), - std::make_shared<const AllocConfig>(), + ThreadingServiceConfig::make(), + AllocConfig::makeDefault(), "client", docTypeName.getName()); } diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 0a49b15d001..290b4546a5e 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -24,6 +24,7 @@ #include <vespa/searchcore/proton/server/minimal_document_retriever.h> #include <vespa/searchcore/proton/server/reconfig_params.h> #include <vespa/searchcore/proton/server/searchabledocsubdb.h> +#include <vespa/searchcore/proton/server/documentdbconfigmanager.h> #include <vespa/searchcore/proton/test/test.h> #include <vespa/searchcore/proton/test/thread_utils.h> #include <vespa/searchcore/proton/test/transport_helper.h> diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index 8be44f0fd09..d5acd5d40bf 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -12,6 +12,7 @@ #include <vespa/document/repo/documenttyperepo.h> #include <vespa/searchcore/proton/server/bootstrapconfig.h> #include <vespa/searchcore/proton/server/fileconfigmanager.h> +#include <vespa/searchcore/proton/server/documentdbconfigmanager.h> #include <vespa/searchcore/proton/test/documentdb_config_builder.h> #include <vespa/searchcore/proton/test/transport_helper.h> #include <vespa/searchsummary/config/config-juniperrc.h> 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 8a12219de3c..3aa014ca8ac 100644 --- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp +++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp @@ -106,8 +106,8 @@ struct DBConfigFixture { buildSchema(), std::make_shared<DocumentDBMaintenanceConfig>(), search::LogDocumentStore::Config(), - std::make_shared<const ThreadingServiceConfig>(ThreadingServiceConfig::make()), - std::make_shared<const AllocConfig>(), + ThreadingServiceConfig::make(), + AllocConfig::makeDefault(), configId, docTypeName); } diff --git a/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp b/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp index 14c96faef42..981106f018e 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp +++ b/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp @@ -202,8 +202,8 @@ std::shared_ptr<DocumentDBConfig> make_document_db_config(std::shared_ptr<Docume schema, std::make_shared<proton::DocumentDBMaintenanceConfig>(), search::LogDocumentStore::Config(), - std::make_shared<const proton::ThreadingServiceConfig>(proton::ThreadingServiceConfig::make()), - std::make_shared<const proton::AllocConfig>(), + proton::ThreadingServiceConfig::make(), + proton::AllocConfig::makeDefault(), "client", doc_type_name.getName()); } diff --git a/searchcore/src/vespa/searchcore/proton/common/alloc_config.cpp b/searchcore/src/vespa/searchcore/proton/common/alloc_config.cpp index 69a2d4f3ea9..2eb365e245c 100644 --- a/searchcore/src/vespa/searchcore/proton/common/alloc_config.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/alloc_config.cpp @@ -17,11 +17,6 @@ AllocConfig::AllocConfig(const AllocStrategy& alloc_strategy, { } -AllocConfig::AllocConfig() - : AllocConfig(AllocStrategy(), 1, 1) -{ -} - AllocConfig::~AllocConfig() = default; bool diff --git a/searchcore/src/vespa/searchcore/proton/common/alloc_config.h b/searchcore/src/vespa/searchcore/proton/common/alloc_config.h index 4eb604edb49..79a6cc51164 100644 --- a/searchcore/src/vespa/searchcore/proton/common/alloc_config.h +++ b/searchcore/src/vespa/searchcore/proton/common/alloc_config.h @@ -21,7 +21,6 @@ class AllocConfig public: AllocConfig(const AllocStrategy& alloc_strategy, uint32_t redundancy, uint32_t searchable_copies); - AllocConfig(); ~AllocConfig(); bool operator==(const AllocConfig &rhs) const noexcept; @@ -29,6 +28,7 @@ public: return !operator==(rhs); } AllocStrategy make_alloc_strategy(SubDbType sub_db_type) const; + static AllocConfig makeDefault() { return AllocConfig(AllocStrategy(), 1, 1); } }; } diff --git a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.h b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.h index 4ae0adeb5a6..e69b015e782 100644 --- a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfig.h @@ -2,16 +2,18 @@ #pragma once -#include "documentdbconfig.h" #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/searchcore/config/config-proton.h> #include <vespa/document/config/config-documenttypes.h> +#include <vespa/document/config/documenttypes_config_fwd.h> #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/config/retriever/configsnapshot.h> #include <vespa/fileacquirer/config-filedistributorrpc.h> namespace vespa::config::content::core::internal { class InternalBucketspacesType; } +namespace document { class DocumentTypeRepo; } + namespace proton { /** @@ -25,7 +27,7 @@ public: using FiledistributorrpcConfig = const cloud::config::filedistribution::FiledistributorrpcConfig; using FiledistributorrpcConfigSP = std::shared_ptr<FiledistributorrpcConfig>; - typedef DocumentDBConfig::DocumenttypesConfigSP DocumenttypesConfigSP; + using DocumenttypesConfigSP = std::shared_ptr<DocumenttypesConfig>; using BucketspacesConfig = const vespa::config::content::core::internal::InternalBucketspacesType; using BucketspacesConfigSP = std::shared_ptr<BucketspacesConfig>; diff --git a/searchcore/src/vespa/searchcore/proton/server/configstore.h b/searchcore/src/vespa/searchcore/proton/server/configstore.h index 4971c77369c..b6923e45e2a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/configstore.h +++ b/searchcore/src/vespa/searchcore/proton/server/configstore.h @@ -2,7 +2,6 @@ #pragma once -#include "documentdbconfig.h" #include "feedconfigstore.h" #include <vespa/searchcommon/common/schema.h> @@ -11,6 +10,8 @@ namespace vespa::config::search::core::internal { } namespace proton { +class DocumentDBConfig; + struct ConfigStore : FeedConfigStore { typedef std::unique_ptr<ConfigStore> UP; typedef search::SerialNum SerialNum; @@ -25,7 +26,7 @@ struct ConfigStore : FeedConfigStore { * resulting config snapshot. */ virtual void loadConfig(const DocumentDBConfig ¤tSnapshot, SerialNum serialNum, - DocumentDBConfig::SP &loadedSnapshot) = 0; + std::shared_ptr<DocumentDBConfig> &loadedSnapshot) = 0; virtual void saveConfig(const DocumentDBConfig &snapshot, SerialNum serialNum) = 0; virtual void removeInvalid() = 0; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 66b4d293100..3fdf82ea61d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -449,7 +449,7 @@ DocumentDB::applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum return; } - ConfigComparisonResult cmpres; + DocumentDBConfig::ComparisonResult cmpres; Schema::SP oldSchema; int64_t generation = configSnapshot->getGeneration(); { diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index 078fce65ff2..96944ba25e7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -8,7 +8,6 @@ #include "disk_mem_usage_forwarder.h" #include "document_db_config_owner.h" #include "documentdb_metrics_updater.h" -#include "documentdbconfig.h" #include "documentsubdbcollection.h" #include "executorthreadingservice.h" #include "i_document_subdb_owner.h" @@ -77,11 +76,10 @@ private: using IFlushTargetList = std::vector<std::shared_ptr<searchcorespi::IFlushTarget>>; using StatusReportUP = std::unique_ptr<StatusReport>; using ProtonConfig = const vespa::config::search::core::internal::InternalProtonType; - using ConfigComparisonResult = DocumentDBConfig::ComparisonResult; using lock_guard = std::lock_guard<std::mutex>; using SerialNum = search::SerialNum; using Schema = search::index::Schema; - + using DocumentDBConfigSP = std::shared_ptr<DocumentDBConfig>; DocTypeName _docTypeName; document::BucketSpace _bucketSpace; @@ -93,52 +91,52 @@ private: InitializeThreads _initializeThreads; // variables related to reconfig - DocumentDBConfig::SP _initConfigSnapshot; - SerialNum _initConfigSerialNum; - vespalib::VarHolder<DocumentDBConfig::SP> _pendingConfigSnapshot; - mutable std::mutex _configMutex; // protects _active* below. - mutable std::condition_variable _configCV; - DocumentDBConfig::SP _activeConfigSnapshot; - int64_t _activeConfigSnapshotGeneration; - const bool _validateAndSanitizeDocStore; - vespalib::Gate _initGate; - - ClusterStateHandler _clusterStateHandler; - BucketHandler _bucketHandler; - index::IndexConfig _indexCfg; - std::unique_ptr<ReplayThrottlingPolicy> _replay_throttling_policy; - ConfigStore::UP _config_store; - std::shared_ptr<matching::SessionManager> _sessionManager; // TODO: This should not have to be a shared pointer. - MetricsWireService &_metricsWireService; - DocumentDBTaggedMetrics _metrics; - std::unique_ptr<metrics::UpdateHook> _metricsHook; - vespalib::VarHolder<IFeedView::SP> _feedView; - vespalib::MonitoredRefCount _refCount; - IDocumentDBOwner &_owner; - storage::spi::BucketExecutor &_bucketExecutor; - DDBState _state; - DiskMemUsageForwarder _dmUsageForwarder; - AttributeUsageFilter _writeFilter; + DocumentDBConfigSP _initConfigSnapshot; + SerialNum _initConfigSerialNum; + vespalib::VarHolder<DocumentDBConfigSP> _pendingConfigSnapshot; + mutable std::mutex _configMutex; // protects _active* below. + mutable std::condition_variable _configCV; + DocumentDBConfigSP _activeConfigSnapshot; + int64_t _activeConfigSnapshotGeneration; + const bool _validateAndSanitizeDocStore; + vespalib::Gate _initGate; + + ClusterStateHandler _clusterStateHandler; + BucketHandler _bucketHandler; + index::IndexConfig _indexCfg; + std::unique_ptr<ReplayThrottlingPolicy> _replay_throttling_policy; + ConfigStore::UP _config_store; + std::shared_ptr<matching::SessionManager> _sessionManager; // TODO: This should not have to be a shared pointer. + MetricsWireService &_metricsWireService; + DocumentDBTaggedMetrics _metrics; + std::unique_ptr<metrics::UpdateHook> _metricsHook; + vespalib::VarHolder<IFeedView::SP> _feedView; + vespalib::MonitoredRefCount _refCount; + IDocumentDBOwner &_owner; + storage::spi::BucketExecutor &_bucketExecutor; + DDBState _state; + DiskMemUsageForwarder _dmUsageForwarder; + AttributeUsageFilter _writeFilter; std::shared_ptr<ITransientResourceUsageProvider> _transient_usage_provider; - std::unique_ptr<FeedHandler> _feedHandler; - DocumentSubDBCollection _subDBs; - MaintenanceController _maintenanceController; - DocumentDBJobTrackers _jobTrackers; - std::shared_ptr<IBucketStateCalculator> _calc; - DocumentDBMetricsUpdater _metricsUpdater; + std::unique_ptr<FeedHandler> _feedHandler; + DocumentSubDBCollection _subDBs; + MaintenanceController _maintenanceController; + DocumentDBJobTrackers _jobTrackers; + std::shared_ptr<IBucketStateCalculator> _calc; + DocumentDBMetricsUpdater _metricsUpdater; void registerReference(); - void setActiveConfig(const DocumentDBConfig::SP &config, int64_t generation); - DocumentDBConfig::SP getActiveConfig() const; + void setActiveConfig(const DocumentDBConfigSP &config, int64_t generation); + DocumentDBConfigSP getActiveConfig() const; void internalInit(); void initManagers(); - void initFinish(DocumentDBConfig::SP configSnapshot); - void performReconfig(DocumentDBConfig::SP configSnapshot); + void initFinish(DocumentDBConfigSP configSnapshot); + void performReconfig(DocumentDBConfigSP configSnapshot); void closeSubDBs(); void applySubDBConfig(const DocumentDBConfig &newConfigSnapshot, SerialNum serialNum, const ReconfigParams ¶ms); - void applyConfig(DocumentDBConfig::SP configSnapshot, SerialNum serialNum); + void applyConfig(DocumentDBConfigSP configSnapshot, SerialNum serialNum); /** * Save initial config if we don't have any saved config snapshots. @@ -195,7 +193,7 @@ private: friend class InitDoneTask; DocumentDB(const vespalib::string &baseDir, - DocumentDBConfig::SP currentSnapshot, + DocumentDBConfigSP currentSnapshot, const vespalib::string &tlsSpec, matching::QueryLimiter &queryLimiter, const DocTypeName &docTypeName, @@ -225,7 +223,7 @@ public: */ static DocumentDB::SP create(const vespalib::string &baseDir, - DocumentDBConfig::SP currentSnapshot, + DocumentDBConfigSP currentSnapshot, const vespalib::string &tlsSpec, matching::QueryLimiter &queryLimiter, const DocTypeName &docTypeName, @@ -371,8 +369,8 @@ public: bool getDelayedConfig() const { return _state.getDelayedConfig(); } void replayConfig(SerialNum serialNum) override; const DocTypeName & getDocTypeName() const { return _docTypeName; } - void newConfigSnapshot(DocumentDBConfig::SP snapshot); - void reconfigure(const DocumentDBConfig::SP & snapshot) override; + void newConfigSnapshot(DocumentDBConfigSP snapshot); + void reconfigure(const DocumentDBConfigSP & snapshot) override; int64_t getActiveGeneration() const; /* * Implements IDocumentSubDBOwner diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp index 5bc54404721..8c067cfc3db 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.cpp @@ -4,7 +4,6 @@ #include "threading_service_config.h" #include <vespa/config-attributes.h> #include <vespa/config-imported-fields.h> -#include <vespa/config-indexschema.h> #include <vespa/config-rank-profiles.h> #include <vespa/config-summary.h> #include <vespa/config-summarymap.h> @@ -51,7 +50,6 @@ DocumentDBConfig::ComparisonResult::ComparisonResult() storeChanged(false), visibilityDelayChanged(false), flushChanged(false), - threading_service_config_changed(false), alloc_config_changed(false) { } @@ -73,8 +71,8 @@ DocumentDBConfig::DocumentDBConfig( const Schema::SP &schema, const DocumentDBMaintenanceConfig::SP &maintenance, const search::LogDocumentStore::Config & storeConfig, - std::shared_ptr<const ThreadingServiceConfig> threading_service_config, - std::shared_ptr<const AllocConfig> alloc_config, + const ThreadingServiceConfig & threading_service_config, + const AllocConfig & alloc_config, const vespalib::string &configId, const vespalib::string &docTypeName) noexcept : _configId(configId), @@ -96,8 +94,8 @@ DocumentDBConfig::DocumentDBConfig( _schema(schema), _maintenance(maintenance), _storeConfig(storeConfig), - _threading_service_config(std::move(threading_service_config)), - _alloc_config(std::move(alloc_config)), + _threading_service_config(threading_service_config), + _alloc_config(alloc_config), _orig(), _delayedAttributeAspects(false) { } @@ -150,9 +148,9 @@ DocumentDBConfig::operator==(const DocumentDBConfig & rhs) const equals<TuneFileDocumentDB>(_tuneFileDocumentDB.get(), rhs._tuneFileDocumentDB.get()) && equals<Schema>(_schema.get(), rhs._schema.get()) && equals<DocumentDBMaintenanceConfig>(_maintenance.get(), rhs._maintenance.get()) && - _storeConfig == rhs._storeConfig && - equals<ThreadingServiceConfig>(_threading_service_config.get(), rhs._threading_service_config.get()) && - equals<AllocConfig>(_alloc_config.get(), rhs._alloc_config.get()); + (_storeConfig == rhs._storeConfig) && + (_threading_service_config == rhs._threading_service_config) && + (_alloc_config == rhs._alloc_config); } @@ -178,8 +176,7 @@ DocumentDBConfig::compare(const DocumentDBConfig &rhs) const retval.storeChanged = (_storeConfig != rhs._storeConfig); retval.visibilityDelayChanged = (_maintenance->getVisibilityDelay() != rhs._maintenance->getVisibilityDelay()); retval.flushChanged = !equals<DocumentDBMaintenanceConfig>(_maintenance.get(), rhs._maintenance.get(), [](const auto &l, const auto &r) { return l.getFlushConfig() == r.getFlushConfig(); }); - retval.threading_service_config_changed = !equals<ThreadingServiceConfig>(_threading_service_config.get(), rhs._threading_service_config.get()); - retval.alloc_config_changed = !equals<AllocConfig>(_alloc_config.get(), rhs._alloc_config.get()); + retval.alloc_config_changed = (_alloc_config != rhs._alloc_config); return retval; } @@ -201,9 +198,7 @@ DocumentDBConfig::valid() const _importedFields && _tuneFileDocumentDB && _schema && - _maintenance && - _threading_service_config && - _alloc_config; + _maintenance; } namespace diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h index c0b0eb9dd1b..5f5887df6ea 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfig.h @@ -3,15 +3,18 @@ #pragma once #include "document_db_maintenance_config.h" -#include <vespa/document/config/documenttypes_config_fwd.h> -#include <vespa/searchlib/common/tunefileinfo.h> -#include <vespa/searchcommon/common/schema.h> +#include "threading_service_config.h" +#include <vespa/searchcore/proton/common/alloc_config.h> #include <vespa/searchcore/proton/matching/ranking_constants.h> #include <vespa/searchcore/proton/matching/ranking_expressions.h> #include <vespa/searchcore/proton/matching/onnx_models.h> +#include <vespa/searchlib/common/tunefileinfo.h> +#include <vespa/searchlib/docstore/logdocumentstore.h> +#include <vespa/searchcommon/common/schema.h> +#include <vespa/document/config/documenttypes_config_fwd.h> + #include <vespa/config/retriever/configkeyset.h> #include <vespa/config/retriever/configsnapshot.h> -#include <vespa/searchlib/docstore/logdocumentstore.h> namespace vespa::config::search::internal { class InternalSummaryType; @@ -30,9 +33,6 @@ namespace document { namespace proton { -class ThreadingServiceConfig; -class AllocConfig; - class DocumentDBConfig { public: @@ -57,7 +57,6 @@ public: bool storeChanged; bool visibilityDelayChanged; bool flushChanged; - bool threading_service_config_changed; bool alloc_config_changed; ComparisonResult(); @@ -92,7 +91,6 @@ public: } return *this; } - ComparisonResult &set_threading_service_config_changed(bool val) { threading_service_config_changed = val; return *this; } ComparisonResult &set_alloc_config_changed(bool val) { alloc_config_changed = val; return *this; } }; @@ -137,8 +135,8 @@ private: search::index::Schema::SP _schema; MaintenanceConfigSP _maintenance; search::LogDocumentStore::Config _storeConfig; - std::shared_ptr<const ThreadingServiceConfig> _threading_service_config; - std::shared_ptr<const AllocConfig> _alloc_config; + const ThreadingServiceConfig _threading_service_config; + const AllocConfig _alloc_config; SP _orig; bool _delayedAttributeAspects; @@ -146,18 +144,18 @@ private: template <typename T> bool equals(const T * lhs, const T * rhs) const { - if (lhs == NULL) { - return rhs == NULL; + if (lhs == nullptr) { + return rhs == nullptr; } - return rhs != NULL && *lhs == *rhs; + return rhs != nullptr && *lhs == *rhs; } template <typename T, typename Func> bool equals(const T *lhs, const T *rhs, Func isEqual) const { - if (lhs == NULL) { - return rhs == NULL; + if (lhs == nullptr) { + return rhs == nullptr; } - return rhs != NULL && isEqual(*lhs, *rhs); + return rhs != nullptr && isEqual(*lhs, *rhs); } public: DocumentDBConfig(int64_t generation, @@ -177,8 +175,8 @@ public: const search::index::Schema::SP &schema, const DocumentDBMaintenanceConfig::SP &maintenance, const search::LogDocumentStore::Config & storeConfig, - std::shared_ptr<const ThreadingServiceConfig> threading_service_config, - std::shared_ptr<const AllocConfig> alloc_config, + const ThreadingServiceConfig & threading_service_config, + const AllocConfig & alloc_config, const vespalib::string &configId, const vespalib::string &docTypeName) noexcept; @@ -220,10 +218,8 @@ public: const MaintenanceConfigSP &getMaintenanceConfigSP() const { return _maintenance; } const search::TuneFileDocumentDB::SP &getTuneFileDocumentDBSP() const { return _tuneFileDocumentDB; } bool getDelayedAttributeAspects() const { return _delayedAttributeAspects; } - const ThreadingServiceConfig& get_threading_service_config() const { return *_threading_service_config; } - const std::shared_ptr<const ThreadingServiceConfig>& get_threading_service_config_shared_ptr() const { return _threading_service_config; } - const AllocConfig& get_alloc_config() const { return *_alloc_config; } - const std::shared_ptr<const AllocConfig>& get_alloc_config_shared_ptr() const { return _alloc_config; } + const ThreadingServiceConfig& get_threading_service_config() const { return _threading_service_config; } + const AllocConfig& get_alloc_config() const { return _alloc_config; } bool operator==(const DocumentDBConfig &rhs) const; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp index bb6d45ac482..64c1a9c58a7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp @@ -248,7 +248,7 @@ find_document_db_config_entry(const ProtonConfig::DocumentdbVector& document_dbs return default_document_db_config_entry; } -std::shared_ptr<const AllocConfig> +const AllocConfig build_alloc_config(const ProtonConfig& proton_config, const vespalib::string& doc_type_name) { auto& document_db_config_entry = find_document_db_config_entry(proton_config.documentdb, doc_type_name); @@ -256,9 +256,8 @@ build_alloc_config(const ProtonConfig& proton_config, const vespalib::string& do auto& distribution_config = proton_config.distribution; search::GrowStrategy grow_strategy(alloc_config.initialnumdocs, alloc_config.growfactor, alloc_config.growbias, alloc_config.multivaluegrowfactor); CompactionStrategy compaction_strategy(alloc_config.maxDeadBytesRatio, alloc_config.maxDeadAddressSpaceRatio, alloc_config.maxCompactBuffers, alloc_config.activeBuffersRatio); - return std::make_shared<const AllocConfig> - (AllocStrategy(grow_strategy, compaction_strategy, alloc_config.amortizecount), - distribution_config.redundancy, distribution_config.searchablecopies); + return AllocConfig(AllocStrategy(grow_strategy, compaction_strategy, alloc_config.amortizecount), + distribution_config.redundancy, distribution_config.searchablecopies); } vespalib::string @@ -305,8 +304,6 @@ DocumentDBConfigManager::update(FNET_Transport & transport, const ConfigSnapshot IndexschemaConfigSP newIndexschemaConfig; MaintenanceConfigSP oldMaintenanceConfig; MaintenanceConfigSP newMaintenanceConfig; - std::shared_ptr<const ThreadingServiceConfig> old_threading_service_config; - std::shared_ptr<const AllocConfig> old_alloc_config; constexpr vespalib::duration file_resolve_timeout = 60min; if (!_ignoreForwardedConfig) { @@ -332,8 +329,6 @@ DocumentDBConfigManager::update(FNET_Transport & transport, const ConfigSnapshot newOnnxModels = current->getOnnxModelsSP(); newIndexschemaConfig = current->getIndexschemaConfigSP(); oldMaintenanceConfig = current->getMaintenanceConfigSP(); - old_threading_service_config = current->get_threading_service_config_shared_ptr(); - old_alloc_config = current->get_alloc_config_shared_ptr(); currentGeneration = current->getGeneration(); } @@ -408,15 +403,6 @@ DocumentDBConfigManager::update(FNET_Transport & transport, const ConfigSnapshot if (newMaintenanceConfig && oldMaintenanceConfig && (*newMaintenanceConfig == *oldMaintenanceConfig)) { newMaintenanceConfig = oldMaintenanceConfig; } - auto new_threading_service_config = std::make_shared<const ThreadingServiceConfig>(ThreadingServiceConfig::make(_bootstrapConfig->getProtonConfig())); - if (new_threading_service_config && old_threading_service_config && - (*new_threading_service_config == *old_threading_service_config)) { - new_threading_service_config = old_threading_service_config; - } - auto new_alloc_config = build_alloc_config(_bootstrapConfig->getProtonConfig(), _docTypeName); - if (new_alloc_config && old_alloc_config &&(*new_alloc_config == *old_alloc_config)) { - new_alloc_config = old_alloc_config; - } auto newSnapshot = std::make_shared<DocumentDBConfig>(generation, newRankProfilesConfig, newRankingConstants, @@ -434,8 +420,8 @@ DocumentDBConfigManager::update(FNET_Transport & transport, const ConfigSnapshot schema, newMaintenanceConfig, storeConfig, - new_threading_service_config, - new_alloc_config, + ThreadingServiceConfig::make(_bootstrapConfig->getProtonConfig()), + build_alloc_config(_bootstrapConfig->getProtonConfig(), _docTypeName), _configId, _docTypeName); assert(newSnapshot->valid()); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp index 07786eba1bb..f7df7086316 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.cpp @@ -1,20 +1,19 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "documentdbconfigscout.h" +#include "documentdbconfig.h" #include <vespa/searchcore/proton/attribute/attributesconfigscout.h> using vespa::config::search::AttributesConfig; namespace proton { - -DocumentDBConfig::SP -DocumentDBConfigScout::scout(const DocumentDBConfig::SP &config, +std::shared_ptr<DocumentDBConfig> +DocumentDBConfigScout::scout(const std::shared_ptr<DocumentDBConfig> &config, const DocumentDBConfig &liveConfig) { AttributesConfigScout acScout(liveConfig.getAttributesConfig()); - std::shared_ptr<AttributesConfig> - ac(acScout.adjust(config->getAttributesConfig())); + std::shared_ptr<AttributesConfig> ac(acScout.adjust(config->getAttributesConfig())); if (*ac == config->getAttributesConfig()) return config; // no change return config->newFromAttributesConfig(ac); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.h index 5c1c9e9ac56..c0c19dab423 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigscout.h @@ -2,10 +2,11 @@ #pragma once -#include "documentdbconfig.h" +#include <memory> -namespace proton -{ +namespace proton { + +class DocumentDBConfig; /** * Class to create adjusted document db config that minimizes the number of @@ -16,9 +17,8 @@ namespace proton class DocumentDBConfigScout { public: - static DocumentDBConfig::SP - scout(const DocumentDBConfig::SP &config, - const DocumentDBConfig &liveConfig); + static std::shared_ptr<DocumentDBConfig> + scout(const std::shared_ptr<DocumentDBConfig> &config, const DocumentDBConfig &liveConfig); }; } diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp index ee811f93789..6f9cbf42efe 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.cpp @@ -2,6 +2,7 @@ #include "fast_access_doc_subdb_configurer.h" #include "i_attribute_writer_factory.h" +#include "documentdbconfig.h" #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/common/document_type_inspector.h> #include <vespa/searchcore/proton/common/indexschema_inspector.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index 8ffa6c0a84d..de0d2e65acd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -2,6 +2,7 @@ #include "fileconfigmanager.h" #include "bootstrapconfig.h" +#include "documentdbconfigmanager.h" #include <vespa/searchcore/proton/common/hw_info_sampler.h> #include <vespa/config/print/fileconfigwriter.h> #include <vespa/config-bucketspaces.h> @@ -17,6 +18,7 @@ #include <vespa/config-summary.h> #include <vespa/searchsummary/config/config-juniperrc.h> #include <vespa/config/helper/configgetter.hpp> +#include <vespa/fastos/file.h> #include <sstream> #include <cassert> #include <fcntl.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.h b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.h index cca68d7d84c..36fb2c5492b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.h +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.h @@ -2,11 +2,12 @@ #pragma once #include "configstore.h" -#include "documentdbconfigmanager.h" #include <vespa/searchlib/common/indexmetainfo.h> #include <vespa/searchlib/common/serialnum.h> #include <vespa/vespalib/objects/nbostream.h> +class FNET_Transport; + namespace proton { class FileConfigManager : public ConfigStore { @@ -47,7 +48,7 @@ public: * resulting config snapshot. */ void loadConfig(const DocumentDBConfig ¤tSnapshot, SerialNum serialNum, - DocumentDBConfig::SP &loadedSnapshot) override; + std::shared_ptr<DocumentDBConfig> &loadedSnapshot) override; void removeInvalid() override; void prune(SerialNum serialNum) override; diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp b/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp index 0681ff2c40b..989254c7aa1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "memoryconfigstore.h" +#include "documentdbconfig.h" #include <cassert> #include <vespa/log/log.h> @@ -38,12 +39,12 @@ void MemoryConfigStore::saveConfig(const DocumentDBConfig &config, SerialNum serial) { - _maps->configs[serial].reset(new DocumentDBConfig(config)); + _maps->configs[serial] = std::make_shared<DocumentDBConfig>(config); _maps->_valid.insert(serial); } void MemoryConfigStore::loadConfig(const DocumentDBConfig &, SerialNum serial, - DocumentDBConfig::SP &loaded_config) + std::shared_ptr<DocumentDBConfig> &loaded_config) { assert(hasValidSerial(serial)); loaded_config = _maps->configs[serial]; @@ -88,7 +89,7 @@ MemoryConfigStores::getConfigStore(const std::string &type) { if (!_config_maps[type].get()) { _config_maps[type].reset(new ConfigMaps); } - return ConfigStore::UP(new MemoryConfigStore(_config_maps[type])); + return std::make_unique<MemoryConfigStore>(_config_maps[type]); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.h b/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.h index 735006389dc..e42328d9fd1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.h +++ b/searchcore/src/vespa/searchcore/proton/server/memoryconfigstore.h @@ -3,15 +3,15 @@ #pragma once #include "configstore.h" -#include "documentdbconfig.h" #include <vespa/searchcommon/common/schema.h> #include <map> +#include <set> namespace proton { struct ConfigMaps { typedef std::shared_ptr<ConfigMaps> SP; - std::map<search::SerialNum, DocumentDBConfig::SP> configs; + std::map<search::SerialNum, std::shared_ptr<DocumentDBConfig>> configs; std::set<search::SerialNum> _valid; ~ConfigMaps(); }; @@ -32,7 +32,7 @@ public: bool hasValidSerial(SerialNum serial) const override; SerialNum getPrevValidSerial(SerialNum serial) const override; void saveConfig(const DocumentDBConfig &config, SerialNum serial) override; - void loadConfig(const DocumentDBConfig &, SerialNum serial, DocumentDBConfig::SP &loaded_config) override; + void loadConfig(const DocumentDBConfig &, SerialNum serial, std::shared_ptr<DocumentDBConfig> &loaded_config) override; void removeInvalid() override; void prune(SerialNum serial) override; void serializeConfig(SerialNum, vespalib::nbostream &) override; diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index c6e352e6df7..fd6f785fa58 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -15,6 +15,7 @@ #include "resource_usage_explorer.h" #include "searchhandlerproxy.h" #include "simpleflush.h" +#include "documentdbconfig.h" #include <vespa/document/base/exceptions.h> #include <vespa/document/datatype/documenttype.h> @@ -46,6 +47,7 @@ #include <vespa/vespalib/util/random.h> #include <vespa/vespalib/util/sequencedtaskexecutor.h> #include <vespa/vespalib/util/size_literals.h> +#include <vespa/fastos/file.h> #ifdef __linux__ #include <malloc.h> #endif @@ -398,7 +400,7 @@ Proton::addDocumentDB(const DocTypeName &docTypeName, document::BucketSpace bucketSpace, const vespalib::string &configId, const BootstrapConfig::SP &bootstrapConfig, - const DocumentDBConfig::SP &documentDBConfig, + const std::shared_ptr<DocumentDBConfig> &documentDBConfig, InitializeThreads initializeThreads) { try { @@ -586,7 +588,7 @@ DocumentDB::SP Proton::addDocumentDB(const document::DocumentType &docType, document::BucketSpace bucketSpace, const BootstrapConfig::SP &bootstrapConfig, - const DocumentDBConfig::SP &documentDBConfig, + const std::shared_ptr<DocumentDBConfig> &documentDBConfig, InitializeThreads initializeThreads) { const ProtonConfig &config(bootstrapConfig->getProtonConfig()); diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp index b1a7bd87067..64a09a0bb25 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.cpp @@ -4,6 +4,7 @@ #include "bootstrapconfig.h" #include "proton_config_snapshot.h" #include "i_proton_configurer.h" +#include "documentdbconfigmanager.h" #include <vespa/config/common/exceptions.h> #include <vespa/vespalib/util/exceptions.h> #include <thread> diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h index 77184f01604..a0c7c276e62 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h @@ -3,18 +3,21 @@ #pragma once #include "bootstrapconfigmanager.h" -#include "documentdbconfigmanager.h" #include "i_document_db_config_owner.h" #include <vespa/fastos/thread.h> #include <vespa/searchcore/proton/common/doctypename.h> #include <vespa/config/retriever/configretriever.h> #include <vespa/config/subscription/configuri.h> +#include <deque> + +class FNET_Transport; namespace document { class DocumentTypeRepo; } namespace proton { class BootstrapConfig; +class DocumentDBConfigManager; class IProtonConfigurer; /** @@ -46,7 +49,7 @@ public: void Run(FastOS_ThreadInterface * thread, void *arg) override; private: - typedef std::map<DocTypeName, DocumentDBConfigManager::SP> DBManagerMap; + typedef std::map<DocTypeName, std::shared_ptr<DocumentDBConfigManager>> DBManagerMap; using OldDocumentTypeRepo = std::pair<vespalib::steady_time, std::shared_ptr<const document::DocumentTypeRepo>>; using lock_guard = std::lock_guard<std::mutex>; diff --git a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp index a2817601c55..a320dd0f9ac 100644 --- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp @@ -4,6 +4,7 @@ #include "proton.h" #include <vespa/searchcore/proton/matchengine/matchengine.h> #include <vespa/vespalib/util/lambdatask.h> +#include <vespa/vespalib/util/compressionconfig.h> #include <vespa/fnet/frt/supervisor.h> #include <vespa/fnet/transport.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp index 9c8feebef50..2d5f9ff826b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "reconfig_params.h" #include "searchable_doc_subdb_configurer.h" +#include "reconfig_params.h" #include <vespa/searchcore/proton/matching/matcher.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h index f05a8e39ef4..7112cf7931e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h @@ -2,7 +2,6 @@ #pragma once -#include "documentdbconfigmanager.h" #include "isummaryadapter.h" #include "matchers.h" #include "matchview.h" @@ -23,6 +22,10 @@ #include <vespa/vespalib/util/varholder.h> #include <vespa/searchcore/proton/reference/i_document_db_reference_resolver.h> +namespace proton::matching { + class RankingExpressions; + class OnnxModels; +} namespace proton { struct IDocumentDBReferenceResolver; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index e6da0e958e8..08b34a3fbe6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -7,6 +7,7 @@ #include "searchview.h" #include "summaryadapter.h" #include "igetserialnum.h" +#include "document_db_flush_config.h" #include <vespa/eval/eval/value_cache/constant_tensor_loader.h> #include <vespa/eval/eval/value_cache/constant_value_cache.h> #include <vespa/searchcore/proton/attribute/attributemanager.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index d43b865c000..d694d92d0ad 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "documentdbconfig.h" #include "idocumentsubdb.h" #include "storeonlyfeedview.h" #include "summaryadapter.h" @@ -21,6 +20,7 @@ namespace proton { class AllocStrategy; +class DocumentDBConfig; struct DocumentDBTaggedMetrics; class DocumentMetaStoreInitializerResult; class FeedHandler; diff --git a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp index 301f2a97d14..5c57f821fe1 100644 --- a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp +++ b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.cpp @@ -48,15 +48,15 @@ DocumentDBConfigBuilder::DocumentDBConfigBuilder(int64_t generation, _schema(schema), _maintenance(std::make_shared<DocumentDBMaintenanceConfig>()), _store(), - _threading_service_config(std::make_shared<const ThreadingServiceConfig>(ThreadingServiceConfig::make())), - _alloc_config(std::make_shared<const AllocConfig>()), + _threading_service_config(ThreadingServiceConfig::make()), + _alloc_config(AllocConfig::makeDefault()), _configId(configId), _docTypeName(docTypeName) { } DocumentDBConfigBuilder::DocumentDBConfigBuilder(const DocumentDBConfig &cfg) - : _generation(cfg.getGeneration()), + : _generation(cfg.getGeneration()), _rankProfiles(cfg.getRankProfilesConfigSP()), _rankingConstants(cfg.getRankingConstantsSP()), _rankingExpressions(cfg.getRankingExpressionsSP()), @@ -73,13 +73,13 @@ DocumentDBConfigBuilder::DocumentDBConfigBuilder(const DocumentDBConfig &cfg) _schema(cfg.getSchemaSP()), _maintenance(cfg.getMaintenanceConfigSP()), _store(cfg.getStoreConfig()), - _threading_service_config(cfg.get_threading_service_config_shared_ptr()), - _alloc_config(cfg.get_alloc_config_shared_ptr()), + _threading_service_config(cfg.get_threading_service_config()), + _alloc_config(cfg.get_alloc_config()), _configId(cfg.getConfigId()), _docTypeName(cfg.getDocTypeName()) {} -DocumentDBConfigBuilder::~DocumentDBConfigBuilder() {} +DocumentDBConfigBuilder::~DocumentDBConfigBuilder() = default; DocumentDBConfig::SP DocumentDBConfigBuilder::build() diff --git a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h index 1d927e93d16..c8d49c3175b 100644 --- a/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h +++ b/searchcore/src/vespa/searchcore/proton/test/documentdb_config_builder.h @@ -28,8 +28,8 @@ private: search::index::Schema::SP _schema; DocumentDBConfig::MaintenanceConfigSP _maintenance; search::LogDocumentStore::Config _store; - std::shared_ptr<const ThreadingServiceConfig> _threading_service_config; - std::shared_ptr<const AllocConfig> _alloc_config; + const ThreadingServiceConfig _threading_service_config; + const AllocConfig _alloc_config; vespalib::string _configId; vespalib::string _docTypeName; |