From 81c7abb70e1385464698b22410fd9e43edd90cb0 Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Tue, 24 Oct 2023 15:02:22 +0000 Subject: Rewire `FileStorManager` config --- storage/src/tests/bucketdb/bucketmanagertest.cpp | 4 ++- .../persistence/common/filestortestfixture.cpp | 18 ++++++---- .../filestorage/filestormanagertest.cpp | 7 ++-- storage/src/tests/visiting/visitormanagertest.cpp | 4 ++- .../persistence/filestorage/filestormanager.cpp | 24 ++++++------- .../persistence/filestorage/filestormanager.h | 16 +++------ .../storage/storageserver/servicelayernode.cpp | 10 +++++- .../vespa/storage/storageserver/servicelayernode.h | 39 ++++++++++++---------- 8 files changed, 68 insertions(+), 54 deletions(-) (limited to 'storage') diff --git a/storage/src/tests/bucketdb/bucketmanagertest.cpp b/storage/src/tests/bucketdb/bucketmanagertest.cpp index 52ac6f7dba1..7a2c22553f7 100644 --- a/storage/src/tests/bucketdb/bucketmanagertest.cpp +++ b/storage/src/tests/bucketdb/bucketmanagertest.cpp @@ -158,7 +158,9 @@ void BucketManagerTest::setupTestEnvironment(bool fakePersistenceLayer, bool noD _bottom = bottom.get(); _top->push_back(std::move(bottom)); } else { - auto bottom = std::make_unique(config::ConfigUri(config.getConfigId()), + using vespa::config::content::StorFilestorConfig; + auto filestor_cfg = config_from(config_uri); + auto bottom = std::make_unique(*filestor_cfg, _node->getPersistenceProvider(), _node->getComponentRegister(), *_node, _node->get_host_info()); _top->push_back(std::move(bottom)); diff --git a/storage/src/tests/persistence/common/filestortestfixture.cpp b/storage/src/tests/persistence/common/filestortestfixture.cpp index c989acd5228..74d34fb0f50 100644 --- a/storage/src/tests/persistence/common/filestortestfixture.cpp +++ b/storage/src/tests/persistence/common/filestortestfixture.cpp @@ -1,15 +1,17 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -#include -#include +#include #include -#include +#include #include +#include #include -#include +#include #include +#include +#include +#include +#include #include using storage::spi::test::makeSpiBucket; @@ -73,7 +75,9 @@ FileStorTestFixture::TestFileStorComponents::TestFileStorComponents( manager(nullptr) { injector.inject(top); - auto fsm = std::make_unique(config::ConfigUri(fixture._config->getConfigId()), fixture._node->getPersistenceProvider(), + using vespa::config::content::StorFilestorConfig; + auto config = config_from(config::ConfigUri(fixture._config->getConfigId())); + auto fsm = std::make_unique(*config, fixture._node->getPersistenceProvider(), fixture._node->getComponentRegister(), *fixture._node, fixture._node->get_host_info()); manager = fsm.get(); top.push_back(std::move(fsm)); diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp index b09febce408..586863251c9 100644 --- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -223,8 +224,10 @@ struct TestFileStorComponents { explicit TestFileStorComponents(FileStorTestBase& test, bool use_small_config = false) : manager(nullptr) { - auto fsm = std::make_unique(config::ConfigUri((use_small_config ? test.smallConfig : test.config)->getConfigId()), - test._node->getPersistenceProvider(), + using vespa::config::content::StorFilestorConfig; + auto config_uri = config::ConfigUri((use_small_config ? test.smallConfig : test.config)->getConfigId()); + auto config = config_from(config_uri); + auto fsm = std::make_unique(*config, test._node->getPersistenceProvider(), test._node->getComponentRegister(), *test._node, test._node->get_host_info()); manager = fsm.get(); top.push_back(std::move(fsm)); diff --git a/storage/src/tests/visiting/visitormanagertest.cpp b/storage/src/tests/visiting/visitormanagertest.cpp index d4047bc9a72..4fb857f9e67 100644 --- a/storage/src/tests/visiting/visitormanagertest.cpp +++ b/storage/src/tests/visiting/visitormanagertest.cpp @@ -98,7 +98,9 @@ VisitorManagerTest::initializeTest(bool defer_manager_thread_start) defer_manager_thread_start); _manager = vm.get(); _top->push_back(std::move(vm)); - _top->push_back(std::make_unique(config::ConfigUri(config.getConfigId()), _node->getPersistenceProvider(), + using vespa::config::content::StorFilestorConfig; + auto filestor_cfg = config_from(config::ConfigUri(config.getConfigId())); + _top->push_back(std::make_unique(*filestor_cfg, _node->getPersistenceProvider(), _node->getComponentRegister(), *_node, _node->get_host_info())); _manager->setTimeBetweenTicks(10); _top->open(); diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp index 97be1a510c4..6c49fcd0878 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp +++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp @@ -62,7 +62,7 @@ private: } FileStorManager:: -FileStorManager(const config::ConfigUri & configUri, spi::PersistenceProvider& provider, +FileStorManager(const StorFilestorConfig& bootstrap_config, spi::PersistenceProvider& provider, ServiceLayerComponentRegister& compReg, DoneInitializeHandler& init_handler, HostInfo& hostInfoReporterRegistrar) : StorageLinkQueued("File store manager", compReg), @@ -75,7 +75,6 @@ FileStorManager(const config::ConfigUri & configUri, spi::PersistenceProvider& p _persistenceHandlers(), _threads(), _bucketOwnershipNotifier(std::make_unique(_component, *this)), - _configFetcher(std::make_unique(configUri.getContext())), _use_async_message_handling_on_schedule(false), _metrics(std::make_unique()), _filestorHandler(), @@ -85,8 +84,7 @@ FileStorManager(const config::ConfigUri & configUri, spi::PersistenceProvider& p _host_info_reporter(_component.getStateUpdater()), _resource_usage_listener_registration(provider.register_resource_usage_listener(_host_info_reporter)) { - _configFetcher->subscribe(configUri.getConfigId(), this); - _configFetcher->start(); + on_configure(bootstrap_config); _component.registerMetric(*_metrics); _component.registerStatusPage(*this); _component.getStateUpdater().addStateListener(*this); @@ -207,19 +205,19 @@ FileStorManager::getThreadLocalHandler() { } void -FileStorManager::configure(std::unique_ptr config) +FileStorManager::on_configure(const StorFilestorConfig& config) { // If true, this is not the first configure. const bool liveUpdate = ! _threads.empty(); - _use_async_message_handling_on_schedule = config->useAsyncMessageHandlingOnSchedule; - _host_info_reporter.set_noise_level(config->resourceUsageReporterNoiseLevel); - const bool use_dynamic_throttling = ((config->asyncOperationThrottlerType == StorFilestorConfig::AsyncOperationThrottlerType::DYNAMIC) || - (config->asyncOperationThrottler.type == StorFilestorConfig::AsyncOperationThrottler::Type::DYNAMIC)); - const bool throttle_merge_feed_ops = config->asyncOperationThrottler.throttleIndividualMergeFeedOps; + _use_async_message_handling_on_schedule = config.useAsyncMessageHandlingOnSchedule; + _host_info_reporter.set_noise_level(config.resourceUsageReporterNoiseLevel); + const bool use_dynamic_throttling = ((config.asyncOperationThrottlerType == StorFilestorConfig::AsyncOperationThrottlerType::DYNAMIC) || + (config.asyncOperationThrottler.type == StorFilestorConfig::AsyncOperationThrottler::Type::DYNAMIC)); + const bool throttle_merge_feed_ops = config.asyncOperationThrottler.throttleIndividualMergeFeedOps; if (!liveUpdate) { - _config = std::move(config); + _config = std::make_unique(config); uint32_t numThreads = std::max(1, _config->numThreads); uint32_t numStripes = std::max(1u, numThreads / 2); _metrics->initDiskMetrics(numStripes, computeAllPossibleHandlerThreads(*_config)); @@ -240,7 +238,7 @@ FileStorManager::configure(std::unique_ptr config) _bucketExecutorRegistration = _provider->register_executor(std::make_shared(*this)); } else { assert(_filestorHandler); - auto updated_dyn_throttle_params = dynamic_throttle_params_from_config(*config, _threads.size()); + auto updated_dyn_throttle_params = dynamic_throttle_params_from_config(config, _threads.size()); _filestorHandler->reconfigure_dynamic_throttler(updated_dyn_throttle_params); } // TODO remove once desired dynamic throttling behavior is set in stone @@ -828,8 +826,6 @@ void FileStorManager::onClose() LOG(debug, "Start closing"); _bucketExecutorRegistration.reset(); _resource_usage_listener_registration.reset(); - // Avoid getting config during shutdown - _configFetcher->close(); LOG(debug, "Closed _configFetcher."); _filestorHandler->close(); LOG(debug, "Closed _filestorHandler."); diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h index 68491ab1e38..96cff8dfeee 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h +++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h @@ -1,10 +1,4 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * @class storage::FileStorManager - * @ingroup filestorage - * - * @version $Id$ - */ #pragma once @@ -42,7 +36,6 @@ namespace spi { struct PersistenceProvider; } class ContentBucketSpace; struct FileStorManagerTest; -class ReadBucketList; class BucketOwnershipNotifier; class AbortBucketOperationsCommand; struct DoneInitializeHandler; @@ -54,10 +47,11 @@ class ProviderErrorWrapper; class FileStorManager : public StorageLinkQueued, public framework::HtmlStatusReporter, public StateListener, - private config::IFetcherCallback, public MessageSender, public spi::BucketExecutor { + using StorFilestorConfig = vespa::config::content::StorFilestorConfig; + ServiceLayerComponentRegister & _compReg; ServiceLayerComponent _component; std::unique_ptr _provider; @@ -69,7 +63,6 @@ class FileStorManager : public StorageLinkQueued, std::unique_ptr _bucketOwnershipNotifier; std::unique_ptr _config; - std::unique_ptr _configFetcher; bool _use_async_message_handling_on_schedule; std::shared_ptr _metrics; std::unique_ptr _filestorHandler; @@ -82,7 +75,7 @@ class FileStorManager : public StorageLinkQueued, std::unique_ptr _resource_usage_listener_registration; public: - FileStorManager(const config::ConfigUri &, spi::PersistenceProvider&, + FileStorManager(const StorFilestorConfig&, spi::PersistenceProvider&, ServiceLayerComponentRegister&, DoneInitializeHandler&, HostInfo&); FileStorManager(const FileStorManager &) = delete; FileStorManager& operator=(const FileStorManager &) = delete; @@ -118,8 +111,9 @@ public: const FileStorMetrics& get_metrics() const { return *_metrics; } + void on_configure(const vespa::config::content::StorFilestorConfig& config); + private: - void configure(std::unique_ptr config) override; PersistenceHandler & createRegisteredHandler(const ServiceLayerComponent & component); VESPA_DLL_LOCAL PersistenceHandler & getThreadLocalHandler(); diff --git a/storage/src/vespa/storage/storageserver/servicelayernode.cpp b/storage/src/vespa/storage/storageserver/servicelayernode.cpp index b6e87c1bb59..f494840ca13 100644 --- a/storage/src/vespa/storage/storageserver/servicelayernode.cpp +++ b/storage/src/vespa/storage/storageserver/servicelayernode.cpp @@ -43,6 +43,7 @@ ServiceLayerNode::ServiceLayerNode(const config::ConfigUri & configUri, _externalVisitors(externalVisitors), _persistence_bootstrap_config(std::move(bootstrap_configs.persistence_cfg)), _visitor_bootstrap_config(std::move(bootstrap_configs.visitor_cfg)), + _filestor_bootstrap_config(std::move(bootstrap_configs.filestor_cfg)), _bouncer(nullptr), _bucket_manager(nullptr), _changed_bucket_ownership_handler(nullptr), @@ -188,7 +189,8 @@ ServiceLayerNode::createChain(IStorageChainBuilder &builder) _modified_bucket_checker = bucket_checker.get(); builder.add(std::move(bucket_checker)); auto state_manager = releaseStateManager(); - auto filstor_manager = std::make_unique(_configUri, _persistenceProvider, _context.getComponentRegister(), + auto filstor_manager = std::make_unique(*_filestor_bootstrap_config, _persistenceProvider, + _context.getComponentRegister(), getDoneInitializeHandler(), state_manager->getHostInfo()); _fileStorManager = filstor_manager.get(); builder.add(std::move(filstor_manager)); @@ -227,6 +229,12 @@ ServiceLayerNode::on_configure(const StorVisitorConfig& config) _visitor_manager->on_configure(config); } +void +ServiceLayerNode::on_configure(const StorFilestorConfig& config) +{ + assert(_fileStorManager); + _fileStorManager->on_configure(config); +} ResumeGuard ServiceLayerNode::pause() diff --git a/storage/src/vespa/storage/storageserver/servicelayernode.h b/storage/src/vespa/storage/storageserver/servicelayernode.h index 078d179795f..ae39bb0805e 100644 --- a/storage/src/vespa/storage/storageserver/servicelayernode.h +++ b/storage/src/vespa/storage/storageserver/servicelayernode.h @@ -7,6 +7,7 @@ #include "storagenode.h" #include "vespa/vespalib/util/jsonstream.h" #include +#include #include #include #include @@ -31,30 +32,33 @@ class ServiceLayerNode { public: - using PersistenceConfig = vespa::config::content::PersistenceConfig; - using StorVisitorConfig = vespa::config::content::core::StorVisitorConfig; + using PersistenceConfig = vespa::config::content::PersistenceConfig; + using StorVisitorConfig = vespa::config::content::core::StorVisitorConfig; + using StorFilestorConfig = vespa::config::content::StorFilestorConfig; private: - ServiceLayerNodeContext& _context; - spi::PersistenceProvider& _persistenceProvider; - VisitorFactory::Map _externalVisitors; - std::unique_ptr _persistence_bootstrap_config; - std::unique_ptr _visitor_bootstrap_config; - Bouncer* _bouncer; - BucketManager* _bucket_manager; - ChangedBucketOwnershipHandler* _changed_bucket_ownership_handler; - FileStorManager* _fileStorManager; - MergeThrottler* _merge_throttler; - VisitorManager* _visitor_manager; - ModifiedBucketChecker* _modified_bucket_checker; - bool _init_has_been_called; + ServiceLayerNodeContext& _context; + spi::PersistenceProvider& _persistenceProvider; + VisitorFactory::Map _externalVisitors; + std::unique_ptr _persistence_bootstrap_config; + std::unique_ptr _visitor_bootstrap_config; + std::unique_ptr _filestor_bootstrap_config; + Bouncer* _bouncer; + BucketManager* _bucket_manager; + ChangedBucketOwnershipHandler* _changed_bucket_ownership_handler; + FileStorManager* _fileStorManager; + MergeThrottler* _merge_throttler; + VisitorManager* _visitor_manager; + ModifiedBucketChecker* _modified_bucket_checker; + bool _init_has_been_called; public: using UP = std::unique_ptr; struct ServiceLayerBootstrapConfigs { BootstrapConfigs storage_bootstrap_configs; - std::unique_ptr persistence_cfg; - std::unique_ptr visitor_cfg; + std::unique_ptr persistence_cfg; + std::unique_ptr visitor_cfg; + std::unique_ptr filestor_cfg; ServiceLayerBootstrapConfigs(); ~ServiceLayerBootstrapConfigs(); @@ -77,6 +81,7 @@ public: void on_configure(const StorServerConfig& config); void on_configure(const PersistenceConfig& config); void on_configure(const StorVisitorConfig& config); + void on_configure(const StorFilestorConfig& config); const lib::NodeType& getNodeType() const override { return lib::NodeType::STORAGE; } -- cgit v1.2.3