aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-03-22 21:41:34 +0100
committerHenning Baldersheim <balder@oath.com>2018-04-03 18:33:28 +0200
commitccc71ef497b9cc60468c42a51ae349cc4f86e450 (patch)
treeee6c15aab1abe71824a493f309565b4a352f85a5 /storage
parent99c4a2573660d7bbb0fea00444a8177f2c8acd43 (diff)
Do not pregenerate a string that is only needed when debugging
Diffstat (limited to 'storage')
-rw-r--r--storage/src/vespa/storage/distributor/activecopy.cpp131
-rw-r--r--storage/src/vespa/storage/distributor/activecopy.h31
-rw-r--r--storage/src/vespa/storage/distributor/distributor_bucket_space.h11
-rw-r--r--storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h7
-rw-r--r--storage/src/vespa/storage/distributor/distributorcomponent.cpp13
-rw-r--r--storage/src/vespa/storage/distributor/distributorcomponent.h7
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/putoperation.cpp3
-rw-r--r--storage/src/vespa/storage/distributor/statecheckers.cpp9
-rw-r--r--storage/src/vespa/storage/distributor/statecheckers.h6
10 files changed, 91 insertions, 131 deletions
diff --git a/storage/src/vespa/storage/distributor/activecopy.cpp b/storage/src/vespa/storage/distributor/activecopy.cpp
index 2ef0be27e4a..234fddacfdf 100644
--- a/storage/src/vespa/storage/distributor/activecopy.cpp
+++ b/storage/src/vespa/storage/distributor/activecopy.cpp
@@ -20,80 +20,70 @@ namespace std {
}
}
-namespace storage {
-namespace distributor {
+namespace storage::distributor {
-namespace {
- struct Entry {
- uint16_t _nodeIndex;
- uint16_t _ideal;
- bool _ready;
- bool _trusted;
- bool _active;
-
- Entry(uint16_t node, BucketDatabase::Entry& e,
- const std::vector<uint16_t>& idealState)
- : _nodeIndex(node),
- _ideal(0xffff)
- {
- const BucketCopy* copy = e->getNode(node);
- assert(copy != 0);
- _ready = copy->ready();
- _trusted = copy->trusted();
- _active = copy->active();
- for (uint32_t i=0; i<idealState.size(); ++i) {
- if (idealState[i] == node) _ideal = i;
- }
- }
+ActiveCopy::ActiveCopy(uint16_t node, BucketDatabase::Entry& e, const std::vector<uint16_t>& idealState) :
+ nodeIndex(node),
+ _ideal(0xffff)
+{
+ const BucketCopy* copy = e->getNode(node);
+ assert(copy != 0);
+ _ready = copy->ready();
+ _trusted = copy->trusted();
+ _active = copy->active();
+ for (uint32_t i=0; i<idealState.size(); ++i) {
+ if (idealState[i] == node) _ideal = i;
+ }
+}
- vespalib::string getReason() {
- if (_ready && _trusted && _ideal < 0xffff) {
- vespalib::asciistream ost;
- ost << "copy is ready, trusted and ideal state priority "
- << _ideal;
- return ost.str();
- } else if (_ready && _trusted) {
- return "copy is ready and trusted";
- } else if (_ready) {
- return "copy is ready";
- } else if (_trusted && _ideal < 0xffff) {
- vespalib::asciistream ost;
- ost << "copy is trusted and ideal state priority " << _ideal;
- return ost.str();
- } else if (_trusted) {
- return "copy is trusted";
- } else if (_ideal < 0xffff) {
- vespalib::asciistream ost;
- ost << "copy is ideal state priority " << _ideal;
- return ost.str();
- } else {
- return "first available copy";
- }
- }
+vespalib::string
+ActiveCopy::getReason() const {
+ if (_ready && _trusted && _ideal < 0xffff) {
+ vespalib::asciistream ost;
+ ost << "copy is ready, trusted and ideal state priority " << _ideal;
+ return ost.str();
+ } else if (_ready && _trusted) {
+ return "copy is ready and trusted";
+ } else if (_ready) {
+ return "copy is ready";
+ } else if (_trusted && _ideal < 0xffff) {
+ vespalib::asciistream ost;
+ ost << "copy is trusted and ideal state priority " << _ideal;
+ return ost.str();
+ } else if (_trusted) {
+ return "copy is trusted";
+ } else if (_ideal < 0xffff) {
+ vespalib::asciistream ost;
+ ost << "copy is ideal state priority " << _ideal;
+ return ost.str();
+ } else {
+ return "first available copy";
+ }
+}
- friend std::ostream& operator<<(std::ostream& out, const Entry& e) {
- out << "Entry(Node " << e._nodeIndex;
- if (e._ready) out << ", ready";
- if (e._trusted) out << ", trusted";
- if (e._ideal < 0xffff) out << ", ideal pri " << e._ideal;
- out << ")";
- return out;
- }
- };
+std::ostream&
+operator<<(std::ostream& out, const ActiveCopy & e) {
+ out << "Entry(Node " << e.nodeIndex;
+ if (e._ready) out << ", ready";
+ if (e._trusted) out << ", trusted";
+ if (e._ideal < 0xffff) out << ", ideal pri " << e._ideal;
+ out << ")";
+ return out;
+}
+
+namespace {
struct ActiveStateOrder {
- bool operator()(const Entry& e1, const Entry& e2) {
+ bool operator()(const ActiveCopy & e1, const ActiveCopy & e2) {
if (e1._ready != e2._ready) return e1._ready;
if (e1._trusted != e2._trusted) return e1._trusted;
if (e1._ideal != e2._ideal) return e1._ideal < e2._ideal;
if (e1._active != e2._active) return e1._active;
- return e1._nodeIndex < e2._nodeIndex;
+ return e1.nodeIndex < e2.nodeIndex;
}
};
- void buildValidNodeIndexList(BucketDatabase::Entry& e,
- std::vector<uint16_t>& result)
- {
+ void buildValidNodeIndexList(BucketDatabase::Entry& e, std::vector<uint16_t>& result) {
for (uint32_t i=0, n=e->getNodeCount(); i < n; ++i) {
const BucketCopy& cp = e->getNodeRef(i);
if (!cp.valid()) continue;
@@ -104,10 +94,10 @@ namespace {
void buildNodeList(BucketDatabase::Entry& e,
const std::vector<uint16_t>& nodeIndexes,
const std::vector<uint16_t>& idealState,
- std::vector<Entry>& result)
+ std::vector<ActiveCopy>& result)
{
for (uint32_t i=0; i<nodeIndexes.size(); ++i) {
- result.push_back(Entry(nodeIndexes[i], e, idealState));
+ result.push_back(ActiveCopy(nodeIndexes[i], e, idealState));
}
}
}
@@ -139,14 +129,12 @@ ActiveCopy::calculate(const std::vector<uint16_t>& idealState,
groups.push_back(validNodesWithCopy);
}
for (uint32_t i=0; i<groups.size(); ++i) {
- std::vector<Entry> entries;
+ std::vector<ActiveCopy> entries;
buildNodeList(e, groups[i], idealState, entries);
DEBUG(std::cerr << "Finding active for group " << entries << "\n");
- auto best = std::min_element(entries.begin(), entries.end(),
- ActiveStateOrder());
+ auto best = std::min_element(entries.begin(), entries.end(), ActiveStateOrder());
DEBUG(std::cerr << "Best copy " << *best << "\n");
- result.push_back(ActiveCopy(best->_nodeIndex,
- best->getReason()));
+ result.push_back(ActiveCopy(*best));
}
return ActiveList(result);
}
@@ -159,7 +147,7 @@ ActiveList::print(std::ostream& out, bool verbose,
if (verbose) {
for (size_t i=0; i<_v.size(); ++i) {
out << "\n" << indent << " "
- << _v[i].nodeIndex << " " << _v[i].reason;
+ << _v[i].nodeIndex << " " << _v[i].getReason();
}
if (!_v.empty()) out << "\n" << indent;
} else {
@@ -180,5 +168,4 @@ ActiveList::contains(uint16_t node) const
return false;
}
-} // distributor
-} // storage
+}
diff --git a/storage/src/vespa/storage/distributor/activecopy.h b/storage/src/vespa/storage/distributor/activecopy.h
index 6b379f98bef..8fcaf814947 100644
--- a/storage/src/vespa/storage/distributor/activecopy.h
+++ b/storage/src/vespa/storage/distributor/activecopy.h
@@ -4,25 +4,27 @@
#include <vespa/storage/bucketdb/bucketdatabase.h>
-namespace storage {
-namespace lib {
- class Distribution;
-}
-namespace distributor {
+namespace storage::lib { class Distribution; }
+namespace storage::distributor {
class ActiveList;
struct ActiveCopy {
- uint16_t nodeIndex;
- vespalib::string reason;
+public:
+ ActiveCopy() : nodeIndex(-1), _ideal(-1), _ready(false), _trusted(false), _active(false) { }
+ ActiveCopy(uint16_t node, BucketDatabase::Entry& e, const std::vector<uint16_t>& idealState);
- ActiveCopy() : nodeIndex(0xffff), reason(0) {}
- ActiveCopy(uint16_t index, vespalib::stringref r)
- : nodeIndex(index), reason(r) {}
+ vespalib::string getReason() const;
+ friend std::ostream& operator<<(std::ostream& out, const ActiveCopy& e);
- static ActiveList calculate(
- const std::vector<uint16_t>& idealState,
- const lib::Distribution&, BucketDatabase::Entry&);
+ static ActiveList calculate(const std::vector<uint16_t>& idealState,
+ const lib::Distribution&, BucketDatabase::Entry&);
+
+ uint16_t nodeIndex;
+ uint16_t _ideal;
+ bool _ready;
+ bool _trusted;
+ bool _active;
};
class ActiveList : public vespalib::Printable {
@@ -40,5 +42,4 @@ public:
void print(std::ostream&, bool verbose, const std::string& indent) const override;
};
-} // distributor
-} // storage
+}
diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space.h b/storage/src/vespa/storage/distributor/distributor_bucket_space.h
index eca50d4263e..23d00c6ae43 100644
--- a/storage/src/vespa/storage/distributor/distributor_bucket_space.h
+++ b/storage/src/vespa/storage/distributor/distributor_bucket_space.h
@@ -4,14 +4,12 @@
#include <vespa/storage/bucketdb/mapbucketdatabase.h>
#include <memory>
-namespace storage {
-
-namespace lib {
-class ClusterState;
-class Distribution;
+namespace storage::lib {
+ class ClusterState;
+ class Distribution;
}
-namespace distributor {
+namespace storage::distributor {
/**
* A distributor bucket space holds specific state and information required for
@@ -58,4 +56,3 @@ public:
};
}
-}
diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp
index cc1b1eb9a17..744c54676ae 100644
--- a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp
+++ b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.cpp
@@ -11,8 +11,7 @@ LOG_SETUP(".distributor.distributor_bucket_space_repo");
using document::BucketSpace;
-namespace storage {
-namespace distributor {
+namespace storage::distributor {
DistributorBucketSpaceRepo::DistributorBucketSpaceRepo()
: _map()
@@ -46,4 +45,3 @@ DistributorBucketSpaceRepo::get(BucketSpace bucketSpace) const
}
}
-}
diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h
index e30438771b2..ee36842969a 100644
--- a/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h
+++ b/storage/src/vespa/storage/distributor/distributor_bucket_space_repo.h
@@ -5,11 +5,9 @@
#include <memory>
#include <unordered_map>
-namespace storage {
+namespace storage::lib { class Distribution; }
-namespace lib { class Distribution; }
-
-namespace distributor {
+namespace storage::distributor {
class DistributorBucketSpace;
@@ -38,4 +36,3 @@ public:
};
}
-}
diff --git a/storage/src/vespa/storage/distributor/distributorcomponent.cpp b/storage/src/vespa/storage/distributor/distributorcomponent.cpp
index 1d2465fb41a..d3d07350d35 100644
--- a/storage/src/vespa/storage/distributor/distributorcomponent.cpp
+++ b/storage/src/vespa/storage/distributor/distributorcomponent.cpp
@@ -1,20 +1,17 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "distributorcomponent.h"
-#include <vespa/storage/common/bucketoperationlogger.h>
-#include <vespa/storageapi/messageapi/storagereply.h>
-#include <vespa/vdslib/distribution/distribution.h>
-#include <vespa/vdslib/state/cluster_state_bundle.h>
#include "distributor_bucket_space_repo.h"
#include "distributor_bucket_space.h"
+#include <vespa/storage/common/bucketoperationlogger.h>
+#include <vespa/vdslib/state/cluster_state_bundle.h>
+
#include <vespa/log/log.h>
LOG_SETUP(".distributorstoragelink");
using document::BucketSpace;
-namespace storage {
-
-namespace distributor {
+namespace storage::distributor {
DistributorComponent::DistributorComponent(
DistributorInterface& distributor,
@@ -356,5 +353,3 @@ DistributorComponent::initializing() const {
}
}
-
-}
diff --git a/storage/src/vespa/storage/distributor/distributorcomponent.h b/storage/src/vespa/storage/distributor/distributorcomponent.h
index 184ac768afb..561904cee8d 100644
--- a/storage/src/vespa/storage/distributor/distributorcomponent.h
+++ b/storage/src/vespa/storage/distributor/distributorcomponent.h
@@ -10,9 +10,7 @@
#include <vespa/storageapi/buckets/bucketinfo.h>
#include <vespa/vdslib/state/clusterstate.h>
-namespace storage {
-
-namespace distributor {
+namespace storage::distributor {
class DistributorBucketSpaceRepo;
@@ -186,6 +184,3 @@ protected:
};
}
-
-}
-
diff --git a/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp
index de0d1559c1f..d08afdacfad 100644
--- a/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/putoperation.cpp
@@ -5,11 +5,8 @@
#include <vespa/document/fieldvalue/document.h>
#include <vespa/log/log.h>
#include <vespa/storage/distributor/activecopy.h>
-#include <vespa/storage/distributor/distributorcomponent.h>
-#include <vespa/storage/distributor/distributormetricsset.h>
#include <vespa/storage/distributor/operationtargetresolverimpl.h>
#include <vespa/storage/distributor/pendingmessagetracker.h>
-#include <vespa/storageapi/message/bucket.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/vdslib/distribution/idealnodecalculatorimpl.h>
#include <vespa/storage/distributor/distributor_bucket_space.h>
diff --git a/storage/src/vespa/storage/distributor/statecheckers.cpp b/storage/src/vespa/storage/distributor/statecheckers.cpp
index 4d6e9d8164f..cafac5b67a5 100644
--- a/storage/src/vespa/storage/distributor/statecheckers.cpp
+++ b/storage/src/vespa/storage/distributor/statecheckers.cpp
@@ -8,7 +8,6 @@
#include <vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h>
#include <vespa/storage/distributor/operations/idealstate/mergeoperation.h>
#include <vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h>
-#include <vespa/storage/bucketdb/bucketdatabase.h>
#include <vespa/storage/common/bucketoperationlogger.h>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -17,8 +16,7 @@ LOG_SETUP(".distributor.operation.checkers");
using document::BucketSpace;
-namespace storage {
-namespace distributor {
+namespace storage::distributor {
bool
SplitBucketStateChecker::validForSplit(StateChecker::Context& c)
@@ -1058,7 +1056,7 @@ BucketStateStateChecker::check(StateChecker::Context& c)
}
operationNodes.push_back(activeNodes[i].nodeIndex);
reason << "[Setting node " << activeNodes[i].nodeIndex << " as active: "
- << activeNodes[i].reason << "]";
+ << activeNodes[i].getReason() << "]";
}
// Deactivate all copies that are currently marked as active.
@@ -1148,5 +1146,4 @@ GarbageCollectionStateChecker::check(Context& c)
}
}
-} // distributor
-} // storage
+}
diff --git a/storage/src/vespa/storage/distributor/statecheckers.h b/storage/src/vespa/storage/distributor/statecheckers.h
index 4f72d31aac5..0e39436c67c 100644
--- a/storage/src/vespa/storage/distributor/statecheckers.h
+++ b/storage/src/vespa/storage/distributor/statecheckers.h
@@ -3,9 +3,7 @@
#include "idealstatemanager.h"
-namespace storage {
-
-namespace distributor {
+namespace storage::distributor {
class SynchronizeAndMoveStateChecker : public StateChecker
{
@@ -116,5 +114,3 @@ public:
};
}
-
-}