diff options
30 files changed, 604 insertions, 454 deletions
diff --git a/config/src/apps/configproxy-cmd/flags.h b/config/src/apps/configproxy-cmd/flags.h deleted file mode 100644 index ce64889256b..00000000000 --- a/config/src/apps/configproxy-cmd/flags.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <vespa/vespalib/stllike/string.h> -#include <vector> - -struct Flags { - vespalib::string method; - std::vector<vespalib::string> args; - vespalib::string hostname; - int portnumber; - Flags() : method("cache"), args(), hostname("localhost"), portnumber(19090) {} -}; - diff --git a/config/src/apps/configproxy-cmd/main.cpp b/config/src/apps/configproxy-cmd/main.cpp index b9090d3b641..3a8cf33c343 100644 --- a/config/src/apps/configproxy-cmd/main.cpp +++ b/config/src/apps/configproxy-cmd/main.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "flags.h" #include "proxycmd.h" #include "methods.h" #include <vespa/fastos/app.h> diff --git a/config/src/apps/configproxy-cmd/proxycmd.cpp b/config/src/apps/configproxy-cmd/proxycmd.cpp index 48c343367f7..794c005f485 100644 --- a/config/src/apps/configproxy-cmd/proxycmd.cpp +++ b/config/src/apps/configproxy-cmd/proxycmd.cpp @@ -4,12 +4,24 @@ #include <iostream> #include <vespa/vespalib/util/stringfmt.h> +Flags::Flags(const Flags &) = default; +Flags & Flags::operator=(const Flags &) = default; +Flags::Flags() + : method("cache"), + args(), + hostname("localhost"), + portnumber(19090) +{ } +Flags::~Flags() { } + ProxyCmd::ProxyCmd(const Flags& flags) : _supervisor(NULL), _target(NULL), _req(NULL), _flags(flags) -{} +{ } + +ProxyCmd::~ProxyCmd() { } void ProxyCmd::initRPC() { _supervisor = new FRT_Supervisor(); diff --git a/config/src/apps/configproxy-cmd/proxycmd.h b/config/src/apps/configproxy-cmd/proxycmd.h index 6fc8261991f..a0ef02edaae 100644 --- a/config/src/apps/configproxy-cmd/proxycmd.h +++ b/config/src/apps/configproxy-cmd/proxycmd.h @@ -1,9 +1,18 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "flags.h" #include <vespa/fnet/frt/frt.h> +struct Flags { + vespalib::string method; + std::vector<vespalib::string> args; + vespalib::string hostname; + int portnumber; + Flags(const Flags &); + Flags & operator=(const Flags &); + Flags(); + ~Flags(); +}; class ProxyCmd { @@ -22,7 +31,7 @@ private: public: ProxyCmd(const Flags& flags); - virtual ~ProxyCmd() {} + virtual ~ProxyCmd(); int action(); }; diff --git a/config/src/tests/configfetcher/configfetcher.cpp b/config/src/tests/configfetcher/configfetcher.cpp index 6d319fdff67..5d4ee8dcd2b 100644 --- a/config/src/tests/configfetcher/configfetcher.cpp +++ b/config/src/tests/configfetcher/configfetcher.cpp @@ -12,8 +12,9 @@ using namespace config; class MyCallback : public IFetcherCallback<MyConfig> { public: - MyCallback(const std::string & badConfig="") : _config(), _configured(false), _badConfig(badConfig) { } - void configure(std::unique_ptr<MyConfig> config) + MyCallback(const std::string & badConfig=""); + ~MyCallback(); + void configure(std::unique_ptr<MyConfig> config) override { _config = std::move(config); _configured = true; @@ -26,6 +27,9 @@ public: std::string _badConfig; }; +MyCallback::MyCallback(const std::string & badConfig) : _config(), _configured(false), _badConfig(badConfig) { } +MyCallback::~MyCallback() { } + TEST("requireThatConfigIsAvailableOnConstruction") { RawSpec spec("myField \"foo\"\n"); MyCallback cb; diff --git a/config/src/tests/configmanager/configmanager.cpp b/config/src/tests/configmanager/configmanager.cpp index d0e8f5444e0..1b20458b47e 100644 --- a/config/src/tests/configmanager/configmanager.cpp +++ b/config/src/tests/configmanager/configmanager.cpp @@ -106,11 +106,8 @@ namespace { ConfigManager _mgr; ConfigSubscription::SP sub; - ManagerTester(const ConfigKey & k, const MySpec & s) - : key(k), - _mgr(s.createSourceFactory(testTimingValues), 1) - { - } + ManagerTester(const ConfigKey & k, const MySpec & s); + ~ManagerTester(); void subscribe() { @@ -118,6 +115,12 @@ namespace { } }; + ManagerTester::ManagerTester(const ConfigKey & k, const MySpec & s) + : key(k), + _mgr(s.createSourceFactory(testTimingValues), 1) + { } + ManagerTester::~ManagerTester() { } + } TEST("requireThatSubscriptionTimesout") { diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp index 597951af352..89cf9dd9e6a 100644 --- a/config/src/tests/frt/frt.cpp +++ b/config/src/tests/frt/frt.cpp @@ -128,13 +128,8 @@ namespace { FRT_Supervisor supervisor; FNET_Scheduler scheduler; vespalib::string address; - ConnectionMock(FRT_RPCRequest * answer = NULL) - : errorCode(0), - timeout(0), - ans(answer), - supervisor(), - address() - { } + ConnectionMock(FRT_RPCRequest * answer = NULL); + ~ConnectionMock(); FRT_RPCRequest * allocRPCRequest() { return supervisor.AllocRPCRequest(); } void setError(int ec) { errorCode = ec; } void invoke(FRT_RPCRequest * req, double t, FRT_IRequestWait * waiter) @@ -149,6 +144,15 @@ namespace { void setTransientDelay(int64_t delay) { (void) delay; } }; + ConnectionMock::ConnectionMock(FRT_RPCRequest * answer) + : errorCode(0), + timeout(0), + ans(answer), + supervisor(), + address() + { } + ConnectionMock::~ConnectionMock() { } + struct FactoryMock : public ConnectionFactory { ConnectionMock * current; FactoryMock(ConnectionMock * c) : current(c) { } diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp index 24d50b44ca4..deed6f15f1a 100644 --- a/config/src/tests/functiontest/functiontest.cpp +++ b/config/src/tests/functiontest/functiontest.cpp @@ -94,13 +94,16 @@ struct LazyTestFixture ConfigHandle<FunctionTestConfig>::UP _handle; std::unique_ptr<FunctionTestConfig> _config; - LazyTestFixture(const std::string & dirName) + LazyTestFixture(const std::string & dirName); + ~LazyTestFixture(); +}; + +LazyTestFixture::LazyTestFixture(const std::string & dirName) : _spec(TEST_PATH(dirName)), _subscriber(_spec), _handle(_subscriber.subscribe<FunctionTestConfig>("")) - { - } -}; +{ } +LazyTestFixture::~LazyTestFixture() { } struct TestFixture : public LazyTestFixture { diff --git a/eval/src/tests/eval/function/function_test.cpp b/eval/src/tests/eval/function/function_test.cpp index 306fdb95386..e90525ce2fa 100644 --- a/eval/src/tests/eval/function/function_test.cpp +++ b/eval/src/tests/eval/function/function_test.cpp @@ -608,8 +608,12 @@ struct UnWrapped { vespalib::string wrapper; vespalib::string body; vespalib::string error; + ~UnWrapped(); }; + +UnWrapped::~UnWrapped() {} + UnWrapped unwrap(const vespalib::string &str) { UnWrapped result; bool ok = Function::unwrap(str, result.wrapper, result.body, result.error); diff --git a/eval/src/tests/eval/value_type/value_type_test.cpp b/eval/src/tests/eval/value_type/value_type_test.cpp index 529d45e616d..b72b5a3a972 100644 --- a/eval/src/tests/eval/value_type/value_type_test.cpp +++ b/eval/src/tests/eval/value_type/value_type_test.cpp @@ -308,14 +308,18 @@ struct ParseResult { const char *end; const char *after; ValueType type; - ParseResult(const vespalib::string &spec_in) - : spec(spec_in), - pos(spec.data()), - end(pos + spec.size()), - after(nullptr), - type(value_type::parse_spec(pos, end, after)) {} + ParseResult(const vespalib::string &spec_in); + ~ParseResult(); bool after_inside() const { return ((after > pos) && (after < end)); } }; +ParseResult::ParseResult(const vespalib::string &spec_in) + : spec(spec_in), + pos(spec.data()), + end(pos + spec.size()), + after(nullptr), + type(value_type::parse_spec(pos, end, after)) +{ } +ParseResult::~ParseResult() { } TEST("require that we can parse a partial string into a type with the low-level API") { ParseResult result("tensor(a[]) , "); diff --git a/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp b/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp index 8b7ea1d03a9..3b16c9e3026 100644 --- a/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp +++ b/eval/src/tests/tensor/dense_dot_product_function/dense_dot_product_function_test.cpp @@ -90,11 +90,8 @@ struct Fixture { DenseDotProductFunction function; FunctionInput input; - Fixture(size_t lhsNumCells, size_t rhsNumCells) - : function(0, 1), - input(lhsNumCells, rhsNumCells) - { - } + Fixture(size_t lhsNumCells, size_t rhsNumCells); + ~Fixture(); double eval() const { Stash stash; const Value &result = function.eval(input, stash); @@ -107,6 +104,13 @@ struct Fixture } }; +Fixture::Fixture(size_t lhsNumCells, size_t rhsNumCells) + : function(0, 1), + input(lhsNumCells, rhsNumCells) +{ } + +Fixture::~Fixture() { } + void assertDotProduct(size_t numCells) { diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp b/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp index 5112df7de09..f9375fd607a 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp +++ b/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp @@ -64,72 +64,90 @@ struct TrackingTask : public Scheduler::Task { const libtorrent::tracker_request& trackerRequest, const TorrentSP & torrent, const std::weak_ptr<FileDownloader>& downloader, - const std::shared_ptr<FileDistributionModel>& model) - : Task(scheduler), - _numTimesRescheduled(0), - _trackerRequest(trackerRequest), - _torrent(torrent), - _downloader(downloader), - _model(model) - {} + const std::shared_ptr<FileDistributionModel>& model); + ~TrackingTask(); //TODO: refactor - void doHandle() { - if (std::shared_ptr<FileDownloader> downloader = _downloader.lock()) { - //All torrents must be destructed before the session is destructed. - //It's okay to prevent the torrent from expiring here - //since the session can't be destructed while - //we hold a shared_ptr to the downloader. - if (TorrentSP torrent = _torrent.lock()) { - PeerEntries peers = getPeers(downloader); - - if (!peers.empty()) { - torrent->session().m_io_service.dispatch( - [torrent_weak_ptr = _torrent, trackerRequest = _trackerRequest, peers = peers]() mutable { - if (auto torrent_sp = torrent_weak_ptr.lock()) { - torrent_sp->tracker_response( - trackerRequest, - libtorrent::address(), - std::list<libtorrent::address>(), - peers, - -1, -1, -1, -1, -1, - libtorrent::address(), "trackerid"); - } - }); - } - - if (peers.size() < 5) { - reschedule(); - } + void doHandle(); + PeerEntries getPeers(const std::shared_ptr<FileDownloader>& downloader); + void reschedule(); +}; + +TrackingTask::TrackingTask(Scheduler& scheduler, + const libtorrent::tracker_request& trackerRequest, + const TorrentSP & torrent, + const std::weak_ptr<FileDownloader>& downloader, + const std::shared_ptr<FileDistributionModel>& model) + : Task(scheduler), + _numTimesRescheduled(0), + _trackerRequest(trackerRequest), + _torrent(torrent), + _downloader(downloader), + _model(model) +{ } + +TrackingTask::~TrackingTask() {} + + +//TODO: refactor +void +TrackingTask::doHandle() { + if (std::shared_ptr<FileDownloader> downloader = _downloader.lock()) { + //All torrents must be destructed before the session is destructed. + //It's okay to prevent the torrent from expiring here + //since the session can't be destructed while + //we hold a shared_ptr to the downloader. + if (TorrentSP torrent = _torrent.lock()) { + PeerEntries peers = getPeers(downloader); + + if (!peers.empty()) { + torrent->session().m_io_service.dispatch( + [torrent_weak_ptr = _torrent, trackerRequest = _trackerRequest, peers = peers]() mutable { + if (auto torrent_sp = torrent_weak_ptr.lock()) { + torrent_sp->tracker_response( + trackerRequest, + libtorrent::address(), + std::list<libtorrent::address>(), + peers, + -1, -1, -1, -1, -1, + libtorrent::address(), "trackerid"); + } + }); + } + + if (peers.size() < 5) { + reschedule(); } } } +} - PeerEntries getPeers(const std::shared_ptr<FileDownloader>& downloader) { - std::string fileReference = downloader->infoHash2FileReference(_trackerRequest.info_hash); - - const size_t recommendedMaxNumberOfPeers = 30; - PeerEntries peers = _model->getPeers(fileReference, recommendedMaxNumberOfPeers); +PeerEntries +TrackingTask::getPeers(const std::shared_ptr<FileDownloader>& downloader) { + std::string fileReference = downloader->infoHash2FileReference(_trackerRequest.info_hash); - //currently, libtorrent stops working if it tries to connect to itself. - filterSelf(peers, downloader->_hostName, downloader->_port); - resolveIPAddresses(peers); - for (const auto& peer: peers) { - LOG(debug, "Returning peer with ip %s", peer.ip.c_str()); - } + const size_t recommendedMaxNumberOfPeers = 30; + PeerEntries peers = _model->getPeers(fileReference, recommendedMaxNumberOfPeers); - return peers; + //currently, libtorrent stops working if it tries to connect to itself. + filterSelf(peers, downloader->_hostName, downloader->_port); + resolveIPAddresses(peers); + for (const auto& peer: peers) { + LOG(debug, "Returning peer with ip %s", peer.ip.c_str()); } - void reschedule() { - if (_numTimesRescheduled < 5) { - double fudgeFactor = 0.1; - schedule(boost::posix_time::seconds(static_cast<int>( - std::pow(3., _numTimesRescheduled) + fudgeFactor))); - _numTimesRescheduled++; - } + return peers; +} + +void +TrackingTask::reschedule() { + if (_numTimesRescheduled < 5) { + double fudgeFactor = 0.1; + schedule(boost::posix_time::seconds(static_cast<int>( + std::pow(3., _numTimesRescheduled) + fudgeFactor))); + _numTimesRescheduled++; } -}; +} } //anonymous namespace diff --git a/juniper/src/test/auxTest.cpp b/juniper/src/test/auxTest.cpp index 99ccd24af35..4b1274cb2a6 100644 --- a/juniper/src/test/auxTest.cpp +++ b/juniper/src/test/auxTest.cpp @@ -696,6 +696,32 @@ AuxTest::assertChar(ucs4_t act, char exp) return _test((char) act == exp); } +typedef std::unique_ptr<QueryNode> QueryNodeUP; +struct QB { + QueryNodeUP q; + QB(size_t numTerms) : q(new QueryNode(numTerms, 0, 0)) {} + QB(QB & rhs) : q(std::move(rhs.q)) { } + QB & add(const char * t, bool st = true) { + QueryTerm * qt = new QueryTerm(t, strlen(t), 0); + if (st) qt->_options |= X_SPECIALTOKEN; + q->AddChild(qt); + return *this; + } +}; +struct Ctx { + std::string text; + QB qb; + SpecialTokenRegistry str; + Fast_NormalizeWordFolder wf; + TokenProcessor tp; + JuniperTokenizer jt; + Ctx(const std::string & text_, QB & qb_); + ~Ctx(); +}; + +Ctx::Ctx(const std::string & text_, QB & qb_) : text(text_), qb(qb_), str(qb.q.get()), wf(), tp(text), jt(&wf, text.c_str(), text.size(), &tp, &str) { jt.scan(); } +Ctx::~Ctx() { } + void AuxTest::TestSpecialTokenRegistry() { @@ -775,27 +801,6 @@ AuxTest::TestSpecialTokenRegistry() } } { // test tokenizer with special token registry - typedef std::unique_ptr<QueryNode> QueryNodeUP; - struct QB { - QueryNodeUP q; - QB(size_t numTerms) : q(new QueryNode(numTerms, 0, 0)) {} - QB(QB & rhs) : q(std::move(rhs.q)) { } - QB & add(const char * t, bool st = true) { - QueryTerm * qt = new QueryTerm(t, strlen(t), 0); - if (st) qt->_options |= X_SPECIALTOKEN; - q->AddChild(qt); - return *this; - } - }; - struct Ctx { - std::string text; - QB qb; - SpecialTokenRegistry str; - Fast_NormalizeWordFolder wf; - TokenProcessor tp; - JuniperTokenizer jt; - Ctx(const std::string & text_, QB & qb_) : text(text_), qb(qb_), str(qb.q.get()), wf(), tp(text), jt(&wf, text.c_str(), text.size(), &tp, &str) { jt.scan(); } - }; { // only special token registered Ctx c("foo", QB(2).add("c++").add("foo", false)); diff --git a/metrics/src/tests/metricmanagertest.cpp b/metrics/src/tests/metricmanagertest.cpp index 72a4a287f2c..7159207e0ff 100644 --- a/metrics/src/tests/metricmanagertest.cpp +++ b/metrics/src/tests/metricmanagertest.cpp @@ -63,17 +63,22 @@ struct SubMetricSet : public MetricSet DoubleValueMetric val2; SumMetric<DoubleValueMetric> valsum; - SubMetricSet(const Metric::String & name, MetricSet* owner) - : MetricSet(name, "sub", "sub desc", owner, "sub"), - val1("val1", "tag4 snaptest", "val1 desc", this), - val2("val2", "tag5", "val2 desc", this), - valsum("valsum", "tag4 snaptest", "valsum desc", this) - { - valsum.addMetricToSum(val1); - valsum.addMetricToSum(val2); - } + SubMetricSet(const Metric::String & name, MetricSet* owner); + ~SubMetricSet(); }; + +SubMetricSet::SubMetricSet(const Metric::String & name, MetricSet* owner) + : MetricSet(name, "sub", "sub desc", owner, "sub"), + val1("val1", "tag4 snaptest", "val1 desc", this), + val2("val2", "tag5", "val2 desc", this), + valsum("valsum", "tag4 snaptest", "valsum desc", this) +{ + valsum.addMetricToSum(val1); + valsum.addMetricToSum(val2); +} +SubMetricSet::~SubMetricSet() { } + struct MultiSubMetricSet { MetricSet set; @@ -82,21 +87,23 @@ struct MultiSubMetricSet SubMetricSet b; SumMetric<MetricSet> sum; - MultiSubMetricSet(MetricSet* owner) - : set("multisub", "multisub", "", owner), - count("count", "snaptest", "counter", &set), - a("a", &set), - b("b", &set), - sum("sum", "snaptest", "", &set) - { - sum.addMetricToSum(a); - sum.addMetricToSum(b); - } - + MultiSubMetricSet(MetricSet* owner); + ~MultiSubMetricSet(); }; -struct TestMetricSet +MultiSubMetricSet::MultiSubMetricSet(MetricSet* owner) + : set("multisub", "multisub", "", owner), + count("count", "snaptest", "counter", &set), + a("a", &set), + b("b", &set), + sum("sum", "snaptest", "", &set) { + sum.addMetricToSum(a); + sum.addMetricToSum(b); +} + MultiSubMetricSet::~MultiSubMetricSet() { } + +struct TestMetricSet { MetricSet set; DoubleValueMetric val1; DoubleValueMetric val2; @@ -109,23 +116,27 @@ struct TestMetricSet SubMetricSet val9; MultiSubMetricSet val10; - TestMetricSet() - : set("temp", "test", "desc of test set"), - val1("val1", "tag1", "val1 desc", &set), - val2("val2", "tag1 tag2", "val2 desc", &set), - val3("val3", "tag2 tag3", "val3 desc", &set), - val4("val4", "tag3", "val4 desc", &set), - val5("val5", "tag2", "val5 desc", &set), - val6("val6", "tag4 snaptest", "val6 desc", &set), - val7("val7", "", "val7 desc", &set), - val8("val8", "tag6", "val8 desc", &set), - val9("sub", &set), - val10(&set) - { - } - + TestMetricSet(); + ~TestMetricSet(); }; +TestMetricSet::TestMetricSet() + : set("temp", "test", "desc of test set"), + val1("val1", "tag1", "val1 desc", &set), + val2("val2", "tag1 tag2", "val2 desc", &set), + val3("val3", "tag2 tag3", "val3 desc", &set), + val4("val4", "tag3", "val4 desc", &set), + val5("val5", "tag2", "val5 desc", &set), + val6("val6", "tag4 snaptest", "val6 desc", &set), + val7("val7", "", "val7 desc", &set), + val8("val8", "tag6", "val8 desc", &set), + val9("sub", &set), + val10(&set) +{ } + +TestMetricSet::~TestMetricSet() { } + + struct MetricNameVisitor : public MetricVisitor { std::ostringstream ost; bool debug; @@ -898,12 +909,8 @@ class JsonMetricWrapper std::string _jsonText; vespalib::Slime _tree; public: - JsonMetricWrapper(const std::string& jsonText) - : _jsonText(jsonText) - { - vespalib::slime::JsonFormat::decode( - vespalib::Memory(jsonText), _tree); - } + JsonMetricWrapper(const std::string& jsonText); + ~JsonMetricWrapper(); // XXX ideally all these should be const, but is not clear how/if it's // possible to get a const cursor into the underlying tree. @@ -945,20 +952,29 @@ public: } }; +JsonMetricWrapper::JsonMetricWrapper(const std::string& jsonText) + : _jsonText(jsonText) +{ + vespalib::slime::JsonFormat::decode(vespalib::Memory(jsonText), _tree); +} +JsonMetricWrapper::~JsonMetricWrapper() { } + struct DimensionTestMetricSet : MetricSet { DoubleValueMetric val1; LongCountMetric val2; - DimensionTestMetricSet(MetricSet* owner = nullptr) - : MetricSet("temp", {{"foo", "megafoo"}, {"bar", "hyperbar"}}, - "", owner), - val1("val1", "tag1", "val1 desc", this), // Legacy tag; not dimension - val2("val2", {{"baz", "superbaz"}}, "val2 desc", this) - { - } + DimensionTestMetricSet(MetricSet* owner = nullptr); + ~DimensionTestMetricSet(); }; +DimensionTestMetricSet::DimensionTestMetricSet(MetricSet* owner) + : MetricSet("temp", {{"foo", "megafoo"}, {"bar", "hyperbar"}}, "", owner), + val1("val1", "tag1", "val1 desc", this), + val2("val2", {{"baz", "superbaz"}}, "val2 desc", this) +{ } +DimensionTestMetricSet::~DimensionTestMetricSet() { } + } // anon ns void @@ -1027,8 +1043,7 @@ struct DimensionOverridableTestMetricSet : MetricSet MetricSet* owner = nullptr) : MetricSet("temp", {{"foo", dimValue}}, "", owner), val("val", "", "val desc", this) - { - } + { } }; struct SameNamesTestMetricSet : MetricSet @@ -1036,14 +1051,17 @@ struct SameNamesTestMetricSet : MetricSet DimensionOverridableTestMetricSet set1; DimensionOverridableTestMetricSet set2; - SameNamesTestMetricSet() - : MetricSet("outer", {{"fancy", "stuff"}}, ""), - set1("bar", this), - set2("baz", this) - { - } + SameNamesTestMetricSet(); + ~SameNamesTestMetricSet(); }; +SameNamesTestMetricSet::SameNamesTestMetricSet() + : MetricSet("outer", {{"fancy", "stuff"}}, ""), + set1("bar", this), + set2("baz", this) +{ } +SameNamesTestMetricSet::~SameNamesTestMetricSet() { } + } // anon ns void diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp index 253b7b4f2de..2527a048df6 100644 --- a/metrics/src/tests/snapshottest.cpp +++ b/metrics/src/tests/snapshottest.cpp @@ -38,63 +38,71 @@ struct SubSubMetricSet : public MetricSet { LoadMetric<DoubleAverageMetric> loadAverage; SumMetric<DoubleAverageMetric> averageSum; - SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - loadTypes(loadTypes_), - incVal(1), - count1("count1", "", "", this), - count2("count2", "", "", this), - loadCount(loadTypes, LongCountMetric("loadCount", "", ""), this), - countSum("countSum", "", "", this), - value1("value1", "", "", this), - value2("value2", "", "", this), - loadValue(loadTypes, DoubleValueMetric("loadValue", "", ""), this), - valueSum("valueSum", "", "", this), - average1("average1", "", "", this), - average2("average2", "", "", this), - loadAverage(loadTypes, DoubleAverageMetric("loadAverage", "", ""), - this), - averageSum("averageSum", "", "", this) - { - countSum.addMetricToSum(count1); - countSum.addMetricToSum(count2); - valueSum.addMetricToSum(value1); - valueSum.addMetricToSum(value2); - averageSum.addMetricToSum(average1); - averageSum.addMetricToSum(average2); - } + SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); + ~SubSubMetricSet(); + virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + metrics::MetricSet* owner, bool includeUnused) const; + void incValues(); +}; - virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, - CopyType copyType, metrics::MetricSet* owner, - bool includeUnused) const - { - if (copyType == INACTIVE) { - return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); - } - return (SubSubMetricSet*) (new SubSubMetricSet( - getName(), loadTypes, owner)) - ->assignValues(*this); +SubSubMetricSet::SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) + : MetricSet(name, "", "", owner), + loadTypes(loadTypes_), + incVal(1), + count1("count1", "", "", this), + count2("count2", "", "", this), + loadCount(loadTypes, LongCountMetric("loadCount", "", ""), this), + countSum("countSum", "", "", this), + value1("value1", "", "", this), + value2("value2", "", "", this), + loadValue(loadTypes, DoubleValueMetric("loadValue", "", ""), this), + valueSum("valueSum", "", "", this), + average1("average1", "", "", this), + average2("average2", "", "", this), + loadAverage(loadTypes, DoubleAverageMetric("loadAverage", "", ""), this), + averageSum("averageSum", "", "", this) +{ + countSum.addMetricToSum(count1); + countSum.addMetricToSum(count2); + valueSum.addMetricToSum(value1); + valueSum.addMetricToSum(value2); + averageSum.addMetricToSum(average1); + averageSum.addMetricToSum(average2); +} +SubSubMetricSet::~SubSubMetricSet() { } + +MetricSet* +SubSubMetricSet::clone(std::vector<Metric::LP>& ownerList, + CopyType copyType, metrics::MetricSet* owner, + bool includeUnused) const +{ + if (copyType == INACTIVE) { + return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); } + return (SubSubMetricSet*) (new SubSubMetricSet( + getName(), loadTypes, owner)) + ->assignValues(*this); +} - void incValues() { - count1.inc(incVal); - count2.inc(incVal); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadCount[loadTypes[i]].inc(incVal); - } - value1.set(incVal); - value2.set(incVal); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadValue[loadTypes[i]].set(incVal); - } - average1.set(incVal); - average2.set(incVal); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadAverage[loadTypes[i]].set(incVal); - } +void +SubSubMetricSet::incValues() { + count1.inc(incVal); + count2.inc(incVal); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadCount[loadTypes[i]].inc(incVal); } -}; + value1.set(incVal); + value2.set(incVal); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadValue[loadTypes[i]].set(incVal); + } + average1.set(incVal); + average2.set(incVal); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadAverage[loadTypes[i]].set(incVal); + } +} + struct SubMetricSet : public MetricSet { const LoadTypeSet& loadTypes; @@ -103,39 +111,47 @@ struct SubMetricSet : public MetricSet { LoadMetric<SubSubMetricSet> loadSet; SumMetric<SubSubMetricSet> setSum; - SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - loadTypes(loadTypes_), - set1("set1", loadTypes, this), - set2("set2", loadTypes, this), - loadSet(loadTypes, *std::unique_ptr<SubSubMetricSet>( - new SubSubMetricSet("loadSet", loadTypes)), this), - setSum("setSum", "", "", this) - { - setSum.addMetricToSum(set1); - setSum.addMetricToSum(set2); - } + SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); + ~SubMetricSet(); - virtual MetricSet* clone(std::vector<Metric::LP>& ownerList, - CopyType copyType, metrics::MetricSet* owner, - bool includeUnused) const - { - if (copyType == INACTIVE) { - return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); - } - return (SubMetricSet*) (new SubMetricSet(getName(), loadTypes, owner)) - ->assignValues(*this); + MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + metrics::MetricSet* owner, bool includeUnused) const override; + + void incValues(); +}; + +SubMetricSet::SubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) + : MetricSet(name, "", "", owner), + loadTypes(loadTypes_), + set1("set1", loadTypes, this), + set2("set2", loadTypes, this), + loadSet(loadTypes, *std::unique_ptr<SubSubMetricSet>(new SubSubMetricSet("loadSet", loadTypes)), this), + setSum("setSum", "", "", this) +{ + setSum.addMetricToSum(set1); + setSum.addMetricToSum(set2); +} +SubMetricSet::~SubMetricSet() { } + +MetricSet* +SubMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + metrics::MetricSet* owner, bool includeUnused) const +{ + if (copyType == INACTIVE) { + return MetricSet::clone(ownerList, INACTIVE, owner, includeUnused); } + return (SubMetricSet*) (new SubMetricSet(getName(), loadTypes, owner)) + ->assignValues(*this); +} - void incValues() { - set1.incValues(); - set2.incValues(); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadSet[loadTypes[i]].incValues(); - } +void +SubMetricSet::incValues() { + set1.incValues(); + set2.incValues(); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadSet[loadTypes[i]].incValues(); } -}; +} struct TestMetricSet : public MetricSet { const LoadTypeSet& loadTypes; @@ -144,29 +160,35 @@ struct TestMetricSet : public MetricSet { LoadMetric<SubMetricSet> loadSet; SumMetric<SubMetricSet> setSum; - TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - loadTypes(loadTypes_), - set1("set1", loadTypes, this), - set2("set2", loadTypes, this), - loadSet(loadTypes, *std::unique_ptr<SubMetricSet>( - new SubMetricSet("loadSet", loadTypes)), this), - setSum("setSum", "", "", this) - { - setSum.addMetricToSum(set1); - setSum.addMetricToSum(set2); - } + TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); + ~TestMetricSet(); - void incValues() { - set1.incValues(); - set2.incValues(); - for (uint32_t i=0; i<loadTypes.size(); ++i) { - loadSet[loadTypes[i]].incValues(); - } - } + void incValues(); }; + +TestMetricSet::TestMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner) + : MetricSet(name, "", "", owner), + loadTypes(loadTypes_), + set1("set1", loadTypes, this), + set2("set2", loadTypes, this), + loadSet(loadTypes, *std::unique_ptr<SubMetricSet>(new SubMetricSet("loadSet", loadTypes)), this), + setSum("setSum", "", "", this) +{ + setSum.addMetricToSum(set1); + setSum.addMetricToSum(set2); +} +TestMetricSet::~TestMetricSet() { } + +void +TestMetricSet::incValues() { + set1.incValues(); + set2.incValues(); + for (uint32_t i=0; i<loadTypes.size(); ++i) { + loadSet[loadTypes[i]].incValues(); + } +} + struct FakeTimer : public MetricManager::Timer { uint32_t _timeInSecs; diff --git a/metrics/src/tests/stresstest.cpp b/metrics/src/tests/stresstest.cpp index a0e56289d4d..9eb13e00a79 100644 --- a/metrics/src/tests/stresstest.cpp +++ b/metrics/src/tests/stresstest.cpp @@ -22,58 +22,72 @@ struct StressTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE_REGISTRATION(StressTest); namespace { - struct InnerMetricSet : public MetricSet { - const LoadTypeSet& _loadTypes; - LongCountMetric _count; - LongAverageMetric _value1; - LongAverageMetric _value2; - SumMetric<LongAverageMetric> _valueSum; - LoadMetric<LongAverageMetric> _load; - - InnerMetricSet(const char* name, const LoadTypeSet& lt, - MetricSet* owner = 0) - : MetricSet(name, "", "", owner), - _loadTypes(lt), - _count("count", "", "", this), - _value1("value1", "", "", this), - _value2("value2", "", "", this), - _valueSum("valuesum", "", "", this), - _load(lt, LongAverageMetric("load", "", ""), this) - { - _valueSum.addMetricToSum(_value1); - _valueSum.addMetricToSum(_value2); - } +struct InnerMetricSet : public MetricSet { + const LoadTypeSet& _loadTypes; + LongCountMetric _count; + LongAverageMetric _value1; + LongAverageMetric _value2; + SumMetric<LongAverageMetric> _valueSum; + LoadMetric<LongAverageMetric> _load; + + InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner = 0); + ~InnerMetricSet(); + + MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet* owner, bool includeUnused) const override; +}; + +InnerMetricSet::InnerMetricSet(const char* name, const LoadTypeSet& lt, MetricSet* owner) + : MetricSet(name, "", "", owner), + _loadTypes(lt), + _count("count", "", "", this), + _value1("value1", "", "", this), + _value2("value2", "", "", this), + _valueSum("valuesum", "", "", this), + _load(lt, LongAverageMetric("load", "", ""), this) +{ + _valueSum.addMetricToSum(_value1); + _valueSum.addMetricToSum(_value2); +} +InnerMetricSet::~InnerMetricSet() { } + + MetricSet* + InnerMetricSet::clone(std::vector<Metric::LP>& ownerList, CopyType copyType, + MetricSet* owner, bool includeUnused) const +{ + if (copyType != CLONE) { + return MetricSet::clone(ownerList, copyType, owner, includeUnused); +} + InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), _loadTypes, owner); + myset->assignValues(*this); + return myset; +} + +struct OuterMetricSet : public MetricSet { + InnerMetricSet _inner1; + InnerMetricSet _inner2; + SumMetric<InnerMetricSet> _innerSum; + InnerMetricSet _tmp; + LoadMetric<InnerMetricSet> _load; + + OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner = 0); + ~OuterMetricSet(); +}; + +OuterMetricSet::OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner) + : MetricSet("outer", "", "", owner), + _inner1("inner1", lt, this), + _inner2("inner2", lt, this), + _innerSum("innersum", "", "", this), + _tmp("innertmp", lt, 0), + _load(lt, _tmp, this) +{ + _innerSum.addMetricToSum(_inner1); + _innerSum.addMetricToSum(_inner2); +} + +OuterMetricSet::~OuterMetricSet() { } - MetricSet* clone(std::vector<Metric::LP>& ownerList, CopyType copyType, - MetricSet* owner, bool includeUnused) const override - { - if (copyType != CLONE) { - return MetricSet::clone(ownerList, copyType, owner, includeUnused); - } - InnerMetricSet * myset = new InnerMetricSet(getName().c_str(), _loadTypes, owner); - myset->assignValues(*this); - return myset; - } - }; - struct OuterMetricSet : public MetricSet { - InnerMetricSet _inner1; - InnerMetricSet _inner2; - SumMetric<InnerMetricSet> _innerSum; - InnerMetricSet _tmp; - LoadMetric<InnerMetricSet> _load; - - OuterMetricSet(const LoadTypeSet& lt, MetricSet* owner = 0) - : MetricSet("outer", "", "", owner), - _inner1("inner1", lt, this), - _inner2("inner2", lt, this), - _innerSum("innersum", "", "", this), - _tmp("innertmp", lt, 0), - _load(lt, _tmp, this) - { - _innerSum.addMetricToSum(_inner1); - _innerSum.addMetricToSum(_inner2); - } - }; struct Hammer : public document::Runnable { typedef vespalib::LinkedPtr<Hammer> LP; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp index 22649d43dd3..a61ab0cb7c7 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp @@ -3,8 +3,6 @@ #include "documentdb_tagged_metrics.h" #include <vespa/vespalib/util/stringfmt.h> -using vespalib::make_string; - namespace proton { DocumentDBTaggedMetrics::JobMetrics::JobMetrics(metrics::MetricSet* parent) @@ -22,18 +20,16 @@ DocumentDBTaggedMetrics::JobMetrics::JobMetrics(metrics::MetricSet* parent) removedDocumentsPrune("removed_documents_prune", "", "Pruning of removed documents in 'removed' sub database", this), total("total", "", "The job load average total of all job metrics", this) -{ -} +{ } -DocumentDBTaggedMetrics::JobMetrics::~JobMetrics() {} +DocumentDBTaggedMetrics::JobMetrics::~JobMetrics() { } DocumentDBTaggedMetrics::SubDBMetrics::SubDBMetrics(const vespalib::string &name, MetricSet *parent) : MetricSet(name, "", "Sub database metrics", parent), lidSpace(this), documentStore(this), attributes(this) -{ -} +{ } DocumentDBTaggedMetrics::SubDBMetrics::~SubDBMetrics() { } @@ -48,8 +44,7 @@ DocumentDBTaggedMetrics::SubDBMetrics::LidSpaceMetrics::LidSpaceMetrics(MetricSe lidFragmentationFactor("lid_fragmentation_factor", "", "The fragmentation factor of this lid space, indicating the amount of holes in the currently used part of the lid space " "((highest_used_lid - used_lids) / highest_used_lid)", this) -{ -} +{ } DocumentDBTaggedMetrics::SubDBMetrics::LidSpaceMetrics::~LidSpaceMetrics() { } @@ -59,18 +54,16 @@ DocumentDBTaggedMetrics::SubDBMetrics::DocumentStoreMetrics::DocumentStoreMetric diskBloat("disk_bloat", "", "Disk space bloat in bytes", this), maxBucketSpread("max_bucket_spread", "", "Max bucket spread in underlying files (sum(unique buckets in each chunk)/unique buckets in file)", this), memoryUsage(this) -{ -} +{ } -DocumentDBTaggedMetrics::SubDBMetrics::DocumentStoreMetrics::~DocumentStoreMetrics() {} +DocumentDBTaggedMetrics::SubDBMetrics::DocumentStoreMetrics::~DocumentStoreMetrics() { } DocumentDBTaggedMetrics::AttributeMetrics::AttributeMetrics(MetricSet *parent) : MetricSet("attribute", "", "Attribute vector metrics for this document db", parent), resourceUsage(this) -{ -} +{ } -DocumentDBTaggedMetrics::AttributeMetrics::~AttributeMetrics() {} +DocumentDBTaggedMetrics::AttributeMetrics::~AttributeMetrics() { } DocumentDBTaggedMetrics::AttributeMetrics::ResourceUsageMetrics::ResourceUsageMetrics(MetricSet *parent) : MetricSet("resource_usage", "", "Usage metrics for various attribute vector resources", parent), @@ -82,13 +75,14 @@ DocumentDBTaggedMetrics::AttributeMetrics::ResourceUsageMetrics::ResourceUsageMe { } +DocumentDBTaggedMetrics::AttributeMetrics::ResourceUsageMetrics::~ResourceUsageMetrics() { } + DocumentDBTaggedMetrics::IndexMetrics::IndexMetrics(MetricSet *parent) : MetricSet("index", "", "Index metrics (memory and disk) for this document db", parent), memoryUsage(this) -{ -} +{ } -DocumentDBTaggedMetrics::IndexMetrics::~IndexMetrics() {} +DocumentDBTaggedMetrics::IndexMetrics::~IndexMetrics() { } DocumentDBTaggedMetrics::DocumentDBTaggedMetrics(const vespalib::string &docTypeName) : MetricSet("documentdb", {{"documenttype", docTypeName}}, "Document DB metrics", nullptr), @@ -98,9 +92,8 @@ DocumentDBTaggedMetrics::DocumentDBTaggedMetrics(const vespalib::string &docType ready("ready", this), notReady("notready", this), removed("removed", this) -{ -} +{ } -DocumentDBTaggedMetrics::~DocumentDBTaggedMetrics() {} +DocumentDBTaggedMetrics::~DocumentDBTaggedMetrics() { } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt index ee83f93043d..4db9e0c0f38 100644 --- a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt @@ -17,6 +17,7 @@ vespa_add_library(searchcore_server STATIC docstorevalidator.cpp document_db_explorer.cpp document_db_maintenance_config.cpp + document_meta_store_read_guards.cpp document_scan_iterator.cpp document_subdb_collection_explorer.cpp document_subdb_collection_initializer.cpp @@ -56,6 +57,7 @@ vespa_add_library(searchcore_server STATIC maintenance_controller_explorer.cpp maintenance_jobs_injector.cpp maintenancecontroller.cpp + maintenancedocumentsubdb.cpp maintenancejobrunner.cpp matchers.cpp matchview.cpp diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp index 5612b5d70c6..eacab26edd0 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.cpp @@ -1,9 +1,7 @@ // 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 "disk_mem_usage_filter.h" #include "i_disk_mem_usage_listener.h" -#include <sstream> namespace proton { @@ -108,9 +106,9 @@ DiskMemUsageFilter::DiskMemUsageFilter(uint64_t physicalMemory_in) _acceptWrite(true), _dmstate(), _listeners() -{ -} +{ } +DiskMemUsageFilter::~DiskMemUsageFilter() { } void DiskMemUsageFilter::setMemoryStats(vespalib::ProcessMemoryStats memoryStats_in) diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h index 8d9906b236b..07e1587d171 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_filter.h @@ -2,13 +2,14 @@ #pragma once -#include <experimental/filesystem> -#include <vespa/vespalib/util/process_memory_stats.h> +#include "i_disk_mem_usage_notifier.h" +#include "disk_mem_usage_state.h" #include <vespa/searchcore/proton/persistenceengine/i_resource_write_filter.h> +#include <vespa/vespalib/util/process_memory_stats.h> #include <mutex> #include <atomic> -#include "i_disk_mem_usage_notifier.h" -#include "disk_mem_usage_state.h" +#include <experimental/filesystem> + namespace proton { @@ -29,28 +30,23 @@ public: double _memoryLimit; double _diskLimit; - Config() - : _memoryLimit(1.0), - _diskLimit(1.0) - { - } + Config() : Config(1.0, 1.0) { } Config(double memoryLimit_in, double diskLimit_in) : _memoryLimit(memoryLimit_in), _diskLimit(diskLimit_in) - { - } + { } }; private: mutable Mutex _lock; // protect _memoryStats, _diskStats, _config, _state vespalib::ProcessMemoryStats _memoryStats; - uint64_t _physicalMemory; - space_info _diskStats; - Config _config; - State _state; - std::atomic<bool> _acceptWrite; - DiskMemUsageState _dmstate; + uint64_t _physicalMemory; + space_info _diskStats; + Config _config; + State _state; + std::atomic<bool> _acceptWrite; + DiskMemUsageState _dmstate; std::vector<IDiskMemUsageListener *> _listeners; void recalcState(const Guard &guard); // called with _lock held @@ -70,10 +66,10 @@ public: uint64_t getPhysicalMemory() const { return _physicalMemory; } double getMemoryUsedRatio() const; double getDiskUsedRatio() const; - virtual bool acceptWriteOperation() const override; - virtual State getAcceptState() const override; - virtual void addDiskMemUsageListener(IDiskMemUsageListener *listener) override; - virtual void removeDiskMemUsageListener(IDiskMemUsageListener *listener) override; + bool acceptWriteOperation() const override; + State getAcceptState() const override; + void addDiskMemUsageListener(IDiskMemUsageListener *listener) override; + void removeDiskMemUsageListener(IDiskMemUsageListener *listener) override; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp index abd05ed8783..2c1768b6548 100644 --- a/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/disk_mem_usage_sampler.cpp @@ -1,6 +1,5 @@ // 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 "disk_mem_usage_sampler.h" #include <vespa/vespalib/util/timer.h> #include <vespa/searchlib/common/lambdatask.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp new file mode 100644 index 00000000000..680dadda5dd --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp @@ -0,0 +1,16 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "document_meta_store_read_guards.h" +#include "documentsubdbcollection.h" + +namespace proton { + +DocumentMetaStoreReadGuards::DocumentMetaStoreReadGuards(DocumentSubDBCollection &subDBs) + : readydms(subDBs.getReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), + notreadydms(subDBs.getNotReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), + remdms(subDBs.getRemSubDB()->getDocumentMetaStoreContext().getReadGuard()) +{ } + +DocumentMetaStoreReadGuards::~DocumentMetaStoreReadGuards() { } + +} diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h index 65b9400c8f8..54acb03d54d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h @@ -2,11 +2,12 @@ #pragma once -#include "documentsubdbcollection.h" #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h> namespace proton { +class DocumentSubDBCollection; + /** * Class that takes and owns read guards of the document meta stores of the 3 sub databases. * Provides stats regarding the number of documents in the sub databases. @@ -16,13 +17,10 @@ struct DocumentMetaStoreReadGuards IDocumentMetaStoreContext::IReadGuard::UP readydms; IDocumentMetaStoreContext::IReadGuard::UP notreadydms; IDocumentMetaStoreContext::IReadGuard::UP remdms; - DocumentMetaStoreReadGuards(DocumentSubDBCollection &subDBs) - : readydms(subDBs.getReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), - notreadydms(subDBs.getNotReadySubDB()->getDocumentMetaStoreContext().getReadGuard()), - remdms(subDBs.getRemSubDB()->getDocumentMetaStoreContext().getReadGuard()) - { - } + + DocumentMetaStoreReadGuards(DocumentSubDBCollection &subDBs); ~DocumentMetaStoreReadGuards(); + uint32_t numActiveDocs() const { return readydms->get().getNumActiveLids(); } diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp new file mode 100644 index 00000000000..85e906d621d --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.cpp @@ -0,0 +1,30 @@ +// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "maintenancedocumentsubdb.h" + +namespace proton { + +MaintenanceDocumentSubDB::MaintenanceDocumentSubDB() + : _metaStore(), + _retriever(), + _subDbId(0u) +{ } + +MaintenanceDocumentSubDB::~MaintenanceDocumentSubDB() { } + +MaintenanceDocumentSubDB::MaintenanceDocumentSubDB(const IDocumentMetaStore::SP & metaStore, + const IDocumentRetriever::SP & retriever, + uint32_t subDbId) + : _metaStore(metaStore), + _retriever(retriever), + _subDbId(subDbId) +{ } + +void +MaintenanceDocumentSubDB::clear() { + _metaStore.reset(); + _retriever.reset(); + _subDbId = 0u; +} + +} // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h index 1b805f5f0de..2a44b3ea390 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancedocumentsubdb.h @@ -5,8 +5,7 @@ #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store.h> #include <vespa/searchcore/proton/persistenceengine/i_document_retriever.h> -namespace proton -{ +namespace proton { /** * The view of a document sub db as seen from the maintenance controller @@ -19,31 +18,16 @@ public: IDocumentRetriever::SP _retriever; uint32_t _subDbId; - MaintenanceDocumentSubDB() - : _metaStore(), - _retriever(), - _subDbId(0u) - { - } + MaintenanceDocumentSubDB(); ~MaintenanceDocumentSubDB(); MaintenanceDocumentSubDB(const IDocumentMetaStore::SP & metaStore, const IDocumentRetriever::SP & retriever, - uint32_t subDbId) - : _metaStore(metaStore), - _retriever(retriever), - _subDbId(subDbId) - { - } + uint32_t subDbId); bool valid() const { return bool(_metaStore); } - void clear() { - _metaStore.reset(); - _retriever.reset(); - _subDbId = 0u; - } + void clear(); }; - -} // namespace proton +} diff --git a/staging_vespalib/src/tests/objectdump/objectdump.cpp b/staging_vespalib/src/tests/objectdump/objectdump.cpp index 421e9a4daf6..1488397911e 100644 --- a/staging_vespalib/src/tests/objectdump/objectdump.cpp +++ b/staging_vespalib/src/tests/objectdump/objectdump.cpp @@ -75,23 +75,32 @@ struct Foo : public Base std::vector<Bar> _list; std::vector<IdentifiablePtr<Base> > _list2; - Foo() : _objMember(), _objMember2(), _objPtr(0), _list(), _list2() { - _list.push_back(Bar()); - _list.push_back(Bar()); - _list.push_back(Bar()); - _list2.push_back(Bar()); - _list2.push_back(Baz()); - } - virtual Foo *clone() const { return new Foo(*this); } - - virtual void visitMembers(ObjectVisitor &v) const { - visit(v, "_objMember", _objMember); - visit(v, "_objMember2", _objMember2); - visit(v, "_objPtr", _objPtr); - visit(v, "_list", _list); - visit(v, "_list2", _list2); - } + Foo(); + ~Foo(); + Foo *clone() const override { return new Foo(*this); } + void visitMembers(ObjectVisitor &v) const override; }; + +Foo::~Foo() { } +Foo::Foo() + : _objMember(), _objMember2(), _objPtr(0), _list(), _list2() +{ + _list.push_back(Bar()); + _list.push_back(Bar()); + _list.push_back(Bar()); + _list2.push_back(Bar()); + _list2.push_back(Baz()); +} + +void +Foo::visitMembers(ObjectVisitor &v) const { + visit(v, "_objMember", _objMember); + visit(v, "_objMember2", _objMember2); + visit(v, "_objPtr", _objPtr); + visit(v, "_list", _list); + visit(v, "_list2", _list2); +} + IMPLEMENT_IDENTIFIABLE(Foo, Base); TEST_SETUP(Test); diff --git a/staging_vespalib/src/tests/programoptions/programoptions_test.cpp b/staging_vespalib/src/tests/programoptions/programoptions_test.cpp index 5dd27c1ce38..cabff89f9bb 100644 --- a/staging_vespalib/src/tests/programoptions/programoptions_test.cpp +++ b/staging_vespalib/src/tests/programoptions/programoptions_test.cpp @@ -52,40 +52,44 @@ struct MyOptions : public ProgramOptions { std::map<std::string, std::string> properties; int anotherOptionalArg; - MyOptions(int argc, const char* const* argv) - : ProgramOptions(argc, argv) - { - // Required options - addOption("uintopt u", uintOpt, "Sets an unsigned int"); - // Optional options - addOption("b bool", boolOpt, "Enables a flag"); - addOption("boolwithdef", boolWithDefOpt, true, "If set turns to false"); + MyOptions(int argc, const char *const *argv); + ~MyOptions(); +}; - addOption("intopt i", intOpt, 5, "Sets a signed int"); - addOption("floatopt", floatOpt, 4.0f, "Sets a float\nMultiline baby"); - addOption("string s", stringOpt, std::string("ballalaika"), - "Sets a string value. This is a very long description that " - "should be broken down into multiple lines in some sensible " - "way."); - addOptionHeader("Advanced options"); - addOption("p properties", properties, "Property map"); - addHiddenIdentifiers("prop"); - setArgumentTypeName("key"); - setArgumentTypeName("value", 1); +MyOptions::MyOptions(int argc, const char* const* argv) + : ProgramOptions(argc, argv) +{ + // Required options + addOption("uintopt u", uintOpt, "Sets an unsigned int"); + // Optional options + addOption("b bool", boolOpt, "Enables a flag"); + addOption("boolwithdef", boolWithDefOpt, true, "If set turns to false"); - addArgument("argString", argString, "Required string argument."); - addArgument("argInt", argInt, "Required int argument."); - addArgument("argOptionalString", argOptionalString, std::string("foo"), - "Optional string argument with a long description so we " - "can see that it will be broken correctly."); - addArgument("argSecondOptional", anotherOptionalArg, 3, - "Yet another optional argument"); + addOption("intopt i", intOpt, 5, "Sets a signed int"); + addOption("floatopt", floatOpt, 4.0f, "Sets a float\nMultiline baby"); + addOption("string s", stringOpt, std::string("ballalaika"), + "Sets a string value. This is a very long description that " + "should be broken down into multiple lines in some sensible " + "way."); + addOptionHeader("Advanced options"); + addOption("p properties", properties, "Property map"); + addHiddenIdentifiers("prop"); + setArgumentTypeName("key"); + setArgumentTypeName("value", 1); - setSyntaxMessage("A test program to see if this utility works."); - setSyntaxPageMaxLeftColumnSize(25); - } + addArgument("argString", argString, "Required string argument."); + addArgument("argInt", argInt, "Required int argument."); + addArgument("argOptionalString", argOptionalString, std::string("foo"), + "Optional string argument with a long description so we " + "can see that it will be broken correctly."); + addArgument("argSecondOptional", anotherOptionalArg, 3, + "Yet another optional argument"); -}; + setSyntaxMessage("A test program to see if this utility works."); + setSyntaxPageMaxLeftColumnSize(25); +} + +MyOptions::~MyOptions() { } void Test::testSyntaxPage() { AppOptions opts("myapp"); diff --git a/vespalib/src/tests/slime/slime_inject_test.cpp b/vespalib/src/tests/slime/slime_inject_test.cpp index 6c98568e0ed..41da9fb1a73 100644 --- a/vespalib/src/tests/slime/slime_inject_test.cpp +++ b/vespalib/src/tests/slime/slime_inject_test.cpp @@ -43,8 +43,13 @@ struct DstFixture { Slime slime7; Slime slime8; Slime slime9; + DstFixture(); + ~DstFixture(); }; +DstFixture::DstFixture() { } +DstFixture::~DstFixture() { } + TEST_FF("inject into slime", SrcFixture(), DstFixture()) { EXPECT_TRUE(f1.empty.get().valid()); // explicit nix diff --git a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp index 5fd5d3be3e9..d86ffa243fc 100644 --- a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp +++ b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp @@ -10,6 +10,7 @@ struct MyBuffer : public Output { std::vector<char> data; size_t used; MyBuffer() : data(1024 * 1024), used(0) {} + ~MyBuffer(); WritableMemory reserve(size_t bytes) override { assert(data.size() >= (used + bytes)); return WritableMemory(&data[used], data.size() - used); @@ -20,6 +21,8 @@ struct MyBuffer : public Output { } }; +MyBuffer::~MyBuffer() { } + std::string make_name(size_t idx) { return make_string("summary_feature_%zu", idx); } diff --git a/vespalib/src/tests/websocket/websocket_test.cpp b/vespalib/src/tests/websocket/websocket_test.cpp index c756cb3d22d..962a78c5606 100644 --- a/vespalib/src/tests/websocket/websocket_test.cpp +++ b/vespalib/src/tests/websocket/websocket_test.cpp @@ -17,12 +17,16 @@ template <typename T> struct Receptor : vespalib::ws::Handler<T> { std::unique_ptr<T> obj; vespalib::Gate gate; + ~Receptor(); void handle(std::unique_ptr<T> t) override { obj = std::move(t); gate.countDown(); } }; +template <typename T> +Receptor<T>::~Receptor() { } + vespalib::string read_bytes(Socket &socket, size_t wanted_bytes) { char tmp[64]; vespalib::string result; |