summaryrefslogtreecommitdiffstats
path: root/persistence
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-11-23 21:46:41 +0100
committerGitHub <noreply@github.com>2021-11-23 21:46:41 +0100
commit3fc1bdd5329c6b3796bbf2619f78225a675e705b (patch)
tree267354537445d8a5169b483d3570b04819c488cc /persistence
parent6e7385e7858ee5491f028c7012d9928ea340d678 (diff)
Revert "Continue serving search queries when in Maintenance node state [run-systemtest]"
Diffstat (limited to 'persistence')
-rw-r--r--persistence/src/tests/spi/clusterstatetest.cpp27
-rw-r--r--persistence/src/vespa/persistence/spi/clusterstate.cpp25
-rw-r--r--persistence/src/vespa/persistence/spi/clusterstate.h24
3 files changed, 18 insertions, 58 deletions
diff --git a/persistence/src/tests/spi/clusterstatetest.cpp b/persistence/src/tests/spi/clusterstatetest.cpp
index ac67903244f..8a303c1a1ac 100644
--- a/persistence/src/tests/spi/clusterstatetest.cpp
+++ b/persistence/src/tests/spi/clusterstatetest.cpp
@@ -233,31 +233,4 @@ TEST(ClusterStateTest, can_infer_own_node_retired_state)
EXPECT_TRUE(!node_marked_as_retired_in_state("distributor:3 storage:3 .1.s:r", d, 0));
}
-namespace {
-
-bool
-node_marked_as_maintenance_in_state(const std::string& stateStr,
- const lib::Distribution& d,
- uint16_t node,
- bool maintenance_in_all_spaces)
-{
- lib::ClusterState s(stateStr);
- ClusterState state(s, node, d, maintenance_in_all_spaces);
- return state.nodeMaintenance();
-}
-
-}
-
-// We want to track the maintenance state for the _node_, not just the _bucket space_.
-TEST(ClusterStateTest, node_maintenance_state_is_set_independent_of_bucket_space_state_string)
-{
- lib::Distribution d(lib::Distribution::getDefaultDistributionConfig(3, 3));
-
- // Note: it doesn't actually matter what the cluster state string itself says here
- EXPECT_FALSE(node_marked_as_maintenance_in_state("distributor:3 storage:3", d, 0, false));
- EXPECT_TRUE(node_marked_as_maintenance_in_state("distributor:3 storage:3", d, 0, true));
- EXPECT_TRUE(node_marked_as_maintenance_in_state("distributor:3 storage:3 .0.s:d", d, 0, true));
- EXPECT_FALSE(node_marked_as_maintenance_in_state("distributor:3 storage:3 .0.s:m", d, 0, false));
-}
-
}
diff --git a/persistence/src/vespa/persistence/spi/clusterstate.cpp b/persistence/src/vespa/persistence/spi/clusterstate.cpp
index f82e6165fb8..4bc538996ca 100644
--- a/persistence/src/vespa/persistence/spi/clusterstate.cpp
+++ b/persistence/src/vespa/persistence/spi/clusterstate.cpp
@@ -14,12 +14,10 @@ namespace storage::spi {
ClusterState::ClusterState(const lib::ClusterState& state,
uint16_t nodeIndex,
- const lib::Distribution& distribution,
- bool maintenanceInAllSpaces)
+ const lib::Distribution& distribution)
: _state(std::make_unique<lib::ClusterState>(state)),
_distribution(std::make_unique<lib::Distribution>(distribution.serialize())),
- _nodeIndex(nodeIndex),
- _maintenanceInAllSpaces(maintenanceInAllSpaces)
+ _nodeIndex(nodeIndex)
{
}
@@ -35,11 +33,14 @@ void ClusterState::deserialize(vespalib::nbostream& i) {
_distribution = std::make_unique<lib::Distribution>(distribution);
}
+ClusterState::ClusterState(vespalib::nbostream& i) {
+ deserialize(i);
+}
+
ClusterState::ClusterState(const ClusterState& other) {
vespalib::nbostream o;
other.serialize(o);
deserialize(o);
- _maintenanceInAllSpaces = other._maintenanceInAllSpaces;
}
ClusterState::~ClusterState() = default;
@@ -67,32 +68,28 @@ ClusterState::shouldBeReady(const Bucket& b) const {
return Trinary::False;
}
-bool ClusterState::clusterUp() const noexcept {
+bool ClusterState::clusterUp() const {
return _state && _state->getClusterState() == lib::State::UP;
}
-bool ClusterState::nodeHasStateOneOf(const char* states) const noexcept {
+bool ClusterState::nodeHasStateOneOf(const char* states) const {
return _state &&
_state->getNodeState(lib::Node(lib::NodeType::STORAGE, _nodeIndex)).
getState().oneOf(states);
}
-bool ClusterState::nodeUp() const noexcept {
+bool ClusterState::nodeUp() const {
return nodeHasStateOneOf("uir");
}
-bool ClusterState::nodeInitializing() const noexcept {
+bool ClusterState::nodeInitializing() const {
return nodeHasStateOneOf("i");
}
-bool ClusterState::nodeRetired() const noexcept {
+bool ClusterState::nodeRetired() const {
return nodeHasStateOneOf("r");
}
-bool ClusterState::nodeMaintenance() const noexcept {
- return _maintenanceInAllSpaces;
-}
-
void ClusterState::serialize(vespalib::nbostream& o) const {
assert(_distribution);
assert(_state);
diff --git a/persistence/src/vespa/persistence/spi/clusterstate.h b/persistence/src/vespa/persistence/spi/clusterstate.h
index bde7e5bdbf4..8e48758e243 100644
--- a/persistence/src/vespa/persistence/spi/clusterstate.h
+++ b/persistence/src/vespa/persistence/spi/clusterstate.h
@@ -23,9 +23,9 @@ public:
ClusterState(const lib::ClusterState& state,
uint16_t nodeIndex,
- const lib::Distribution& distribution,
- bool maintenanceInAllSpaces = false);
+ const lib::Distribution& distribution);
+ ClusterState(vespalib::nbostream& i);
ClusterState(const ClusterState& other);
ClusterState& operator=(const ClusterState& other) = delete;
~ClusterState();
@@ -45,32 +45,23 @@ public:
* compared to the complete list of nodes, and deigns the system to be
* unusable.
*/
- [[nodiscard]] bool clusterUp() const noexcept;
+ bool clusterUp() const;
/**
* Returns false if this node has been set in a state where it should not
* receive external load.
- *
- * TODO rename to indicate bucket space affinity.
*/
- [[nodiscard]] bool nodeUp() const noexcept;
+ bool nodeUp() const;
/**
* Returns true iff this node is marked as Initializing in the cluster state.
- *
- * TODO remove, init no longer used internally.
*/
- [[nodiscard]] bool nodeInitializing() const noexcept;
+ bool nodeInitializing() const;
/**
* Returns true iff this node is marked as Retired in the cluster state.
*/
- [[nodiscard]] bool nodeRetired() const noexcept;
-
- /**
- * Returns true iff this node is marked as Maintenance in all bucket space cluster states.
- */
- [[nodiscard]] bool nodeMaintenance() const noexcept;
+ bool nodeRetired() const;
/**
* Returns a serialized form of this object.
@@ -81,10 +72,9 @@ private:
std::unique_ptr<lib::ClusterState> _state;
std::unique_ptr<lib::Distribution> _distribution;
uint16_t _nodeIndex;
- bool _maintenanceInAllSpaces;
void deserialize(vespalib::nbostream&);
- bool nodeHasStateOneOf(const char* states) const noexcept;
+ bool nodeHasStateOneOf(const char* states) const;
};
}