aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2018-03-13 12:16:02 +0000
committerTor Egge <Tor.Egge@oath.com>2018-03-13 12:16:02 +0000
commit4af9166212914a827d0d21a6e28245aa27351943 (patch)
treed35a48c5493d611a13e695737e97a63fb1171d72 /storage
parent46ac5d90cc7196d13a1d26e7159ec45a2deba106 (diff)
Add cluster state to content bucket space.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/common/testnodestateupdater.cpp2
-rw-r--r--storage/src/tests/storageserver/statemanagertest.cpp2
-rw-r--r--storage/src/vespa/storage/common/content_bucket_space.cpp15
-rw-r--r--storage/src/vespa/storage/common/content_bucket_space.h8
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp13
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormanager.h1
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.cpp4
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.h2
8 files changed, 40 insertions, 7 deletions
diff --git a/storage/src/tests/common/testnodestateupdater.cpp b/storage/src/tests/common/testnodestateupdater.cpp
index c7fd47e37c7..ae3f69e2605 100644
--- a/storage/src/tests/common/testnodestateupdater.cpp
+++ b/storage/src/tests/common/testnodestateupdater.cpp
@@ -8,7 +8,7 @@ namespace storage {
TestNodeStateUpdater::TestNodeStateUpdater(const lib::NodeType& type)
: _reported(new lib::NodeState(type, lib::State::UP)),
_current(new lib::NodeState(type, lib::State::UP)),
- _clusterStateBundle(),
+ _clusterStateBundle(std::make_shared<const lib::ClusterStateBundle>(lib::ClusterState())),
_listeners()
{ }
diff --git a/storage/src/tests/storageserver/statemanagertest.cpp b/storage/src/tests/storageserver/statemanagertest.cpp
index 7c5303f74fe..8821d271e52 100644
--- a/storage/src/tests/storageserver/statemanagertest.cpp
+++ b/storage/src/tests/storageserver/statemanagertest.cpp
@@ -228,7 +228,7 @@ StateManagerTest::testClusterStateVersion()
{
ClusterState state(*_manager->getClusterStateBundle()->getBaselineClusterState());
state.setVersion(123);
- _manager->setClusterState(state);
+ _manager->setClusterStateBundle(lib::ClusterStateBundle(state));
std::string nodeInfoString(_manager->getNodeInfo());
vespalib::Memory goldenMemory(nodeInfoString);
diff --git a/storage/src/vespa/storage/common/content_bucket_space.cpp b/storage/src/vespa/storage/common/content_bucket_space.cpp
index 4344bccc785..8ddd1d5677f 100644
--- a/storage/src/vespa/storage/common/content_bucket_space.cpp
+++ b/storage/src/vespa/storage/common/content_bucket_space.cpp
@@ -8,11 +8,26 @@ ContentBucketSpace::ContentBucketSpace(document::BucketSpace bucketSpace)
: _bucketSpace(bucketSpace),
_bucketDatabase(),
_lock(),
+ _clusterState(),
_distribution()
{
}
void
+ContentBucketSpace::setClusterState(std::shared_ptr<const lib::ClusterState> clusterState)
+{
+ std::lock_guard<std::mutex> guard(_lock);
+ _clusterState = std::move(clusterState);
+}
+
+std::shared_ptr<const lib::ClusterState>
+ContentBucketSpace::getClusterState() const
+{
+ std::lock_guard<std::mutex> guard(_lock);
+ return _clusterState;
+}
+
+void
ContentBucketSpace::setDistribution(std::shared_ptr<const lib::Distribution> distribution)
{
std::lock_guard<std::mutex> guard(_lock);
diff --git a/storage/src/vespa/storage/common/content_bucket_space.h b/storage/src/vespa/storage/common/content_bucket_space.h
index 3b3dddade4f..6ccc82bc4fb 100644
--- a/storage/src/vespa/storage/common/content_bucket_space.h
+++ b/storage/src/vespa/storage/common/content_bucket_space.h
@@ -7,7 +7,10 @@
namespace storage {
-namespace lib { class Distribution; }
+namespace lib {
+class ClusterState;
+class Distribution;
+}
/**
* Class representing a bucket space (with associated bucket database) on a content node.
@@ -17,6 +20,7 @@ private:
document::BucketSpace _bucketSpace;
StorBucketDatabase _bucketDatabase;
mutable std::mutex _lock;
+ std::shared_ptr<const lib::ClusterState> _clusterState;
std::shared_ptr<const lib::Distribution> _distribution;
public:
@@ -25,6 +29,8 @@ public:
document::BucketSpace bucketSpace() const noexcept { return _bucketSpace; }
StorBucketDatabase &bucketDatabase() { return _bucketDatabase; }
+ void setClusterState(std::shared_ptr<const lib::ClusterState> clusterState);
+ std::shared_ptr<const lib::ClusterState> getClusterState() const;
void setDistribution(std::shared_ptr<const lib::Distribution> distribution);
std::shared_ptr<const lib::Distribution> getDistribution() const;
};
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
index 311dc52767d..d5e08da7fe0 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
@@ -61,6 +61,7 @@ FileStorManager(const config::ConfigUri & configUri,
_component.registerMetric(*_metrics);
_component.registerStatusPage(*this);
_component.getStateUpdater().addStateListener(*this);
+ propagateClusterStates();
}
FileStorManager::~FileStorManager()
@@ -980,7 +981,7 @@ FileStorManager::updateState()
}
for (const auto &elem : _component.getBucketSpaceRepo()) {
BucketSpace bucketSpace(elem.first);
- spi::ClusterState spiState(*state, _component.getIndex(), *elem.second->getDistribution());
+ spi::ClusterState spiState(*elem.second->getClusterState(), _component.getIndex(), *elem.second->getDistribution());
_provider->setClusterState(bucketSpace, spiState);
}
_nodeUpInLastNodeStateSeenByProvider = nodeUp;
@@ -993,8 +994,18 @@ FileStorManager::storageDistributionChanged()
}
void
+FileStorManager::propagateClusterStates()
+{
+ auto clusterStateBundle = _component.getStateUpdater().getClusterStateBundle();
+ for (const auto &elem : _component.getBucketSpaceRepo()) {
+ elem.second->setClusterState(clusterStateBundle->getDerivedClusterState(elem.first));
+ }
+}
+
+void
FileStorManager::handleNewState()
{
+ propagateClusterStates();
//TODO: Don't update if it isn't necessary (distributor-only change)
updateState();
}
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h
index fe103fdcdd0..4043bb9de8b 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h
@@ -183,6 +183,7 @@ private:
void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override;
void storageDistributionChanged() override;
void updateState();
+ void propagateClusterStates();
};
} // storage
diff --git a/storage/src/vespa/storage/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp
index 11ca0bcc9ae..24e0c9209a9 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.cpp
+++ b/storage/src/vespa/storage/storageserver/statemanager.cpp
@@ -421,7 +421,7 @@ StateManager::onGetNodeState(const api::GetNodeStateCommand::SP& cmd)
}
void
-StateManager::setClusterState(const lib::ClusterState& c)
+StateManager::setClusterStateBundle(const ClusterStateBundle& c)
{
{
vespalib::LockGuard lock(_stateLock);
@@ -434,7 +434,7 @@ bool
StateManager::onSetSystemState(
const std::shared_ptr<api::SetSystemStateCommand>& cmd)
{
- setClusterState(cmd->getSystemState());
+ setClusterStateBundle(cmd->getClusterStateBundle());
std::shared_ptr<api::SetSystemStateReply> reply(
new api::SetSystemStateReply(*cmd));
sendUp(reply);
diff --git a/storage/src/vespa/storage/storageserver/statemanager.h b/storage/src/vespa/storage/storageserver/statemanager.h
index 9f5c60b42aa..9e997098c04 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.h
+++ b/storage/src/vespa/storage/storageserver/statemanager.h
@@ -88,7 +88,7 @@ public:
Lock::SP grabStateChangeLock() override;
void setReportedNodeState(const lib::NodeState& state) override;
- void setClusterState(const lib::ClusterState& c);
+ void setClusterStateBundle(const ClusterStateBundle& c);
HostInfo& getHostInfo() { return *_hostInfo; }
private: