summaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-11-30 18:06:54 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2016-12-12 02:55:41 +0100
commit602bb910df6998d0f7c56a67d2707c9c6c2e7d58 (patch)
treebb0d0f57b4de9e3ef8ea03d29929747f586e8d40 /vdslib
parentc650f2f379179780d428fb5505a0ed3d52f48ba4 (diff)
Targeted include
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/tests/state/clusterstatetest.cpp3
-rw-r--r--vdslib/src/vespa/vdslib/distribution/CMakeLists.txt3
-rw-r--r--vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp57
-rw-r--r--vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h49
4 files changed, 69 insertions, 43 deletions
diff --git a/vdslib/src/tests/state/clusterstatetest.cpp b/vdslib/src/tests/state/clusterstatetest.cpp
index c2abfef8403..712de5ae881 100644
--- a/vdslib/src/tests/state/clusterstatetest.cpp
+++ b/vdslib/src/tests/state/clusterstatetest.cpp
@@ -1,7 +1,6 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
#include <vespa/vdslib/state/clusterstate.h>
-
+#include <vespa/vespalib/util/exception.h>
#include <list>
#include <vespa/document/bucket/bucketidfactory.h>
#include <cmath>
diff --git a/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt b/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt
index 0f86ffee0b8..1f1516025be 100644
--- a/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt
+++ b/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt
@@ -1,8 +1,9 @@
# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(vdslib_distribution OBJECT
SOURCES
- group.cpp
distribution.cpp
+ group.cpp
+ idealnodecalculatorimpl.cpp
redundancygroupdistribution.cpp
DEPENDS
)
diff --git a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp
new file mode 100644
index 00000000000..86c63f289e4
--- /dev/null
+++ b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp
@@ -0,0 +1,57 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "idealnodecalculatorimpl.h"
+#include <vespa/vespalib/util/exceptions.h>
+
+namespace storage {
+namespace lib {
+
+IdealNodeCalculatorImpl::IdealNodeCalculatorImpl()
+ : _distribution(0),
+ _clusterState(0)
+{
+ initUpStateMapping();
+}
+
+IdealNodeCalculatorImpl::~IdealNodeCalculatorImpl() { }
+
+void
+IdealNodeCalculatorImpl::setDistribution(const Distribution& d) {
+ _distribution = &d;
+}
+void
+IdealNodeCalculatorImpl::setClusterState(const ClusterState& cs) {
+ _clusterState = &cs;
+}
+
+IdealNodeList
+IdealNodeCalculatorImpl::getIdealNodes(const NodeType& nodeType,
+ const document::BucketId& bucket,
+ UpStates upStates) const
+{
+ assert(_clusterState != 0);
+ assert(_distribution != 0);
+ std::vector<uint16_t> nodes;
+ _distribution->getIdealNodes(nodeType, *_clusterState, bucket, nodes, _upStates[upStates]);
+ IdealNodeList list;
+ for (uint32_t i=0; i<nodes.size(); ++i) {
+ list.push_back(Node(nodeType, nodes[i]));
+ }
+ return list;
+}
+
+void
+IdealNodeCalculatorImpl::initUpStateMapping() {
+ _upStates.clear();
+ _upStates.resize(UP_STATE_COUNT);
+ _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);
+ }
+}
+
+} // lib
+} // storage
diff --git a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h
index 43619c4a419..a5a7e70db72 100644
--- a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h
+++ b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h
@@ -5,7 +5,7 @@
*/
#pragma once
-#include <vespa/vdslib/distribution/idealnodecalculator.h>
+#include "idealnodecalculator.h"
namespace storage {
namespace lib {
@@ -16,48 +16,17 @@ class IdealNodeCalculatorImpl : public IdealNodeCalculatorConfigurable {
const ClusterState* _clusterState;
public:
- IdealNodeCalculatorImpl()
- : _distribution(0),
- _clusterState(0)
- {
- initUpStateMapping();
- }
+ IdealNodeCalculatorImpl();
+ ~IdealNodeCalculatorImpl();
- virtual void setDistribution(const Distribution& d) {
- _distribution = &d;
- }
- virtual void setClusterState(const ClusterState& cs) {
- _clusterState = &cs;
- }
-
- virtual IdealNodeList getIdealNodes(const NodeType& nodeType,
- const document::BucketId& bucket,
- UpStates upStates) const
- {
- assert(_clusterState != 0);
- assert(_distribution != 0);
- std::vector<uint16_t> nodes;
- _distribution->getIdealNodes(nodeType, *_clusterState, bucket, nodes,
- _upStates[upStates]);
- IdealNodeList list;
- for (uint32_t i=0; i<nodes.size(); ++i) {
- list.push_back(Node(nodeType, nodes[i]));
- }
- return list;
- }
+ void setDistribution(const Distribution& d) override;
+ void setClusterState(const ClusterState& cs) override;
+ IdealNodeList getIdealNodes(const NodeType& nodeType,
+ const document::BucketId& bucket,
+ UpStates upStates) const override;
private:
- void initUpStateMapping() {
- _upStates.clear();
- _upStates.resize(UP_STATE_COUNT);
- _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);
- }
- }
+ void initUpStateMapping();
};
} // lib