diff options
author | Geir Storli <geirst@oath.com> | 2017-12-15 16:17:42 +0000 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2017-12-18 09:54:47 +0000 |
commit | 603b6931cbff7f596e0faa1cac2ededbf369f0bb (patch) | |
tree | d28fbee764a8888bd9d5eaa5c22f92e0c029e433 /storage | |
parent | 012722079ebdf505ae141be8e2b41bb6370c0bea (diff) |
Let StorageNode subscribe to BucketspacesConfig and propagate to storage components.
Diffstat (limited to 'storage')
6 files changed, 127 insertions, 30 deletions
diff --git a/storage/src/vespa/storage/common/storagecomponent.cpp b/storage/src/vespa/storage/common/storagecomponent.cpp index bf387240dc5..3bf2beba0eb 100644 --- a/storage/src/vespa/storage/common/storagecomponent.cpp +++ b/storage/src/vespa/storage/common/storagecomponent.cpp @@ -62,6 +62,13 @@ StorageComponent::setDistribution(DistributionSP distribution) } void +StorageComponent::enableMultipleBucketSpaces(bool value) +{ + std::lock_guard<std::mutex> guard(_lock); + _enableMultipleBucketSpaces = value; +} + +void StorageComponent::setNodeStateUpdater(NodeStateUpdater& updater) { std::lock_guard<std::mutex> guard(_lock); @@ -76,10 +83,16 @@ StorageComponent::StorageComponent(StorageComponentRegister& compReg, vespalib::stringref name) : Component(compReg, name), _clusterName(), - _nodeType(0), + _nodeType(nullptr), _index(0), + _docTypeRepo(), + _loadTypes(), _priorityMapper(new PriorityMapper), - _nodeStateUpdater(0) + _bucketIdFactory(), + _distribution(), + _nodeStateUpdater(nullptr), + _lock(), + _enableMultipleBucketSpaces(false) { compReg.registerStorageComponent(*this); } @@ -132,4 +145,11 @@ StorageComponent::getDistribution() const return _distribution; } +bool +StorageComponent::enableMultipleBucketSpaces() const +{ + std::lock_guard<std::mutex> guard(_lock); + return _enableMultipleBucketSpaces; +} + } // storage diff --git a/storage/src/vespa/storage/common/storagecomponent.h b/storage/src/vespa/storage/common/storagecomponent.h index d469540b55f..e136d991ac5 100644 --- a/storage/src/vespa/storage/common/storagecomponent.h +++ b/storage/src/vespa/storage/common/storagecomponent.h @@ -37,10 +37,9 @@ #include <vespa/vdslib/state/node.h> #include <mutex> -namespace vespa { namespace config { namespace content { namespace core { -namespace internal { +namespace vespa::config::content::core::internal { class InternalStorPrioritymappingType; -} } } } } +} namespace document { class DocumentTypeRepo; } @@ -59,11 +58,11 @@ class StorageComponentRegister; class StorageComponent : public framework::Component { public: - typedef std::unique_ptr<StorageComponent> UP; - typedef vespa::config::content::core::internal::InternalStorPrioritymappingType PriorityConfig; - typedef std::shared_ptr<document::DocumentTypeRepo> DocumentTypeRepoSP; - typedef std::shared_ptr<documentapi::LoadTypeSet> LoadTypeSetSP; - typedef std::shared_ptr<lib::Distribution> DistributionSP; + using UP = std::unique_ptr<StorageComponent>; + using PriorityConfig = vespa::config::content::core::internal::InternalStorPrioritymappingType; + using DocumentTypeRepoSP = std::shared_ptr<document::DocumentTypeRepo>; + using LoadTypeSetSP = std::shared_ptr<documentapi::LoadTypeSet>; + using DistributionSP = std::shared_ptr<lib::Distribution>; /** * Node type is supposed to be set immediately, and never be updated. @@ -84,6 +83,7 @@ public: void setPriorityConfig(const PriorityConfig&); void setBucketIdFactory(const document::BucketIdFactory&); void setDistribution(DistributionSP); + void enableMultipleBucketSpaces(bool value); StorageComponent(StorageComponentRegister&, vespalib::stringref name); virtual ~StorageComponent(); @@ -102,6 +102,7 @@ public: uint8_t getPriority(const documentapi::LoadType&) const; DistributionSP getDistribution() const; NodeStateUpdater& getStateUpdater() const; + bool enableMultipleBucketSpaces() const; private: vespalib::string _clusterName; @@ -114,6 +115,7 @@ private: DistributionSP _distribution; NodeStateUpdater* _nodeStateUpdater; mutable std::mutex _lock; + bool _enableMultipleBucketSpaces; }; struct StorageComponentRegister : public virtual framework::ComponentRegister diff --git a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp index d2cb8fa4380..2f9430c49bb 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp +++ b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp @@ -10,11 +10,20 @@ LOG_SETUP(".storage.component.register"); namespace storage { StorageComponentRegisterImpl::StorageComponentRegisterImpl() - : _nodeType(0), + : _componentLock(), + _components(), + _clusterName(), + _nodeType(nullptr), _index(0xffff), + _docTypeRepo(), _loadTypes(new documentapi::LoadTypeSet), - _nodeStateUpdater(0) -{ } + _priorityConfig(), + _bucketIdFactory(), + _distribution(), + _nodeStateUpdater(nullptr), + _bucketSpacesConfig() +{ +} StorageComponentRegisterImpl::~StorageComponentRegisterImpl() { } @@ -33,6 +42,7 @@ StorageComponentRegisterImpl::registerStorageComponent(StorageComponent& smc) smc.setPriorityConfig(_priorityConfig); smc.setBucketIdFactory(_bucketIdFactory); smc.setDistribution(_distribution); + smc.enableMultipleBucketSpaces(_bucketSpacesConfig.enableMultipleBucketSpaces); } void @@ -115,4 +125,14 @@ StorageComponentRegisterImpl::setDistribution(lib::Distribution::SP distribution } } +void +StorageComponentRegisterImpl::setBucketSpacesConfig(const BucketspacesConfig& config) +{ + vespalib::LockGuard lock(_componentLock); + _bucketSpacesConfig = config; + for (size_t i = 0; i < _components.size(); ++i) { + _components[i]->enableMultipleBucketSpaces(config.enableMultipleBucketSpaces); + } +} + } // storage diff --git a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h index 49387e2c2b5..afd9f11a88b 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h +++ b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h @@ -11,6 +11,7 @@ #include <vespa/document/repo/documenttyperepo.h> #include <vespa/documentapi/loadtypes/loadtypeset.h> #include <vespa/storage/common/storagecomponent.h> +#include <vespa/storage/config/config-bucketspaces.h> #include <vespa/storage/config/config-stor-prioritymapping.h> #include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> #include <vespa/vdslib/distribution/distribution.h> @@ -21,9 +22,9 @@ class StorageComponentRegisterImpl : public virtual StorageComponentRegister, public virtual framework::defaultimplementation::ComponentRegisterImpl { - typedef framework::defaultimplementation::ComponentRegisterImpl CompRegImpl; - typedef StorageComponent::PriorityConfig PriorityConfig; - //CompRegImpl _compReg; + using PriorityConfig = StorageComponent::PriorityConfig; + using BucketspacesConfig = vespa::config::content::core::internal::InternalBucketspacesType; + vespalib::Lock _componentLock; std::vector<StorageComponent*> _components; vespalib::string _clusterName; @@ -35,6 +36,7 @@ class StorageComponentRegisterImpl document::BucketIdFactory _bucketIdFactory; lib::Distribution::SP _distribution; NodeStateUpdater* _nodeStateUpdater; + BucketspacesConfig _bucketSpacesConfig; public: typedef std::unique_ptr<StorageComponentRegisterImpl> UP; @@ -64,6 +66,7 @@ public: virtual void setPriorityConfig(const PriorityConfig&); virtual void setBucketIdFactory(const document::BucketIdFactory&); virtual void setDistribution(lib::Distribution::SP); + virtual void setBucketSpacesConfig(const BucketspacesConfig&); }; diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp index ba1556bd3b9..8f0ebccb26f 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.cpp +++ b/storage/src/vespa/storage/storageserver/storagenode.cpp @@ -76,12 +76,38 @@ StorageNode::StorageNode( std::unique_ptr<HostInfo> hostInfo, RunMode mode) : _singleThreadedDebugMode(mode == SINGLE_THREADED_TEST_MODE), + _configFetcher(), _hostInfo(std::move(hostInfo)), _context(context), _generationFetcher(generationFetcher), + _rootFolder(), _attemptedStopped(false), + _pidFile(), + _statusWebServer(), + _metrics(), + _metricManager(), + _deadLockDetector(), + _statusMetrics(), + _stateReporter(), + _stateManager(), + _chain(), + _configLock(), + _initial_config_mutex(), + _serverConfig(), + _clusterConfig(), + _distributionConfig(), + _priorityConfig(), + _doctypesConfig(), + _bucketSpacesConfig(), + _newServerConfig(), + _newClusterConfig(), + _newDistributionConfig(), + _newPriorityConfig(), + _newDoctypesConfig(), + _newBucketSpacesConfig(), + _component(), _configUri(configUri), - _communicationManager(0) + _communicationManager(nullptr) { } @@ -93,6 +119,7 @@ StorageNode::subscribeToConfigs() _configFetcher->subscribe<UpgradingConfig>(_configUri.getConfigId(), this); _configFetcher->subscribe<StorServerConfig>(_configUri.getConfigId(), this); _configFetcher->subscribe<StorPrioritymappingConfig>(_configUri.getConfigId(), this); + _configFetcher->subscribe<BucketspacesConfig>(_configUri.getConfigId(), this); _configFetcher->start(); @@ -101,6 +128,7 @@ StorageNode::subscribeToConfigs() _clusterConfig = std::move(_newClusterConfig); _distributionConfig = std::move(_newDistributionConfig); _priorityConfig = std::move(_newPriorityConfig); + _bucketSpacesConfig = std::move(_newBucketSpacesConfig); } void @@ -127,6 +155,7 @@ StorageNode::initialize() _context.getComponentRegister().setBucketIdFactory(document::BucketIdFactory()); _context.getComponentRegister().setDistribution(make_shared<lib::Distribution>(*_distributionConfig)); _context.getComponentRegister().setPriorityConfig(*_priorityConfig); + _context.getComponentRegister().setBucketSpacesConfig(*_bucketSpacesConfig); _metrics.reset(new StorageMetricSet); _component.reset(new StorageComponent(_context.getComponentRegister(), "storagenode")); @@ -315,6 +344,11 @@ StorageNode::handleLiveConfigUpdate(const InitialGuard & initGuard) _priorityConfig = std::move(_newPriorityConfig); _context.getComponentRegister().setPriorityConfig(*_priorityConfig); } + if (_newBucketSpacesConfig) { + _bucketSpacesConfig = std::move(_newBucketSpacesConfig); + _context.getComponentRegister().setBucketSpacesConfig(*_bucketSpacesConfig); + // TODO: Add new bucket space resolver to document api converter + } } void @@ -485,8 +519,9 @@ StorageNode::configure(std::unique_ptr<StorPrioritymappingConfig> config) } } -void StorageNode::configure(std::unique_ptr<document::DocumenttypesConfig> config, - bool hasChanged, int64_t generation) +void +StorageNode::configure(std::unique_ptr<document::DocumenttypesConfig> config, + bool hasChanged, int64_t generation) { (void) generation; if (!hasChanged) @@ -501,6 +536,19 @@ void StorageNode::configure(std::unique_ptr<document::DocumenttypesConfig> confi } } +void +StorageNode::configure(std::unique_ptr<BucketspacesConfig> config) +{ + { + vespalib::LockGuard configLockGuard(_configLock); + _newBucketSpacesConfig.reset(config.release()); + } + if (_bucketSpacesConfig) { + InitialGuard concurrent_config_guard(_initial_config_mutex); + handleLiveConfigUpdate(concurrent_config_guard); + } +} + bool StorageNode::attemptedStopped() const { diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h index e9d3004be68..a07d1c0c534 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.h +++ b/storage/src/vespa/storage/storageserver/storagenode.h @@ -12,20 +12,19 @@ #pragma once -#include <vespa/storage/storageutil/resumeguard.h> -#include <vespa/storage/common/doneinitializehandler.h> -#include <vespa/storageframework/generic/metric/metricupdatehook.h> -#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> - -#include <vespa/config/subscription/configuri.h> -#include <vespa/config/helper/ifetchercallback.h> +#include <vespa/config-stor-distribution.h> +#include <vespa/config-upgrading.h> #include <vespa/config/helper/configfetcher.h> - +#include <vespa/config/helper/ifetchercallback.h> +#include <vespa/config/subscription/configuri.h> +#include <vespa/document/config/config-documenttypes.h> +#include <vespa/storage/common/doneinitializehandler.h> +#include <vespa/storage/config/config-bucketspaces.h> #include <vespa/storage/config/config-stor-prioritymapping.h> #include <vespa/storage/config/config-stor-server.h> -#include <vespa/document/config/config-documenttypes.h> -#include <vespa/config-upgrading.h> -#include <vespa/config-stor-distribution.h> +#include <vespa/storage/storageutil/resumeguard.h> +#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> +#include <vespa/storageframework/generic/metric/metricupdatehook.h> #include <mutex> namespace document { class DocumentTypeRepo; } @@ -54,6 +53,7 @@ class StorageNode : private config::IFetcherCallback<vespa::config::content::cor private config::IFetcherCallback<vespa::config::content::StorDistributionConfig>, private config::IFetcherCallback<vespa::config::content::UpgradingConfig>, private config::IFetcherCallback<vespa::config::content::core::StorPrioritymappingConfig>, + private config::IFetcherCallback<vespa::config::content::core::BucketspacesConfig>, private framework::MetricUpdateHook, private DoneInitializeHandler, private framework::defaultimplementation::ShutdownListener @@ -101,6 +101,7 @@ protected: using UpgradingConfig = vespa::config::content::UpgradingConfig; using StorDistributionConfig = vespa::config::content::StorDistributionConfig; using StorPrioritymappingConfig = vespa::config::content::core::StorPrioritymappingConfig; + using BucketspacesConfig = vespa::config::content::core::BucketspacesConfig; private: bool _singleThreadedDebugMode; // Subscriptions to config @@ -137,6 +138,7 @@ private: void configure(std::unique_ptr<StorPrioritymappingConfig>) override; virtual void configure(std::unique_ptr<document::DocumenttypesConfig> config, bool hasChanged, int64_t generation); + void configure(std::unique_ptr<BucketspacesConfig>) override; void updateUpgradeFlag(const UpgradingConfig&); protected: @@ -151,12 +153,14 @@ protected: std::unique_ptr<StorDistributionConfig> _distributionConfig; std::unique_ptr<StorPrioritymappingConfig> _priorityConfig; std::unique_ptr<document::DocumenttypesConfig> _doctypesConfig; + std::unique_ptr<BucketspacesConfig> _bucketSpacesConfig; // New configs gotten that has yet to have been handled std::unique_ptr<StorServerConfig> _newServerConfig; std::unique_ptr<UpgradingConfig> _newClusterConfig; std::unique_ptr<StorDistributionConfig> _newDistributionConfig; std::unique_ptr<StorPrioritymappingConfig> _newPriorityConfig; std::unique_ptr<document::DocumenttypesConfig> _newDoctypesConfig; + std::unique_ptr<BucketspacesConfig> _newBucketSpacesConfig; std::unique_ptr<StorageComponent> _component; config::ConfigUri _configUri; CommunicationManager* _communicationManager; |