From 8aae2bb96d56a1f4389ba3c67191445ecdd6921e Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Mon, 23 Oct 2023 10:00:57 +0000 Subject: Propagate existing StorageNode config from main Process reconfig loop --- .../storage/storageserver/distributornode.cpp | 5 +- .../vespa/storage/storageserver/distributornode.h | 8 +-- .../storage/storageserver/servicelayernode.cpp | 22 ++------ .../vespa/storage/storageserver/servicelayernode.h | 19 +++---- .../vespa/storage/storageserver/storagenode.cpp | 59 +++++++--------------- .../src/vespa/storage/storageserver/storagenode.h | 54 ++++++++++---------- storageserver/src/tests/storageservertest.cpp | 9 ++-- .../vespa/storageserver/app/distributorprocess.cpp | 18 +++++-- .../src/vespa/storageserver/app/process.cpp | 45 +++++++++++++---- .../src/vespa/storageserver/app/process.h | 26 ++++++++-- .../storageserver/app/servicelayerprocess.cpp | 28 +++++++++- .../vespa/storageserver/app/servicelayerprocess.h | 4 ++ 12 files changed, 167 insertions(+), 130 deletions(-) diff --git a/storage/src/vespa/storage/storageserver/distributornode.cpp b/storage/src/vespa/storage/storageserver/distributornode.cpp index 0c7bee01715..ef7579f8085 100644 --- a/storage/src/vespa/storage/storageserver/distributornode.cpp +++ b/storage/src/vespa/storage/storageserver/distributornode.cpp @@ -18,12 +18,13 @@ namespace storage { DistributorNode::DistributorNode( const config::ConfigUri& configUri, DistributorNodeContext& context, + BootstrapConfigs bootstrap_configs, ApplicationGenerationFetcher& generationFetcher, uint32_t num_distributor_stripes, StorageLink::UP communicationManager, std::unique_ptr storage_chain_builder) - : StorageNode(configUri, context, generationFetcher, - std::make_unique(), + : StorageNode(configUri, context, std::move(bootstrap_configs), + generationFetcher, std::make_unique(), !communicationManager ? NORMAL : SINGLE_THREADED_TEST_MODE), _threadPool(framework::TickingThreadPool::createDefault("distributor", 100ms, 1, 5s)), _stripe_pool(std::make_unique()), diff --git a/storage/src/vespa/storage/storageserver/distributornode.h b/storage/src/vespa/storage/storageserver/distributornode.h index b725f320851..7870af95a0f 100644 --- a/storage/src/vespa/storage/storageserver/distributornode.h +++ b/storage/src/vespa/storage/storageserver/distributornode.h @@ -1,11 +1,4 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * \class storage::DistributorNode - * \ingroup storageserver - * - * \brief Class for setting up a distributor node. - */ - #pragma once #include "distributornodecontext.h" @@ -49,6 +42,7 @@ public: DistributorNode(const config::ConfigUri & configUri, DistributorNodeContext&, + BootstrapConfigs bootstrap_configs, ApplicationGenerationFetcher& generationFetcher, uint32_t num_distributor_stripes, std::unique_ptr communicationManager, diff --git a/storage/src/vespa/storage/storageserver/servicelayernode.cpp b/storage/src/vespa/storage/storageserver/servicelayernode.cpp index e76625ccca7..3faa8a3ddec 100644 --- a/storage/src/vespa/storage/storageserver/servicelayernode.cpp +++ b/storage/src/vespa/storage/storageserver/servicelayernode.cpp @@ -24,11 +24,13 @@ LOG_SETUP(".node.servicelayer"); namespace storage { -ServiceLayerNode::ServiceLayerNode(const config::ConfigUri & configUri, ServiceLayerNodeContext& context, +ServiceLayerNode::ServiceLayerNode(const config::ConfigUri & configUri, + ServiceLayerNodeContext& context, + BootstrapConfigs bootstrap_configs, ApplicationGenerationFetcher& generationFetcher, spi::PersistenceProvider& persistenceProvider, const VisitorFactory::Map& externalVisitors) - : StorageNode(configUri, context, generationFetcher, std::make_unique()), + : StorageNode(configUri, context, std::move(bootstrap_configs), generationFetcher, std::make_unique()), _context(context), _persistenceProvider(persistenceProvider), _externalVisitors(externalVisitors), @@ -85,21 +87,6 @@ ServiceLayerNode::~ServiceLayerNode() shutdown(); } -void -ServiceLayerNode::subscribeToConfigs() -{ - StorageNode::subscribeToConfigs(); - // TODO consolidate this with existing config fetcher in StorageNode parent... - _configFetcher.reset(new config::ConfigFetcher(_configUri.getContext())); -} - -void -ServiceLayerNode::removeConfigSubscriptions() -{ - StorageNode::removeConfigSubscriptions(); - _configFetcher.reset(); -} - void ServiceLayerNode::initializeNodeSpecific() { @@ -134,6 +121,7 @@ ServiceLayerNode::handleLiveConfigUpdate(const InitialGuard & initGuard) ns.setCapacity(newC.nodeCapacity); } if (updated) { + // FIXME this always gets overwritten by StorageNode::handleLiveConfigUpdate...! Intentional? _server_config.active = std::make_unique(oldC); _component->getStateUpdater().setReportedNodeState(ns); } diff --git a/storage/src/vespa/storage/storageserver/servicelayernode.h b/storage/src/vespa/storage/storageserver/servicelayernode.h index 4a5c2e37bb3..dabc1c979a5 100644 --- a/storage/src/vespa/storage/storageserver/servicelayernode.h +++ b/storage/src/vespa/storage/storageserver/servicelayernode.h @@ -30,22 +30,21 @@ class ServiceLayerNode private NodeStateReporter { - ServiceLayerNodeContext & _context; - spi::PersistenceProvider & _persistenceProvider; - VisitorFactory::Map _externalVisitors; + ServiceLayerNodeContext& _context; + spi::PersistenceProvider& _persistenceProvider; + VisitorFactory::Map _externalVisitors; - // FIXME: Should probably use the fetcher in StorageNode - std::unique_ptr _configFetcher; - Bouncer* _bouncer; - BucketManager* _bucket_manager; - FileStorManager* _fileStorManager; - bool _init_has_been_called; + Bouncer* _bouncer; + BucketManager* _bucket_manager; + FileStorManager* _fileStorManager; + bool _init_has_been_called; public: using UP = std::unique_ptr; ServiceLayerNode(const config::ConfigUri & configUri, ServiceLayerNodeContext& context, + BootstrapConfigs bootstrap_configs, ApplicationGenerationFetcher& generationFetcher, spi::PersistenceProvider& persistenceProvider, const VisitorFactory::Map& externalVisitors); @@ -61,14 +60,12 @@ public: private: void report(vespalib::JsonStream &writer) const override; - void subscribeToConfigs() override; void initializeNodeSpecific() override; void perform_post_chain_creation_init_steps() override; void handleLiveConfigUpdate(const InitialGuard & initGuard) override; VisitorMessageSession::UP createSession(Visitor&, VisitorThread&) override; documentapi::Priority::Value toDocumentPriority(uint8_t storagePriority) const override; void createChain(IStorageChainBuilder &builder) override; - void removeConfigSubscriptions() override; void on_bouncer_config_changed() override; }; diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp index 3b0f3d875cd..ac833b9eae4 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.cpp +++ b/storage/src/vespa/storage/storageserver/storagenode.cpp @@ -69,11 +69,11 @@ removePidFile(const vespalib::string& pidfile) StorageNode::StorageNode( const config::ConfigUri & configUri, StorageNodeContext& context, + BootstrapConfigs bootstrap_configs, ApplicationGenerationFetcher& generationFetcher, std::unique_ptr hostInfo, RunMode mode) : _singleThreadedDebugMode(mode == SINGLE_THREADED_TEST_MODE), - _configFetcher(), _hostInfo(std::move(hostInfo)), _context(context), _generationFetcher(generationFetcher), @@ -90,10 +90,11 @@ StorageNode::StorageNode( _chain(), _configLock(), _initial_config_mutex(), - _bucket_spaces_config(), - _comm_mgr_config(), - _distribution_config(), - _server_config(), + _bouncer_config(std::move(bootstrap_configs.bouncer_cfg)), + _bucket_spaces_config(std::move(bootstrap_configs.bucket_spaces_cfg)), + _comm_mgr_config(std::move(bootstrap_configs.comm_mgr_cfg)), + _distribution_config(std::move(bootstrap_configs.distribution_cfg)), + _server_config(std::move(bootstrap_configs.server_cfg)), _component(), _node_identity(), _configUri(configUri), @@ -102,40 +103,16 @@ StorageNode::StorageNode( { } -void -StorageNode::subscribeToConfigs() -{ - _configFetcher = std::make_unique(_configUri.getContext()); - _configFetcher->subscribe(_configUri.getConfigId(), this); - _configFetcher->subscribe(_configUri.getConfigId(), this); - _configFetcher->subscribe(_configUri.getConfigId(), this); - _configFetcher->subscribe(_configUri.getConfigId(), this); - _configFetcher->subscribe(_configUri.getConfigId(), this); - - _configFetcher->start(); - - // All the below config instances were synchronously populated as part of start()ing the config fetcher - std::lock_guard configLockGuard(_configLock); - _bouncer_config.promote_staging_to_active(); - _bucket_spaces_config.promote_staging_to_active(); - _comm_mgr_config.promote_staging_to_active(); - _distribution_config.promote_staging_to_active(); - _server_config.promote_staging_to_active(); -} - void StorageNode::initialize(const NodeStateReporter & nodeStateReporter) { // Avoid racing with concurrent reconfigurations before we've set up the entire // node component stack. + // TODO no longer needed... probably std::lock_guard concurrent_config_guard(_initial_config_mutex); _context.getComponentRegister().registerShutdownListener(*this); - // Fetch configs needed first. These functions will just grab the config - // and store them away, while having the config lock. - subscribeToConfigs(); - // First update some basics that doesn't depend on anything else to be // available _rootFolder = server_config().rootFolder; @@ -260,7 +237,7 @@ StorageNode::handleLiveConfigUpdate(const InitialGuard & initGuard) DIFFERWARN(clusterName, "Cannot alter cluster name of node live"); DIFFERWARN(nodeIndex, "Cannot alter node index of node live"); DIFFERWARN(isDistributor, "Cannot alter role of node live"); - _server_config.active = std::make_unique(oldC); // TODO isn't this a no-op...? + _server_config.active = std::make_unique(oldC); // TODO this overwrites from ServiceLayerNode _server_config.staging.reset(); _deadLockDetector->enableWarning(server_config().enableDeadLockDetectorWarnings); _deadLockDetector->enableShutdown(server_config().enableDeadLockDetector); @@ -346,13 +323,6 @@ StorageNode::notifyDoneInitializing() StorageNode::~StorageNode() = default; -void -StorageNode::removeConfigSubscriptions() -{ - LOG(debug, "Removing config subscribers"); - _configFetcher.reset(); -} - void StorageNode::shutdown() { @@ -364,8 +334,6 @@ StorageNode::shutdown() LOG(debug, "Storage killed before requestShutdown() was called. No " "reason has been given for why we're stopping."); } - // Remove the subscription to avoid more callbacks from config - removeConfigSubscriptions(); if (_chain) { LOG(debug, "Closing storage chain"); @@ -535,13 +503,20 @@ StorageNode::set_storage_chain_builder(std::unique_ptr bui } template -StorageNode::ConfigWrapper::ConfigWrapper() = default; +StorageNode::ConfigWrapper::ConfigWrapper() noexcept = default; + +template +StorageNode::ConfigWrapper::ConfigWrapper(std::unique_ptr initial_active) noexcept + : staging(), + active(std::move(initial_active)) +{ +} template StorageNode::ConfigWrapper::~ConfigWrapper() = default; template -void StorageNode::ConfigWrapper::promote_staging_to_active() { +void StorageNode::ConfigWrapper::promote_staging_to_active() noexcept { assert(staging); active = std::move(staging); } diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h index ef2879d8f8a..25d08756ec1 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.h +++ b/storage/src/vespa/storage/storageserver/storagenode.h @@ -49,30 +49,40 @@ struct StorageNodeContext; namespace lib { class NodeType; } -class StorageNode : private config::IFetcherCallback, - private config::IFetcherCallback, - private config::IFetcherCallback, - private config::IFetcherCallback, - private config::IFetcherCallback, - private framework::MetricUpdateHook, +class StorageNode : private framework::MetricUpdateHook, private DoneInitializeHandler, private framework::defaultimplementation::ShutdownListener { public: + using BucketspacesConfig = vespa::config::content::core::BucketspacesConfig; + using CommunicationManagerConfig = vespa::config::content::core::StorCommunicationmanagerConfig; + using StorBouncerConfig = vespa::config::content::core::StorBouncerConfig; + using StorDistributionConfig = vespa::config::content::StorDistributionConfig; + using StorServerConfig = vespa::config::content::core::StorServerConfig; + enum RunMode { NORMAL, SINGLE_THREADED_TEST_MODE }; StorageNode(const StorageNode &) = delete; StorageNode & operator = (const StorageNode &) = delete; + struct BootstrapConfigs { + std::unique_ptr bouncer_cfg; + std::unique_ptr bucket_spaces_cfg; + std::unique_ptr comm_mgr_cfg; + std::unique_ptr distribution_cfg; + std::unique_ptr server_cfg; + }; + StorageNode(const config::ConfigUri& configUri, StorageNodeContext& context, + BootstrapConfigs bootstrap_configs, ApplicationGenerationFetcher& generationFetcher, std::unique_ptr hostInfo, RunMode = NORMAL); ~StorageNode() override; virtual const lib::NodeType& getNodeType() const = 0; - bool attemptedStopped() const; + [[nodiscard]] bool attemptedStopped() const; void notifyDoneInitializing() override; void waitUntilInitialized(vespalib::duration timeout = 15s); void updateMetrics(const MetricLockGuard & guard) override; @@ -88,19 +98,17 @@ public: void requestShutdown(vespalib::stringref reason) override; DoneInitializeHandler& getDoneInitializeHandler() { return *this; } + void configure(std::unique_ptr config); + void configure(std::unique_ptr config); + void configure(std::unique_ptr); + void configure(std::unique_ptr config); + void configure(std::unique_ptr config); + // For testing StorageLink* getChain() { return _chain.get(); } virtual void initializeStatusWebServer(); -protected: - using BucketspacesConfig = vespa::config::content::core::BucketspacesConfig; - using CommunicationManagerConfig = vespa::config::content::core::StorCommunicationmanagerConfig; - using StorBouncerConfig = vespa::config::content::core::StorBouncerConfig; - using StorDistributionConfig = vespa::config::content::StorDistributionConfig; - using StorServerConfig = vespa::config::content::core::StorServerConfig; private: bool _singleThreadedDebugMode; - // Subscriptions to config - std::unique_ptr _configFetcher; std::unique_ptr _hostInfo; @@ -131,26 +139,20 @@ private: std::unique_ptr staging; std::unique_ptr active; - ConfigWrapper(); + ConfigWrapper() noexcept; + explicit ConfigWrapper(std::unique_ptr initial_active) noexcept; ~ConfigWrapper(); - void promote_staging_to_active(); + void promote_staging_to_active() noexcept; }; template void stage_config_change(ConfigWrapper& my_cfg, std::unique_ptr new_cfg); - /** Implementation of config callbacks. */ - void configure(std::unique_ptr config) override; - void configure(std::unique_ptr config) override; - void configure(std::unique_ptr) override; - void configure(std::unique_ptr config) override; - void configure(std::unique_ptr config) override; - protected: // Lock taken while doing configuration of the server. std::mutex _configLock; - std::mutex _initial_config_mutex; + std::mutex _initial_config_mutex; // TODO can probably be removed using InitialGuard = std::lock_guard; ConfigWrapper _bouncer_config; @@ -193,13 +195,11 @@ protected: std::unique_ptr releaseStateManager(); void initialize(const NodeStateReporter & reporter); - virtual void subscribeToConfigs(); virtual void initializeNodeSpecific() = 0; virtual void perform_post_chain_creation_init_steps() = 0; virtual void createChain(IStorageChainBuilder &builder) = 0; virtual void handleLiveConfigUpdate(const InitialGuard & initGuard); void shutdown(); - virtual void removeConfigSubscriptions(); virtual void on_bouncer_config_changed() { /* no-op by default */ } public: diff --git a/storageserver/src/tests/storageservertest.cpp b/storageserver/src/tests/storageservertest.cpp index 2633449f28a..b18b241acaa 100644 --- a/storageserver/src/tests/storageservertest.cpp +++ b/storageserver/src/tests/storageservertest.cpp @@ -43,7 +43,7 @@ struct Node { struct Distributor : public Node { DistributorProcess _process; - Distributor(vdstestlib::DirConfig& config); + explicit Distributor(vdstestlib::DirConfig& config); ~Distributor() override; StorageNode& getNode() override { return _process.getNode(); } @@ -54,7 +54,7 @@ struct Storage : public Node { DummyServiceLayerProcess _process; StorageComponent::UP _component; - Storage(vdstestlib::DirConfig& config); + explicit Storage(vdstestlib::DirConfig& config); ~Storage() override; StorageNode& getNode() override { return _process.getNode(); } @@ -75,8 +75,7 @@ Storage::Storage(vdstestlib::DirConfig& config) { _process.setupConfig(60000ms); _process.createNode(); - _component = std::make_unique( - getContext().getComponentRegister(), "test"); + _component = std::make_unique(getContext().getComponentRegister(), "test"); } Storage::~Storage() = default; @@ -93,7 +92,6 @@ StorageServerTest::SetUp() storConfig = std::make_unique(getStandardConfig(true)); addSlobrokConfig(*distConfig, *slobrok); addSlobrokConfig(*storConfig, *slobrok); - storConfig->getConfig("stor-filestor").set("fail_disk_after_error_count", "1"); systemResult = system("mkdir -p vdsroot/disks/d0"); systemResult = system("mkdir -p vdsroot.distributor"); } @@ -101,6 +99,7 @@ StorageServerTest::SetUp() void StorageServerTest::TearDown() { + // TODO wipe temp dirs storConfig.reset(nullptr); distConfig.reset(nullptr); slobrok.reset(nullptr); diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp index aad813a49fc..b56a4e1884b 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp @@ -61,9 +61,6 @@ DistributorProcess::setupConfig(vespalib::duration subscribeTimeout) using vespa::config::content::core::StorDistributormanagerConfig; using vespa::config::content::core::StorVisitordispatcherConfig; - auto distr_cfg = config::ConfigGetter::getConfig( - _configUri.getConfigId(), _configUri.getContext(), subscribeTimeout); - _num_distributor_stripes = adjusted_num_distributor_stripes(distr_cfg->numDistributorStripes); _distributorConfigHandler = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); _visitDispatcherConfigHandler = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); Process::setupConfig(subscribeTimeout); @@ -99,8 +96,19 @@ DistributorProcess::configUpdated() void DistributorProcess::createNode() { - _node = std::make_unique(_configUri, _context, *this, _num_distributor_stripes, StorageLink::UP(), std::move(_storage_chain_builder)); - _node->handleConfigChange(*_distributorConfigHandler->getConfig()); + auto distributor_config = _distributorConfigHandler->getConfig(); + _num_distributor_stripes = adjusted_num_distributor_stripes(distributor_config->numDistributorStripes); + // TODO dedupe, consolidate + StorageNode::BootstrapConfigs bc; + bc.bucket_spaces_cfg = _bucket_spaces_cfg_handle->getConfig(); + bc.bouncer_cfg = _bouncer_cfg_handle->getConfig(); + bc.comm_mgr_cfg = _comm_mgr_cfg_handle->getConfig(); + bc.distribution_cfg = _distribution_cfg_handle->getConfig(); + bc.server_cfg = _server_cfg_handle->getConfig(); + + _node = std::make_unique(_configUri, _context, std::move(bc), *this, _num_distributor_stripes, + StorageLink::UP(), std::move(_storage_chain_builder)); + _node->handleConfigChange(*distributor_config); _node->handleConfigChange(*_visitDispatcherConfigHandler->getConfig()); } diff --git a/storageserver/src/vespa/storageserver/app/process.cpp b/storageserver/src/vespa/storageserver/app/process.cpp index 4b1586032e4..87b20f9ec2e 100644 --- a/storageserver/src/vespa/storageserver/app/process.cpp +++ b/storageserver/src/vespa/storageserver/app/process.cpp @@ -1,11 +1,12 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "process.h" + +#include #include #include #include #include -#include #include LOG_SETUP(".process"); @@ -24,11 +25,17 @@ Process::~Process() = default; void Process::setupConfig(vespalib::duration subscribeTimeout) { - _documentHandler = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _document_cfg_handle = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _bucket_spaces_cfg_handle = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _comm_mgr_cfg_handle = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _bouncer_cfg_handle = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _distribution_cfg_handle = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + _server_cfg_handle = _configSubscriber.subscribe(_configUri.getConfigId(), subscribeTimeout); + if (!_configSubscriber.nextConfig()) { - throw vespalib::TimeoutException("Could not subscribe to document config within timeout"); + throw vespalib::TimeoutException("Could not subscribe to configs within timeout"); } - _repos.push_back(DocumentTypeRepoFactory::make(*_documentHandler->getConfig())); + _repos.push_back(DocumentTypeRepoFactory::make(*_document_cfg_handle->getConfig())); getContext().getComponentRegister().setDocumentTypeRepo(_repos.back()); } @@ -36,26 +43,46 @@ bool Process::configUpdated() { _configSubscriber.nextGenerationNow(); - if (_documentHandler->isChanged()) { + if (_document_cfg_handle->isChanged()) { LOG(info, "Document config detected changed"); return true; } - return false; + bool changed = (_bucket_spaces_cfg_handle->isChanged() + || _comm_mgr_cfg_handle->isChanged() + || _bouncer_cfg_handle->isChanged() + || _distribution_cfg_handle->isChanged() + || _server_cfg_handle->isChanged()); + return changed; } void Process::updateConfig() { - if (_documentHandler->isChanged()) { - _repos.push_back(DocumentTypeRepoFactory::make(*_documentHandler->getConfig())); + if (_document_cfg_handle->isChanged()) { + _repos.push_back(DocumentTypeRepoFactory::make(*_document_cfg_handle->getConfig())); getNode().setNewDocumentRepo(_repos.back()); } + if (_bucket_spaces_cfg_handle->isChanged()) { + getNode().configure(_bucket_spaces_cfg_handle->getConfig()); + } + if (_comm_mgr_cfg_handle->isChanged()) { + getNode().configure(_comm_mgr_cfg_handle->getConfig()); + } + if (_bouncer_cfg_handle->isChanged()) { + getNode().configure(_bouncer_cfg_handle->getConfig()); + } + if (_distribution_cfg_handle->isChanged()) { + getNode().configure(_distribution_cfg_handle->getConfig()); + } + if (_server_cfg_handle->isChanged()) { + getNode().configure(_server_cfg_handle->getConfig()); + } } void Process::shutdown() { - removeConfigSubscriptions(); + removeConfigSubscriptions(); // TODO remove? unused } int64_t diff --git a/storageserver/src/vespa/storageserver/app/process.h b/storageserver/src/vespa/storageserver/app/process.h index e70427c6e04..a30611b78c8 100644 --- a/storageserver/src/vespa/storageserver/app/process.h +++ b/storageserver/src/vespa/storageserver/app/process.h @@ -14,10 +14,15 @@ #pragma once +#include +#include +#include +#include #include +#include +#include +#include #include -#include -#include namespace document { class DocumentTypeRepo; } @@ -28,19 +33,32 @@ struct StorageNodeContext; class Process : public ApplicationGenerationFetcher { protected: + using DocumentTypesConfig = document::config::DocumenttypesConfig; + using BucketspacesConfig = vespa::config::content::core::BucketspacesConfig; + using CommunicationManagerConfig = vespa::config::content::core::StorCommunicationmanagerConfig; + using StorBouncerConfig = vespa::config::content::core::StorBouncerConfig; + using StorDistributionConfig = vespa::config::content::StorDistributionConfig; + using StorServerConfig = vespa::config::content::core::StorServerConfig; + using DocumentTypeRepoSP = std::shared_ptr; config::ConfigUri _configUri; DocumentTypeRepoSP getTypeRepo() { return _repos.back(); } config::ConfigSubscriber _configSubscriber; + std::unique_ptr> _document_cfg_handle; + std::unique_ptr> _bucket_spaces_cfg_handle; + std::unique_ptr> _comm_mgr_cfg_handle; + std::unique_ptr> _bouncer_cfg_handle; + std::unique_ptr> _distribution_cfg_handle; + std::unique_ptr> _server_cfg_handle; + private: - config::ConfigHandle::UP _documentHandler; std::vector _repos; public: using UP = std::unique_ptr; - Process(const config::ConfigUri & configUri); + explicit Process(const config::ConfigUri & configUri); ~Process() override; virtual void setupConfig(vespalib::duration subscribeTimeout); diff --git a/storageserver/src/vespa/storageserver/app/servicelayerprocess.cpp b/storageserver/src/vespa/storageserver/app/servicelayerprocess.cpp index 369cca4b166..6b713b8e3f4 100644 --- a/storageserver/src/vespa/storageserver/app/servicelayerprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/servicelayerprocess.cpp @@ -50,12 +50,38 @@ ServiceLayerProcess::shutdown() _node.reset(); } +void +ServiceLayerProcess::setupConfig(vespalib::duration subscribe_timeout) +{ + Process::setupConfig(subscribe_timeout); +} + +void +ServiceLayerProcess::updateConfig() +{ + Process::updateConfig(); +} + +bool +ServiceLayerProcess::configUpdated() +{ + return Process::configUpdated(); +} + void ServiceLayerProcess::createNode() { add_external_visitors(); setupProvider(); - _node = std::make_unique(_configUri, _context, *this, getProvider(), _externalVisitors); + // TODO dedupe, consolidate + StorageNode::BootstrapConfigs bc; + bc.bucket_spaces_cfg = _bucket_spaces_cfg_handle->getConfig(); + bc.bouncer_cfg = _bouncer_cfg_handle->getConfig(); + bc.comm_mgr_cfg = _comm_mgr_cfg_handle->getConfig(); + bc.distribution_cfg = _distribution_cfg_handle->getConfig(); + bc.server_cfg = _server_cfg_handle->getConfig(); + + _node = std::make_unique(_configUri, _context, std::move(bc), *this, getProvider(), _externalVisitors); if (_storage_chain_builder) { _node->set_storage_chain_builder(std::move(_storage_chain_builder)); } diff --git a/storageserver/src/vespa/storageserver/app/servicelayerprocess.h b/storageserver/src/vespa/storageserver/app/servicelayerprocess.h index f95b952a68d..7e981748d1a 100644 --- a/storageserver/src/vespa/storageserver/app/servicelayerprocess.h +++ b/storageserver/src/vespa/storageserver/app/servicelayerprocess.h @@ -45,6 +45,10 @@ public: void shutdown() override; + void setupConfig(vespalib::duration subscribe_timeout) override; + bool configUpdated() override; + void updateConfig() override; + virtual void setupProvider() = 0; virtual spi::PersistenceProvider& getProvider() = 0; -- cgit v1.2.3 From 24ea2ed4064452a25e0816faedc3b589abc7ed3c Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Mon, 23 Oct 2023 15:50:15 +0000 Subject: Explicitly de-inline `BootstrapConfigs` ctor/dtor --- storage/src/vespa/storage/storageserver/storagenode.cpp | 5 +++++ storage/src/vespa/storage/storageserver/storagenode.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp index ac833b9eae4..f7a426a0527 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.cpp +++ b/storage/src/vespa/storage/storageserver/storagenode.cpp @@ -66,6 +66,11 @@ removePidFile(const vespalib::string& pidfile) } // End of anonymous namespace +StorageNode::BootstrapConfigs::BootstrapConfigs() = default; +StorageNode::BootstrapConfigs::~BootstrapConfigs() = default; +StorageNode::BootstrapConfigs::BootstrapConfigs(BootstrapConfigs&&) noexcept = default; +StorageNode::BootstrapConfigs& StorageNode::BootstrapConfigs::operator=(BootstrapConfigs&&) noexcept = default; + StorageNode::StorageNode( const config::ConfigUri & configUri, StorageNodeContext& context, diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h index 25d08756ec1..a96f6b52a66 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.h +++ b/storage/src/vespa/storage/storageserver/storagenode.h @@ -71,6 +71,11 @@ public: std::unique_ptr comm_mgr_cfg; std::unique_ptr distribution_cfg; std::unique_ptr server_cfg; + + BootstrapConfigs(); + ~BootstrapConfigs(); + BootstrapConfigs(BootstrapConfigs&&) noexcept; + BootstrapConfigs& operator=(BootstrapConfigs&&) noexcept; }; StorageNode(const config::ConfigUri& configUri, -- cgit v1.2.3