summaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-02-03 19:18:50 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2024-02-03 19:39:10 +0000
commit3b590870d88f329c9219759d46924571ce3db66d (patch)
tree392c5bc7ed64999a4e4be421a332103083731982 /vdslib
parent359bc341f0a85993a231c16f0e7b8c508ea55dc8 (diff)
GC unused distributor_auto_ownership_transfer_on_whole_group_down
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/test/java/com/yahoo/vdslib/distribution/DistributionTestCase.java2
-rw-r--r--vdslib/src/vespa/vdslib/distribution/distribution.cpp33
-rw-r--r--vdslib/src/vespa/vdslib/distribution/distribution.h12
3 files changed, 21 insertions, 26 deletions
diff --git a/vdslib/src/test/java/com/yahoo/vdslib/distribution/DistributionTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/distribution/DistributionTestCase.java
index b2afe2146fc..6fe36c2d259 100644
--- a/vdslib/src/test/java/com/yahoo/vdslib/distribution/DistributionTestCase.java
+++ b/vdslib/src/test/java/com/yahoo/vdslib/distribution/DistributionTestCase.java
@@ -337,7 +337,7 @@ public class DistributionTestCase {
@Test
public void testDistributorGroupTakeover() throws Exception {
test = new DistributionTestFactory("hierarchical-grouping-distributor-takeover")
- .setDistribution(buildHierarchicalConfig(6, 3, 1, "1|2|*", 3).distributor_auto_ownership_transfer_on_whole_group_down(true))
+ .setDistribution(buildHierarchicalConfig(6, 3, 1, "1|2|*", 3))
.setNodeType(NodeType.DISTRIBUTOR)
.setClusterState(new ClusterState("distributor:2 storage:9"));
for (BucketId bucket : getTestBuckets()) {
diff --git a/vdslib/src/vespa/vdslib/distribution/distribution.cpp b/vdslib/src/vespa/vdslib/distribution/distribution.cpp
index 4d18c9e5ef3..7ca85998d7e 100644
--- a/vdslib/src/vespa/vdslib/distribution/distribution.cpp
+++ b/vdslib/src/vespa/vdslib/distribution/distribution.cpp
@@ -121,7 +121,7 @@ Distribution::configure(const vespa::config::content::StorDistributionConfig& co
if (nodeGraph) {
path = DistributionConfigUtil::getGroupPath(cg.index);
}
- bool isLeafGroup = (cg.nodes.size() > 0);
+ bool isLeafGroup = ! cg.nodes.empty();
uint16_t index = (path.empty() ? 0 : path.back());
std::unique_ptr<Group> group = (isLeafGroup)
? std::make_unique<Group>(index, cg.name)
@@ -163,7 +163,6 @@ Distribution::configure(const vespa::config::content::StorDistributionConfig& co
_ensurePrimaryPersisted = config.ensurePrimaryPersisted;
_readyCopies = config.readyCopies;
_activePerGroup = config.activePerLeafGroup;
- _distributorAutoOwnershipTransferOnWholeGroupDown = config.distributorAutoOwnershipTransferOnWholeGroupDown;
}
uint32_t
@@ -318,9 +317,7 @@ Distribution::getIdealDistributorGroup(const document::BucketId& bucket, const C
score = std::pow(score, 1.0 / subGroup.second->getCapacity().getValue());
}
if (score > result._score) {
- if (!_distributorAutoOwnershipTransferOnWholeGroupDown
- || !allDistributorsDown(*subGroup.second, clusterState))
- {
+ if (!allDistributorsDown(*subGroup.second, clusterState)) {
result = ScoredGroup(score, subGroup.second);
}
}
@@ -335,8 +332,8 @@ bool
Distribution::allDistributorsDown(const Group& g, const ClusterState& cs)
{
if (g.isLeafGroup()) {
- for (uint32_t i=0, n=g.getNodes().size(); i<n; ++i) {
- const NodeState& ns(cs.getNodeState(Node(NodeType::DISTRIBUTOR, g.getNodes()[i])));
+ for (unsigned short node : g.getNodes()) {
+ const NodeState& ns(cs.getNodeState(Node(NodeType::DISTRIBUTOR, node)));
if (ns.getState().oneOf("ui")) return false;
}
} else {
@@ -378,38 +375,38 @@ Distribution::getIdealNodes(const NodeType& nodeType, const ClusterState& cluste
ss << "There is no legal distributor target in state with version " << clusterState.getVersion();
throw NoDistributorsAvailableException(ss.str(), VESPA_STRLOC);
}
- _groupDistribution.push_back(ResultGroup(*group, 1));
+ _groupDistribution.emplace_back(*group, 1);
}
RandomGen random(seed);
uint32_t randomIndex = 0;
std::vector<ScoredNode> tmpResults;
- for (uint32_t i=0, n=_groupDistribution.size(); i<n; ++i) {
- uint16_t groupRedundancy(_groupDistribution[i]._redundancy);
- const std::vector<uint16_t>& nodes(_groupDistribution[i]._group->getNodes());
+ for (const auto & group : _groupDistribution) {
+ uint16_t groupRedundancy(group._redundancy);
+ const std::vector<uint16_t>& nodes(group._group->getNodes());
// Create temporary place to hold results.
// Stuff in redundancy fake entries to
// avoid needing to check size during iteration.
tmpResults.reserve(groupRedundancy);
tmpResults.clear();
tmpResults.resize(groupRedundancy);
- for (uint32_t j=0; j < nodes.size(); ++j) {
+ for (unsigned short node : nodes) {
// Verify that the node is legal target before starting to grab
// random number. Helps worst case of having to start new random
// seed if the node that is out of order is illegal anyways.
- const NodeState& nodeState(clusterState.getNodeState(Node(nodeType, nodes[j])));
+ const NodeState& nodeState(clusterState.getNodeState(Node(nodeType, node)));
if (!nodeState.getState().oneOf(upStates)) continue;
// Get the score from the random number generator. Make sure we
// pick correct random number. Optimize for the case where we
// pick in rising order.
- if (nodes[j] != randomIndex) {
- if (nodes[j] < randomIndex) {
+ if (node != randomIndex) {
+ if (node < randomIndex) {
random.setSeed(seed);
randomIndex = 0;
}
- for (uint32_t k=randomIndex, o=nodes[j]; k<o; ++k) {
+ for (uint32_t k=randomIndex, o=node; k<o; ++k) {
random.nextDouble();
}
- randomIndex = nodes[j];
+ randomIndex = node;
}
double score = random.nextDouble();
++randomIndex;
@@ -417,7 +414,7 @@ Distribution::getIdealNodes(const NodeType& nodeType, const ClusterState& cluste
score = std::pow(score, 1.0 / nodeState.getCapacity().getValue());
}
if (score > tmpResults.back()._score) {
- insertOrdered(tmpResults, ScoredNode(score, nodes[j]));
+ insertOrdered(tmpResults, ScoredNode(score, node));
}
}
trimResult(tmpResults, groupRedundancy);
diff --git a/vdslib/src/vespa/vdslib/distribution/distribution.h b/vdslib/src/vespa/vdslib/distribution/distribution.h
index ebe84ad3be9..38ddac30fc0 100644
--- a/vdslib/src/vespa/vdslib/distribution/distribution.h
+++ b/vdslib/src/vespa/vdslib/distribution/distribution.h
@@ -41,7 +41,6 @@ private:
uint16_t _readyCopies;
bool _activePerGroup;
bool _ensurePrimaryPersisted;
- bool _distributorAutoOwnershipTransferOnWholeGroupDown;
vespalib::string _serialized;
struct ResultGroup {
@@ -91,7 +90,7 @@ public:
public:
ConfigWrapper(ConfigWrapper && rhs) noexcept = default;
ConfigWrapper & operator = (ConfigWrapper && rhs) noexcept = default;
- ConfigWrapper(std::unique_ptr<DistributionConfig> cfg) noexcept;
+ explicit ConfigWrapper(std::unique_ptr<DistributionConfig> cfg) noexcept;
~ConfigWrapper();
const DistributionConfig & get() const { return *_cfg; }
private:
@@ -99,10 +98,10 @@ public:
};
Distribution();
Distribution(const Distribution&);
- Distribution(const ConfigWrapper & cfg);
- Distribution(const DistributionConfig & cfg);
- Distribution(const vespalib::string& serialized);
- ~Distribution();
+ explicit Distribution(const ConfigWrapper & cfg);
+ explicit Distribution(const DistributionConfig & cfg);
+ explicit Distribution(const vespalib::string& serialized);
+ ~Distribution() override;
Distribution& operator=(const Distribution&) = delete;
@@ -113,7 +112,6 @@ public:
uint16_t getInitialRedundancy() const noexcept { return _initialRedundancy; }
uint16_t getReadyCopies() const noexcept { return _readyCopies; }
bool ensurePrimaryPersisted() const noexcept { return _ensurePrimaryPersisted; }
- bool distributorAutoOwnershipTransferOnWholeGroupDown() const noexcept { return _distributorAutoOwnershipTransferOnWholeGroupDown; }
bool activePerGroup() const noexcept { return _activePerGroup; }
bool operator==(const Distribution& o) const noexcept { return (_serialized == o._serialized); }