diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2018-02-23 19:51:08 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2018-02-26 10:00:44 +0000 |
commit | a45887bb27174bc0b550b09f344963f24675d707 (patch) | |
tree | f61fcd247663c95ae19d05abce9fc6f8c05e3f2b | |
parent | 92258b807a6ec3ce6a6ac1b728a47d437f071c17 (diff) |
Populate cluster state in distributor bucket space.
4 files changed, 34 insertions, 7 deletions
diff --git a/storage/src/vespa/storage/distributor/distributor.cpp b/storage/src/vespa/storage/distributor/distributor.cpp index 39658912a2e..fa6d63da32e 100644 --- a/storage/src/vespa/storage/distributor/distributor.cpp +++ b/storage/src/vespa/storage/distributor/distributor.cpp @@ -107,6 +107,7 @@ Distributor::Distributor(DistributorComponentRegister& compReg, _bucketDBStatusDelegate.registerStatusPage(); hostInfoReporterRegistrar.registerReporter(&_hostInfoReporter); propagateDefaultDistribution(_component.getDistribution()); + propagateClusterStates(); }; Distributor::~Distributor() @@ -336,6 +337,7 @@ Distributor::enableClusterState(const lib::ClusterState& state) { lib::ClusterState oldState = _clusterState; _clusterState = state; + propagateClusterStates(); lib::Node myNode(lib::NodeType::DISTRIBUTOR, _component.getIndex()); @@ -533,6 +535,15 @@ Distributor::propagateDefaultDistribution( } void +Distributor::propagateClusterStates() +{ + auto clusterState = std::make_shared<lib::ClusterState>(_clusterState); + for (auto &iter : *_bucketSpaceRepo) { + iter.second->setClusterState(clusterState); + } +} + +void Distributor::signalWorkWasDone() { _tickResult = framework::ThreadWaitInfo::MORE_WORK_ENQUEUED; diff --git a/storage/src/vespa/storage/distributor/distributor.h b/storage/src/vespa/storage/distributor/distributor.h index b4b235838c5..9ec21d6ab05 100644 --- a/storage/src/vespa/storage/distributor/distributor.h +++ b/storage/src/vespa/storage/distributor/distributor.h @@ -233,6 +233,7 @@ private: void enableNextDistribution(); void propagateDefaultDistribution(std::shared_ptr<const lib::Distribution>); + void propagateClusterStates(); lib::ClusterState _clusterState; diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp b/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp index 68fe9f441d7..dcf7792860e 100644 --- a/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp +++ b/storage/src/vespa/storage/distributor/distributor_bucket_space.cpp @@ -1,18 +1,30 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "distributor_bucket_space.h" +#include <vespa/vdslib/state/clusterstate.h> +#include <vespa/vdslib/distribution/distribution.h> -namespace storage { -namespace distributor { +namespace storage::distributor { DistributorBucketSpace::DistributorBucketSpace() : _bucketDatabase(), + _clusterState(), _distribution() { } -DistributorBucketSpace::~DistributorBucketSpace() { +DistributorBucketSpace::~DistributorBucketSpace() = default; + +void +DistributorBucketSpace::setClusterState(std::shared_ptr<const lib::ClusterState> clusterState) +{ + _clusterState = std::move(clusterState); } + +void +DistributorBucketSpace::setDistribution(std::shared_ptr<const lib::Distribution> distribution) { + _distribution = std::move(distribution); } + } diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space.h b/storage/src/vespa/storage/distributor/distributor_bucket_space.h index 30893e8cfb1..eca50d4263e 100644 --- a/storage/src/vespa/storage/distributor/distributor_bucket_space.h +++ b/storage/src/vespa/storage/distributor/distributor_bucket_space.h @@ -2,12 +2,12 @@ #pragma once #include <vespa/storage/bucketdb/mapbucketdatabase.h> -#include <vespa/vdslib/distribution/distribution.h> #include <memory> namespace storage { namespace lib { +class ClusterState; class Distribution; } @@ -26,6 +26,7 @@ namespace distributor { */ class DistributorBucketSpace { MapBucketDatabase _bucketDatabase; + std::shared_ptr<const lib::ClusterState> _clusterState; std::shared_ptr<const lib::Distribution> _distribution; public: DistributorBucketSpace(); @@ -43,9 +44,11 @@ public: return _bucketDatabase; } - void setDistribution(std::shared_ptr<const lib::Distribution> distribution) { - _distribution = std::move(distribution); - } + void setClusterState(std::shared_ptr<const lib::ClusterState> clusterState); + + const lib::ClusterState &getClusterState() const noexcept { return *_clusterState; } + + void setDistribution(std::shared_ptr<const lib::Distribution> distribution); // Precondition: setDistribution has been called at least once prior. const lib::Distribution& getDistribution() const noexcept { |