diff options
Diffstat (limited to 'storageserver/src/vespa')
9 files changed, 149 insertions, 45 deletions
diff --git a/storageserver/src/vespa/storageserver/app/CMakeLists.txt b/storageserver/src/vespa/storageserver/app/CMakeLists.txt index 67bafb2256f..837571ae6ad 100644 --- a/storageserver/src/vespa/storageserver/app/CMakeLists.txt +++ b/storageserver/src/vespa/storageserver/app/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_library(storageserver_storageapp STATIC SOURCES process.cpp diff --git a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp index 987b3b613d8..b56a4e1884b 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "distributorprocess.h" #include <vespa/config/helper/configgetter.hpp> @@ -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<StorDistributormanagerConfig>::getConfig( - _configUri.getConfigId(), _configUri.getContext(), subscribeTimeout); - _num_distributor_stripes = adjusted_num_distributor_stripes(distr_cfg->numDistributorStripes); _distributorConfigHandler = _configSubscriber.subscribe<StorDistributormanagerConfig>(_configUri.getConfigId(), subscribeTimeout); _visitDispatcherConfigHandler = _configSubscriber.subscribe<StorVisitordispatcherConfig>(_configUri.getConfigId(), subscribeTimeout); Process::setupConfig(subscribeTimeout); @@ -99,8 +96,19 @@ DistributorProcess::configUpdated() void DistributorProcess::createNode() { - _node = std::make_unique<DistributorNode>(_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<DistributorNode>(_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/distributorprocess.h b/storageserver/src/vespa/storageserver/app/distributorprocess.h index f9d6cc41f4d..2eeb037207e 100644 --- a/storageserver/src/vespa/storageserver/app/distributorprocess.h +++ b/storageserver/src/vespa/storageserver/app/distributorprocess.h @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * \class storage::DistributorProcess * diff --git a/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.cpp b/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.cpp index 9b4f058ea2b..8940c2a320e 100644 --- a/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "dummyservicelayerprocess.h" diff --git a/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h b/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h index 197443816f6..f4e3d386767 100644 --- a/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h +++ b/storageserver/src/vespa/storageserver/app/dummyservicelayerprocess.h @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * \class storage::DummyServiceLayerProcess * diff --git a/storageserver/src/vespa/storageserver/app/process.cpp b/storageserver/src/vespa/storageserver/app/process.cpp index ad4d9ffa7f6..87b20f9ec2e 100644 --- a/storageserver/src/vespa/storageserver/app/process.cpp +++ b/storageserver/src/vespa/storageserver/app/process.cpp @@ -1,11 +1,12 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "process.h" + +#include <vespa/config/subscription/configsubscriber.hpp> #include <vespa/document/repo/document_type_repo_factory.h> #include <vespa/storage/storageserver/storagenode.h> #include <vespa/storage/storageserver/storagenodecontext.h> #include <vespa/vespalib/util/exceptions.h> -#include <vespa/config/subscription/configsubscriber.hpp> #include <vespa/log/log.h> LOG_SETUP(".process"); @@ -24,11 +25,17 @@ Process::~Process() = default; void Process::setupConfig(vespalib::duration subscribeTimeout) { - _documentHandler = _configSubscriber.subscribe<document::config::DocumenttypesConfig>(_configUri.getConfigId(), subscribeTimeout); + _document_cfg_handle = _configSubscriber.subscribe<DocumentTypesConfig>(_configUri.getConfigId(), subscribeTimeout); + _bucket_spaces_cfg_handle = _configSubscriber.subscribe<BucketspacesConfig>(_configUri.getConfigId(), subscribeTimeout); + _comm_mgr_cfg_handle = _configSubscriber.subscribe<CommunicationManagerConfig>(_configUri.getConfigId(), subscribeTimeout); + _bouncer_cfg_handle = _configSubscriber.subscribe<StorBouncerConfig>(_configUri.getConfigId(), subscribeTimeout); + _distribution_cfg_handle = _configSubscriber.subscribe<StorDistributionConfig>(_configUri.getConfigId(), subscribeTimeout); + _server_cfg_handle = _configSubscriber.subscribe<StorServerConfig>(_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 7050dca6b92..72b399ac870 100644 --- a/storageserver/src/vespa/storageserver/app/process.h +++ b/storageserver/src/vespa/storageserver/app/process.h @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** * \class storage::Process * @@ -8,16 +8,21 @@ * contains the process as a library such that it can be tested and used in * other pieces of code. * - * Specializations of this class will exist to add the funcionality needed for + * Specializations of this class will exist to add the functionality needed for * the various process types. */ #pragma once +#include <vespa/config-bucketspaces.h> +#include <vespa/config-stor-distribution.h> +#include <vespa/config/subscription/configsubscriber.h> +#include <vespa/config/subscription/configuri.h> #include <vespa/document/config/config-documenttypes.h> +#include <vespa/storage/config/config-stor-bouncer.h> +#include <vespa/storage/config/config-stor-communicationmanager.h> +#include <vespa/storage/config/config-stor-server.h> #include <vespa/storage/storageserver/applicationgenerationfetcher.h> -#include <vespa/config/subscription/configuri.h> -#include <vespa/config/subscription/configsubscriber.h> 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<const document::DocumentTypeRepo>; config::ConfigUri _configUri; DocumentTypeRepoSP getTypeRepo() { return _repos.back(); } config::ConfigSubscriber _configSubscriber; + std::unique_ptr<config::ConfigHandle<DocumentTypesConfig>> _document_cfg_handle; + std::unique_ptr<config::ConfigHandle<BucketspacesConfig>> _bucket_spaces_cfg_handle; + std::unique_ptr<config::ConfigHandle<CommunicationManagerConfig>> _comm_mgr_cfg_handle; + std::unique_ptr<config::ConfigHandle<StorBouncerConfig>> _bouncer_cfg_handle; + std::unique_ptr<config::ConfigHandle<StorDistributionConfig>> _distribution_cfg_handle; + std::unique_ptr<config::ConfigHandle<StorServerConfig>> _server_cfg_handle; + private: - config::ConfigHandle<document::config::DocumenttypesConfig>::UP _documentHandler; std::vector<DocumentTypeRepoSP> _repos; public: using UP = std::unique_ptr<Process>; - 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 8d19d7a356d..bb284bfc108 100644 --- a/storageserver/src/vespa/storageserver/app/servicelayerprocess.cpp +++ b/storageserver/src/vespa/storageserver/app/servicelayerprocess.cpp @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "servicelayerprocess.h" #include <vespa/config/helper/configgetter.hpp> @@ -34,6 +34,9 @@ bucket_db_options_from_config(const config::ConfigUri& config_uri) { ServiceLayerProcess::ServiceLayerProcess(const config::ConfigUri& configUri) : Process(configUri), _externalVisitors(), + _persistence_cfg_handle(), + _visitor_cfg_handle(), + _filestor_cfg_handle(), _node(), _storage_chain_builder(), _context(std::make_unique<framework::defaultimplementation::RealClock>(), @@ -51,11 +54,59 @@ ServiceLayerProcess::shutdown() } void +ServiceLayerProcess::setupConfig(vespalib::duration subscribe_timeout) +{ + _persistence_cfg_handle = _configSubscriber.subscribe<PersistenceConfig>(_configUri.getConfigId(), subscribe_timeout); + _visitor_cfg_handle = _configSubscriber.subscribe<StorVisitorConfig>(_configUri.getConfigId(), subscribe_timeout); + _filestor_cfg_handle = _configSubscriber.subscribe<StorFilestorConfig>(_configUri.getConfigId(), subscribe_timeout); + // We reuse the StorServerConfig subscription from the parent Process + Process::setupConfig(subscribe_timeout); +} + +void +ServiceLayerProcess::updateConfig() +{ + Process::updateConfig(); + if (_server_cfg_handle->isChanged()) { + _node->on_configure(*_server_cfg_handle->getConfig()); + } + if (_persistence_cfg_handle->isChanged()) { + _node->on_configure(*_persistence_cfg_handle->getConfig()); + } + if (_visitor_cfg_handle->isChanged()) { + _node->on_configure(*_visitor_cfg_handle->getConfig()); + } + if (_filestor_cfg_handle->isChanged()) { + _node->on_configure(*_filestor_cfg_handle->getConfig()); + } +} + +bool +ServiceLayerProcess::configUpdated() +{ + return Process::configUpdated(); +} + +void ServiceLayerProcess::createNode() { add_external_visitors(); setupProvider(); - _node = std::make_unique<ServiceLayerNode>(_configUri, _context, *this, getProvider(), _externalVisitors); + + 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(); + + ServiceLayerNode::ServiceLayerBootstrapConfigs sbc; + sbc.storage_bootstrap_configs = std::move(bc); + sbc.persistence_cfg = _persistence_cfg_handle->getConfig(); + sbc.visitor_cfg = _visitor_cfg_handle->getConfig(); + sbc.filestor_cfg = _filestor_cfg_handle->getConfig(); + + _node = std::make_unique<ServiceLayerNode>(_configUri, _context, std::move(sbc), *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 1df7b173890..dcc56f373c4 100644 --- a/storageserver/src/vespa/storageserver/app/servicelayerprocess.h +++ b/storageserver/src/vespa/storageserver/app/servicelayerprocess.h @@ -1,24 +1,12 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * \class storage::ServiceLayerProcess - * - * \brief A process running a service layer. - */ -/** - * \class storage::MemFileServiceLayerProcess - * - * \brief A process running a service layer with memfile persistence provider. - */ -/** - * \class storage::RpcServiceLayerProcess - * - * \brief A process running a service layer with RPC persistence provider. - */ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "process.h" -#include <vespa/storage/storageserver/servicelayernodecontext.h> +#include <vespa/config-persistence.h> +#include <vespa/config-stor-filestor.h> #include <vespa/storage/common/visitorfactory.h> +#include <vespa/storage/storageserver/servicelayernodecontext.h> +#include <vespa/storage/visiting/config-stor-visitor.h> namespace config { class ConfigUri; } @@ -33,6 +21,14 @@ class ServiceLayerProcess : public Process { protected: VisitorFactory::Map _externalVisitors; private: + using PersistenceConfig = vespa::config::content::PersistenceConfig; + using StorVisitorConfig = vespa::config::content::core::StorVisitorConfig; + using StorFilestorConfig = vespa::config::content::StorFilestorConfig; + + std::unique_ptr<config::ConfigHandle<PersistenceConfig>> _persistence_cfg_handle; + std::unique_ptr<config::ConfigHandle<StorVisitorConfig>> _visitor_cfg_handle; + std::unique_ptr<config::ConfigHandle<StorFilestorConfig>> _filestor_cfg_handle; + std::unique_ptr<ServiceLayerNode> _node; std::unique_ptr<IStorageChainBuilder> _storage_chain_builder; @@ -45,6 +41,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; |