summaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-08-11 10:36:34 +0200
committerGitHub <noreply@github.com>2023-08-11 10:36:34 +0200
commit4e19101d1019bc9c44ae077669e4526165387249 (patch)
tree3f3dd2dcb304954802b8a1de81ddd4c9303979be /vdslib
parent906fa79d1f612d3a7813522717bdb0d8e1ab8f39 (diff)
parent190a32ada5a9d536d72462ef91b8d5322cc950e5 (diff)
Merge pull request #28023 from vespa-engine/balder/minor-layout-cleanup
Minor code health.
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/vespa/vdslib/distribution/idealnodecalculator.h35
-rw-r--r--vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp9
2 files changed, 20 insertions, 24 deletions
diff --git a/vdslib/src/vespa/vdslib/distribution/idealnodecalculator.h b/vdslib/src/vespa/vdslib/distribution/idealnodecalculator.h
index bc42df1b49c..4eb8f7e04ae 100644
--- a/vdslib/src/vespa/vdslib/distribution/idealnodecalculator.h
+++ b/vdslib/src/vespa/vdslib/distribution/idealnodecalculator.h
@@ -22,25 +22,20 @@ class ClusterState;
* unneeded details, and make it easily printable.
*/
class IdealNodeList : public document::Printable {
- std::vector<Node> _idealNodes;
-
public:
- IdealNodeList();
+ IdealNodeList() noexcept;
~IdealNodeList();
void push_back(const Node& node) {
_idealNodes.push_back(node);
}
- const Node& operator[](uint32_t i) const { return _idealNodes[i]; }
- uint32_t size() const { return _idealNodes.size(); }
- bool contains(const Node& n) const {
- for (uint32_t i=0; i<_idealNodes.size(); ++i) {
- if (n == _idealNodes[i]) return true;
- }
- return false;
+ const Node& operator[](uint32_t i) const noexcept { return _idealNodes[i]; }
+ uint32_t size() const noexcept { return _idealNodes.size(); }
+ bool contains(const Node& n) const noexcept {
+ return indexOf(n) != 0xffff;
}
- uint16_t indexOf(const Node& n) const {
+ uint16_t indexOf(const Node& n) const noexcept {
for (uint16_t i=0; i<_idealNodes.size(); ++i) {
if (n == _idealNodes[i]) return i;
}
@@ -48,6 +43,8 @@ public:
}
void print(std::ostream& out, bool, const std::string &) const override;
+private:
+ std::vector<Node> _idealNodes;
};
/**
@@ -64,17 +61,15 @@ public:
virtual ~IdealNodeCalculator() = default;
- virtual IdealNodeList getIdealNodes(const NodeType&,
- const document::BucketId&,
- UpStates upStates = UpInit) const = 0;
+ virtual IdealNodeList getIdealNodes(const NodeType&, const document::BucketId&, UpStates upStates = UpInit) const = 0;
// Wrapper functions to make prettier call if nodetype is given.
- IdealNodeList getIdealDistributorNodes(const document::BucketId& bucket,
- UpStates upStates = UpInit) const
- { return getIdealNodes(NodeType::DISTRIBUTOR, bucket, upStates); }
- IdealNodeList getIdealStorageNodes(const document::BucketId& bucket,
- UpStates upStates = UpInit) const
- { return getIdealNodes(NodeType::STORAGE, bucket, upStates); }
+ IdealNodeList getIdealDistributorNodes(const document::BucketId& bucket, UpStates upStates = UpInit) const {
+ return getIdealNodes(NodeType::DISTRIBUTOR, bucket, upStates);
+ }
+ IdealNodeList getIdealStorageNodes(const document::BucketId& bucket, UpStates upStates = UpInit) const {
+ return getIdealNodes(NodeType::STORAGE, bucket, upStates);
+ }
};
diff --git a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp
index da34ec4526a..86123f47d6f 100644
--- a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp
+++ b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp
@@ -8,7 +8,7 @@
namespace storage::lib {
-IdealNodeList::IdealNodeList() = default;
+IdealNodeList::IdealNodeList() noexcept = default;
IdealNodeList::~IdealNodeList() = default;
void
@@ -63,9 +63,10 @@ IdealNodeCalculatorImpl::initUpStateMapping() {
_upStates[UpInit] = "ui";
_upStates[UpInitMaintenance] = "uim";
for (uint32_t i=0; i<_upStates.size(); ++i) {
- if (_upStates[i] == 0) throw vespalib::IllegalStateException(
- "Failed to initialize up state. Code likely not updated "
- "after another upstate was added.", VESPA_STRLOC);
+ if (_upStates[i] == 0) {
+ throw vespalib::IllegalStateException("Failed to initialize up state. Code likely not updated "
+ "after another upstate was added.", VESPA_STRLOC);
+ }
}
}