aboutsummaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2018-02-22 14:54:36 +0000
committerTor Egge <Tor.Egge@oath.com>2018-02-22 14:54:36 +0000
commit880aef37eb6666efb7a257a83a66ba864f3c8b6e (patch)
tree1c4066d884d4f5cca97c7d64ed5d74bd77d8773d /vdslib
parentba99e208ab14f29198bb035d76aa6f6bda641c93 (diff)
Move ClusterStateBundle to vdslib, allowing it to be used outside
storage module.
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/vespa/vdslib/state/CMakeLists.txt1
-rw-r--r--vdslib/src/vespa/vdslib/state/cluster_state_bundle.cpp34
-rw-r--r--vdslib/src/vespa/vdslib/state/cluster_state_bundle.h26
3 files changed, 61 insertions, 0 deletions
diff --git a/vdslib/src/vespa/vdslib/state/CMakeLists.txt b/vdslib/src/vespa/vdslib/state/CMakeLists.txt
index 24402526c85..620e86c2677 100644
--- a/vdslib/src/vespa/vdslib/state/CMakeLists.txt
+++ b/vdslib/src/vespa/vdslib/state/CMakeLists.txt
@@ -7,5 +7,6 @@ vespa_add_library(vdslib_state OBJECT
diskstate.cpp
nodestate.cpp
clusterstate.cpp
+ cluster_state_bundle.cpp
DEPENDS
)
diff --git a/vdslib/src/vespa/vdslib/state/cluster_state_bundle.cpp b/vdslib/src/vespa/vdslib/state/cluster_state_bundle.cpp
new file mode 100644
index 00000000000..c55f1aadd06
--- /dev/null
+++ b/vdslib/src/vespa/vdslib/state/cluster_state_bundle.cpp
@@ -0,0 +1,34 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "cluster_state_bundle.h"
+#include "clusterstate.h"
+
+namespace storage::lib {
+
+ClusterStateBundle::ClusterStateBundle(const ClusterState &baselineClusterState)
+ : _baselineClusterState(std::make_shared<const ClusterState>(baselineClusterState))
+{
+}
+
+ClusterStateBundle::~ClusterStateBundle() = default;
+
+const std::shared_ptr<const lib::ClusterState> &
+ClusterStateBundle::getBaselineClusterState() const
+{
+ return _baselineClusterState;
+}
+
+const std::shared_ptr<const lib::ClusterState> &
+ClusterStateBundle::getDerivedClusterState(document::BucketSpace) const
+{
+ // For now, just return the baseline cluster state.
+ return _baselineClusterState;
+}
+
+uint32_t
+ClusterStateBundle::getVersion() const
+{
+ return _baselineClusterState->getVersion();
+}
+
+}
diff --git a/vdslib/src/vespa/vdslib/state/cluster_state_bundle.h b/vdslib/src/vespa/vdslib/state/cluster_state_bundle.h
new file mode 100644
index 00000000000..c54df1d1952
--- /dev/null
+++ b/vdslib/src/vespa/vdslib/state/cluster_state_bundle.h
@@ -0,0 +1,26 @@
+// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <vespa/document/bucket/bucketspace.h>
+
+namespace storage::lib {
+
+class ClusterState;
+
+/**
+ * Class representing the baseline cluster state and the derived cluster
+ * state for each bucket space.
+ */
+class ClusterStateBundle
+{
+ std::shared_ptr<const ClusterState> _baselineClusterState;
+public:
+ explicit ClusterStateBundle(const ClusterState &baselineClusterState);
+ ~ClusterStateBundle();
+ const std::shared_ptr<const ClusterState> &getBaselineClusterState() const;
+ const std::shared_ptr<const ClusterState> &getDerivedClusterState(document::BucketSpace bucketSpace) const;
+ uint32_t getVersion() const;
+};
+
+}