aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2022-10-24 19:23:06 +0200
committerGitHub <noreply@github.com>2022-10-24 19:23:06 +0200
commit528b0295d8fe5a868186f25cb4c0ccc632aa36b2 (patch)
treefb0854bb2cc5b070a77a747d45c1413e4811d91d
parent764b8fac1b36484adbd25e3a5857e1d5f110ce9a (diff)
parent91c764b68aad5a9848493b3d3dc81119b1178a4b (diff)
Merge pull request #24545 from vespa-engine/toregge/move-related-non-local-variables-to-same-translation-unit
Move related non-local variables to same translation unit to ensure
-rw-r--r--vdslib/src/vespa/vdslib/state/CMakeLists.txt1
-rw-r--r--vdslib/src/vespa/vdslib/state/clusterstate.cpp10
-rw-r--r--vdslib/src/vespa/vdslib/state/globals.cpp24
-rw-r--r--vdslib/src/vespa/vdslib/state/globals.h13
-rw-r--r--vdslib/src/vespa/vdslib/state/state.cpp8
5 files changed, 44 insertions, 12 deletions
diff --git a/vdslib/src/vespa/vdslib/state/CMakeLists.txt b/vdslib/src/vespa/vdslib/state/CMakeLists.txt
index 8d4e994da93..49f1c942724 100644
--- a/vdslib/src/vespa/vdslib/state/CMakeLists.txt
+++ b/vdslib/src/vespa/vdslib/state/CMakeLists.txt
@@ -1,6 +1,7 @@
# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(vdslib_state OBJECT
SOURCES
+ globals.cpp
nodetype.cpp
node.cpp
state.cpp
diff --git a/vdslib/src/vespa/vdslib/state/clusterstate.cpp b/vdslib/src/vespa/vdslib/state/clusterstate.cpp
index e58389e1475..e9159eef631 100644
--- a/vdslib/src/vespa/vdslib/state/clusterstate.cpp
+++ b/vdslib/src/vespa/vdslib/state/clusterstate.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "clusterstate.h"
+#include "globals.h"
#include <vespa/vespalib/text/stringtokenizer.h>
#include <vespa/document/util/stringutil.h>
@@ -13,6 +14,11 @@ LOG_SETUP(".vdslib.state.cluster");
using vespalib::IllegalArgumentException;
+using storage::lib::clusterstate::_G_defaultSDState;
+using storage::lib::clusterstate::_G_defaultDDState;
+using storage::lib::clusterstate::_G_defaultSUState;
+using storage::lib::clusterstate::_G_defaultDUState;
+
namespace storage::lib {
ClusterState::ClusterState()
@@ -266,10 +272,6 @@ ClusterState::getNodeCount(const NodeType& type) const
}
namespace {
- NodeState _G_defaultSDState(NodeType::STORAGE, State::DOWN);
- NodeState _G_defaultDDState(NodeType::DISTRIBUTOR, State::DOWN);
- NodeState _G_defaultSUState(NodeType::STORAGE, State::UP);
- NodeState _G_defaultDUState(NodeType::DISTRIBUTOR, State::UP);
[[noreturn]] void throwUnknownType(const Node & node) __attribute__((noinline));
void throwUnknownType(const Node & node) {
throw vespalib::IllegalStateException("Unknown node type " + node.getType().toString(), VESPA_STRLOC);
diff --git a/vdslib/src/vespa/vdslib/state/globals.cpp b/vdslib/src/vespa/vdslib/state/globals.cpp
new file mode 100644
index 00000000000..08c314e70f9
--- /dev/null
+++ b/vdslib/src/vespa/vdslib/state/globals.cpp
@@ -0,0 +1,24 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "globals.h"
+
+namespace storage::lib {
+
+const State State::UNKNOWN("Unknown", "-", 0, true, true, false, false, false);
+const State State::MAINTENANCE("Maintenance", "m", 1, false, false, true, true, false);
+const State State::DOWN("Down", "d", 2, false, false, true, true, true);
+const State State::STOPPING("Stopping", "s", 3, true, true, false, false, true);
+const State State::INITIALIZING("Initializing", "i", 4, true, true, false, false, true);
+const State State::RETIRED("Retired", "r", 5, false, false, true, true, false);
+const State State::UP("Up", "u", 6, true, true, true, true, true);
+
+}
+
+namespace storage::lib::clusterstate {
+
+NodeState _G_defaultSDState(NodeType::STORAGE, State::DOWN);
+NodeState _G_defaultDDState(NodeType::DISTRIBUTOR, State::DOWN);
+NodeState _G_defaultSUState(NodeType::STORAGE, State::UP);
+NodeState _G_defaultDUState(NodeType::DISTRIBUTOR, State::UP);
+
+}
diff --git a/vdslib/src/vespa/vdslib/state/globals.h b/vdslib/src/vespa/vdslib/state/globals.h
new file mode 100644
index 00000000000..e3a88e6abfa
--- /dev/null
+++ b/vdslib/src/vespa/vdslib/state/globals.h
@@ -0,0 +1,13 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "state.h"
+#include "nodestate.h"
+
+namespace storage::lib::clusterstate {
+
+extern NodeState _G_defaultSDState;
+extern NodeState _G_defaultDDState;
+extern NodeState _G_defaultSUState;
+extern NodeState _G_defaultDUState;
+
+}
diff --git a/vdslib/src/vespa/vdslib/state/state.cpp b/vdslib/src/vespa/vdslib/state/state.cpp
index e8f243b1a1e..ffa25c5a543 100644
--- a/vdslib/src/vespa/vdslib/state/state.cpp
+++ b/vdslib/src/vespa/vdslib/state/state.cpp
@@ -6,14 +6,6 @@
namespace storage::lib {
-const State State::UNKNOWN("Unknown", "-", 0, true, true, false, false, false);
-const State State::MAINTENANCE("Maintenance", "m", 1, false, false, true, true, false);
-const State State::DOWN("Down", "d", 2, false, false, true, true, true);
-const State State::STOPPING("Stopping", "s", 3, true, true, false, false, true);
-const State State::INITIALIZING("Initializing", "i", 4, true, true, false, false, true);
-const State State::RETIRED("Retired", "r", 5, false, false, true, true, false);
-const State State::UP("Up", "u", 6, true, true, true, true, true);
-
const State&
State::get(vespalib::stringref serialized)
{