diff options
author | Arne H Juul <arnej27959@users.noreply.github.com> | 2017-04-24 12:10:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-24 12:10:42 +0200 |
commit | 9ff4bdb407ed8d855a3f86a17c99906ff738177b (patch) | |
tree | fc2b050224d7dde92d57e1f9cac12c1e5aaf6b90 | |
parent | 32ae190acc9ac5081049e1c7008d1602c68cf821 (diff) |
Revert "Balder/enforce override 2"
467 files changed, 4205 insertions, 2085 deletions
diff --git a/config/src/apps/configproxy-cmd/main.cpp b/config/src/apps/configproxy-cmd/main.cpp index 1d5934f2817..fcf2a0ca5d7 100644 --- a/config/src/apps/configproxy-cmd/main.cpp +++ b/config/src/apps/configproxy-cmd/main.cpp @@ -10,8 +10,8 @@ class Application : public FastOS_Application Flags _flags; bool parseOpts(); public: - void usage(); - int Main() override; + void usage(void); + int Main(void) override; Application() : _flags() {} }; diff --git a/config/src/apps/getvespaconfig/getconfig.cpp b/config/src/apps/getvespaconfig/getconfig.cpp index df7bbba48b0..23127b79333 100644 --- a/config/src/apps/getvespaconfig/getconfig.cpp +++ b/config/src/apps/getvespaconfig/getconfig.cpp @@ -32,7 +32,7 @@ public: int usage(); void initRPC(const char *spec); void finiRPC(); - int Main() override; + virtual int Main() override; }; diff --git a/config/src/apps/pingproxy/pingproxy.cpp b/config/src/apps/pingproxy/pingproxy.cpp index ba35892c03c..667d5689691 100644 --- a/config/src/apps/pingproxy/pingproxy.cpp +++ b/config/src/apps/pingproxy/pingproxy.cpp @@ -24,7 +24,7 @@ public: int usage(); void initRPC(const char *spec); void finiRPC(); - int Main() override; + virtual int Main() override; }; diff --git a/config/src/tests/configagent/configagent.cpp b/config/src/tests/configagent/configagent.cpp index 0693c33467d..91b657b42f2 100644 --- a/config/src/tests/configagent/configagent.cpp +++ b/config/src/tests/configagent/configagent.cpp @@ -1,4 +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 <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/config.h> #include <vespa/config/raw/rawsource.h> @@ -18,10 +19,25 @@ public: : _key(key) { } - const ConfigKey & getKey() const override { return _key; } - bool abort() override { return false; } - bool isAborted() const override { return false; } - void setError(int errorCode) override { (void) errorCode; } + const ConfigKey & getKey() const override + { + return _key; + } + + bool abort() override + { + return false; + } + + bool isAborted() const override + { + return false; + } + + void setError(int errorCode) override + { + (void) errorCode; + } const ConfigKey _key; }; @@ -41,15 +57,51 @@ public: _isError(iserror) { } - const ConfigKey& getKey() const override { return _key; } - const ConfigValue & getValue() const override { return _value; } - const ConfigState & getConfigState() const override { return _state; } - bool hasValidResponse() const override { return _valid; } - bool validateResponse() override { return _valid; } - void fill() override { _fillCalled = true; } - vespalib::string errorMessage() const override { return _errorMessage; } - int errorCode() const override { return _errorCode; } - bool isError() const override { return _isError; } + const ConfigKey& getKey() const override + { + return _key; + } + + const ConfigValue & getValue() const override + { + return _value; + } + + const ConfigState & getConfigState() const override + { + return _state; + } + + bool hasValidResponse() const override + { + return _valid; + } + + bool validateResponse() override + { + return _valid; + } + + void fill() override + { + _fillCalled = true; + } + + vespalib::string errorMessage() const override + { + return _errorMessage; + } + + int errorCode() const override + { + return _errorCode; + } + + bool isError() const override + { + return _isError; + } + const Trace & getTrace() const override { return _trace; } const ConfigKey _key; diff --git a/config/src/tests/configretriever/configretriever.cpp b/config/src/tests/configretriever/configretriever.cpp index 8273eee2c73..bb4dda0e10e 100644 --- a/config/src/tests/configretriever/configretriever.cpp +++ b/config/src/tests/configretriever/configretriever.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("configretriever"); #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/config/config.h> diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp index 0de1908858f..26f95df8f42 100644 --- a/config/src/tests/frt/frt.cpp +++ b/config/src/tests/frt/frt.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("frt"); #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/common/iconfigholder.h> #include <vespa/config/common/trace.h> diff --git a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp index b563ea1929b..96dad86a54d 100644 --- a/config/src/tests/frtconnectionpool/frtconnectionpool.cpp +++ b/config/src/tests/frtconnectionpool/frtconnectionpool.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("frtconnectionpool_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/config/frt/frtconnectionpool.h> #include <vespa/fnet/frt/error.h> diff --git a/config/src/tests/subscription/subscription.cpp b/config/src/tests/subscription/subscription.cpp index 5974279518a..e47f8b11e60 100644 --- a/config/src/tests/subscription/subscription.cpp +++ b/config/src/tests/subscription/subscription.cpp @@ -1,4 +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 <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/common/misc.h> #include <vespa/config/common/configholder.h> diff --git a/config/src/tests/trace/trace.cpp b/config/src/tests/trace/trace.cpp index 195f7d659a9..566077d47e1 100644 --- a/config/src/tests/trace/trace.cpp +++ b/config/src/tests/trace/trace.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("frt"); #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/common/trace.h> #include <vespa/vespalib/trace/tracenode.h> diff --git a/config/src/vespa/config/helper/ifetchercallback.h b/config/src/vespa/config/helper/ifetchercallback.h index 50c26f2d3fc..9bc6e848827 100644 --- a/config/src/vespa/config/helper/ifetchercallback.h +++ b/config/src/vespa/config/helper/ifetchercallback.h @@ -26,11 +26,14 @@ public: template <typename ConfigType> class IFetcherCallback : public ICallback { +public: + virtual ~IFetcherCallback() { } protected: - void configure(std::unique_ptr<const ConfigInstance> config) override { + virtual void configure(std::unique_ptr<const ConfigInstance> config) override { configure(std::unique_ptr<ConfigType>(static_cast<const ConfigType *>(config.release()))); } virtual void configure(std::unique_ptr<ConfigType> config) = 0; }; } // namespace config + diff --git a/configd/src/tests/messages/messages.cpp b/configd/src/tests/messages/messages.cpp index a8b2e37af36..46fa229ff29 100644 --- a/configd/src/tests/messages/messages.cpp +++ b/configd/src/tests/messages/messages.cpp @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include <vespa/log/log.h> #include <vespa/vespalib/testkit/testapp.h> +LOG_SETUP("messages_test"); + class MessagesTest : public vespalib::TestApp { public: diff --git a/configutil/src/apps/configstatus/main.cpp b/configutil/src/apps/configstatus/main.cpp index 4583af033c2..f774afa355d 100644 --- a/configutil/src/apps/configstatus/main.cpp +++ b/configutil/src/apps/configstatus/main.cpp @@ -17,8 +17,8 @@ class Application : public FastOS_Application { vespalib::string getSources(); HostFilter parse_host_set(vespalib::stringref raw_arg) const; public: - void usage(); - int Main() override; + void usage(void); + int Main(void) override; Application(); ~Application(); diff --git a/configutil/src/lib/configstatus.cpp b/configutil/src/lib/configstatus.cpp index 5a876a30ab5..174350c5eca 100644 --- a/configutil/src/lib/configstatus.cpp +++ b/configutil/src/lib/configstatus.cpp @@ -9,6 +9,9 @@ #include <vbench/http/http_client.h> #include <iostream> +#include <vespa/log/log.h> +LOG_SETUP("vespa-config-status"); + using configdefinitions::tagsContain; struct ComponentTraverser : public vespalib::slime::ObjectTraverser @@ -38,7 +41,8 @@ struct ComponentTraverser : public vespalib::slime::ObjectTraverser slime.get()["config"].traverse(traverser); } - void field(const vespalib::Memory &symbol_name, const vespalib::slime::Inspector &inspector) override { + virtual void + field(const vespalib::Memory &symbol_name, const vespalib::slime::Inspector &inspector) override { switch (_state) { case ROOT: _component = symbol_name.make_string(); @@ -83,16 +87,16 @@ public: {} ~MyHttpHandler(); - void handleHeader(const vbench::string &name, const vbench::string &value) override { + virtual void handleHeader(const vbench::string &name, const vbench::string &value) override { (void) name; (void) value; } - void handleContent(const vbench::Memory &data) override { + virtual void handleContent(const vbench::Memory &data) override { _json += std::string(data.data, data.size); } - void handleFailure(const vbench::string &reason) override { + virtual void handleFailure(const vbench::string &reason) override { std::cerr << _configId << ": Failed to fetch json: " << reason << std::endl; _error = reason; } diff --git a/configutil/src/tests/config_status/config_status_test.cpp b/configutil/src/tests/config_status/config_status_test.cpp index 39442068330..77fcf1b8da8 100644 --- a/configutil/src/tests/config_status/config_status_test.cpp +++ b/configutil/src/tests/config_status/config_status_test.cpp @@ -1,10 +1,14 @@ // 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/vespalib/testkit/testapp.h> #include <lib/configstatus.h> +#include <iostream> #include <vespa/fastlib/net/httpserver.h> #include <vespa/config-model.h> #include <vespa/config/config.h> #include <vespa/config/subscription/sourcespec.h> +#include <vector> +#include <string> using namespace config; @@ -13,7 +17,8 @@ private: std::string _reply; bool _fail; - void onGetRequest(const string &, const string &, Fast_HTTPConnection &conn) override { + virtual void onGetRequest(const string &, const string &, + Fast_HTTPConnection &conn) override { if (_fail) { conn.Output(conn.GetHTTPVersion().c_str()); conn.Output(" 500 Error\r\n"); diff --git a/configutil/src/tests/model_inspect/model_inspect_test.cpp b/configutil/src/tests/model_inspect/model_inspect_test.cpp index fe818e8e4e4..be45d4d0d46 100644 --- a/configutil/src/tests/model_inspect/model_inspect_test.cpp +++ b/configutil/src/tests/model_inspect/model_inspect_test.cpp @@ -1,7 +1,8 @@ // 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/vespalib/testkit/test_kit.h> #include <lib/modelinspect.h> -#include <sstream> +#include <iostream> class Model { public: @@ -88,11 +89,11 @@ public: void listServices() override { _listServices = true; }; void listClusters() override { _listClusters = true; }; void listConfigIds() override { _listConfigIds = true; }; - int listHost(const vespalib::string) override { _listHost = true; return 0; }; + int listHost(const vespalib::string) override { _listHost = true; return 0; }; int listAllPorts() override { _listAllPorts = true; return 0; }; - int listCluster(const vespalib::string) override { _listCluster = true; return 0; }; - int listService(const vespalib::string) override { _listService = true; return 0; }; - int listService(const vespalib::string, const vespalib::string) override { _listService2 = true; return 0; }; + int listCluster(const vespalib::string) override { _listCluster = true; return 0; }; + int listService(const vespalib::string) override { _listService = true; return 0; }; + int listService(const vespalib::string, const vespalib::string) override { _listService2 = true; return 0; }; int listConfigId(const vespalib::string) override { _listConfigId = true; return 0; }; int getIndexOf(const vespalib::string, const vespalib::string) override { _getIndexOf = true; return 0; }; diff --git a/document/src/tests/arrayfieldvaluetest.cpp b/document/src/tests/arrayfieldvaluetest.cpp index 7f31e0c3b3a..85659c0cbb4 100644 --- a/document/src/tests/arrayfieldvaluetest.cpp +++ b/document/src/tests/arrayfieldvaluetest.cpp @@ -1,5 +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/document/fieldvalue/fieldvalues.h> #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/vdstestlib/cppunit/macros.h> @@ -10,6 +11,9 @@ using vespalib::nbostream; namespace document { struct ArrayFieldValueTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} + void testArray(); CPPUNIT_TEST_SUITE(ArrayFieldValueTest); diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp index 6957634cbde..8e17dd12e12 100644 --- a/document/src/tests/documentselectparsertest.cpp +++ b/document/src/tests/documentselectparsertest.cpp @@ -1,12 +1,17 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +//#include <boost/regex/icu.hpp> +#include <vespa/fastos/fastos.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <vespa/document/repo/configbuilder.h> #include <vespa/document/repo/documenttyperepo.h> +#include <iostream> +#include <memory> #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/base/testdocman.h> +#include <vespa/document/base/testdocrepo.h> #include <vespa/document/select/parser.h> #include <vespa/document/select/visitor.h> #include <vespa/document/select/bodyfielddetector.h> @@ -61,6 +66,7 @@ public: : _bucketIdFactory() {} void setUp() override; + void tearDown() override {} void createDocs(); void testParseTerminals(); @@ -906,27 +912,32 @@ namespace { std::ostringstream data; public: - ~TestVisitor() {} + virtual ~TestVisitor() {} - void visitConstant(const select::Constant& node) override { + void visitConstant(const select::Constant& node) override + { data << "CONSTANT(" << node << ")"; } - void - visitInvalidConstant(const select::InvalidConstant& node) override { + virtual void + visitInvalidConstant(const select::InvalidConstant& node) override + { data << "INVALIDCONSTANT(" << node << ")"; } - void visitDocumentType(const select::DocType& node) override { + void visitDocumentType(const select::DocType& node) override + { data << "DOCTYPE(" << node << ")"; } - void visitComparison(const select::Compare& node) override { + void visitComparison(const select::Compare& node) override + { data << "COMPARE(" << node.getLeft() << " " << node.getOperator() << " " << node.getRight() << ")"; } - void visitAndBranch(const select::And& node) override { + void visitAndBranch(const select::And& node) override + { data << "AND("; node.getLeft().visit(*this); data << ", "; @@ -934,7 +945,8 @@ namespace { data << ")"; } - void visitOrBranch(const select::Or& node) override { + void visitOrBranch(const select::Or& node) override + { data << "OR("; node.getLeft().visit(*this); data << ", "; @@ -942,24 +954,72 @@ namespace { data << ")"; } - void visitNotBranch(const select::Not& node) override { + void visitNotBranch(const select::Not& node) override + { data << "NOT("; node.getChild().visit(*this); data << ")"; } - void visitArithmeticValueNode(const select::ArithmeticValueNode &) override {} - void visitFunctionValueNode(const select::FunctionValueNode &) override {} - void visitIdValueNode(const select::IdValueNode &) override {} - void visitSearchColumnValueNode(const select::SearchColumnValueNode &) override {} - void visitFieldValueNode(const select::FieldValueNode &) override {} - void visitFloatValueNode(const select::FloatValueNode &) override {} - void visitVariableValueNode(const select::VariableValueNode &) override {} - void visitIntegerValueNode(const select::IntegerValueNode &) override {} - void visitCurrentTimeValueNode(const select::CurrentTimeValueNode &) override {} - void visitStringValueNode(const select::StringValueNode &) override {} - void visitNullValueNode(const select::NullValueNode &) override {} - void visitInvalidValueNode(const select::InvalidValueNode &) override {} + virtual void + visitArithmeticValueNode(const select::ArithmeticValueNode &) override + { + } + + virtual void + visitFunctionValueNode(const select::FunctionValueNode &) override + { + } + + virtual void + visitIdValueNode(const select::IdValueNode &) override + { + } + + virtual void + visitSearchColumnValueNode(const select::SearchColumnValueNode &) override + { + } + + virtual void + visitFieldValueNode(const select::FieldValueNode &) override + { + } + + virtual void + visitFloatValueNode(const select::FloatValueNode &) override + { + } + + virtual void + visitVariableValueNode(const select::VariableValueNode &) override + { + } + + virtual void + visitIntegerValueNode(const select::IntegerValueNode &) override + { + } + + virtual void + visitCurrentTimeValueNode(const select::CurrentTimeValueNode &) override + { + } + + virtual void + visitStringValueNode(const select::StringValueNode &) override + { + } + + virtual void + visitNullValueNode(const select::NullValueNode &) override + { + } + + virtual void + visitInvalidValueNode(const select::InvalidValueNode &) override + { + } std::string getVisitString() { return data.str(); } }; diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp index baa777ceca1..5ac7c48c7ad 100644 --- a/document/src/tests/documentupdatetestcase.cpp +++ b/document/src/tests/documentupdatetestcase.cpp @@ -33,6 +33,8 @@ using vespalib::tensor::TensorDimensions; namespace document { struct DocumentUpdateTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} void testSimpleUsage(); void testUpdateApplySingleValue(); diff --git a/document/src/tests/primitivefieldvaluetest.cpp b/document/src/tests/primitivefieldvaluetest.cpp index 15fd6e00959..ba81e0ebbf6 100644 --- a/document/src/tests/primitivefieldvaluetest.cpp +++ b/document/src/tests/primitivefieldvaluetest.cpp @@ -1,5 +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/document/fieldvalue/fieldvalues.h> #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/vdstestlib/cppunit/macros.h> @@ -10,6 +11,8 @@ using vespalib::nbostream; namespace document { struct PrimitiveFieldValueTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} void testLiterals(); void testRaw(); diff --git a/document/src/tests/serialization/annotationserializer_test.cpp b/document/src/tests/serialization/annotationserializer_test.cpp index 49860df128d..9be0d6d334e 100644 --- a/document/src/tests/serialization/annotationserializer_test.cpp +++ b/document/src/tests/serialization/annotationserializer_test.cpp @@ -1,4 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Unit tests for annotation serialization. #include <vespa/document/base/testdocrepo.h> #include <vespa/document/annotation/alternatespanlist.h> diff --git a/document/src/tests/structfieldvaluetest.cpp b/document/src/tests/structfieldvaluetest.cpp index d6e585e0987..0daf8c97302 100644 --- a/document/src/tests/structfieldvaluetest.cpp +++ b/document/src/tests/structfieldvaluetest.cpp @@ -17,6 +17,8 @@ namespace document { struct StructFieldValueTest : public CppUnit::TestFixture { DocumentTypeRepo doc_repo; StructFieldValueTest(); + void setUp() override {} + void tearDown() override {} void testStruct(); void testEmptyStruct(); diff --git a/document/src/tests/testrunner.cpp b/document/src/tests/testrunner.cpp index 815476a3f41..aabdbb3f605 100644 --- a/document/src/tests/testrunner.cpp +++ b/document/src/tests/testrunner.cpp @@ -1,12 +1,13 @@ // 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/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("documentcppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/document/src/tests/teststringutil.h b/document/src/tests/teststringutil.h index cba15682d7e..355d90367ed 100644 --- a/document/src/tests/teststringutil.h +++ b/document/src/tests/teststringutil.h @@ -1,5 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +/* $Id$*/ + #pragma once #include <cppunit/extensions/HelperMacros.h> diff --git a/document/src/tests/weightedsetfieldvaluetest.cpp b/document/src/tests/weightedsetfieldvaluetest.cpp index 81b98da297f..100db297b55 100644 --- a/document/src/tests/weightedsetfieldvaluetest.cpp +++ b/document/src/tests/weightedsetfieldvaluetest.cpp @@ -1,5 +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/document/fieldvalue/fieldvalues.h> #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/vdstestlib/cppunit/macros.h> @@ -10,6 +11,8 @@ using vespalib::nbostream; namespace document { struct WeightedSetFieldValueTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} void testWeightedSet(); void testAddIgnoreZeroWeight(); diff --git a/documentapi/src/tests/loadtypes/testrunner.cpp b/documentapi/src/tests/loadtypes/testrunner.cpp index bdcdcdab944..71200f84224 100644 --- a/documentapi/src/tests/loadtypes/testrunner.cpp +++ b/documentapi/src/tests/loadtypes/testrunner.cpp @@ -1,11 +1,12 @@ // 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/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("storagecppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/documentapi/src/tests/policies/testframe.cpp b/documentapi/src/tests/policies/testframe.cpp index db8a1b48924..8d5b6585529 100644 --- a/documentapi/src/tests/policies/testframe.cpp +++ b/documentapi/src/tests/policies/testframe.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP(".testframe"); #include "testframe.h" #include <vespa/messagebus/emptyreply.h> @@ -8,9 +11,6 @@ #include <vespa/messagebus/testlib/simpleprotocol.h> #include <vespa/messagebus/testlib/simplereply.h> -#include <vespa/log/log.h> -LOG_SETUP(".testframe"); - using document::DocumentTypeRepo; using namespace documentapi; diff --git a/documentapi/src/tests/policies/testframe.h b/documentapi/src/tests/policies/testframe.h index f0e37d979f3..e0780733331 100644 --- a/documentapi/src/tests/policies/testframe.h +++ b/documentapi/src/tests/policies/testframe.h @@ -197,6 +197,8 @@ public: * @return Handle to the system state. */ documentapi::SystemStateHandle getSystemState(); + + // Implements IReplyHandler. void handleReply(mbus::Reply::UP reply) override; }; diff --git a/documentapi/src/tests/replymerger/replymerger_test.cpp b/documentapi/src/tests/replymerger/replymerger_test.cpp index b26290e0bcd..8803994b0cf 100644 --- a/documentapi/src/tests/replymerger/replymerger_test.cpp +++ b/documentapi/src/tests/replymerger/replymerger_test.cpp @@ -1,5 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/log/log.h> +LOG_SETUP("replymerger_test"); +#include <vespa/fastos/fastos.h> #include <iostream> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/documentapi/messagebus/replymerger.h> diff --git a/documentapi/src/tests/routablefactory/routablefactory.cpp b/documentapi/src/tests/routablefactory/routablefactory.cpp index b4449891af2..620142e803b 100644 --- a/documentapi/src/tests/routablefactory/routablefactory.cpp +++ b/documentapi/src/tests/routablefactory/routablefactory.cpp @@ -1,4 +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 <vespa/document/repo/documenttyperepo.h> #include <vespa/documentapi/messagebus/documentprotocol.h> #include <vespa/documentapi/messagebus/routablefactories51.h> diff --git a/documentapi/src/tests/systemstate/systemstate.cpp b/documentapi/src/tests/systemstate/systemstate.cpp index e3163937a3f..a797f55c625 100644 --- a/documentapi/src/tests/systemstate/systemstate.cpp +++ b/documentapi/src/tests/systemstate/systemstate.cpp @@ -1,12 +1,12 @@ // 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/log/log.h> +LOG_SETUP("systemstate_test"); #include <vespa/documentapi/messagebus/systemstate/systemstate.h> #include <vespa/documentapi/messagebus/systemstate/systemstatehandle.h> #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/log/log.h> -LOG_SETUP("systemstate_test"); - using namespace documentapi; class Test : public vespalib::TestApp { diff --git a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h index e1c2b7f4f35..b35cce81b40 100644 --- a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h +++ b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h @@ -303,9 +303,17 @@ public: * @return The system state. */ SystemState &getSystemState() { return *_systemState; } + + // Implements IProtocol. const mbus::string &getName() const override { return NAME; } + + // Implements IProtocol. mbus::IRoutingPolicy::UP createPolicy(const mbus::string &name, const mbus::string ¶m) const override; + + // Implements IProtocol. mbus::Blob encode(const vespalib::Version &version, const mbus::Routable &routable) const override; + + // Implements IProtocol. mbus::Routable::UP decode(const vespalib::Version &version, mbus::BlobRef data) const override; }; diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/documentmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/documentmessage.h index 2887c8435e1..b4adf41ca79 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/documentmessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/documentmessage.h @@ -82,6 +82,7 @@ public: _approxSize = approxSize; } + // Implements mbus::Message. const mbus::string& getProtocol() const override; }; diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/documentreply.h b/documentapi/src/vespa/documentapi/messagebus/messages/documentreply.h index 69563bcc63b..2850c412807 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/documentreply.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/documentreply.h @@ -32,7 +32,7 @@ public: /** * Virtual destructor required for inheritance. */ - ~DocumentReply() { } + virtual ~DocumentReply() { } /** * Returns the priority tag for this message. This is an optional tag added for VDS that is not interpreted by the @@ -41,6 +41,7 @@ public: * @return The priority. */ Priority::Value getPriority() const { return _priority; } + uint8_t priority() const override { return (uint8_t)_priority; } /** @@ -49,8 +50,13 @@ public: * @param priority The priority to set. */ void setPriority(Priority::Value p) { _priority = p; } + + // Implements mbus::Reply. const mbus::string& getProtocol() const override; + + // Implements mbus::Reply. uint32_t getType() const override { return _type; } }; } + diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/documentsummarymessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/documentsummarymessage.h index 0c9c8b09a0c..ac5e141da23 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/documentsummarymessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/documentsummarymessage.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "visitor.h" #include <vespa/vdslib/container/documentsummary.h> +#include <vespa/documentapi/messagebus/messages/visitor.h> namespace documentapi { @@ -30,9 +30,15 @@ public: * @param summary The document summary to contain. */ DocumentSummaryMessage(const vdslib::DocumentSummary &summary); + + // Overrides VisitorMessage. uint32_t getApproxSize() const override; + + // Implements VisitorMessage. uint32_t getType() const override; + string toString() const override { return "documentsummarymessage"; } }; } + diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/emptybucketsmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/emptybucketsmessage.h index bd1805a4a17..54ce4e8de4c 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/emptybucketsmessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/emptybucketsmessage.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "visitor.h" #include <vespa/document/bucket/bucketid.h> +#include <vespa/documentapi/messagebus/messages/visitor.h> namespace documentapi { @@ -21,14 +21,18 @@ protected: public: EmptyBucketsMessage(); // must be serialized into + EmptyBucketsMessage(const std::vector<document::BucketId> &bucketIds); std::vector<document::BucketId> &getBucketIds() { return _bucketIds; } const std::vector<document::BucketId> &getBucketIds() const { return _bucketIds; } void setBucketIds(const std::vector<document::BucketId> &bucketIds); + void resize(uint32_t size); + uint32_t getType() const override; + string toString() const override { return "emptybucketsmessage"; } }; diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h index 2e1e92652d9..c08e36aa3fd 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistmessage.h @@ -40,10 +40,18 @@ public: * @param id The bucket id to set. */ void setBucketId(const document::BucketId& id) { _bucketId = id; } + + // Overrides DocumentMessage. bool hasSequenceId() const override; + + // Overrides DocumentMessage. uint64_t getSequenceId() const override; + + // Implements DocumentMessage. uint32_t getType() const override; + string toString() const override { return "getbucketlistmessage"; } }; } + diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistreply.h b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistreply.h index 0b7df089bce..a207ef206e4 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistreply.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketlistreply.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "documentreply.h" +#include <vespa/documentapi/messagebus/messages/documentreply.h> #include <vespa/document/bucket/bucketid.h> namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketstatemessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketstatemessage.h index 62129a79003..ed27ed11212 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/getbucketstatemessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/getbucketstatemessage.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "documentmessage.h" #include <vespa/document/bucket/bucketid.h> +#include <vespa/documentapi/messagebus/messages/documentmessage.h> namespace documentapi { @@ -40,9 +40,16 @@ public: * @param bucket The bucket id to set. */ void setBucketId(document::BucketId bucket) { _bucket = bucket; } + + // Overrides DocumentMessage. bool hasSequenceId() const override; + + // Overrides DocumentMessage. uint64_t getSequenceId() const override; + + // Implements DocumentMessage. uint32_t getType() const override; + string toString() const override { return "getbucketstatemessage"; } }; diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/multioperationmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/multioperationmessage.h index 4c6f8bf9de7..ac78aea6251 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/multioperationmessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/multioperationmessage.h @@ -1,12 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "visitor.h" -#include "documentreply.h" #include <vespa/vdslib/container/parameters.h> #include <vespa/vdslib/container/documentlist.h> #include <vespa/vdslib/container/operationlist.h> #include <vespa/document/bucket/bucketid.h> +#include <vespa/documentapi/messagebus/messages/visitor.h> +#include <vespa/documentapi/messagebus/messages/documentreply.h> #include <vespa/documentapi/messagebus/documentprotocol.h> namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/putdocumentmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/putdocumentmessage.h index 4537da0fb6e..46af0dfb7a4 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/putdocumentmessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/putdocumentmessage.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "testandsetmessage.h" #include <vespa/document/fieldvalue/document.h> +#include <vespa/documentapi/messagebus/messages/testandsetmessage.h> namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/removedocumentmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/removedocumentmessage.h index a47e35f3098..3904cf0f243 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/removedocumentmessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/removedocumentmessage.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "testandsetmessage.h" #include <vespa/document/base/documentid.h> +#include <vespa/documentapi/messagebus/messages/testandsetmessage.h> namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/removelocationmessage.h b/documentapi/src/vespa/documentapi/messagebus/messages/removelocationmessage.h index ce15fe4eda0..acaf3357d4d 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/removelocationmessage.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/removelocationmessage.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "documentmessage.h" +#include <vespa/documentapi/messagebus/messages/documentmessage.h> #include <vespa/document/bucket/bucketid.h> #include <vespa/document/bucket/bucketselector.h> #include <vespa/document/select/parser.h> @@ -17,9 +17,13 @@ public: RemoveLocationMessage(const document::BucketIdFactory& factory, document::select::Parser& parser, const string& documentSelection); const string& getDocumentSelection() const { return _documentSelection; } - const document::BucketId& getBucketId() const { return _bucketId; }; + uint32_t getType() const override; + + const document::BucketId& getBucketId() const { return _bucketId; }; + string toString() const override { return "removelocationmessage"; } + protected: DocumentReply::UP doCreateReply() const override; diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h index ce30be3ecc2..43045fd44c6 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h +++ b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h @@ -1,16 +1,20 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +/** + * @file persistence.h + * + * Persistence related commands, like put, get & remove + */ #pragma once -#include "writedocumentreply.h" -#include "documentmessage.h" -#include "documentreply.h" #include <vespa/vdslib/container/parameters.h> #include <vespa/vdslib/container/documentlist.h> #include <vespa/vdslib/container/visitorstatistics.h> #include <vespa/document/bucket/bucketid.h> +#include <vespa/documentapi/messagebus/messages/documentmessage.h> +#include <vespa/documentapi/messagebus/messages/documentreply.h> #include <vespa/documentapi/messagebus/documentprotocol.h> #include <vespa/document/select/orderingspecification.h> +#include <vespa/documentapi/messagebus/messages/writedocumentreply.h> namespace documentapi { @@ -135,12 +139,14 @@ public: typedef std::unique_ptr<DestroyVisitorMessage> UP; DestroyVisitorMessage(); // must be deserialized into + DestroyVisitorMessage(const string &instanceId); const string& getInstanceId() const { return _instanceId; } void setInstanceId(const string& id) { _instanceId = id; } uint32_t getType() const override; + string toString() const override { return "destroyvisitormessage"; } }; @@ -208,6 +214,7 @@ public: void setErrorMessage(const string& errorMessage) { _errorMessage = errorMessage; }; uint32_t getType() const override; + string toString() const override { return "visitorinfomessage"; } }; @@ -234,6 +241,7 @@ public: uint32_t getApproxSize() const override; uint32_t getType() const override; + string toString() const override { return "mapvisitormessage"; } }; @@ -248,9 +256,12 @@ public: class Entry { public: Entry(); - Entry(int64_t timestamp, document::Document::SP doc, bool removeEntry); + Entry(int64_t timestamp, + document::Document::SP doc, + bool removeEntry); Entry(const Entry& other); - Entry(const document::DocumentTypeRepo &repo, document::ByteBuffer& buf); + Entry(const document::DocumentTypeRepo &repo, + document::ByteBuffer& buf); int64_t getTimestamp() { return _timestamp; } const document::Document::SP& getDocument() { return _document; } @@ -282,6 +293,7 @@ public: const std::vector<Entry>& getDocuments() const { return _documents; }; uint32_t getType() const override; + string toString() const override { return "documentlistmessage"; } }; diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/andpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/andpolicy.h index a5dc1872e44..0edba2c0872 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/andpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/andpolicy.h @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <vector> #include <vespa/messagebus/routing/hop.h> #include <vespa/messagebus/routing/iroutingpolicy.h> #include <vespa/documentapi/common.h> @@ -25,9 +26,19 @@ public: * @param param A string of recipients to select unless recipients have been configured. */ ANDPolicy(const string& param); - ~ANDPolicy(); - void select(mbus::RoutingContext &context) override; - void merge(mbus::RoutingContext &context) override; + + /** + * Destructor. + * + * Frees all allocated resources. + */ + virtual ~ANDPolicy(); + + // Inherit doc from IRoutingPolicy. + virtual void select(mbus::RoutingContext &context) override; + + // Inherit doc from IRoutingPolicy. + virtual void merge(mbus::RoutingContext &context) override; private: ANDPolicy(const ANDPolicy &); // hide diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h index bf17a77ca6a..2f901ebad2d 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h @@ -10,7 +10,7 @@ class ContentPolicy : public StoragePolicy public: ContentPolicy(const string& param); private: - string createConfigId(const string & clusterName) const override; + virtual string createConfigId(const string & clusterName) const override; }; } diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h index 362185576ff..678210b1416 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h @@ -1,11 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "config-documentrouteselectorpolicy.h" #include <vespa/document/select/node.h> #include <map> #include <vespa/messagebus/routing/iroutingpolicy.h> #include <vespa/vespalib/util/sync.h> +#include <vespa/documentapi/messagebus/policies/config-documentrouteselectorpolicy.h> #include <vespa/documentapi/common.h> #include <vespa/config/config.h> #include <vespa/config/helper/configfetcher.h> @@ -64,8 +64,14 @@ public: * @return The error string, or null if no error. */ const string &getError() const; + + // Implements Subscriber. void configure(std::unique_ptr<messagebus::protocol::DocumentrouteselectorpolicyConfig> cfg) override; + + // Implements IRoutingPolicy. void select(mbus::RoutingContext &context) override; + + // Implements IRoutingPolicy. void merge(mbus::RoutingContext &context) override; }; diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/errorpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/errorpolicy.h index fddccb1e3d9..790e0ab923c 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/errorpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/errorpolicy.h @@ -22,7 +22,11 @@ public: * @param msg The message of the error to assign. */ ErrorPolicy(const string &msg); + + // Implements IRoutingPolicy. void select(mbus::RoutingContext &context) override; + + // Implements IRoutingPolicy. void merge(mbus::RoutingContext &context) override; }; diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/externpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/externpolicy.h index 9dd400f69c3..d1e01cdbe59 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/externpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/externpolicy.h @@ -51,7 +51,13 @@ public: * @param param The address to use for this, if empty this will resolve to hostname. */ ExternPolicy(const string ¶m); - ~ExternPolicy(); + + /** + * Destructor. + * + * Frees all allocated resources. + */ + virtual ~ExternPolicy(); /** * This is a safety mechanism to allow the constructor to fail and signal that it can not be used. @@ -68,7 +74,11 @@ public: * @return The mirror pointer. */ slobrok::api::IMirrorAPI &getMirror() { return *_mirror; } + + // Overrides IRoutingPolicy. void select(mbus::RoutingContext &ctx) override; + + // Overrides IRoutingPolicy. void merge(mbus::RoutingContext &ctx) override; }; diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/externslobrokpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/externslobrokpolicy.h index 825c4a85d35..6a2a673807f 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/externslobrokpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/externslobrokpolicy.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "asyncinitializationpolicy.h" +#include <vespa/documentapi/messagebus/policies/asyncinitializationpolicy.h> #include <vespa/config-slobroks.h> #include <vespa/vdslib/distribution/distribution.h> #include <vespa/slobrok/imirrorapi.h> @@ -29,15 +29,20 @@ protected: public: ExternSlobrokPolicy(const std::map<string, string>& params); - ~ExternSlobrokPolicy(); + virtual ~ExternSlobrokPolicy(); /** * @return a pointer to the slobrok mirror owned by this policy, if any. * If the policy uses the default mirror API, NULL is returned. */ const slobrok::api::IMirrorAPI* getMirror() const { return _mirror.get(); } + slobrok::api::IMirrorAPI::SpecList lookup(mbus::RoutingContext &context, const string& pattern); - string init() override; + + /** + * Initializes the policy + */ + virtual string init() override; }; } diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/loadbalancerpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/loadbalancerpolicy.h index 7b0e7e1f110..0541b784b1f 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/loadbalancerpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/loadbalancerpolicy.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "loadbalancer.h" -#include "externslobrokpolicy.h" +#include <vespa/documentapi/messagebus/policies/loadbalancer.h> +#include <vespa/documentapi/messagebus/policies/externslobrokpolicy.h> namespace documentapi { @@ -10,7 +10,8 @@ class LoadBalancerPolicy : public ExternSlobrokPolicy { public: LoadBalancerPolicy(const string& param); - void doSelect(mbus::RoutingContext &context) override; + + virtual void doSelect(mbus::RoutingContext &context) override; /** Finds the TCP address of the target docproc. @@ -21,7 +22,7 @@ public: return _loadBalancer->getRecipient(lookup(context, _pattern)); } - void merge(mbus::RoutingContext &context) override; + virtual void merge(mbus::RoutingContext &context) override; private: string _pattern; diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.h index d471e3051c8..af63403a8b1 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.h @@ -74,9 +74,19 @@ public: * @param param The address to use for this, if empty this will resolve to hostname. */ LocalServicePolicy(const string ¶m); - ~LocalServicePolicy(); - void select(mbus::RoutingContext &context) override; - void merge(mbus::RoutingContext &context) override; + + /** + * Destructor. + * + * Frees all allocated resources. + */ + virtual ~LocalServicePolicy(); + + // Inherit doc from IRoutingPolicy. + virtual void select(mbus::RoutingContext &context) override; + + // Inherit doc from IRoutingPolicy. + virtual void merge(mbus::RoutingContext &context) override; }; } diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp index 4d260a8e81f..f55967b1c09 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp @@ -18,8 +18,6 @@ MessageTypePolicy::MessageTypePolicy(const config::ConfigUri & configUri) : _fetcher.start(); } -MessageTypePolicy::~MessageTypePolicy() {} - void MessageTypePolicy::configure(std::unique_ptr<MessagetyperouteselectorpolicyConfig> cfg) { diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h index d9a324a79c5..d29439db50c 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h @@ -43,10 +43,16 @@ public: * @param configUri The configuration uri to subscribe with. */ MessageTypePolicy(const config::ConfigUri & configUri); - ~MessageTypePolicy(); + + // Implements Subscriber. void configure(std::unique_ptr<vespa::config::content::MessagetyperouteselectorpolicyConfig> cfg) override; + + // Implements IRoutingPolicy. void select(mbus::RoutingContext &context) override; + + // Implements IRoutingPolicy. void merge(mbus::RoutingContext &context) override; }; } + diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/roundrobinpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/roundrobinpolicy.h index a14c2afdbc7..3a3a22090f9 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/roundrobinpolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/roundrobinpolicy.h @@ -61,9 +61,19 @@ public: * in slobrok. */ RoundRobinPolicy(const string ¶m); - ~RoundRobinPolicy(); - void select(mbus::RoutingContext &context) override; - void merge(mbus::RoutingContext &context) override; + + /** + * Destructor. + * + * Frees all allocated resources. + */ + virtual ~RoundRobinPolicy(); + + // Inherit doc from IRoutingPolicy. + virtual void select(mbus::RoutingContext &context) override; + + // Inherit doc from IRoutingPolicy. + virtual void merge(mbus::RoutingContext &context) override; }; } diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h index c73c4c8560d..ef6478e368a 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h @@ -39,9 +39,13 @@ private: public: StoragePolicy(const string& param); - ~StoragePolicy(); - void doSelect(mbus::RoutingContext &context) override; - void merge(mbus::RoutingContext &context) override; + virtual ~StoragePolicy(); + + // Inherit doc from IRoutingPolicy. + virtual void doSelect(mbus::RoutingContext &context) override; + + // Inherit doc from IRoutingPolicy. + virtual void merge(mbus::RoutingContext &context) override; void updateStateFromReply(WrongDistributionReply& reply); @@ -52,6 +56,7 @@ public: const storage::lib::ClusterState* getSystemState() const { return _state.get(); } virtual void configure(std::unique_ptr<storage::lib::Distribution::DistributionConfig> config); + string init() override; private: diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.h index 4d6dadb7156..49724785361 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.h @@ -65,9 +65,20 @@ public: * @param param The number of services to include in the set. */ SubsetServicePolicy(const string ¶m); - ~SubsetServicePolicy(); - void select(mbus::RoutingContext &context) override; - void merge(mbus::RoutingContext &context) override; + + /** + * Destructor. + * + * Frees all allocated resources. + */ + virtual ~SubsetServicePolicy(); + + // Inherit doc from IRoutingPolicy. + virtual void select(mbus::RoutingContext &context) override; + + // Inherit doc from IRoutingPolicy. + virtual void merge(mbus::RoutingContext &context) override; }; } + diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h index c715792f263..aed43b8b2e5 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h +++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h @@ -99,7 +99,11 @@ public: */ typedef std::unique_ptr<IRoutableFactory> UP; typedef std::shared_ptr<IRoutableFactory> SP; + + // Implements IRoutableFactory. bool encode(const mbus::Routable &obj, vespalib::GrowableByteBuffer &out) const override; + + // Implements IRoutableFactory. mbus::Routable::UP decode(document::ByteBuffer &in, const LoadTypeSet& loadTypes) const override; }; @@ -139,7 +143,10 @@ public: typedef std::unique_ptr<IRoutableFactory> UP; typedef std::shared_ptr<IRoutableFactory> SP; + // Implements IRoutableFactory. bool encode(const mbus::Routable &obj, vespalib::GrowableByteBuffer &out) const override; + + // Implements IRoutableFactory. mbus::Routable::UP decode(document::ByteBuffer &in, const LoadTypeSet& loadTypes) const override; }; @@ -173,7 +180,8 @@ public: DocumentMessage::UP doDecode(document::ByteBuffer &buf) const override; bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: - BatchDocumentUpdateMessageFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + BatchDocumentUpdateMessageFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class BatchDocumentUpdateReplyFactory : public DocumentReplyFactory { protected: @@ -186,7 +194,8 @@ public: DocumentMessage::UP doDecode(document::ByteBuffer &buf) const override; bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: - CreateVisitorMessageFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + CreateVisitorMessageFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class CreateVisitorReplyFactory : public DocumentReplyFactory { protected: @@ -276,7 +285,8 @@ public: DocumentReply::UP doDecode(document::ByteBuffer &buf) const override; bool doEncode(const DocumentReply &msg, vespalib::GrowableByteBuffer &buf) const override; public: - GetDocumentReplyFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + GetDocumentReplyFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class MapVisitorMessageFactory : public DocumentMessageFactory { const document::DocumentTypeRepo &_repo; @@ -284,7 +294,8 @@ public: DocumentMessage::UP doDecode(document::ByteBuffer &buf) const override; bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: - MapVisitorMessageFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + MapVisitorMessageFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class MapVisitorReplyFactory : public DocumentReplyFactory { protected: @@ -297,7 +308,8 @@ public: DocumentMessage::UP doDecode(document::ByteBuffer &buf) const override; bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: - MultiOperationMessageFactory(const document::DocumentTypeRepo::SP &r) : _repo(r) {} + MultiOperationMessageFactory(const document::DocumentTypeRepo::SP &r) + : _repo(r) {} }; class MultiOperationReplyFactory : public DocumentReplyFactory { protected: @@ -314,7 +326,8 @@ public: bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: void decodeInto(PutDocumentMessage & msg, document::ByteBuffer & buf) const; - PutDocumentMessageFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + PutDocumentMessageFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class PutDocumentReplyFactory : public DocumentReplyFactory { protected: @@ -341,7 +354,8 @@ public: DocumentMessage::UP doDecode(document::ByteBuffer &buf) const override; bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: - RemoveLocationMessageFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + RemoveLocationMessageFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class RemoveLocationReplyFactory : public DocumentReplyFactory { protected: @@ -388,7 +402,8 @@ public: bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: void decodeInto(UpdateDocumentMessage & msg, document::ByteBuffer & buf) const; - UpdateDocumentMessageFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + UpdateDocumentMessageFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class UpdateDocumentReplyFactory : public DocumentReplyFactory { protected: diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories51.h b/documentapi/src/vespa/documentapi/messagebus/routablefactories51.h index 429c86e5049..bfa25c21d84 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routablefactories51.h +++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories51.h @@ -58,7 +58,10 @@ public: typedef std::unique_ptr<IRoutableFactory> UP; typedef std::shared_ptr<IRoutableFactory> SP; + // Implements IRoutableFactory. bool encode(const mbus::Routable &obj, vespalib::GrowableByteBuffer &out) const override; + + // Implements IRoutableFactory. mbus::Routable::UP decode(document::ByteBuffer &in, const LoadTypeSet& loadTypes) const override; }; @@ -98,7 +101,10 @@ public: typedef std::unique_ptr<IRoutableFactory> UP; typedef std::shared_ptr<IRoutableFactory> SP; + // Implements IRoutableFactory. bool encode(const mbus::Routable &obj, vespalib::GrowableByteBuffer &out) const override; + + // Implements IRoutableFactory. mbus::Routable::UP decode(document::ByteBuffer &in, const LoadTypeSet& loadTypes) const override; }; @@ -139,7 +145,8 @@ public: DocumentMessage::UP doDecode(document::ByteBuffer &buf) const override; bool doEncode(const DocumentMessage &msg, vespalib::GrowableByteBuffer &buf) const override; public: - CreateVisitorMessageFactory(const document::DocumentTypeRepo &r) : _repo(r) {} + CreateVisitorMessageFactory(const document::DocumentTypeRepo &r) + : _repo(r) {} }; class GetDocumentMessageFactory : public DocumentMessageFactory { diff --git a/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h b/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h index a41ae155170..906fc508bd7 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h +++ b/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.h @@ -36,7 +36,9 @@ public: const document::DocumentTypeRepo &_repo; string _configId; public: - DocumentRouteSelectorPolicyFactory(const document::DocumentTypeRepo &repo, const string &configId); + DocumentRouteSelectorPolicyFactory( + const document::DocumentTypeRepo &repo, + const string &configId); mbus::IRoutingPolicy::UP createPolicy(const string ¶m) const override; }; class ExternPolicyFactory : public IRoutingPolicyFactory { @@ -66,3 +68,4 @@ public: }; } + diff --git a/eval/src/tests/eval/function/function_test.cpp b/eval/src/tests/eval/function/function_test.cpp index 964c48b670b..773b3e17d2e 100644 --- a/eval/src/tests/eval/function/function_test.cpp +++ b/eval/src/tests/eval/function/function_test.cpp @@ -374,7 +374,7 @@ TEST("require that Call children can be accessed") { struct MyNodeHandler : public NodeHandler { std::vector<nodes::Node_UP> nodes; - void handle(nodes::Node_UP node) override { + virtual void handle(nodes::Node_UP node) override { if (node.get() != nullptr) { nodes.push_back(std::move(node)); } @@ -657,9 +657,9 @@ struct MySymbolExtractor : SymbolExtractor { } MySymbolExtractor() : extra(), invoke_count() {} explicit MySymbolExtractor(std::initializer_list<char> extra_in) : extra(extra_in), invoke_count() {} - - void extract_symbol(const char *pos_in, const char *end_in, - const char *&pos_out, vespalib::string &symbol_out) const override + virtual void extract_symbol(const char *pos_in, const char *end_in, + const char *&pos_out, vespalib::string &symbol_out) + const override { ++invoke_count; for (; pos_in < end_in; ++pos_in) { diff --git a/fastlib/src/vespa/fastlib/io/fileinputstream.h b/fastlib/src/vespa/fastlib/io/fileinputstream.h index 045fc61500f..08806f1d19d 100644 --- a/fastlib/src/vespa/fastlib/io/fileinputstream.h +++ b/fastlib/src/vespa/fastlib/io/fileinputstream.h @@ -1,10 +1,39 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +/** +******************************************************************************* +* +* @author Stein Hardy Danielsen +* @date Creation date: 2000-10-07 +* @version $Id$ +* +* @file +* +* FileInputStream class +* +* Copyright (c) : 1997-2000 Fast Search & Transfer ASA +* ALL RIGHTS RESERVED +* +******************************************************************************/ #pragma once -#include "inputstream.h" -#include <vespa/fastos/file.h> +#include <vespa/fastlib/io/inputstream.h> + + + +/** +******************************************************************************** +* +* FileInputStream class +* @author Stein Hardy Danielsen +* @date Creation date: 2000-10-07 +* @version $Id$ +* +* +* Copyright (c) : 1997-2000 Fast Search & Transfer ASA +* ALL RIGHTS RESERVED +* +******************************************************************************/ class Fast_FileInputStream : public Fast_InputStream { private: @@ -19,16 +48,21 @@ private: /** File opened ok flag */ bool _fileOpenedOk; + public: + + /** Constructor */ Fast_FileInputStream(const char *fileName); - ~Fast_FileInputStream(); + + /** Destructor */ + virtual ~Fast_FileInputStream(void); // Implementation of Fast_InputStream interface - ssize_t Read(void *targetBuffer, size_t bufferSize) override; - bool Close() override; - ssize_t Available() override; - ssize_t Skip(size_t) override; + virtual ssize_t Read(void *targetBuffer, size_t bufferSize); + virtual bool Close(); + virtual ssize_t Available(); + virtual ssize_t Skip(size_t); }; diff --git a/fastlib/src/vespa/fastlib/io/inputstream.h b/fastlib/src/vespa/fastlib/io/inputstream.h index d7b443d28ee..22f65eb95c3 100644 --- a/fastlib/src/vespa/fastlib/io/inputstream.h +++ b/fastlib/src/vespa/fastlib/io/inputstream.h @@ -6,10 +6,11 @@ class Fast_InputStream { public: + virtual ~Fast_InputStream() { } - virtual ssize_t Available() = 0; - virtual bool Close() = 0; + virtual ssize_t Available(void) = 0; + virtual bool Close(void) = 0; virtual ssize_t Read(void *targetBuffer, size_t bufferSize) = 0; virtual ssize_t Skip(size_t skipNBytes) = 0; }; diff --git a/fastlib/src/vespa/fastlib/net/tests/httpheaderparsertest.cpp b/fastlib/src/vespa/fastlib/net/tests/httpheaderparsertest.cpp index 5c8f8d4d8f2..6c355b78aa1 100644 --- a/fastlib/src/vespa/fastlib/net/tests/httpheaderparsertest.cpp +++ b/fastlib/src/vespa/fastlib/net/tests/httpheaderparsertest.cpp @@ -1,13 +1,17 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/app.h> +#include <vespa/fastos/fastos.h> #include <vespa/fastlib/net/httpheaderparser.h> #include <vespa/fastlib/io/fileinputstream.h> #include <vespa/fastlib/io/bufferedinputstream.h> + + + class HeaderReaderApp : public FastOS_Application { public: - int Main() override + + int Main(void) override { if (_argc != 2) { diff --git a/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h b/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h index 082ab62a75e..36477f6b010 100644 --- a/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h +++ b/fastlib/src/vespa/fastlib/text/tests/latintokenizertest.h @@ -4,7 +4,7 @@ #include <vespa/fastlib/testsuite/test.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/stringfmt.h> -#include <vespa/fastlib/text/latintokenizer.h> +#include "../latintokenizer.h" class Mapel_Pucntuation { private: @@ -142,9 +142,10 @@ private: void TestTypeparamObservers(); public: - LatinTokenizerTest(); - ~LatinTokenizerTest(); - void Run() override; + LatinTokenizerTest(); + virtual ~LatinTokenizerTest(); + + virtual void Run() override; }; @@ -458,7 +459,7 @@ void LatinTokenizerTest::Run() class LatinTokenizerTestApp : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; diff --git a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp index 98860410eef..b3bb709def9 100644 --- a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp +++ b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.cpp @@ -1,4 +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 "unicodeutiltest.h" int UnicodeUtilTestApp::Main() diff --git a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h index a18728c51a9..28f1323384f 100644 --- a/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h +++ b/fastlib/src/vespa/fastlib/text/tests/unicodeutiltest.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastlib/testsuite/test.h> -#include <vespa/fastlib/text/unicodeutil.h> -#include <vespa/fastos/app.h> + +#include "../unicodeutil.h" class UnicodeUtilTest : public Test { @@ -40,15 +40,15 @@ class UnicodeUtilTest : public Test } public: - void Run() override { - // do the tests - _test(GetUTF8Char_WrongInput()); - _test(IsTerminalPunctuationChar()); - } + virtual void Run() override { + // do the tests + _test(GetUTF8Char_WrongInput()); + _test(IsTerminalPunctuationChar()); + } }; class UnicodeUtilTestApp : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; diff --git a/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h b/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h index c4eb6867dbd..3c18be1d552 100644 --- a/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h +++ b/fastlib/src/vespa/fastlib/text/tests/wordfolderstest.h @@ -1,6 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <memory> #include <vespa/fastlib/testsuite/test.h> -#include <vespa/fastlib/text/normwordfolder.h> + +#include "../wordfolder.h" +#include "../normwordfolder.h" class WordFoldersTest : public Test { @@ -112,18 +115,17 @@ class WordFoldersTest : public Test public: - - void Run() override { - // do the tests - _test(NormalizeWordFolderConstruction()); - _test(TokenizeAnnotatedBuffer()); - _test(TokenizeAnnotatedUCS4Buffer()); - _test(AccentRemovalTest()); - } + virtual void Run() override { + // do the tests + _test(NormalizeWordFolderConstruction()); + _test(TokenizeAnnotatedBuffer()); + _test(TokenizeAnnotatedUCS4Buffer()); + _test(AccentRemovalTest()); + } }; class WordFoldersTestApp : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; diff --git a/fastlib/src/vespa/fastlib/util/tests/bagtest.h b/fastlib/src/vespa/fastlib/util/tests/bagtest.h index 597317bf38e..7ca33f318f0 100644 --- a/fastlib/src/vespa/fastlib/util/tests/bagtest.h +++ b/fastlib/src/vespa/fastlib/util/tests/bagtest.h @@ -1,8 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <iostream> + #include <vespa/fastlib/util/bag.h> + #include <vespa/fastlib/testsuite/test.h> -#include <iostream> /** @@ -525,30 +527,37 @@ public: delete[] _array; } - void Run() override { - RunTest(&BagTester::IterPtrInitTest); - RunTest(&BagTester::IterRefInitTest); - RunTest(&BagTester::IterPtrStartTest); - RunTest(&BagTester::IterRefStartTest); - RunTest(&BagTester::IterStartOverTest); - RunTest(&BagTester::IterPPOperTest); - RunTest(&BagTester::GrowTest); - RunTest(&BagTester::AssignTest); - RunTest(&BagTester::CopyConstTest); - RunTest(&BagTester::EqualTest); - RunTest(&BagTester::DeleteEnumTest); - RunTest(&BagTester::RemoveTest); - RunTest(&BagTester::HasElementTest); - RunTest(&BagTester::RemoveAllElementsTest); - RunTest(&BagTester::GetBlocksizeTest); - RunTest(&BagTester::SetBlocksizeTest); - RunTest(&BagTester::NumberOfElementsTest); - } + + + virtual void Run() override { + RunTest(&BagTester::IterPtrInitTest); + RunTest(&BagTester::IterRefInitTest); + RunTest(&BagTester::IterPtrStartTest); + RunTest(&BagTester::IterRefStartTest); + RunTest(&BagTester::IterStartOverTest); + RunTest(&BagTester::IterPPOperTest); + RunTest(&BagTester::GrowTest); + RunTest(&BagTester::AssignTest); + RunTest(&BagTester::CopyConstTest); + RunTest(&BagTester::EqualTest); + RunTest(&BagTester::DeleteEnumTest); + RunTest(&BagTester::RemoveTest); + RunTest(&BagTester::HasElementTest); + RunTest(&BagTester::RemoveAllElementsTest); + RunTest(&BagTester::GetBlocksizeTest); + RunTest(&BagTester::SetBlocksizeTest); + RunTest(&BagTester::NumberOfElementsTest); + } + + }; class BagTest : public FastOS_Application { public: - int Main() override; + + virtual int Main() override; }; + + diff --git a/fastlib/src/vespa/fastlib/util/tests/base64test.cpp b/fastlib/src/vespa/fastlib/util/tests/base64test.cpp index 92cc2fee719..970f87831b1 100644 --- a/fastlib/src/vespa/fastlib/util/tests/base64test.cpp +++ b/fastlib/src/vespa/fastlib/util/tests/base64test.cpp @@ -1,12 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/app.h> -#include <vespa/fastos/file.h> +#include <vespa/fastos/fastos.h> +#include <stdio.h> +#include <assert.h> +#include <memory> #include <vespa/vespalib/stllike/string.h> -#include <vespa/fastlib/util/base64.h> +#include "../base64.h" class Base64Test : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; int diff --git a/filedistribution/src/tests/filedownloader/testfiledownloader.cpp b/filedistribution/src/tests/filedownloader/testfiledownloader.cpp index 9bf96abc1eb..56a664ea7e1 100644 --- a/filedistribution/src/tests/filedownloader/testfiledownloader.cpp +++ b/filedistribution/src/tests/filedownloader/testfiledownloader.cpp @@ -2,6 +2,7 @@ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN +#include <vespa/fastos/fastos.h> #include <vespa/filedistribution/distributor/filedownloader.h> #include <vespa/filedistribution/distributor/filedistributortrackerimpl.h> @@ -11,7 +12,12 @@ #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> +#include <libtorrent/session.hpp> +#include <libtorrent/tracker_manager.hpp> +#include <libtorrent/torrent.hpp> + #include <vespa/filedistribution/manager/createtorrent.h> +#include <vespa/filedistribution/model/filedistributionmodel.h> #include <vespa/filedistribution/common/componentsdeleter.h> namespace fs = boost::filesystem; @@ -41,16 +47,16 @@ createDownloader(ComponentsDeleter& deleter, } //anonymous namespace class MockFileDistributionModel : public FileDistributionModel { - FileDBModel& getFileDBModel() override { + virtual FileDBModel& getFileDBModel() override { abort(); } - std::set<std::string> getFilesToDownload() override { + virtual std::set<std::string> getFilesToDownload() override { return std::set<std::string>(); } - PeerEntries getPeers(const std::string& , size_t) override { - PeerEntries peers(2); + virtual PeerEntries getPeers(const std::string&, size_t) override { + PeerEntries peers(2); peers[0].ip = localHost; peers[0].port = uploaderPort; @@ -60,9 +66,9 @@ class MockFileDistributionModel : public FileDistributionModel { return peers; } - void addPeer(const std::string&) override {} - void removePeer(const std::string&) override {} - void peerFinished(const std::string&) override {} + virtual void addPeer(const std::string&) override {} + virtual void removePeer(const std::string&) override {} + virtual void peerFinished(const std::string&) override {} }; diff --git a/filedistribution/src/tests/rpc/mockfileprovider.h b/filedistribution/src/tests/rpc/mockfileprovider.h index fd66acfb0fc..33177d939c1 100644 --- a/filedistribution/src/tests/rpc/mockfileprovider.h +++ b/filedistribution/src/tests/rpc/mockfileprovider.h @@ -32,6 +32,7 @@ public: downloadCompleted()(fileReference, "downloaded/path/" + fileReference); } + //Overrides DownloadCompletedSignal& downloadCompleted() override { return _downloadCompleted; } diff --git a/filedistribution/src/tests/scheduler/test-scheduler.cpp b/filedistribution/src/tests/scheduler/test-scheduler.cpp index 1ce5cbb9bc2..5be60569449 100644 --- a/filedistribution/src/tests/scheduler/test-scheduler.cpp +++ b/filedistribution/src/tests/scheduler/test-scheduler.cpp @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN - +#include <vespa/fastos/fastos.h> #include <boost/test/unit_test.hpp> #include <vespa/filedistribution/distributor/scheduler.h> @@ -9,6 +9,7 @@ #include <iostream> #include <boost/thread/barrier.hpp> +#include <thread> using filedistribution::Scheduler; using namespace std::literals; diff --git a/filedistribution/src/tests/zkfacade/test-zkfacade.cpp b/filedistribution/src/tests/zkfacade/test-zkfacade.cpp index 51a3f0b40e3..46db660d452 100644 --- a/filedistribution/src/tests/zkfacade/test-zkfacade.cpp +++ b/filedistribution/src/tests/zkfacade/test-zkfacade.cpp @@ -2,10 +2,14 @@ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #define BOOST_TEST_MODULE zkfacade test - +#include <vespa/fastos/fastos.h> #include <boost/test/unit_test.hpp> + #include <iostream> + #include <boost/thread/barrier.hpp> +#include <boost/checked_delete.hpp> + #include <vespa/filedistribution/common/componentsdeleter.h> #include <vespa/filedistribution/model/zkfacade.h> diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp b/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp index 9906074afc5..1db2f7c6e49 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp +++ b/filedistribution/src/vespa/filedistribution/distributor/filedistributortrackerimpl.cpp @@ -1,8 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "filedistributortrackerimpl.h" -#include "filedownloader.h" +#include <cmath> +#include <libtorrent/tracker_manager.hpp> +#include <libtorrent/torrent.hpp> +#include <vespa/filedistribution/model/filedistributionmodel.h> #include <vespa/filedistribution/model/zkfacade.h> +#include "filedownloader.h" +#include "hostname.h" #include <vespa/log/log.h> LOG_SETUP(".filedistributiontrackerimpl"); diff --git a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp index 3b4d043a30b..0288f3082f8 100644 --- a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp +++ b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.cpp @@ -1,15 +1,22 @@ // 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 "filedistributionmodel.h" -#include "zkfiledbmodel.h" -#include "deployedfilestodownload.h" -#include "filedistributionmodelimpl.h" + +#include <vector> +#include <set> +#include <string> +#include <cstdlib> + #include <boost/filesystem.hpp> #include <zookeeper/zookeeper.h> #include <vespa/log/log.h> LOG_SETUP(".filedistributionmodel"); +#include "zkfiledbmodel.h" +#include "deployedfilestodownload.h" +#include "filedistributionmodelimpl.h" + namespace fs = boost::filesystem; using filedistribution::ZKFileDBModel; diff --git a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h index 4b2b14ea21f..e132ec8b230 100644 --- a/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h +++ b/filedistribution/src/vespa/filedistribution/model/filedistributionmodelimpl.h @@ -2,7 +2,7 @@ #pragma once #include "filedistributionmodel.h" -#include "config-filereferences.h" +#include <vespa/filedistribution/model/config-filereferences.h> #include "zkfacade.h" #include "zkfiledbmodel.h" #include <vespa/config/config.h> diff --git a/fnet/src/examples/frt/rpc/echo_client.cpp b/fnet/src/examples/frt/rpc/echo_client.cpp index 9a5cf7cbd64..b5fabb32363 100644 --- a/fnet/src/examples/frt/rpc/echo_client.cpp +++ b/fnet/src/examples/frt/rpc/echo_client.cpp @@ -1,12 +1,13 @@ // 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/log/log.h> +LOG_SETUP("echo_client"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> class EchoClient : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; int diff --git a/fnet/src/examples/frt/rpc/rpc_callback_client.cpp b/fnet/src/examples/frt/rpc/rpc_callback_client.cpp index 2bf740f7b1e..3dd936f7fea 100644 --- a/fnet/src/examples/frt/rpc/rpc_callback_client.cpp +++ b/fnet/src/examples/frt/rpc/rpc_callback_client.cpp @@ -1,7 +1,9 @@ // 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/log/log.h> +LOG_SETUP("rpc_callback_client"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + struct RPC : public FRT_Invokable { @@ -32,7 +34,7 @@ RPC::Init(FRT_Supervisor *s) class MyApp : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; int diff --git a/fnet/src/examples/frt/rpc/rpc_callback_server.cpp b/fnet/src/examples/frt/rpc/rpc_callback_server.cpp index 67eac0743d6..419b1266d23 100644 --- a/fnet/src/examples/frt/rpc/rpc_callback_server.cpp +++ b/fnet/src/examples/frt/rpc/rpc_callback_server.cpp @@ -1,7 +1,9 @@ // 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/log/log.h> +LOG_SETUP("rpc_callback_server"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + struct RPC : public FRT_Invokable { @@ -38,7 +40,7 @@ RPC::Init(FRT_Supervisor *s) class MyApp : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; int diff --git a/fnet/src/examples/frt/rpc/rpc_client.cpp b/fnet/src/examples/frt/rpc/rpc_client.cpp index 435bfb6f08c..f5e5a9fe1e2 100644 --- a/fnet/src/examples/frt/rpc/rpc_client.cpp +++ b/fnet/src/examples/frt/rpc/rpc_client.cpp @@ -1,12 +1,14 @@ // 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/log/log.h> +LOG_SETUP("rpc_client"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + class RPCClient : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; int diff --git a/fnet/src/examples/frt/rpc/rpc_info.cpp b/fnet/src/examples/frt/rpc/rpc_info.cpp index ae9eafa210d..5b7aebd6bdd 100644 --- a/fnet/src/examples/frt/rpc/rpc_info.cpp +++ b/fnet/src/examples/frt/rpc/rpc_info.cpp @@ -1,7 +1,8 @@ // 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/log/log.h> +LOG_SETUP("rpc_info"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> class RPCInfo : public FastOS_Application { @@ -63,7 +64,7 @@ public: printf("\n"); } - int Main() override; + virtual int Main() override; }; diff --git a/fnet/src/examples/frt/rpc/rpc_invoke.cpp b/fnet/src/examples/frt/rpc/rpc_invoke.cpp index 1bb572a6025..0f64ef9b539 100644 --- a/fnet/src/examples/frt/rpc/rpc_invoke.cpp +++ b/fnet/src/examples/frt/rpc/rpc_invoke.cpp @@ -1,7 +1,8 @@ // 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/log/log.h> +LOG_SETUP("rpc_invoke"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> class RPCClient : public FastOS_Application { @@ -42,7 +43,7 @@ private: int run(); public: - int Main() override; + virtual int Main() override; }; int diff --git a/fnet/src/examples/frt/rpc/rpc_proxy.cpp b/fnet/src/examples/frt/rpc/rpc_proxy.cpp index e73f556b9d8..6c805d6a173 100644 --- a/fnet/src/examples/frt/rpc/rpc_proxy.cpp +++ b/fnet/src/examples/frt/rpc/rpc_proxy.cpp @@ -1,7 +1,9 @@ // 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/log/log.h> +LOG_SETUP("rpc_proxy"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + //----------------------------------------------------------------------------- struct Session @@ -66,7 +68,7 @@ private: public: ReqDone(RPCProxy &proxy) : _proxy(proxy) {} - void RequestDone(FRT_RPCRequest *req) override; + virtual void RequestDone(FRT_RPCRequest *req) override; }; void @@ -207,7 +209,7 @@ RPCProxy::HOOK_Fini(FRT_RPCRequest *req) class App : public FastOS_Application { public: - int Main() override; + virtual int Main() override; }; int diff --git a/fnet/src/examples/frt/rpc/rpc_server.cpp b/fnet/src/examples/frt/rpc/rpc_server.cpp index 2b7e16b91b6..823d3c893b1 100644 --- a/fnet/src/examples/frt/rpc/rpc_server.cpp +++ b/fnet/src/examples/frt/rpc/rpc_server.cpp @@ -1,7 +1,9 @@ // 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/log/log.h> +LOG_SETUP("rpc_server"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + class RPCServer : public FRT_Invokable { @@ -105,7 +107,7 @@ private: public: App() : _server() {} - int Main() override; + virtual int Main() override; }; int diff --git a/fnet/src/examples/ping/packets.h b/fnet/src/examples/ping/packets.h index 27a06bdaab3..68cc27ccb5b 100644 --- a/fnet/src/examples/ping/packets.h +++ b/fnet/src/examples/ping/packets.h @@ -1,36 +1,36 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/fnet/packet.h> -#include <vespa/fnet/ipacketfactory.h> enum { PCODE_PING_REQUEST = 1, PCODE_PING_REPLY = 2 }; + class PingRequest : public FNET_Packet { public: - uint32_t GetPCODE() override; - uint32_t GetLength() override; - void Encode(FNET_DataBuffer *) override; - bool Decode(FNET_DataBuffer *src, uint32_t len) override; + virtual uint32_t GetPCODE() override; + virtual uint32_t GetLength() override; + virtual void Encode(FNET_DataBuffer *) override; + virtual bool Decode(FNET_DataBuffer *src, uint32_t len) override; }; + class PingReply : public FNET_Packet { public: - uint32_t GetPCODE() override; - uint32_t GetLength() override; - void Encode(FNET_DataBuffer *) override; - bool Decode(FNET_DataBuffer *src, uint32_t len) override; + virtual uint32_t GetPCODE() override; + virtual uint32_t GetLength() override; + virtual void Encode(FNET_DataBuffer *) override; + virtual bool Decode(FNET_DataBuffer *src, uint32_t len) override; }; class PingPacketFactory : public FNET_IPacketFactory { public: - FNET_Packet *CreatePacket(uint32_t pcode, FNET_Context) override; + virtual FNET_Packet *CreatePacket(uint32_t pcode, FNET_Context) override; }; diff --git a/fnet/src/examples/ping/pingclient.cpp b/fnet/src/examples/ping/pingclient.cpp index 0b28f118685..fb834b9108b 100644 --- a/fnet/src/examples/ping/pingclient.cpp +++ b/fnet/src/examples/ping/pingclient.cpp @@ -1,13 +1,15 @@ // 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/log/log.h> +LOG_SETUP("pingclient"); #include <vespa/fnet/fnet.h> #include <examples/ping/packets.h> -#include <vespa/fastos/app.h> + class PingClient : public FastOS_Application { public: - int Main() override; + int Main() override; }; diff --git a/fnet/src/examples/ping/pingserver.cpp b/fnet/src/examples/ping/pingserver.cpp index 3c76bc951ec..173e627ac23 100644 --- a/fnet/src/examples/ping/pingserver.cpp +++ b/fnet/src/examples/ping/pingserver.cpp @@ -1,8 +1,10 @@ // 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/log/log.h> +LOG_SETUP("pingserver"); #include <vespa/fnet/fnet.h> #include <examples/ping/packets.h> -#include <vespa/fastos/app.h> + class PingServer : public FNET_IServerAdapter, public FNET_IPacketHandler, @@ -10,13 +12,15 @@ class PingServer : public FNET_IServerAdapter, { public: bool InitAdminChannel(FNET_Channel *) override { return false; } - bool InitChannel(FNET_Channel *channel, uint32_t) override { + bool InitChannel(FNET_Channel *channel, uint32_t) override + { channel->SetContext(FNET_Context(channel)); channel->SetHandler(this); return true; } - - HP_RetCode HandlePacket(FNET_Packet *packet, FNET_Context context) override { + + HP_RetCode HandlePacket(FNET_Packet *packet, FNET_Context context) override + { if (packet->GetPCODE() == PCODE_PING_REQUEST) { fprintf(stderr, "Got ping request, sending ping reply\n"); context._value.CHANNEL->Send(new PingReply()); @@ -24,8 +28,8 @@ public: packet->Free(); return FNET_FREE_CHANNEL; } - - int Main() override; + + int Main() override; }; diff --git a/fnet/src/examples/proxy/proxy.cpp b/fnet/src/examples/proxy/proxy.cpp index 2d1d44174a4..40d7a44c7f6 100644 --- a/fnet/src/examples/proxy/proxy.cpp +++ b/fnet/src/examples/proxy/proxy.cpp @@ -1,10 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/fnet/fnet.h> -#include <vespa/fastos/app.h> - +#include <vespa/fastos/fastos.h> #include <vespa/log/log.h> LOG_SETUP("proxy"); +#include <vespa/fnet/fnet.h> + class RawPacket : public FNET_Packet { @@ -13,10 +12,10 @@ private: public: RawPacket() : _data() {} - uint32_t GetPCODE() override; - uint32_t GetLength() override; - void Encode(FNET_DataBuffer *) override; - bool Decode(FNET_DataBuffer *src, uint32_t len) override; + virtual uint32_t GetPCODE() override; + virtual uint32_t GetLength() override; + virtual void Encode(FNET_DataBuffer *) override; + virtual bool Decode(FNET_DataBuffer *src, uint32_t len) override; }; uint32_t @@ -70,7 +69,7 @@ public: _server = server; } - HP_RetCode HandlePacket(FNET_Packet *packet, FNET_Context context) override; + virtual HP_RetCode HandlePacket(FNET_Packet *packet, FNET_Context context) override; }; @@ -140,14 +139,14 @@ private: public: Proxy() : _transport() {} - bool GetPacketInfo(FNET_DataBuffer *src, uint32_t *plen, uint32_t *pcode, uint32_t *chid, bool *) override; - FNET_Packet *Decode(FNET_DataBuffer *src, uint32_t plen, uint32_t pcode, FNET_Context) override; - void Encode(FNET_Packet *packet, uint32_t chid, FNET_DataBuffer *dst) override; + virtual bool GetPacketInfo(FNET_DataBuffer *src, uint32_t *plen, uint32_t *pcode, uint32_t *chid, bool *) override; + virtual FNET_Packet *Decode(FNET_DataBuffer *src, uint32_t plen, uint32_t pcode, FNET_Context) override; + virtual void Encode(FNET_Packet *packet, uint32_t chid, FNET_DataBuffer *dst) override; // --------------------------------------------- - bool InitAdminChannel(FNET_Channel *channel) override; - bool InitChannel(FNET_Channel *, uint32_t) override; + virtual bool InitAdminChannel(FNET_Channel *channel) override; + virtual bool InitChannel(FNET_Channel *, uint32_t) override; // --------------------------------------------- - int Main() override; + virtual int Main() override; }; diff --git a/fnet/src/examples/timeout/timeout.cpp b/fnet/src/examples/timeout/timeout.cpp index 7edfbe4fb1c..8a52d769282 100644 --- a/fnet/src/examples/timeout/timeout.cpp +++ b/fnet/src/examples/timeout/timeout.cpp @@ -1,7 +1,9 @@ // 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/log/log.h> +LOG_SETUP("timeout"); #include <vespa/fnet/fnet.h> -#include <vespa/fastos/app.h> + class Timeout : public FNET_Task { @@ -18,7 +20,7 @@ public: _queue(queue) {} - void PerformTask() override; + virtual void PerformTask() override; }; diff --git a/fnet/src/tests/frt/method_pt/method_pt.cpp b/fnet/src/tests/frt/method_pt/method_pt.cpp index 98ab9d228a1..4b869f6ba9f 100644 --- a/fnet/src/tests/frt/method_pt/method_pt.cpp +++ b/fnet/src/tests/frt/method_pt/method_pt.cpp @@ -112,9 +112,9 @@ class MediumHandler1 : public FRT_Invokable, public MediumB { public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); + virtual void foo() override {} + virtual void bar() override {} + void RPC_Method(FRT_RPCRequest *req); }; @@ -123,9 +123,9 @@ class MediumHandler2 : public MediumA, public MediumB { public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); + virtual void foo() override {} + virtual void bar() override {} + void RPC_Method(FRT_RPCRequest *req); }; @@ -134,9 +134,9 @@ class MediumHandler3 : public MediumA, public FRT_Invokable { public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); + virtual void foo() override {} + virtual void bar() override {} + void RPC_Method(FRT_RPCRequest *req); }; //------------------------------------------------------------- @@ -146,9 +146,9 @@ class ComplexHandler1 : public FRT_Invokable, public ComplexB { public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); + virtual void foo() override {} + virtual void bar() override {} + void RPC_Method(FRT_RPCRequest *req); }; @@ -157,9 +157,9 @@ class ComplexHandler2 : public ComplexA, public ComplexB { public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); + virtual void foo() override {} + virtual void bar() override {} + void RPC_Method(FRT_RPCRequest *req); }; @@ -168,9 +168,9 @@ class ComplexHandler3 : public ComplexA, public FRT_Invokable { public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); + virtual void foo() override {} + virtual void bar() override {} + void RPC_Method(FRT_RPCRequest *req); }; //------------------------------------------------------------- diff --git a/fnet/src/tests/frt/rpc/invoke.cpp b/fnet/src/tests/frt/rpc/invoke.cpp index d51557e9cfd..7853c473f5e 100644 --- a/fnet/src/tests/frt/rpc/invoke.cpp +++ b/fnet/src/tests/frt/rpc/invoke.cpp @@ -48,7 +48,8 @@ struct LockedReqWait : public FRT_IRequestWait return ret; } - void RequestDone(FRT_RPCRequest *) override { + virtual void RequestDone(FRT_RPCRequest *) override + { _wasLocked = isLocked(); _cond.Lock(); _done = true; @@ -56,7 +57,8 @@ struct LockedReqWait : public FRT_IRequestWait _cond.Unlock(); } - void waitReq() { + void waitReq() + { _cond.Lock(); while(!_done) { _cond.Wait(); @@ -76,7 +78,9 @@ private: DelayedReturn &operator=(const DelayedReturn &); public: - DelayedReturn(FNET_Scheduler *sched, FRT_RPCRequest *req, double delay) + DelayedReturn(FNET_Scheduler *sched, + FRT_RPCRequest *req, + double delay) : FNET_Task(sched), _req(req) { diff --git a/fnet/src/tests/frt/rpc/sharedblob.cpp b/fnet/src/tests/frt/rpc/sharedblob.cpp index 363a7891cbd..a086584b36a 100644 --- a/fnet/src/tests/frt/rpc/sharedblob.cpp +++ b/fnet/src/tests/frt/rpc/sharedblob.cpp @@ -10,10 +10,10 @@ struct MyBlob : FRT_ISharedBlob { int refcnt; MyBlob() : refcnt(1) {} - uint32_t getLen() override { return (strlen("blob_test") + 1); } - const char *getData() override { return "blob_test"; } - void addRef() override { ++refcnt; } - void subRef() override { --refcnt; } + virtual uint32_t getLen() override { return (strlen("blob_test") + 1); } + virtual const char *getData() override { return "blob_test"; } + virtual void addRef() override { ++refcnt; } + virtual void subRef() override { --refcnt; } }; struct Data diff --git a/fnet/src/tests/locking/castspeed.cpp b/fnet/src/tests/locking/castspeed.cpp index 859ec08ec69..1f57bc4757c 100644 --- a/fnet/src/tests/locking/castspeed.cpp +++ b/fnet/src/tests/locking/castspeed.cpp @@ -18,14 +18,14 @@ class C: public A { public: B *otherB; - B* asB() override { return otherB; } + virtual B* asB() override { return otherB; } C() : otherB(nullptr) {} }; class B: public C { public: - B* asB() override { return this; } + virtual B* asB() override { return this; } }; diff --git a/fnet/src/tests/locking/drainpackets.cpp b/fnet/src/tests/locking/drainpackets.cpp index b453793843f..fb86371c9ec 100644 --- a/fnet/src/tests/locking/drainpackets.cpp +++ b/fnet/src/tests/locking/drainpackets.cpp @@ -2,13 +2,15 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/fnet/fnet.h> + class MyPacket : public FNET_Packet { public: - uint32_t GetPCODE() override { return 0; } + uint32_t GetPCODE() override { return 0; } uint32_t GetLength() override { return 0; } void Encode(FNET_DataBuffer *) override {} - bool Decode(FNET_DataBuffer *, uint32_t) override { return true; } + bool Decode(FNET_DataBuffer *, uint32_t) override + { return true; } }; diff --git a/fnet/src/tests/scheduling/sloweventloop.cpp b/fnet/src/tests/scheduling/sloweventloop.cpp index a13205f4b0e..a4b57cfd218 100644 --- a/fnet/src/tests/scheduling/sloweventloop.cpp +++ b/fnet/src/tests/scheduling/sloweventloop.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/fnet/fnet.h> + class MyTask : public FNET_Task { public: diff --git a/fnet/src/tests/sync_execute/sync_execute.cpp b/fnet/src/tests/sync_execute/sync_execute.cpp index ca77ab6f73b..c832ef0330d 100644 --- a/fnet/src/tests/sync_execute/sync_execute.cpp +++ b/fnet/src/tests/sync_execute/sync_execute.cpp @@ -1,11 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/fnet/transport.h> -#include <vespa/fnet/iexecutable.h> +#include <vespa/fnet/fnet.h> +#include <vespa/vespalib/util/sync.h> struct DoIt : public FNET_IExecutable { vespalib::Gate gate; - void execute() override { + virtual void execute() override { gate.countDown(); } }; diff --git a/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp b/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp index 19ebdb253a3..75defdc3881 100644 --- a/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp +++ b/jrt_test/src/jrt-test/simpleserver/simpleserver.cpp @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include <vespa/log/log.h> +LOG_SETUP("simpleserver"); +#include <vespa/fastos/fastos.h> #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + class Server : public FRT_Invokable { diff --git a/jrt_test/src/tests/echo/echo-client.cpp b/jrt_test/src/tests/echo/echo-client.cpp index 14faac3ca9e..2d72cdc937b 100644 --- a/jrt_test/src/tests/echo/echo-client.cpp +++ b/jrt_test/src/tests/echo/echo-client.cpp @@ -1,7 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include <vespa/log/log.h> +LOG_SETUP("echo_client"); +#include <vespa/fastos/fastos.h> #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> class EchoClient : public FastOS_Application { diff --git a/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp b/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp index 9857ea073c2..98584e9a284 100644 --- a/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp +++ b/jrt_test/src/tests/mandatory-methods/extract-reflection.cpp @@ -1,6 +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/app.h> +#include <vespa/fastos/fastos.h> #include <vespa/fnet/frt/frt.h> class RPCInfo : public FastOS_Application diff --git a/jrt_test/src/tests/mockup-invoke/mockup-server.cpp b/jrt_test/src/tests/mockup-invoke/mockup-server.cpp index 41624eaf108..46a1e2bc11a 100644 --- a/jrt_test/src/tests/mockup-invoke/mockup-server.cpp +++ b/jrt_test/src/tests/mockup-invoke/mockup-server.cpp @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include <vespa/log/log.h> +LOG_SETUP("mockup_server"); +#include <vespa/fastos/fastos.h> #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + class MockupServer : public FRT_Invokable { diff --git a/jrt_test/src/tests/rpc-error/test-errors.cpp b/jrt_test/src/tests/rpc-error/test-errors.cpp index 184e733da82..07ff7425f9a 100644 --- a/jrt_test/src/tests/rpc-error/test-errors.cpp +++ b/jrt_test/src/tests/rpc-error/test-errors.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/fnet/frt/frt.h> + class TestErrors : public vespalib::TestApp { private: diff --git a/juniper/src/test/SrcTestSuite.cpp b/juniper/src/test/SrcTestSuite.cpp index 4a648e6af19..f73e4c8fc3a 100644 --- a/juniper/src/test/SrcTestSuite.cpp +++ b/juniper/src/test/SrcTestSuite.cpp @@ -1,12 +1,29 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +/** + * Implementation of the test suite application SrcTestSuite. + * + * @file SrcTestSuite.cpp + * + * @author Knut Omang + * + * @date Created 21 Feb 2003 + * + * $Id$ + * + * <pre> + * Copyright (c) : 2003 Fast Search & Transfer ASA + * ALL RIGHTS RESERVED + * </pre> + ****************************************************************************/ +#include <vespa/fastos/fastos.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/fastlib/testsuite/suite.h> #include "testenv.h" #include "mcandTest.h" #include "queryparserTest.h" #include "matchobjectTest.h" #include "auxTest.h" -#include <vespa/vespalib/testkit/testapp.h> -#include <vespa/fastlib/testsuite/suite.h> + /** * The SrcTestSuite class runs all the unit tests for the src module. * @@ -36,7 +53,7 @@ SrcTestSuite::SrcTestSuite() : */ class SrcTestSuiteApp : public vespalib::TestApp { public: - int Main() override; + virtual int Main() override; }; int SrcTestSuiteApp::Main() { diff --git a/juniper/src/test/auxTest.cpp b/juniper/src/test/auxTest.cpp index 349792ed723..2dc3457e6c3 100644 --- a/juniper/src/test/auxTest.cpp +++ b/juniper/src/test/auxTest.cpp @@ -1,9 +1,9 @@ // 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/log/log.h> +LOG_SETUP(""); #include "auxTest.h" -#include <vespa/fastos/file.h> -#include <vespa/log/log.h> -LOG_SETUP(".auxtest"); // Using separator definitions only from here: @@ -560,7 +560,7 @@ void AuxTest::test_summary(Matcher& m, const char* content, size_t content_len, class DefProps : public IJuniperProperties { public: - const char* GetProperty(const char*, const char* def) override { + virtual const char* GetProperty(const char*, const char* def) override { return def; } }; @@ -626,12 +626,12 @@ public: TokenChecker(Token* output) : _out(output), i(0) { } - void handle_token(Token& token) override { + virtual void handle_token(Token& token) override { _out[i] = token; i++; } - void handle_end(Token&) override {} + virtual void handle_end(Token&) override {} }; @@ -670,13 +670,13 @@ private: std::vector<std::string> _tokens; public: TokenProcessor(const std::string & text) : _text(text), _tokens() {} - void handle_token(Token & t) override { + virtual void handle_token(Token & t) override { _tokens.push_back(std::string(_text.c_str() + t.bytepos, t.bytelen)); //LOG(info, "handle_token(%s): bytepos(%d), wordpos(%d), bytelen(%d), curlen(%d)", //_tokens.back().c_str(), //(int)t.bytepos, (int)t.wordpos, t.bytelen, t.curlen); } - void handle_end(Token & t) override { + virtual void handle_end(Token & t) override { _tokens.push_back(std::string(_text.c_str() + t.bytepos, t.bytelen)); //LOG(info, "handle_end(%s): bytepos(%d), wordpos(%d), bytelen(%d), curlen(%d)", //_tokens.back().c_str(), diff --git a/juniper/src/test/auxTest.h b/juniper/src/test/auxTest.h index a98adc732f4..218dcaab6d0 100644 --- a/juniper/src/test/auxTest.h +++ b/juniper/src/test/auxTest.h @@ -7,6 +7,7 @@ #include <vespa/fastlib/testsuite/test.h> #include "testenv.h" + class AuxTest : public Test { private: @@ -24,14 +25,14 @@ public: void Run(MethodContainer::iterator &itr); void Run(const char* method); void Run(int argc, char* argv[]); - void Run() override; + virtual void Run() override; protected: /** * Since we are running within Emacs, the default behavior of * print_progress which includes backspace does not work. * We'll use a single '.' instead. */ - void print_progress() override { *m_osptr << '.' << std::flush; } + virtual void print_progress() override { *m_osptr << '.' << std::flush; } private: // tests: void TestPropertyMap(); diff --git a/juniper/src/test/auxTestApp.cpp b/juniper/src/test/auxTestApp.cpp index a9475998aa4..3f43c706d35 100644 --- a/juniper/src/test/auxTestApp.cpp +++ b/juniper/src/test/auxTestApp.cpp @@ -1,11 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "auxTest.h" +#include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/testapp.h> +#include "auxTest.h" class AuxTestApp : public vespalib::TestApp { public: - int Main() override; + virtual int Main() override; }; diff --git a/juniper/src/test/fakerewriter.h b/juniper/src/test/fakerewriter.h index cf78fd28255..0a0554f76fc 100644 --- a/juniper/src/test/fakerewriter.h +++ b/juniper/src/test/fakerewriter.h @@ -8,10 +8,10 @@ class FakeRewriter: public juniper::IRewriter { public: FakeRewriter() : _name() {} - const char* Name() const override; - juniper::RewriteHandle* Rewrite(uint32_t langid, const char* term) override; - juniper::RewriteHandle* Rewrite(uint32_t langid, const char* term, size_t length) override; - const char* NextTerm(juniper::RewriteHandle* exp, size_t& length) override; + virtual const char* Name() const override; + virtual juniper::RewriteHandle* Rewrite(uint32_t langid, const char* term) override; + virtual juniper::RewriteHandle* Rewrite(uint32_t langid, const char* term, size_t length) override; + virtual const char* NextTerm(juniper::RewriteHandle* exp, size_t& length) override; private: std::string _name; }; diff --git a/juniper/src/test/matchobjectTest.h b/juniper/src/test/matchobjectTest.h index 0f4a1ace55b..9e0828cfa77 100644 --- a/juniper/src/test/matchobjectTest.h +++ b/juniper/src/test/matchobjectTest.h @@ -17,9 +17,9 @@ ***************************************************************************/ #pragma once -#include "testenv.h" -#include <vespa/fastlib/testsuite/test.h> #include <map> +#include <vespa/fastlib/testsuite/test.h> +#include "testenv.h" /** * The MatchObjectTest class holds @@ -98,7 +98,8 @@ protected: * print_progress which includes backspace does not work. * We'll use a single '.' instead. */ - void print_progress() override { *m_osptr << '.' << std::flush; } + virtual void print_progress() override { *m_osptr << '.' << std::flush; } + public: MatchObjectTest() : Test("MatchObject"), test_methods_() { init(); } @@ -108,7 +109,7 @@ public: * main entry points *************************************************************************/ void Run(MethodContainer::iterator &itr); - void Run() override; + virtual void Run() override; void Run(const char *method); void Run(int argc, char* argv[]); }; diff --git a/juniper/src/test/matchobjectTestApp.cpp b/juniper/src/test/matchobjectTestApp.cpp index f755c3e932a..065af199589 100644 --- a/juniper/src/test/matchobjectTestApp.cpp +++ b/juniper/src/test/matchobjectTestApp.cpp @@ -1,8 +1,25 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +/** + * Definition and implementation of the application for running unit tests + * for the MatchObject class in isolation. + * + * @file matchobjectTestApp.cpp + * + * @author Knut Omang + * + * @date Created 21 Feb 2003 + * + * $Id$ + * + * <pre> + * Copyright (c) : 2003 Fast Search & Transfer ASA + * ALL RIGHTS RESERVED + * </pre> + ****************************************************************************/ +#include <vespa/fastos/fastos.h> +#include <vespa/vespalib/testkit/testapp.h> #include "matchobjectTest.h" #include "testenv.h" -#include <vespa/vespalib/testkit/testapp.h> /** * The MatchObjectTestApp class is the main routine for running the unit @@ -12,7 +29,7 @@ */ class MatchObjectTestApp : public vespalib::TestApp { public: - int Main() override { + virtual int Main() override { juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); MatchObjectTest test; test.SetStream(&std::cout); diff --git a/juniper/src/test/mcandTest.cpp b/juniper/src/test/mcandTest.cpp index 7f7d7d42100..b185707c1be 100644 --- a/juniper/src/test/mcandTest.cpp +++ b/juniper/src/test/mcandTest.cpp @@ -16,11 +16,11 @@ * ALL RIGHTS RESERVED * </pre> ***************************************************************************/ - -#include "mcandTest.h" - +#include <vespa/fastos/fastos.h> #include <vespa/log/log.h> -LOG_SETUP(".mcandtest"); +LOG_SETUP(""); +#include "mcandTest.h" +#include "testenv.h" // Comment out cerr below to ignore unimplemented tests #define NOTEST(name) \ @@ -405,13 +405,13 @@ struct MyTokenProcessor : public ITokenProcessor Matcher &_m; std::vector<size_t> _cands; MyTokenProcessor(Matcher &m) : _m(m), _cands() {} - void handle_token(Token &token) override { + virtual void handle_token(Token &token) override { _m.handle_token(token); const match_sequence *ms = _m.GetWorkSet(); _cands.push_back(ms[0].size()); LOG(info, "match_sequence[0].size(%zu)", _cands.back()); } - void handle_end(Token &token) override { + virtual void handle_end(Token &token) override { _m.handle_end(token); } }; diff --git a/juniper/src/test/mcandTest.h b/juniper/src/test/mcandTest.h index 3fc32ee9f5d..754c18ee9dd 100644 --- a/juniper/src/test/mcandTest.h +++ b/juniper/src/test/mcandTest.h @@ -196,7 +196,7 @@ protected: * print_progress which includes backspace does not work. * We'll use a single '.' instead. */ - void print_progress() override { *m_osptr << '.' << std::flush; } + virtual void print_progress() override { *m_osptr << '.' << std::flush; } public: @@ -207,7 +207,7 @@ public: * main entry points *************************************************************************/ void Run(MethodContainer::iterator &itr); - void Run() override; + virtual void Run() override; void Run(const char *method); void Run(int argc, char* argv[]); }; diff --git a/juniper/src/test/mcandTestApp.cpp b/juniper/src/test/mcandTestApp.cpp index cb33e503bb5..8a93c14cfc9 100644 --- a/juniper/src/test/mcandTestApp.cpp +++ b/juniper/src/test/mcandTestApp.cpp @@ -1,7 +1,25 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "mcandTest.h" +/** + * Definition and implementation of the application for running unit tests + * for the MatchCandidate class in isolation. + * + * @file mcandTestApp.cpp + * + * @author Knut Omang + * + * @date Created 27 Feb 2003 + * + * $Id$ + * + * <pre> + * Copyright (c) : 2003 Fast Search & Transfer ASA + * ALL RIGHTS RESERVED + * </pre> + ****************************************************************************/ +#include <vespa/fastos/fastos.h> #include <vespa/vespalib/testkit/testapp.h> +#include "mcandTest.h" +#include "testenv.h" /** * The MatchCandidateTestApp class is the main routine for running the unit @@ -11,7 +29,7 @@ */ class MatchCandidateTestApp : public vespalib::TestApp { public: - int Main() override { + virtual int Main() override { juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); MatchCandidateTest test; test.SetStream(&std::cout); diff --git a/juniper/src/test/queryparserTest.h b/juniper/src/test/queryparserTest.h index d868fca659e..b4f464f7592 100644 --- a/juniper/src/test/queryparserTest.h +++ b/juniper/src/test/queryparserTest.h @@ -17,11 +17,11 @@ ***************************************************************************/ #pragma once +#include <map> +#include <vespa/fastlib/testsuite/test.h> #include "testenv.h" #include <vespa/juniper/queryparser.h> #include <vespa/juniper/rewriter.h> -#include <vespa/fastlib/testsuite/test.h> -#include <map> /** * The QueryParserTest class holds @@ -97,7 +97,7 @@ protected: * print_progress which includes backspace does not work. * We'll use a single '.' instead. */ - void print_progress() override { *m_osptr << '.' << std::flush; } + virtual void print_progress() override { *m_osptr << '.' << std::flush; } public: @@ -108,7 +108,7 @@ public: * main entry points *************************************************************************/ void Run(MethodContainer::iterator &itr); - void Run() override; + virtual void Run() override; void Run(const char *method); void Run(int argc, char* argv[]); }; diff --git a/juniper/src/test/queryparserTestApp.cpp b/juniper/src/test/queryparserTestApp.cpp index 7b3151a2314..3559b0177b6 100644 --- a/juniper/src/test/queryparserTestApp.cpp +++ b/juniper/src/test/queryparserTestApp.cpp @@ -1,8 +1,25 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +/** + * Definition and implementation of the application for running unit tests + * for the QueryParser class in isolation. + * + * @file queryparserTestApp.cpp + * + * @author Knut Omang + * + * @date Created 24 Feb 2003 + * + * $Id$ + * + * <pre> + * Copyright (c) : 2003 Fast Search & Transfer ASA + * ALL RIGHTS RESERVED + * </pre> + ****************************************************************************/ +#include <vespa/fastos/fastos.h> +#include <vespa/vespalib/testkit/testapp.h> #include "queryparserTest.h" #include "testenv.h" -#include <vespa/vespalib/testkit/testapp.h> /** * The QueryParserTestApp class is the main routine for running the unit @@ -12,7 +29,7 @@ */ class QueryParserTestApp : public vespalib::TestApp { public: - int Main() override { + virtual int Main() override { juniper::TestEnv te(this, TEST_PATH("../rpclient/testclient.rc").c_str()); QueryParserTest test; test.SetStream(&std::cout); diff --git a/juniper/src/test/testenv.h b/juniper/src/test/testenv.h index cc126f3f3a5..88d250767fc 100644 --- a/juniper/src/test/testenv.h +++ b/juniper/src/test/testenv.h @@ -20,7 +20,6 @@ #include <vespa/juniper/mcand.h> #include <vespa/juniper/propreader.h> #include <vespa/juniper/specialtokenregistry.h> -#include <vespa/fastos/app.h> namespace juniper { @@ -56,9 +55,9 @@ private: std::map<std::string, std::string> _map; public: PropertyMap(); - ~PropertyMap(); + virtual ~PropertyMap(); PropertyMap &set(const char *name, const char *value); - const char* GetProperty(const char* name, const char* def = NULL) override; + virtual const char* GetProperty(const char* name, const char* def = NULL) override; }; diff --git a/memfilepersistence/src/tests/device/devicemanagertest.cpp b/memfilepersistence/src/tests/device/devicemanagertest.cpp index f5e16032361..15882663383 100644 --- a/memfilepersistence/src/tests/device/devicemanagertest.cpp +++ b/memfilepersistence/src/tests/device/devicemanagertest.cpp @@ -1,8 +1,10 @@ // 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/memfilepersistence/device/devicemanager.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/util/exception.h> +#include <sys/errno.h> #include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> namespace storage { @@ -68,17 +70,19 @@ namespace { std::ostringstream ost; Listener() : ost() { ost << "\n"; } - ~Listener() {} + virtual ~Listener() {} - void handleDirectoryEvent(Directory& dir, const IOEvent& e) override { + virtual void handleDirectoryEvent(Directory& dir, const IOEvent& e) override { ost << "Dir " << dir.getPath() << ": " << e.toString(true) << "\n"; } - void handlePartitionEvent(Partition& part, const IOEvent& e) override { - ost << "Partition " << part.getMountPoint() << ": " << e.toString(true) << "\n"; + virtual void handlePartitionEvent(Partition& part, const IOEvent& e) override { + ost << "Partition " << part.getMountPoint() << ": " + << e.toString(true) << "\n"; } - void handleDiskEvent(Disk& disk, const IOEvent& e) override { + virtual void handleDiskEvent(Disk& disk, const IOEvent& e) override { ost << "Disk " << disk.getId() << ": " << e.toString(true) << "\n"; } + }; } diff --git a/memfilepersistence/src/tests/device/partitionmonitortest.cpp b/memfilepersistence/src/tests/device/partitionmonitortest.cpp index d1f40e07320..44f3752d840 100644 --- a/memfilepersistence/src/tests/device/partitionmonitortest.cpp +++ b/memfilepersistence/src/tests/device/partitionmonitortest.cpp @@ -1,5 +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/memfilepersistence/device/partitionmonitor.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vdstestlib/cppunit/macros.h> @@ -55,7 +56,7 @@ struct FakeStatter : public PartitionMonitor::Statter { _info.f_bfree -= (size / _info.f_bsize); } - void statFileSystem(const std::string&, struct statvfs& info) override { + virtual void statFileSystem(const std::string&, struct statvfs& info) override { info = _info; } }; diff --git a/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp b/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp index 4372a8a45a7..673a72068b7 100644 --- a/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp +++ b/memfilepersistence/src/tests/spi/iteratorhandlertest.cpp @@ -1,9 +1,14 @@ // 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 <set> +#include <vector> +#include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> #include <tests/spi/memfiletestutils.h> #include <tests/spi/simulatedfailurefile.h> #include <tests/spi/options_builder.h> +#include <vespa/document/fieldset/fieldsets.h> #include <vespa/document/select/parser.h> namespace storage { diff --git a/memfilepersistence/src/tests/spi/memcachetest.cpp b/memfilepersistence/src/tests/spi/memcachetest.cpp index 7eece580b0a..07697b79cac 100644 --- a/memfilepersistence/src/tests/spi/memcachetest.cpp +++ b/memfilepersistence/src/tests/spi/memcachetest.cpp @@ -1,8 +1,10 @@ // 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/memfilepersistence/memfile/memfilecache.h> #include <vespa/storageframework/defaultimplementation/memory/simplememorylogic.h> #include <tests/spi/memfiletestutils.h> +#include <vespa/vdstestlib/cppunit/macros.h> namespace storage { diff --git a/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp b/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp index 265054a02ba..eefe962979d 100644 --- a/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp +++ b/memfilepersistence/src/tests/spi/memfileautorepairtest.cpp @@ -1,9 +1,13 @@ // 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/memfilepersistence/mapper/memfilemapper.h> #include <vespa/memfilepersistence/mapper/memfile_v1_serializer.h> #include <vespa/memfilepersistence/mapper/memfile_v1_verifier.h> +#include <vespa/memfilepersistence/mapper/fileinfo.h> +#include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> #include <tests/spi/memfiletestutils.h> +#include <vespa/vdstestlib/cppunit/macros.h> namespace storage { namespace memfile { diff --git a/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp b/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp index f612bec1189..ad20a28ed0c 100644 --- a/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp +++ b/memfilepersistence/src/tests/spi/memfilev1serializertest.cpp @@ -1,8 +1,11 @@ // 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/memfilepersistence/mapper/memfilemapper.h> #include <vespa/memfilepersistence/mapper/memfile_v1_serializer.h> +#include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> #include <tests/spi/memfiletestutils.h> +#include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/memfilepersistence/mapper/locationreadplanner.h> #include <tests/spi/simulatedfailurefile.h> #include <tests/spi/options_builder.h> @@ -226,16 +229,23 @@ struct DummyMemFileIOInterface : MemFileIOInterface { void clear(DocumentPart) override {} bool verifyConsistent() const override { return true; } void move(const FileSpecification&) override {} - DataLocation copyCache(const MemFileIOInterface&, DocumentPart, DataLocation) override { + DataLocation copyCache(const MemFileIOInterface&, + DocumentPart, + DataLocation) override + { return DataLocation(); } - void close() override {}; + void close() override {} bool isCached(DataLocation, DocumentPart) const override { return false; } bool isPersisted(DataLocation, DocumentPart) const override { return false; } - uint32_t getSerializedSize(DocumentPart, DataLocation) const override { return 0; } + uint32_t getSerializedSize(DocumentPart, + DataLocation) const override { return 0; } - void ensureCached(Environment&, DocumentPart, const std::vector<DataLocation>&) override {} + void ensureCached(Environment&, + DocumentPart, + const std::vector<DataLocation>&) override + {} size_t getCachedSize(DocumentPart) const override { return 0; } }; diff --git a/memfilepersistence/src/tests/spi/memfilev1verifiertest.cpp b/memfilepersistence/src/tests/spi/memfilev1verifiertest.cpp index 632bded6c6c..51951e22aea 100644 --- a/memfilepersistence/src/tests/spi/memfilev1verifiertest.cpp +++ b/memfilepersistence/src/tests/spi/memfilev1verifiertest.cpp @@ -1,9 +1,14 @@ // 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/memfilepersistence/mapper/memfilemapper.h> #include <vespa/memfilepersistence/mapper/memfile_v1_serializer.h> #include <vespa/memfilepersistence/mapper/memfile_v1_verifier.h> +#include <vespa/memfilepersistence/mapper/fileinfo.h> +#include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> #include <tests/spi/memfiletestutils.h> +#include <vespa/vdstestlib/cppunit/macros.h> +#include <tests/spi/simulatedfailurefile.h> namespace storage { namespace memfile { diff --git a/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp b/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp index cb1bc057705..ffe7972552f 100644 --- a/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp +++ b/memfilepersistence/src/tests/spi/simplememfileiobuffertest.cpp @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> +#include <vespa/vdstestlib/cppunit/macros.h> #include <tests/spi/memfiletestutils.h> #include <tests/spi/options_builder.h> @@ -50,15 +51,19 @@ class SimpleMemFileIOBufferTest : public SingleDiskMemFileTestUtils public: class DummyFileReader : public VersionSerializer { public: - FileVersion getFileVersion() override { return FileVersion(); } - void loadFile(MemFile&, Environment&, Buffer&, uint64_t ) override {} - FlushResult flushUpdatesToFile(MemFile&, Environment&) override { + virtual FileVersion getFileVersion() override { return FileVersion(); } + virtual void loadFile(MemFile&, Environment&, Buffer&, uint64_t ) override {} + virtual FlushResult flushUpdatesToFile(MemFile&, Environment&) override { return FlushResult::TooSmall; } - void rewriteFile(MemFile&, Environment&) override {} - bool verify(MemFile&, Environment&, std::ostream&, bool, uint16_t) override { return false; }; - void cacheLocations(MemFileIOInterface&, Environment&, const Options&, - DocumentPart, const std::vector<DataLocation>&) override {} + virtual void rewriteFile(MemFile&, Environment&) override {} + virtual bool verify(MemFile&, Environment&, + std::ostream&, bool, uint16_t) override { return false; }; + virtual void cacheLocations(MemFileIOInterface&, + Environment&, + const Options&, + DocumentPart, + const std::vector<DataLocation>&) override {} }; DummyFileReader dfr; diff --git a/memfilepersistence/src/tests/testrunner.cpp b/memfilepersistence/src/tests/testrunner.cpp index 5baa0f60b6e..16027870c47 100644 --- a/memfilepersistence/src/tests/testrunner.cpp +++ b/memfilepersistence/src/tests/testrunner.cpp @@ -1,12 +1,14 @@ // 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 <iostream> +#include <vespa/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("persistencecppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp b/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp index 5de40311b2f..0f36f0a0571 100644 --- a/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp +++ b/memfilepersistence/src/tests/tools/vdsdisktooltest.cpp @@ -1,5 +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/config/subscription/configuri.h> #include <vespa/memfilepersistence/tools/vdsdisktool.h> #include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h b/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h index cc2145444a5..23e4857fdb3 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h +++ b/memfilepersistence/src/vespa/memfilepersistence/common/filespecification.h @@ -37,7 +37,8 @@ public: const String& getPath() const { return _path; } FileVersion getWantedFileVersion() const { return _wantedVersion; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, + const std::string& indent) const override; bool operator==(const FileSpecification& o) const { return (_bucketId == o._bucketId && _dir == o._dir @@ -47,3 +48,4 @@ public: } // storage } // memfile + diff --git a/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.cpp b/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.cpp index b0fa6cf6667..b483d4691c4 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/device/partitionmonitor.cpp @@ -26,7 +26,8 @@ namespace { } struct RealStatter : public PartitionMonitor::Statter { - void statFileSystem(const std::string& file, struct statvfs& info) override { + virtual void statFileSystem(const std::string& file, struct statvfs& info) override + { if (statvfs(file.c_str(), &info) != 0) { vespalib::asciistream ost; ost << "Failed to run statvfs to find data on disk containing " diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp index d9cc0c35cc4..742a37fcf36 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.cpp @@ -3,13 +3,16 @@ #include "memfile_v1_serializer.h" #include "memfile_v1_verifier.h" +#include "memfilemapper.h" #include "locationreadplanner.h" #include "uniqueslotgenerator.h" +#include "simplememfileiobuffer.h" #include <vespa/memfilepersistence/common/exceptions.h> #include <vespa/memfilepersistence/spi/memfilepersistenceprovidermetrics.h> +#include <vespa/vespalib/util/crc.h> #include <vespa/vespalib/stllike/asciistream.h> - #include <vespa/log/log.h> + LOG_SETUP(".persistence.memfilev1"); namespace storage { @@ -739,16 +742,19 @@ namespace { _buffer.resize(firstAligned - _headerBlockIndex); } - uint32_t getCachedAmount() const override { return _buffer.size() + _headerBlockIndex; } - char* getCache(uint32_t pos) override { + virtual uint32_t getCachedAmount() const override + { return _buffer.size() + _headerBlockIndex; } + + virtual char* getCache(uint32_t pos) override { // We should never get requests to write prior to header block // index. assert(pos >= _headerBlockIndex); return (&_buffer[0] + (pos - _headerBlockIndex)); } - bool duplicateCacheWrite() const override { return true; } - void setData(const char* data, size_t len, uint64_t pos) override { + virtual bool duplicateCacheWrite() const override { return true; } + + virtual void setData(const char* data, size_t len, uint64_t pos) override { if (pos < _headerBlockIndex) { if (len <= _headerBlockIndex - pos) return; uint32_t diff = (_headerBlockIndex - pos); diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h index 500c47e94e4..283ab174895 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/memfile_v1_serializer.h @@ -1,10 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "bufferedfilewriter.h" -#include "versionserializer.h" -#include "fileinfo.h" -#include "simplememfileiobuffer.h" +#include <vespa/memfilepersistence/mapper/bufferedfilewriter.h> +#include <vespa/memfilepersistence/mapper/versionserializer.h> +#include <vespa/memfilepersistence/mapper/fileinfo.h> +#include <vespa/memfilepersistence/mapper/simplememfileiobuffer.h> #include <vespa/memfilepersistence/common/environment.h> #include <vespa/memfilepersistence/spi/threadmetricprovider.h> @@ -22,25 +22,40 @@ public: MemFileV1Serializer(ThreadMetricProvider&); - FileVersion getFileVersion() override { return TRADITIONAL_SLOTFILE; } - void loadFile(MemFile& file, Environment&, Buffer& buffer, uint64_t bytesRead) override; + virtual FileVersion getFileVersion() override { return TRADITIONAL_SLOTFILE; } - void cacheLocationsForPart(SimpleMemFileIOBuffer& cache, DocumentPart part, uint32_t blockIndex, + virtual void loadFile(MemFile& file, Environment&, + Buffer& buffer, uint64_t bytesRead) override; + + void cacheLocationsForPart(SimpleMemFileIOBuffer& cache, + DocumentPart part, + uint32_t blockIndex, const std::vector<DataLocation>& locationsToCache, const std::vector<DataLocation>& locationsRead, SimpleMemFileIOBuffer::BufferAllocation& buf); - void cacheLocations(MemFileIOInterface& cache, Environment& env, const Options& options, - DocumentPart part, const std::vector<DataLocation>& locations) override; + virtual void cacheLocations(MemFileIOInterface& cache, + Environment& env, + const Options& options, + DocumentPart part, + const std::vector<DataLocation>& locations) override; + + virtual FlushResult flushUpdatesToFile(MemFile&, Environment&) override; + + virtual void rewriteFile(MemFile&, Environment&) override; - FlushResult flushUpdatesToFile(MemFile&, Environment&) override; - void rewriteFile(MemFile&, Environment&) override; - bool verify(MemFile&, Environment&, std::ostream& errorReport, - bool repairErrors, uint16_t fileVerifyFlags) override; + virtual bool verify(MemFile&, Environment&, + std::ostream& errorReport, bool repairErrors, + uint16_t fileVerifyFlags) override; + + uint64_t read(vespalib::LazyFile& file, + char* buf, + const std::vector<DataLocation>& readOps); - uint64_t read(vespalib::LazyFile& file, char* buf, const std::vector<DataLocation>& readOps); void ensureFormatSpecificDataSet(const MemFile& file); - uint32_t writeMetaData(BufferedFileWriter& writer, const MemFile& file); + + uint32_t writeMetaData(BufferedFileWriter& writer, + const MemFile& file); uint32_t writeAndUpdateLocations( MemFile& file, @@ -53,3 +68,4 @@ public: } // memfile } // storage + diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h index 74875d3ee79..6ed529e6c80 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.h @@ -199,7 +199,8 @@ public: class PartNotCachedException : public vespalib::Exception { public: - PartNotCachedException(const std::string& msg, const std::string& location) + PartNotCachedException(const std::string& msg, + const std::string& location) : vespalib::Exception(msg, location) {}; }; @@ -210,39 +211,64 @@ public: const FileSpecification& fileSpec, const Environment& env); - Document::UP getDocumentHeader(const document::DocumentTypeRepo& repo, DataLocation loc) const override; - document::DocumentId getDocumentId(DataLocation loc) const override; - void readBody(const document::DocumentTypeRepo& repo, DataLocation loc, Document& doc) const override; - DataLocation addDocumentIdOnlyHeader(const DocumentId& id, const document::DocumentTypeRepo& repo) override; - DataLocation addHeader(const Document& doc) override; - DataLocation addBody(const Document& doc) override; - void clear(DocumentPart type) override; - bool verifyConsistent() const override; + virtual Document::UP getDocumentHeader( + const document::DocumentTypeRepo& repo, + DataLocation loc) const override; + + virtual document::DocumentId getDocumentId(DataLocation loc) const override; + + virtual void readBody( + const document::DocumentTypeRepo& repo, + DataLocation loc, + Document& doc) const override; + + virtual DataLocation addDocumentIdOnlyHeader( + const DocumentId& id, + const document::DocumentTypeRepo& repo) override; + + virtual DataLocation addHeader(const Document& doc) override; + + virtual DataLocation addBody(const Document& doc) override; + + virtual void clear(DocumentPart type) override; + + virtual bool verifyConsistent() const override; /** * Moves the underlying file to another location. */ - void move(const FileSpecification& target) override; - void close() override; - DataLocation copyCache(const MemFileIOInterface& source, DocumentPart part, DataLocation loc) override; + virtual void move(const FileSpecification& target) override; + + virtual void close() override; + + virtual DataLocation copyCache(const MemFileIOInterface& source, + DocumentPart part, + DataLocation loc) override; /** * Add a location -> buffer mapping */ - void cacheLocation(DocumentPart part, DataLocation loc, BufferType::SP buf, uint32_t bufferPos); + void cacheLocation(DocumentPart part, + DataLocation loc, + BufferType::SP buf, + uint32_t bufferPos); /** * @return Returns true if the given location is cached. */ - bool isCached(DataLocation loc, DocumentPart type) const override; + virtual bool isCached(DataLocation loc, DocumentPart type) const override; /** * @return Returns true if the given location has been persisted to disk. */ + virtual bool isPersisted(DataLocation loc, DocumentPart type) const override; - bool isPersisted(DataLocation loc, DocumentPart type) const override; - uint32_t getSerializedSize(DocumentPart part, DataLocation loc) const override; - void ensureCached(Environment& env, DocumentPart part, const std::vector<DataLocation>& locations) override; + virtual uint32_t getSerializedSize(DocumentPart part, + DataLocation loc) const override; + + virtual void ensureCached(Environment& env, + DocumentPart part, + const std::vector<DataLocation>& locations) override; /** * Moves the given location into the persisted data area. @@ -316,9 +342,14 @@ private: // the reasoning about a given bucket in the face of such actions. std::shared_ptr<const Options> _options; - DataLocation addLocation(DocumentPart part, BufferAllocation newData); + DataLocation addLocation(DocumentPart part, + BufferAllocation newData); + const Data& getData(DocumentPart part, DataLocation loc) const; - BufferAllocation serializeDocumentIdOnlyHeader(const DocumentId& id, const document::DocumentTypeRepo&); + + BufferAllocation serializeDocumentIdOnlyHeader( + const DocumentId& id, + const document::DocumentTypeRepo&); BufferAllocation serializeHeader(const Document& doc); BufferAllocation serializeBody(const Document& doc); @@ -327,3 +358,5 @@ private: } } + + diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h index f22035faf04..b3ac15ed376 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfile.h @@ -27,12 +27,12 @@ #pragma once -#include "memslot.h" -#include "slotiterator.h" -#include "memfileiointerface.h" #include <vespa/memfilepersistence/common/filespecification.h> #include <vespa/memfilepersistence/common/types.h> +#include <vespa/memfilepersistence/memfile/memslot.h> +#include <vespa/memfilepersistence/memfile/slotiterator.h> #include <vespa/vespalib/io/fileutil.h> +#include <vespa/memfilepersistence/memfile/memfileiointerface.h> namespace storage { namespace memfile { diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp index e8fff0facd0..8ea60d57f80 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/memfilecache.cpp @@ -1,16 +1,19 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "memfilecache.h" +#include <vespa/fastos/fastos.h> #include <vespa/memfilepersistence/common/environment.h> #include <vespa/memfilepersistence/mapper/memfilemapper.h> +#include <vespa/memfilepersistence/memfile/memfilecache.h> +#include <vespa/log/log.h> +#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/memfilepersistence/spi/memfilepersistenceprovidermetrics.h> -#include <vespa/log/log.h> LOG_SETUP(".persistence.memfile.cache"); namespace storage { namespace memfile { + void MemFileCache::Entry::setInUse(bool inUse) { LOG(debug, "Setting in use to %d for file %s", inUse, _file.toString().c_str()); @@ -108,7 +111,7 @@ struct MemFileCache::CacheEntryGuard : public MemFilePtr::EntryGuard { _entry(&entry) { } - ~CacheEntryGuard() { + virtual ~CacheEntryGuard() { if (_entry) { _cache.done(*_entry); } @@ -118,20 +121,20 @@ struct MemFileCache::CacheEntryGuard : public MemFilePtr::EntryGuard { return _entry->_file; } - void deleteFile() override { + virtual void deleteFile() override { LOG(debug, "Cache entry guard deleting %s", _file->toString().c_str()); _env._memFileMapper.deleteFile(*_file, _env); erase(); } - void erase() override { + virtual void erase() override { LOG(debug, "Cache entry guard erasing %s from cache", _file->toString().c_str()); _cache.erase(document::BucketId(_entry->_file.getFile().getBucketId())); _entry = 0; } - void move(EntryGuard& target) override { + virtual void move(EntryGuard& target) override { LOG(debug, "Cache entry guard moving %s", _file->toString().c_str()); _cache.move(*this, static_cast<CacheEntryGuard&>(target)); } @@ -172,7 +175,10 @@ MemFileCache::setCacheSize(MemoryUsage cacheSize) vespalib::LockGuard lock(_cacheLock); _cacheLimit = cacheSize; - _memoryToken->resize(std::min(_memoryToken->getSize(), _cacheLimit.sum()), _cacheLimit.sum()); + + _memoryToken->resize(std::min(_memoryToken->getSize(), _cacheLimit.sum()), + _cacheLimit.sum()); + evictWhileFull(); } diff --git a/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h b/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h index 91106cd765b..b1d68591b92 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h +++ b/memfilepersistence/src/vespa/memfilepersistence/memfile/slotiterator.h @@ -65,8 +65,8 @@ public: Timestamp fromTimestamp, Timestamp toTimestamp); - void iterate() const override; - SlotIterator* clone() const override; + virtual void iterate() const override; + virtual SlotIterator* clone() const override; }; class AllSlotsIterator : public SlotIterator { @@ -82,8 +82,8 @@ public: Timestamp fromTimestamp, Timestamp toTimestamp); - void iterate() const override; - SlotIterator* clone() const override; + virtual void iterate() const override; + virtual SlotIterator* clone() const override; }; /** @@ -127,3 +127,4 @@ public: } // memfile } // storage + diff --git a/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp b/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp index 9e75e4fa182..247722588f5 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/spi/splitoperationhandler.cpp @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "splitoperationhandler.h" -#include "cacheevictionguard.h" - +#include <vespa/fastos/fastos.h> +#include <vespa/memfilepersistence/spi/splitoperationhandler.h> +#include <vespa/memfilepersistence/spi/cacheevictionguard.h> #include <vespa/log/log.h> + LOG_SETUP(".persistence.memfile.handler.split"); namespace storage { @@ -25,7 +25,7 @@ struct BucketMatcher : public SlotMatcher { _factory(factory), _bid(bid) {} - bool match(const Slot& slot) override { + virtual bool match(const Slot& slot) override { document::DocumentId id(slot.getDocumentId()); document::BucketId bucket = _factory.getBucketId(id); bucket.setUsedBits(_bid.getUsedBits()); @@ -69,7 +69,7 @@ SplitOperationHandler::splitIntoFile(MemFile& source, MemFileCacheEvictionGuard targetFile(getMemFile(target, false)); LOG(debug, - "Found %zu slots to move from file %s to file %s", + "Found %" PRIu64 " slots to move from file %s to file %s", ts.size(), source.getFile().toString().c_str(), targetFile->getFile().toString().c_str()); diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp index 072b3e9fae0..c794d611767 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp @@ -1,6 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "dumpslotfile.h" + #include <vespa/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> @@ -9,6 +9,7 @@ #include <vespa/memfilepersistence/mapper/memfilemapper.h> #include <vespa/memfilepersistence/memfile/memfilecache.h> #include <vespa/memfilepersistence/spi/memfilepersistenceprovidermetrics.h> +#include <vespa/memfilepersistence/tools/dumpslotfile.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> #include <vespa/storageframework/defaultimplementation/memory/nomemorymanager.h> diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp index 544be9c5eac..f8d13714ae9 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfileapp.cpp @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "dumpslotfile.h" +#include <vespa/fastos/fastos.h> #include <vespa/config/subscription/configuri.h> -#include <vespa/fastos/app.h> +#include <vespa/memfilepersistence/tools/dumpslotfile.h> #include <iostream> namespace { diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp index 34855aeabc1..7127c75cb1b 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/vdsdiskapp.cpp @@ -1,10 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "vdsdisktool.h" +#include <vespa/fastos/fastos.h> #include <vespa/defaults.h> -#include <vespa/fastos/app.h> +#include <vespa/log/log.h> +#include <vespa/memfilepersistence/tools/vdsdisktool.h> #include <iostream> +LOG_SETUP(".vdsdisktool"); + namespace { struct DiskApp : public FastOS_Application { int Main() override { diff --git a/messagebus/src/tests/context/context.cpp b/messagebus/src/tests/context/context.cpp index 3ba19e8f858..5ad36df7c72 100644 --- a/messagebus/src/tests/context/context.cpp +++ b/messagebus/src/tests/context/context.cpp @@ -27,7 +27,7 @@ struct Handler : public IMessageHandler ~Handler() { session.reset(); } - void handleMessage(Message::UP msg) override { + virtual void handleMessage(Message::UP msg) override { session->acknowledge(std::move(msg)); } }; diff --git a/messagebus/src/tests/loadbalance/loadbalance.cpp b/messagebus/src/tests/loadbalance/loadbalance.cpp index 9e2a6e48d24..83ff4c042da 100644 --- a/messagebus/src/tests/loadbalance/loadbalance.cpp +++ b/messagebus/src/tests/loadbalance/loadbalance.cpp @@ -28,7 +28,7 @@ struct Handler : public IMessageHandler ~Handler() { session.reset(); } - void handleMessage(Message::UP msg) override { + virtual void handleMessage(Message::UP msg) override { ++cnt; session->acknowledge(std::move(msg)); } diff --git a/messagebus/src/tests/messageordering/messageordering.cpp b/messagebus/src/tests/messageordering/messageordering.cpp index df6ca38dd0d..e80505b2e89 100644 --- a/messagebus/src/tests/messageordering/messageordering.cpp +++ b/messagebus/src/tests/messageordering/messageordering.cpp @@ -46,8 +46,8 @@ public: _destinationSession(0), _messageCounter(0) {} - void handleMessage(Message::UP msg) override - { + virtual void handleMessage(Message::UP msg) override + { SimpleMessage& simpleMsg(dynamic_cast<SimpleMessage&>(*msg)); LOG(spam, "Attempting to acquire lock for %s", simpleMsg.getValue().c_str()); diff --git a/messagebus/src/tests/messenger/messenger.cpp b/messagebus/src/tests/messenger/messenger.cpp index 7b2b75212ee..5cf3625523f 100644 --- a/messagebus/src/tests/messenger/messenger.cpp +++ b/messagebus/src/tests/messenger/messenger.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("messagebus_test"); #include <vespa/messagebus/messenger.h> #include <vespa/vespalib/util/barrier.h> diff --git a/messagebus/src/tests/oos/oos.cpp b/messagebus/src/tests/oos/oos.cpp index dc224a1519c..b19de4a94f8 100644 --- a/messagebus/src/tests/oos/oos.cpp +++ b/messagebus/src/tests/oos/oos.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("oos_test"); #include <vespa/messagebus/destinationsession.h> #include <vespa/messagebus/errorcode.h> @@ -28,7 +31,7 @@ struct Handler : public IMessageHandler ~Handler() { session.reset(); } - void handleMessage(Message::UP msg) override { + virtual void handleMessage(Message::UP msg) override { session->acknowledge(std::move(msg)); } }; diff --git a/messagebus/src/tests/protocolrepository/protocolrepository.cpp b/messagebus/src/tests/protocolrepository/protocolrepository.cpp index f9c971336c5..cf1d77bdc7e 100644 --- a/messagebus/src/tests/protocolrepository/protocolrepository.cpp +++ b/messagebus/src/tests/protocolrepository/protocolrepository.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("protocolrepository_test"); #include <vespa/messagebus/protocolrepository.h> #include <vespa/vespalib/testkit/testapp.h> diff --git a/messagebus/src/tests/replygate/replygate.cpp b/messagebus/src/tests/replygate/replygate.cpp index 8f784495866..d190f278be4 100644 --- a/messagebus/src/tests/replygate/replygate.cpp +++ b/messagebus/src/tests/replygate/replygate.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("replygate_test"); #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/imessagehandler.h> @@ -41,7 +44,7 @@ struct MySender : public IMessageHandler { // giving a sync reply here is against the API contract, but it is // ok for testing. - void handleMessage(Message::UP msg) override { + virtual void handleMessage(Message::UP msg) override { Reply::UP reply(new MyReply()); msg->swapState(*reply); IReplyHandler &handler = reply->getCallStack().pop(*reply); diff --git a/messagebus/src/tests/resender/resender.cpp b/messagebus/src/tests/resender/resender.cpp index 701ce20737c..dad8ef73e68 100644 --- a/messagebus/src/tests/resender/resender.cpp +++ b/messagebus/src/tests/resender/resender.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("routing_test"); #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/errorcode.h> diff --git a/messagebus/src/tests/result/result.cpp b/messagebus/src/tests/result/result.cpp index 963e44d1dda..a404135d64c 100644 --- a/messagebus/src/tests/result/result.cpp +++ b/messagebus/src/tests/result/result.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("result_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/messagebus/result.h> #include <vespa/messagebus/error.h> diff --git a/messagebus/src/tests/routablequeue/routablequeue.cpp b/messagebus/src/tests/routablequeue/routablequeue.cpp index 3f014236440..a6bd66bd5df 100644 --- a/messagebus/src/tests/routablequeue/routablequeue.cpp +++ b/messagebus/src/tests/routablequeue/routablequeue.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("routablequeue_test"); #include <vespa/messagebus/routablequeue.h> #include <vespa/messagebus/testlib/simplemessage.h> @@ -13,8 +16,8 @@ private: static uint32_t _cnt; public: TestMessage(uint32_t id) : SimpleMessage(""), _id(id) { ++_cnt; } - ~TestMessage() { --_cnt; } - uint32_t getType() const override { return _id; } + virtual ~TestMessage() { --_cnt; } + virtual uint32_t getType() const override { return _id; } static uint32_t getCnt() { return _cnt; } }; uint32_t TestMessage::_cnt = 0; @@ -25,8 +28,8 @@ private: static uint32_t _cnt; public: TestReply(uint32_t id) : SimpleReply(""), _id(id) { ++_cnt; } - ~TestReply() { --_cnt; } - uint32_t getType() const override { return _id; } + virtual ~TestReply() { --_cnt; } + virtual uint32_t getType() const override { return _id; } static uint32_t getCnt() { return _cnt; } }; uint32_t TestReply::_cnt = 0; diff --git a/messagebus/src/tests/routeparser/routeparser.cpp b/messagebus/src/tests/routeparser/routeparser.cpp index fc000fe571b..a00cea825ba 100644 --- a/messagebus/src/tests/routeparser/routeparser.cpp +++ b/messagebus/src/tests/routeparser/routeparser.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("routeparser_test"); #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/routing/errordirective.h> @@ -13,9 +16,6 @@ #include <vespa/messagebus/testlib/testserver.h> #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/log/log.h> -LOG_SETUP("routeparser_test"); - using namespace mbus; class Test : public vespalib::TestApp { diff --git a/messagebus/src/tests/routing/routing.cpp b/messagebus/src/tests/routing/routing.cpp index 8fd2c3951e4..506d003a8b7 100644 --- a/messagebus/src/tests/routing/routing.cpp +++ b/messagebus/src/tests/routing/routing.cpp @@ -1,4 +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 <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/messagebus.h> @@ -14,8 +15,8 @@ #include <vespa/messagebus/testlib/testserver.h> #include <vespa/vespalib/component/vtag.h> #include <vespa/vespalib/testkit/testapp.h> - #include <vespa/log/log.h> + LOG_SETUP("routing_test"); using namespace mbus; @@ -413,9 +414,12 @@ private: public: MyPolicy(const MyPolicyFactory &parent) : _parent(parent) - {} + { + // empty + } - void select(RoutingContext &ctx) override + virtual void + select(RoutingContext &ctx) override { if (!_parent._selectRoute.empty()) { ctx.addChild(Route::parse(_parent._selectRoute)); @@ -429,8 +433,9 @@ public: throw TestException(); } } - - void merge(RoutingContext &ctx) override + + virtual void + merge(RoutingContext &ctx) override { if (_parent._mergeError != ErrorCode::NONE) { Reply::UP reply(new EmptyReply()); diff --git a/messagebus/src/tests/routingcontext/routingcontext.cpp b/messagebus/src/tests/routingcontext/routingcontext.cpp index 281cf782a6b..6ee62b4d697 100644 --- a/messagebus/src/tests/routingcontext/routingcontext.cpp +++ b/messagebus/src/tests/routingcontext/routingcontext.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("routingcontext_test"); #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/errorcode.h> diff --git a/messagebus/src/tests/sendadapter/sendadapter.cpp b/messagebus/src/tests/sendadapter/sendadapter.cpp index 5ab1e57f0d4..bcac60d800a 100644 --- a/messagebus/src/tests/sendadapter/sendadapter.cpp +++ b/messagebus/src/tests/sendadapter/sendadapter.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("sendadapter_test"); #include <vespa/messagebus/messagebus.h> #include <vespa/messagebus/testlib/receptor.h> @@ -9,9 +12,6 @@ #include <vespa/messagebus/testlib/testserver.h> #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/log/log.h> -LOG_SETUP("sendadapter_test"); - using namespace mbus; //////////////////////////////////////////////////////////////////////////////// diff --git a/messagebus/src/tests/serviceaddress/serviceaddress.cpp b/messagebus/src/tests/serviceaddress/serviceaddress.cpp index ea6261f0169..ec2d1374e9b 100644 --- a/messagebus/src/tests/serviceaddress/serviceaddress.cpp +++ b/messagebus/src/tests/serviceaddress/serviceaddress.cpp @@ -1,12 +1,10 @@ // 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/log/log.h> +LOG_SETUP("serviceaddress_test"); #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/messagebus/testlib/slobrok.h> -#include <vespa/messagebus/testlib/testserver.h> -#include <vespa/messagebus/testlib/receptor.h> -#include <vespa/messagebus/testlib/simplemessage.h> -#include <vespa/messagebus/testlib/simplereply.h> -#include <vespa/messagebus/testlib/simpleprotocol.h> +#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/messagebus/messagebus.h> #include <vespa/messagebus/sourcesession.h> #include <vespa/messagebus/intermediatesession.h> @@ -17,7 +15,12 @@ #include <vespa/messagebus/routing/routingspec.h> #include <vespa/messagebus/network/rpcservice.h> #include <vespa/messagebus/sourcesessionparams.h> -#include <vespa/vespalib/util/vstringfmt.h> +#include <vespa/messagebus/testlib/slobrok.h> +#include <vespa/messagebus/testlib/testserver.h> +#include <vespa/messagebus/testlib/receptor.h> +#include <vespa/messagebus/testlib/simplemessage.h> +#include <vespa/messagebus/testlib/simplereply.h> +#include <vespa/messagebus/testlib/simpleprotocol.h> using namespace mbus; diff --git a/messagebus/src/tests/servicepool/servicepool.cpp b/messagebus/src/tests/servicepool/servicepool.cpp index 76c366930d9..8601cfa8fee 100644 --- a/messagebus/src/tests/servicepool/servicepool.cpp +++ b/messagebus/src/tests/servicepool/servicepool.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("servicepool_test"); #include <vespa/messagebus/network/rpcnetwork.h> #include <vespa/messagebus/testlib/slobrok.h> diff --git a/messagebus/src/tests/shutdown/shutdown.cpp b/messagebus/src/tests/shutdown/shutdown.cpp index 1f6944adb9e..5f5fe847f57 100644 --- a/messagebus/src/tests/shutdown/shutdown.cpp +++ b/messagebus/src/tests/shutdown/shutdown.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("shutdown_test"); #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/errorcode.h> diff --git a/messagebus/src/tests/sourcesession/sourcesession.cpp b/messagebus/src/tests/sourcesession/sourcesession.cpp index a7fde7f28e0..24d99f5d44f 100644 --- a/messagebus/src/tests/sourcesession/sourcesession.cpp +++ b/messagebus/src/tests/sourcesession/sourcesession.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("sourcesession_test"); #include <vespa/messagebus/destinationsession.h> #include <vespa/messagebus/error.h> @@ -31,7 +34,7 @@ struct DelayedHandler : public IMessageHandler ~DelayedHandler() { session.reset(); } - void handleMessage(Message::UP msg) override { + virtual void handleMessage(Message::UP msg) override { // this will block the transport thread in the server messagebus, // but that should be ok, as we only want to test the timing in the // client messagebus... diff --git a/messagebus/src/tests/targetpool/targetpool.cpp b/messagebus/src/tests/targetpool/targetpool.cpp index dda44765ba6..30744e74202 100644 --- a/messagebus/src/tests/targetpool/targetpool.cpp +++ b/messagebus/src/tests/targetpool/targetpool.cpp @@ -1,10 +1,11 @@ // 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/messagebus/network/rpctargetpool.h> #include <vespa/messagebus/testlib/slobrok.h> #include <vespa/messagebus/testlib/testserver.h> #include <vespa/vespalib/testkit/testapp.h> - #include <vespa/log/log.h> + LOG_SETUP("targetpool_test"); using namespace mbus; diff --git a/messagebus/src/tests/throttling/throttling.cpp b/messagebus/src/tests/throttling/throttling.cpp index a1065c44487..acc5b2ddc4d 100644 --- a/messagebus/src/tests/throttling/throttling.cpp +++ b/messagebus/src/tests/throttling/throttling.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("throttling_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/messagebus/destinationsession.h> diff --git a/messagebus/src/tests/timeout/timeout.cpp b/messagebus/src/tests/timeout/timeout.cpp index a14176cb1ef..d51ee34a08b 100644 --- a/messagebus/src/tests/timeout/timeout.cpp +++ b/messagebus/src/tests/timeout/timeout.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("timeout_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/emptyreply.h> diff --git a/messagebus/src/tests/trace-roundtrip/trace-roundtrip.cpp b/messagebus/src/tests/trace-roundtrip/trace-roundtrip.cpp index effe461c5a8..5a9324257b5 100644 --- a/messagebus/src/tests/trace-roundtrip/trace-roundtrip.cpp +++ b/messagebus/src/tests/trace-roundtrip/trace-roundtrip.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("simple-roundtrip_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/messagebus.h> diff --git a/messagebus/src/vespa/messagebus/dynamicthrottlepolicy.h b/messagebus/src/vespa/messagebus/dynamicthrottlepolicy.h index ff49f15b416..d552c3c48e9 100644 --- a/messagebus/src/vespa/messagebus/dynamicthrottlepolicy.h +++ b/messagebus/src/vespa/messagebus/dynamicthrottlepolicy.h @@ -164,8 +164,13 @@ public: */ uint32_t getMaxPendingCount() const { return (uint32_t)_windowSize; } + // Implements IThrottlePolicy. bool canSend(const Message &msg, uint32_t pendingCount) override; + + // Implements IThrottlePolicy. void processMessage(Message &msg) override; + + // Implements IThrottlePolicy. void processReply(Reply &reply) override; }; diff --git a/messagebus/src/vespa/messagebus/emptyreply.h b/messagebus/src/vespa/messagebus/emptyreply.h index db8beb33b9b..f2d431c8ada 100644 --- a/messagebus/src/vespa/messagebus/emptyreply.h +++ b/messagebus/src/vespa/messagebus/emptyreply.h @@ -26,23 +26,24 @@ public: * * @return "" */ - const string & getProtocol() const override; + virtual const string & getProtocol() const override; /** * This method returns the message type id reserved for empty replies: 0 * * @return 0 */ - uint32_t getType() const override; + virtual uint32_t getType() const override; /** * Encodes this reply into an empty blob. * * @return empty blob */ - Blob encode() const; + virtual Blob encode() const; uint8_t priority() const override { return 8; } }; } // namespace mbus + diff --git a/messagebus/src/vespa/messagebus/intermediatesession.h b/messagebus/src/vespa/messagebus/intermediatesession.h index b4832d5069a..064b223707f 100644 --- a/messagebus/src/vespa/messagebus/intermediatesession.h +++ b/messagebus/src/vespa/messagebus/intermediatesession.h @@ -87,7 +87,10 @@ public: */ const string getConnectionSpec() const; + // Implements IMessageHandler. void handleMessage(Message::UP message) override; + + // Implements IReplyHandler. void handleReply(Reply::UP reply) override; }; diff --git a/messagebus/src/vespa/messagebus/message.h b/messagebus/src/vespa/messagebus/message.h index cea0aaa91fb..6fc72af0055 100644 --- a/messagebus/src/vespa/messagebus/message.h +++ b/messagebus/src/vespa/messagebus/message.h @@ -35,9 +35,10 @@ public: * will log an error and generate an auto-reply to avoid having the sender * wait indefinetly for a reply. */ - ~Message(); + virtual ~Message(); - void swapState(Routable &rhs) override; + // Overrides Routable. + virtual void swapState(Routable &rhs) override; /** * Returns the timestamp for when this message was last seen by message @@ -138,7 +139,7 @@ public: * * @return false */ - bool isReply() const override { return false; } + virtual bool isReply() const override { return false; } /** * Returns whether or not this message contains a sequence identifier that diff --git a/messagebus/src/vespa/messagebus/messenger.h b/messagebus/src/vespa/messagebus/messenger.h index 70207029e19..fe76513eef9 100644 --- a/messagebus/src/vespa/messagebus/messenger.h +++ b/messagebus/src/vespa/messagebus/messenger.h @@ -47,6 +47,7 @@ private: bool _closed; protected: + // Implements FastOS_Runnable. void Run(FastOS_ThreadInterface *thread, void *arg) override; public: diff --git a/messagebus/src/vespa/messagebus/reply.h b/messagebus/src/vespa/messagebus/reply.h index f352d442931..8bc4f5921e0 100644 --- a/messagebus/src/vespa/messagebus/reply.h +++ b/messagebus/src/vespa/messagebus/reply.h @@ -39,10 +39,17 @@ public: * will log an error and generate an auto-reply to avoid having the sender * wait indefinetly for a reply. */ - ~Reply(); + virtual ~Reply(); - void swapState(Routable &rhs) override; - bool isReply() const override; + // Inherit doc from Routable. + virtual void swapState(Routable &rhs) override; + + /** + * Inherited from Routable. Classifies this object as 'a reply'. + * + * @return true + */ + virtual bool isReply() const override; /** * Add an Error to this Reply diff --git a/messagebus/src/vespa/messagebus/routablequeue.h b/messagebus/src/vespa/messagebus/routablequeue.h index acb99d7269a..ea2b14b64f6 100644 --- a/messagebus/src/vespa/messagebus/routablequeue.h +++ b/messagebus/src/vespa/messagebus/routablequeue.h @@ -76,14 +76,14 @@ public: * * @param msg the Message to handle **/ - void handleMessage(Message::UP msg) override; + virtual void handleMessage(Message::UP msg) override; /** * Handle a Reply by enqueuing it. * * @param reply the Reply to handle **/ - void handleReply(Reply::UP reply) override; + virtual void handleReply(Reply::UP reply) override; }; } // namespace mbus diff --git a/messagebus/src/vespa/messagebus/sendproxy.h b/messagebus/src/vespa/messagebus/sendproxy.h index e0212c4c222..ca0c3f39661 100644 --- a/messagebus/src/vespa/messagebus/sendproxy.h +++ b/messagebus/src/vespa/messagebus/sendproxy.h @@ -34,8 +34,13 @@ public: */ SendProxy(MessageBus &mbus, INetwork &net, Resender *resender); + // Implements IDiscardHandler. void handleDiscard(Context ctx) override; + + // Implements IMessageHandler. void handleMessage(Message::UP msg) override; + + // Implements IReplyHandler. void handleReply(Reply::UP reply) override; }; diff --git a/messagebus/src/vespa/messagebus/staticthrottlepolicy.h b/messagebus/src/vespa/messagebus/staticthrottlepolicy.h index 586451ea83a..b7cc6bdfe99 100644 --- a/messagebus/src/vespa/messagebus/staticthrottlepolicy.h +++ b/messagebus/src/vespa/messagebus/staticthrottlepolicy.h @@ -70,8 +70,13 @@ public: */ uint64_t getPendingSize() const; + // Implements IThrottlePolicy. bool canSend(const Message &msg, uint32_t pendingCount) override; + + // Implements IThrottlePolicy. void processMessage(Message &msg) override; + + // Implements IThrottlePolicy. void processReply(Reply &reply) override; }; diff --git a/messagebus/src/vespa/messagebus/systemtimer.h b/messagebus/src/vespa/messagebus/systemtimer.h index 4a83add0732..14156253067 100644 --- a/messagebus/src/vespa/messagebus/systemtimer.h +++ b/messagebus/src/vespa/messagebus/systemtimer.h @@ -12,6 +12,7 @@ namespace mbus { */ class SystemTimer : public ITimer { public: + // Implements ITimer. uint64_t getMilliTime() const override; }; diff --git a/messagebus/src/vespa/messagebus/testlib/custompolicy.h b/messagebus/src/vespa/messagebus/testlib/custompolicy.h index 4fec4efe7c2..953f4f3c92e 100644 --- a/messagebus/src/vespa/messagebus/testlib/custompolicy.h +++ b/messagebus/src/vespa/messagebus/testlib/custompolicy.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "simpleprotocol.h" #include <vespa/messagebus/routing/iroutingpolicy.h> +#include "simpleprotocol.h" namespace mbus { @@ -17,8 +17,8 @@ public: const std::vector<uint32_t> consumableErrors, const std::vector<Route> &routes); - void select(RoutingContext &context) override; - void merge(RoutingContext &context) override; + virtual void select(RoutingContext &context) override; + virtual void merge(RoutingContext &context) override; }; class CustomPolicyFactory : public SimpleProtocol::IPolicyFactory { @@ -37,3 +37,4 @@ public: }; } // namespace mbus + diff --git a/messagebus/src/vespa/messagebus/testlib/receptor.h b/messagebus/src/vespa/messagebus/testlib/receptor.h index 2e9a424b481..c64e60eb6de 100644 --- a/messagebus/src/vespa/messagebus/testlib/receptor.h +++ b/messagebus/src/vespa/messagebus/testlib/receptor.h @@ -20,10 +20,11 @@ private: Receptor &operator=(const Receptor &); public: Receptor(); - void handleMessage(Message::UP msg) override; - void handleReply(Reply::UP reply) override; + virtual void handleMessage(Message::UP msg) override; + virtual void handleReply(Reply::UP reply) override; Message::UP getMessage(double maxWait = 120.0); Reply::UP getReply(double maxWait = 120.0); }; } // namespace mbus + diff --git a/messagebus/src/vespa/messagebus/testlib/simplemessage.h b/messagebus/src/vespa/messagebus/testlib/simplemessage.h index aeee34045ff..cb14c48dd9f 100644 --- a/messagebus/src/vespa/messagebus/testlib/simplemessage.h +++ b/messagebus/src/vespa/messagebus/testlib/simplemessage.h @@ -8,9 +8,9 @@ namespace mbus { class SimpleMessage : public Message { private: - string _value; - bool _hasSeqId; - uint64_t _seqId; + string _value; + bool _hasSeqId; + uint64_t _seqId; public: SimpleMessage(const string &str); @@ -25,7 +25,9 @@ public: bool hasSequenceId() const override; uint64_t getSequenceId() const override; uint32_t getApproxSize() const override; + uint8_t priority() const override { return 8; } + string toString() const override { return _value; } }; diff --git a/messagebus/src/vespa/messagebus/testlib/simpleprotocol.h b/messagebus/src/vespa/messagebus/testlib/simpleprotocol.h index 0551d177898..843b7675b96 100644 --- a/messagebus/src/vespa/messagebus/testlib/simpleprotocol.h +++ b/messagebus/src/vespa/messagebus/testlib/simpleprotocol.h @@ -2,8 +2,9 @@ #pragma once -#include <vespa/messagebus/iprotocol.h> #include <map> +#include <string> +#include <vespa/messagebus/iprotocol.h> namespace mbus { @@ -48,7 +49,10 @@ public: */ SimpleProtocol(); - ~SimpleProtocol(); + /** + * Frees up any allocated resources. + */ + virtual ~SimpleProtocol(); /** * Registers a policy factory with this protocol under a given name. Whenever a policy is requested that @@ -68,10 +72,19 @@ public: */ static void simpleMerge(RoutingContext &ctx); + // Implements IProtocol. const string & getName() const override; - IRoutingPolicy::UP createPolicy(const string &name, const string ¶m) const override; + + // Implements IProtocol. + IRoutingPolicy::UP createPolicy(const string &name, + const string ¶m) const override; + + // Implements IProtocol. Blob encode(const vespalib::Version &version, const Routable &routable) const override; + + // Implements IProtocol. Routable::UP decode(const vespalib::Version &version, BlobRef data) const override; }; } // namespace mbus + diff --git a/messagebus/src/vespa/messagebus/testlib/simplereply.h b/messagebus/src/vespa/messagebus/testlib/simplereply.h index 3b9ac7fe21e..8016a517453 100644 --- a/messagebus/src/vespa/messagebus/testlib/simplereply.h +++ b/messagebus/src/vespa/messagebus/testlib/simplereply.h @@ -2,8 +2,9 @@ #pragma once -#include "simplemessage.h" +#include <string> #include <vespa/messagebus/reply.h> +#include "simplemessage.h" namespace mbus { @@ -18,10 +19,11 @@ public: virtual ~SimpleReply(); void setValue(const string &value); const string &getValue() const; - const string & getProtocol() const override; - uint32_t getType() const override; + virtual const string & getProtocol() const override; + virtual uint32_t getType() const override; uint8_t priority() const override { return 8; } }; } // namespace mbus + diff --git a/messagebus/src/vespa/messagebus/testlib/slobrok.cpp b/messagebus/src/vespa/messagebus/testlib/slobrok.cpp index fa71cb9f9ad..b3f02b1ad58 100644 --- a/messagebus/src/vespa/messagebus/testlib/slobrok.cpp +++ b/messagebus/src/vespa/messagebus/testlib/slobrok.cpp @@ -20,8 +20,7 @@ public: guard.wait(); } } - - void PerformTask() override { + virtual void PerformTask() override { vespalib::MonitorGuard guard(_mon); _done = true; guard.signal(); diff --git a/messagebus/src/vespa/messagebus/testlib/slobrok.h b/messagebus/src/vespa/messagebus/testlib/slobrok.h index 1677f6635f7..2f8d4180ba5 100644 --- a/messagebus/src/vespa/messagebus/testlib/slobrok.h +++ b/messagebus/src/vespa/messagebus/testlib/slobrok.h @@ -2,6 +2,7 @@ #pragma once +#include <memory> #include <vespa/messagebus/common.h> #include <vespa/slobrok/cfg.h> diff --git a/messagebus_test/src/tests/error/cpp-client.cpp b/messagebus_test/src/tests/error/cpp-client.cpp index 10d7eb7e521..19cb09b3738 100644 --- a/messagebus_test/src/tests/error/cpp-client.cpp +++ b/messagebus_test/src/tests/error/cpp-client.cpp @@ -1,15 +1,19 @@ // 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/log/log.h> +LOG_SETUP("cpp-client"); #include <vespa/messagebus/messagebus.h> #include <vespa/messagebus/sourcesession.h> -#include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/testlib/simplemessage.h> #include <vespa/messagebus/testlib/simplereply.h> #include <vespa/messagebus/testlib/simpleprotocol.h> #include <vespa/messagebus/rpcmessagebus.h> +#include <vespa/messagebus/errorcode.h> +#include <vespa/messagebus/iprotocol.h> +#include <vespa/messagebus/protocolset.h> #include <vespa/messagebus/sourcesessionparams.h> #include <vespa/messagebus/testlib/receptor.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/sync.h> using namespace mbus; diff --git a/messagebus_test/src/tests/error/cpp-server.cpp b/messagebus_test/src/tests/error/cpp-server.cpp index c738c871e9a..13cfa76984b 100644 --- a/messagebus_test/src/tests/error/cpp-server.cpp +++ b/messagebus_test/src/tests/error/cpp-server.cpp @@ -1,11 +1,18 @@ // 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/log/log.h> +LOG_SETUP("cpp-server"); #include <vespa/messagebus/messagebus.h> +#include <vespa/messagebus/destinationsession.h> +#include <vespa/messagebus/testlib/simplemessage.h> +#include <vespa/messagebus/testlib/simplereply.h> #include <vespa/messagebus/testlib/simpleprotocol.h> #include <vespa/messagebus/rpcmessagebus.h> +#include <vespa/messagebus/iprotocol.h> +#include <vespa/messagebus/protocolset.h> #include <vespa/messagebus/emptyreply.h> +#include <vespa/messagebus/error.h> #include <vespa/messagebus/errorcode.h> -#include <vespa/fastos/app.h> using namespace mbus; diff --git a/messagebus_test/src/tests/errorcodes/dumpcodes.cpp b/messagebus_test/src/tests/errorcodes/dumpcodes.cpp index 81a764d02d9..a381efc2238 100644 --- a/messagebus_test/src/tests/errorcodes/dumpcodes.cpp +++ b/messagebus_test/src/tests/errorcodes/dumpcodes.cpp @@ -1,7 +1,9 @@ // 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/log/log.h> +LOG_SETUP("dumpcodes"); #include <vespa/messagebus/errorcode.h> -#include <vespa/fastos/app.h> +#include <string> using namespace mbus; diff --git a/messagebus_test/src/tests/speed/cpp-client.cpp b/messagebus_test/src/tests/speed/cpp-client.cpp index dd3def7efc9..54ccadc9ddd 100644 --- a/messagebus_test/src/tests/speed/cpp-client.cpp +++ b/messagebus_test/src/tests/speed/cpp-client.cpp @@ -1,12 +1,16 @@ // 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/log/log.h> +LOG_SETUP("cpp-client"); #include <vespa/messagebus/messagebus.h> #include <vespa/messagebus/routing/retrytransienterrorspolicy.h> #include <vespa/messagebus/rpcmessagebus.h> +#include <vespa/messagebus/sourcesession.h> +#include <vespa/messagebus/sourcesessionparams.h> #include <vespa/messagebus/testlib/simplemessage.h> #include <vespa/messagebus/testlib/simpleprotocol.h> #include <vespa/messagebus/testlib/simplereply.h> -#include <vespa/fastos/app.h> +#include <vespa/vespalib/util/sync.h> using namespace mbus; diff --git a/messagebus_test/src/tests/speed/cpp-server.cpp b/messagebus_test/src/tests/speed/cpp-server.cpp index 3d29f5641a2..904bf4d6d51 100644 --- a/messagebus_test/src/tests/speed/cpp-server.cpp +++ b/messagebus_test/src/tests/speed/cpp-server.cpp @@ -1,11 +1,15 @@ // 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/log/log.h> +LOG_SETUP("cpp-server"); #include <vespa/messagebus/messagebus.h> +#include <vespa/messagebus/destinationsession.h> #include <vespa/messagebus/testlib/simplemessage.h> #include <vespa/messagebus/testlib/simplereply.h> #include <vespa/messagebus/testlib/simpleprotocol.h> #include <vespa/messagebus/rpcmessagebus.h> -#include <vespa/fastos/app.h> +#include <vespa/messagebus/iprotocol.h> +#include <vespa/messagebus/protocolset.h> using namespace mbus; diff --git a/messagebus_test/src/tests/trace/cpp-server.cpp b/messagebus_test/src/tests/trace/cpp-server.cpp index 62ef2f82bad..ce495090e91 100644 --- a/messagebus_test/src/tests/trace/cpp-server.cpp +++ b/messagebus_test/src/tests/trace/cpp-server.cpp @@ -1,10 +1,16 @@ // 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/log/log.h> +LOG_SETUP("cpp-server"); #include <vespa/messagebus/messagebus.h> +#include <vespa/messagebus/destinationsession.h> +#include <vespa/messagebus/testlib/simplemessage.h> +#include <vespa/messagebus/testlib/simplereply.h> #include <vespa/messagebus/testlib/simpleprotocol.h> #include <vespa/messagebus/rpcmessagebus.h> +#include <vespa/messagebus/iprotocol.h> +#include <vespa/messagebus/protocolset.h> #include <vespa/messagebus/emptyreply.h> -#include <vespa/fastos/app.h> using namespace mbus; diff --git a/metrics/src/tests/metricmanagertest.cpp b/metrics/src/tests/metricmanagertest.cpp index 0ba6bdfbd2f..362cad83a66 100644 --- a/metrics/src/tests/metricmanagertest.cpp +++ b/metrics/src/tests/metricmanagertest.cpp @@ -9,6 +9,8 @@ #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/data/slime/slime.h> +#include <fstream> +#include <sstream> #include <vespa/log/log.h> LOG_SETUP(".test.metricmanager"); @@ -141,20 +143,22 @@ struct MetricNameVisitor : public MetricVisitor { MetricNameVisitor(bool debug_ = false) : debug(debug_) {} - bool visitMetricSet(const MetricSet& metricSet, bool autoGenerated) override { + virtual bool visitMetricSet(const MetricSet& metricSet, + bool autoGenerated) override + { if (debug) { ost << "<" << (autoGenerated ? "*" : "") << metricSet.getPath() << ">\n"; } return true; } - void doneVisitingMetricSet(const MetricSet& metricSet) override { + virtual void doneVisitingMetricSet(const MetricSet& metricSet) override { if (debug) { ost << "</" << metricSet.getPath() << ">\n"; } } - bool visitMetric(const Metric& m, bool autoGenerated) override { + virtual bool visitMetric(const Metric& m, bool autoGenerated) override { ost << (autoGenerated ? "*" : "") << m.getPath() << "\n"; return true; } @@ -386,7 +390,7 @@ namespace { struct FakeTimer : public MetricManager::Timer { time_t _time; FakeTimer(time_t startTime = 0) : _time(startTime) {} - time_t getTime() const override { return _time; } + virtual time_t getTime() const override { return _time; } }; struct BriefValuePrinter : public MetricVisitor { @@ -395,7 +399,7 @@ namespace { BriefValuePrinter() : count(0), ost() {} - bool visitMetric(const Metric& metric, bool) override { + virtual bool visitMetric(const Metric& metric, bool) override { if (++count > 1) ost << ","; //ost << metric.getPath() << ":"; ost << metric.getDoubleValue("value"); diff --git a/metrics/src/tests/metricsettest.cpp b/metrics/src/tests/metricsettest.cpp index 2b45bd049e0..176572acbd4 100644 --- a/metrics/src/tests/metricsettest.cpp +++ b/metrics/src/tests/metricsettest.cpp @@ -1,5 +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 <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/objects/floatingpointtype.h> #include <vespa/metrics/metrics.h> @@ -28,7 +28,7 @@ namespace { TestMetricVisitor(uint32_t setsToVisit_ = 100) : ost(), setsToVisit(setsToVisit_) {} - bool visitMetricSet(const MetricSet& set, bool autoGenerated) override { + virtual bool visitMetricSet(const MetricSet& set, bool autoGenerated) override { ost << "[" << (autoGenerated ? "*" : "") << set.getName() << "]\n"; if (setsToVisit > 0) { --setsToVisit; @@ -36,7 +36,7 @@ namespace { } return false; } - bool visitMetric(const Metric& m, bool autoGenerated) override { + virtual bool visitMetric(const Metric& m, bool autoGenerated) override { ost << (autoGenerated ? "*" : "") << m.getName() << "\n"; return true; } diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp index 5c13a0f82b6..bee3e910fb3 100644 --- a/metrics/src/tests/snapshottest.cpp +++ b/metrics/src/tests/snapshottest.cpp @@ -1,5 +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/metrics/metrics.h> #include <vespa/metrics/loadmetric.hpp> #include <vespa/metrics/summetric.hpp> @@ -39,8 +40,8 @@ struct SubSubMetricSet : public MetricSet { SubSubMetricSet(vespalib::stringref name, const LoadTypeSet& loadTypes_, MetricSet* owner = 0); ~SubSubMetricSet(); - MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType, - metrics::MetricSet* owner, bool includeUnused) const override; + virtual MetricSet* clone(std::vector<Metric::UP> &ownerList, CopyType copyType, + metrics::MetricSet* owner, bool includeUnused) const override; void incValues(); }; @@ -190,8 +191,10 @@ TestMetricSet::incValues() { struct FakeTimer : public MetricManager::Timer { uint32_t _timeInSecs; + FakeTimer() : _timeInSecs(1) {} - time_t getTime() const override { return _timeInSecs; } + + virtual time_t getTime() const override { return _timeInSecs; } }; } // End of anonymous namespace diff --git a/metrics/src/tests/stresstest.cpp b/metrics/src/tests/stresstest.cpp index 70194ecd861..5a2a736e9ba 100644 --- a/metrics/src/tests/stresstest.cpp +++ b/metrics/src/tests/stresstest.cpp @@ -1,5 +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 <vespa/metrics/metrics.h> #include <vespa/metrics/loadmetric.hpp> #include <vespa/metrics/summetric.hpp> @@ -108,7 +108,7 @@ OuterMetricSet::~OuterMetricSet() { } //std::cerr << "Loadgiver thread joined\n"; } - void run() override { + virtual void run() override { uint64_t i = 0; while (running()) { ++i; diff --git a/metrics/src/tests/testrunner.cpp b/metrics/src/tests/testrunner.cpp index 9bf86e3276a..5d8dc8d4c1f 100644 --- a/metrics/src/tests/testrunner.cpp +++ b/metrics/src/tests/testrunner.cpp @@ -1,12 +1,14 @@ // 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 <iostream> +#include <vespa/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("storagecppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/persistence/src/tests/dummyimpl/dummyimpltest.cpp b/persistence/src/tests/dummyimpl/dummyimpltest.cpp index 9348d90c05a..4b107fde324 100644 --- a/persistence/src/tests/dummyimpl/dummyimpltest.cpp +++ b/persistence/src/tests/dummyimpl/dummyimpltest.cpp @@ -1,9 +1,13 @@ // 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/log/log.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/persistence/conformancetest/conformancetest.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> +LOG_SETUP(".test.dummyimpl"); + namespace storage { namespace spi { @@ -16,7 +20,9 @@ struct DummyImplTest : public ConformanceTest { return PersistenceProvider::UP(new dummy::DummyPersistence(repo, 4)); } - bool supportsActiveState() const override { return true; } + bool supportsActiveState() const override { + return true; + } }; DummyImplTest() diff --git a/persistence/src/tests/proxy/mockprovider.h b/persistence/src/tests/proxy/mockprovider.h index a90b4cc27f7..b7019239847 100644 --- a/persistence/src/tests/proxy/mockprovider.h +++ b/persistence/src/tests/proxy/mockprovider.h @@ -20,34 +20,34 @@ struct MockProvider : PersistenceProvider { MockProvider() : last_called(NONE) {} - Result initialize() override { + virtual Result initialize() override { last_called = INITIALIZE; return Result(); } - PartitionStateListResult getPartitionStates() const override { + virtual PartitionStateListResult getPartitionStates() const override { last_called = GET_PARTITION_STATES; return PartitionStateListResult(PartitionStateList(1u)); } - BucketIdListResult listBuckets(PartitionId id) const override { + virtual BucketIdListResult listBuckets(PartitionId id) const override { last_called = LIST_BUCKETS; BucketIdListResult::List result; result.push_back(document::BucketId(id)); return BucketIdListResult(result); } - Result setClusterState(const ClusterState &) override { + virtual Result setClusterState(const ClusterState &) override { last_called = SET_CLUSTER_STATE; return Result(); } - Result setActiveState(const Bucket &, BucketInfo::ActiveState) override { + virtual Result setActiveState(const Bucket &, BucketInfo::ActiveState) override { last_called = SET_ACTIVE_STATE; return Result(); } - BucketInfoResult getBucketInfo(const Bucket &bucket) const override { + virtual BucketInfoResult getBucketInfo(const Bucket &bucket) const override { last_called = GET_BUCKET_INFO; return BucketInfoResult(BucketInfo(BucketChecksum(1), 2, 3, bucket.getBucketId().getRawId(), @@ -56,17 +56,17 @@ struct MockProvider : PersistenceProvider { BucketInfo::ACTIVE)); } - Result put(const Bucket &, Timestamp, const DocumentSP&, Context&) override { + virtual Result put(const Bucket &, Timestamp, const DocumentSP&, Context&) override { last_called = PUT; return Result(); } - RemoveResult remove(const Bucket &, Timestamp, const DocumentId &, Context&) override { + virtual RemoveResult remove(const Bucket &, Timestamp, const DocumentId &, Context&) override { last_called = REMOVE_BY_ID; return RemoveResult(true); } - RemoveResult removeIfFound(const Bucket &, Timestamp, const DocumentId &, Context&) override { + virtual RemoveResult removeIfFound(const Bucket &, Timestamp, const DocumentId &, Context&) override { last_called = REMOVE_IF_FOUND; return RemoveResult(true); } @@ -77,54 +77,54 @@ struct MockProvider : PersistenceProvider { return RemoveResult(true); } - UpdateResult update(const Bucket &, Timestamp timestamp, const DocumentUpdateSP&, Context&) override { + virtual UpdateResult update(const Bucket &, Timestamp timestamp, const DocumentUpdateSP&, Context&) override { last_called = UPDATE; return UpdateResult(Timestamp(timestamp - 10)); } - Result flush(const Bucket&, Context&) override { + virtual Result flush(const Bucket&, Context&) override { last_called = FLUSH; return Result(); } - GetResult get(const Bucket &, const document::FieldSet&, const DocumentId&, Context&) const override { + virtual GetResult get(const Bucket &, const document::FieldSet&, const DocumentId&, Context&) const override { last_called = GET; return GetResult(Document::UP(new Document), Timestamp(6u)); } - CreateIteratorResult createIterator(const Bucket& bucket, - const document::FieldSet&, - const Selection&, - IncludedVersions, - Context&) override + virtual CreateIteratorResult createIterator(const Bucket& bucket, + const document::FieldSet&, + const Selection&, + IncludedVersions, + Context&) override { last_called = CREATE_ITERATOR; return CreateIteratorResult(IteratorId(bucket.getPartition())); } - IterateResult iterate(IteratorId, uint64_t, Context&) const override { + virtual IterateResult iterate(IteratorId, uint64_t, Context&) const override { last_called = ITERATE; IterateResult::List result; result.push_back(DocEntry::UP(new DocEntry(Timestamp(1), 0))); return IterateResult(std::move(result), true); } - Result destroyIterator(IteratorId, Context&) override { + virtual Result destroyIterator(IteratorId, Context&) override { last_called = DESTROY_ITERATOR; return Result(); } - Result createBucket(const Bucket&, Context&) override { + virtual Result createBucket(const Bucket&, Context&) override { last_called = CREATE_BUCKET; return Result(); } - Result deleteBucket(const Bucket&, Context&) override { + virtual Result deleteBucket(const Bucket&, Context&) override { last_called = DELETE_BUCKET; return Result(); } - BucketIdListResult getModifiedBuckets() const override { + virtual BucketIdListResult getModifiedBuckets() const override { last_called = GET_MODIFIED_BUCKETS; BucketIdListResult::List list; list.push_back(document::BucketId(2)); @@ -132,28 +132,30 @@ struct MockProvider : PersistenceProvider { return BucketIdListResult(list); } - Result split(const Bucket &, const Bucket &, const Bucket &, Context&) override { + virtual Result split(const Bucket &, const Bucket &, const Bucket &, Context&) override + { last_called = SPLIT; return Result(); } - Result join(const Bucket &, const Bucket &, const Bucket &, Context&) override { + virtual Result join(const Bucket &, const Bucket &, const Bucket &, Context&) override + { last_called = JOIN; return Result(); } - Result move(const Bucket &, PartitionId, Context&) override { + virtual Result move(const Bucket &, PartitionId, Context&) override { last_called = MOVE; return Result(); } - Result maintain(const Bucket &, MaintenanceLevel) override { + virtual Result maintain(const Bucket &, MaintenanceLevel) override { last_called = MAINTAIN; return Result(); } - Result removeEntry(const Bucket &, Timestamp, Context&) override { + virtual Result removeEntry(const Bucket &, Timestamp, Context&) override { last_called = REMOVE_ENTRY; return Result(); } @@ -161,3 +163,4 @@ struct MockProvider : PersistenceProvider { } // namespace spi } // namespace storage + diff --git a/persistence/src/tests/proxy/providerproxy_conformancetest.cpp b/persistence/src/tests/proxy/providerproxy_conformancetest.cpp index cadcd3c224a..a33b736a12d 100644 --- a/persistence/src/tests/proxy/providerproxy_conformancetest.cpp +++ b/persistence/src/tests/proxy/providerproxy_conformancetest.cpp @@ -1,5 +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/vespalib/testkit/test_kit.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/persistence/conformancetest/conformancetest.h> @@ -20,7 +21,9 @@ struct DummyFactory : Factory { return PersistenceProvider::UP(new dummy::DummyPersistence(repo, 4)); } - bool supportsActiveState() const override { + virtual bool + supportsActiveState() const override + { return true; } }; diff --git a/persistence/src/tests/proxy/proxy_factory_wrapper.h b/persistence/src/tests/proxy/proxy_factory_wrapper.h index 415d43e8033..5d7899e7ff9 100644 --- a/persistence/src/tests/proxy/proxy_factory_wrapper.h +++ b/persistence/src/tests/proxy/proxy_factory_wrapper.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/persistence/conformancetest/conformancetest.h> #include <vespa/persistence/proxy/providerstub.h> #include <vespa/persistence/proxy/providerproxy.h> @@ -33,7 +33,7 @@ struct ProxyFactoryWrapper : ConformanceTest::PersistenceFactory DummyProviderFactory::UP provider; Server::UP server; Wrapper(DummyProviderFactory::UP p, Server::UP s, const Repo &repo) - : Client(vespalib::make_string("tcp/localhost:%u", s->getPort()), repo), + : Client(vespalib::make_vespa_string("tcp/localhost:%u", s->getPort()), repo), provider(std::move(p)), server(std::move(s)) {} @@ -47,7 +47,9 @@ struct ProxyFactoryWrapper : ConformanceTest::PersistenceFactory return Provider::UP(new Wrapper(std::move(provider), std::move(server), *repo)); } - bool supportsActiveState() const override { + virtual bool + supportsActiveState() const override + { return factory->supportsActiveState(); } }; diff --git a/persistence/src/tests/proxy/proxyfactory.h b/persistence/src/tests/proxy/proxyfactory.h index 1d0c7bd2db7..3a18440a6e7 100644 --- a/persistence/src/tests/proxy/proxyfactory.h +++ b/persistence/src/tests/proxy/proxyfactory.h @@ -2,6 +2,7 @@ #pragma once +#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/persistence/conformancetest/conformancetest.h> #include <vespa/persistence/proxy/providerstub.h> #include <vespa/persistence/proxy/providerproxy.h> @@ -29,9 +30,12 @@ struct ProxyFactory : ConformanceTest::PersistenceFactory return Provider::UP(new Client("tcp/localhost:3456", *repo)); } - bool supportsActiveState() const override { + virtual bool + supportsActiveState() const override + { return false; } }; } // namespace spi } // namespace storage + diff --git a/persistence/src/tests/testrunner.cpp b/persistence/src/tests/testrunner.cpp index 5baa0f60b6e..16027870c47 100644 --- a/persistence/src/tests/testrunner.cpp +++ b/persistence/src/tests/testrunner.cpp @@ -1,12 +1,14 @@ // 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 <iostream> +#include <vespa/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("persistencecppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h index a1656ce7ce1..1dee3fb60c3 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h @@ -144,9 +144,14 @@ public: BucketIdListResult getModifiedBuckets() const override; Result setClusterState(const ClusterState& newState) override; - Result setActiveState(const Bucket& bucket, BucketInfo::ActiveState newState) override; + + Result setActiveState(const Bucket& bucket, + BucketInfo::ActiveState newState) override; + BucketInfoResult getBucketInfo(const Bucket&) const override; + Result put(const Bucket&, Timestamp, const DocumentSP&, Context&) override; + GetResult get(const Bucket&, const document::FieldSet& fieldSet, const DocumentId&, @@ -180,6 +185,7 @@ public: Context&) override; Result revert(const Bucket&, Timestamp, Context&); + Result maintain(const Bucket& bucket, MaintenanceLevel level) override; /** @@ -236,3 +242,4 @@ private: } // dummy } // spi } // storage + diff --git a/persistence/src/vespa/persistence/proxy/providerstub.h b/persistence/src/vespa/persistence/proxy/providerstub.h index ce831547ef9..27e726ca538 100644 --- a/persistence/src/vespa/persistence/proxy/providerstub.h +++ b/persistence/src/vespa/persistence/proxy/providerstub.h @@ -29,7 +29,7 @@ private: vespalib::ThreadStackExecutor &e, std::unique_ptr<PersistenceProvider> &p) : FNET_Task(s), executor(e), provider(p) {} - void PerformTask() override { + virtual void PerformTask() override { executor.sync(); assert(provider.get() != 0); provider.reset(); diff --git a/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp b/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp index a9b2a50cac3..29ea819f71d 100644 --- a/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createarraystd.cpp @@ -2,10 +2,14 @@ #include "attributefactory.h" #include "defines.h" + #include "attributevector.hpp" #include "multivalueattribute.hpp" #include "multinumericattribute.hpp" -#include "multistringattribute.hpp" +#include "multistringattribute.h" + +#include <vespa/log/log.h> +LOG_SETUP(".createarraystd"); namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp b/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp index 262ec2c23df..5aa40a20d14 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsetstd.cpp @@ -1,11 +1,16 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "attributefactory.h" +#include <vespa/fastos/fastos.h> +#include <vespa/searchlib/attribute/attributefactory.h> #include "defines.h" -#include "attributevector.hpp" -#include "multivalueattribute.hpp" -#include "multinumericattribute.hpp" -#include "multistringattribute.hpp" + +#include <vespa/log/log.h> +LOG_SETUP(".createsetstd"); + +#include <vespa/searchlib/attribute/attributevector.hpp> +#include <vespa/searchlib/attribute/multivalueattribute.hpp> +#include <vespa/searchlib/attribute/multinumericattribute.hpp> +#include <vespa/searchlib/attribute/multistringattribute.h> namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp index ad08e20808a..02890eb8789 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsinglefastsearch.cpp @@ -1,16 +1,21 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "attributefactory.h" -#include "integerbase.h" -#include "floatbase.h" +#include <vespa/fastos/fastos.h> +#include <vespa/searchlib/attribute/attributefactory.h> +#include <vespa/searchlib/attribute/integerbase.h> +#include <vespa/searchlib/attribute/floatbase.h> #include "defines.h" -#include "singlestringattribute.h" -#include "singlestringpostattribute.hpp" -#include "singlenumericenumattribute.hpp" -#include "singlenumericpostattribute.hpp" -#include "enumstore.hpp" -#include "enumattribute.hpp" -#include "singleenumattribute.hpp" + +#include <vespa/log/log.h> +LOG_SETUP(".createsinglefastsearch"); + +#include <vespa/searchlib/attribute/singlestringattribute.h> +#include <vespa/searchlib/attribute/singlestringpostattribute.hpp> +#include <vespa/searchlib/attribute/singlenumericenumattribute.hpp> +#include <vespa/searchlib/attribute/singlenumericpostattribute.hpp> +#include <vespa/searchlib/attribute/enumstore.hpp> +#include <vespa/searchlib/attribute/enumattribute.hpp> +#include <vespa/searchlib/attribute/singleenumattribute.hpp> #define INTPOSTING(T) SingleValueNumericPostingAttribute< ENUM_ATTRIBUTE(IntegerAttributeTemplate<T>) > #define FLOATPOSTING(T) SingleValueNumericPostingAttribute< ENUM_ATTRIBUTE(FloatingPointAttributeTemplate<T>) > diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp index c3a126631e6..766195c8e9c 100644 --- a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp +++ b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp @@ -1,12 +1,17 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "attributefactory.h" +#include <vespa/fastos/fastos.h> +#include <vespa/searchlib/attribute/attributefactory.h> + +#include <vespa/log/log.h> +LOG_SETUP(".createsinglestd"); + #include "predicate_attribute.h" #include "singlesmallnumericattribute.h" #include "reference_attribute.h" -#include "attributevector.hpp" -#include "singlenumericattribute.hpp" -#include "singlestringattribute.h" +#include <vespa/searchlib/attribute/attributevector.hpp> +#include <vespa/searchlib/attribute/singlenumericattribute.hpp> +#include <vespa/searchlib/attribute/singlestringattribute.h> #include <vespa/searchlib/tensor/generic_tensor_attribute.h> #include <vespa/searchlib/tensor/dense_tensor_attribute.h> diff --git a/searchlib/src/vespa/searchlib/attribute/enumattribute.h b/searchlib/src/vespa/searchlib/attribute/enumattribute.h index ca5058c71d3..94e5da62967 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/enumattribute.h @@ -2,9 +2,9 @@ #pragma once +#include <vespa/searchlib/attribute/enumstore.h> #include "attributevector.h" #include "loadedenumvalue.h" -#include <vespa/searchlib/attribute/enumstore.h> #include <set> namespace search { @@ -61,10 +61,18 @@ protected: virtual EnumType getFromEnum(EnumHandle e) const { return _enumStore.getValue(e); } virtual void fillPostings(LoadedVector & loaded) { (void) loaded; } - void fillEnum(LoadedVector & loaded) override; - void fillEnum0(const void *src, size_t srcLen, EnumIndexVector &eidxs) override; - void fixupEnumRefCounts(const EnumVector &enumHist) override; - uint64_t getUniqueValueCount(void) const override; + virtual void fillEnum(LoadedVector & loaded) override; + + virtual void + fillEnum0(const void *src, + size_t srcLen, + EnumIndexVector &eidxs) override; + + virtual void + fixupEnumRefCounts(const EnumVector &enumHist) override; + + virtual uint64_t + getUniqueValueCount(void) const override; static EnumType getDefaultEnumTypeValue() { return B::defaultValue(); } @@ -82,8 +90,9 @@ public: EnumAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & cfg); - ~EnumAttribute(); + virtual ~EnumAttribute(); virtual bool findEnum(EnumType v, EnumHandle & e) const { return _enumStore.findEnum(v, e); } }; } // namespace search + diff --git a/searchlib/src/vespa/searchlib/attribute/flagattribute.h b/searchlib/src/vespa/searchlib/attribute/flagattribute.h index 3fe2424b97d..ea73ecb7c51 100644 --- a/searchlib/src/vespa/searchlib/attribute/flagattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/flagattribute.h @@ -40,7 +40,8 @@ public: void setNewBVValue(DocId doc, typename B::WType::ValueType value); private: - bool onAddDoc(DocId doc) override; + virtual bool onAddDoc(DocId doc) override; + void onAddDocs(DocId docIdLimit) override; void ensureGuardBit(BitVector & bv); void ensureGuardBit(); diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h index 01d9efe0cbc..6afede8d3b4 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h @@ -256,3 +256,4 @@ public: }; } + diff --git a/searchlib/src/vespa/searchlib/attribute/multistringattribute.cpp b/searchlib/src/vespa/searchlib/attribute/multistringattribute.cpp index 79a2d2001b6..737f464206e 100644 --- a/searchlib/src/vespa/searchlib/attribute/multistringattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/multistringattribute.cpp @@ -1,8 +1,11 @@ // 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 "multistringattribute.h" -#include <vespa/searchlib/query/queryterm.h> +#include "multistringattribute.hpp" +#include <vespa/log/log.h> +LOG_SETUP(".searchlib.attribute.multistringattribute"); namespace search { template class MultiValueStringAttributeT<EnumAttribute<StringAttribute>, multivalue::Value<EnumStoreBase::Index> >; diff --git a/searchlib/src/vespa/searchlib/attribute/multivalueattribute.h b/searchlib/src/vespa/searchlib/attribute/multivalueattribute.h index e02a81e44ef..12b1098bbb3 100644 --- a/searchlib/src/vespa/searchlib/attribute/multivalueattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multivalueattribute.h @@ -3,6 +3,7 @@ #pragma once #include "multi_value_mapping.h" +#include <vespa/vespalib/stllike/string.h> #include "attributevector.h" namespace search { @@ -47,7 +48,7 @@ protected: * Can be overridden by subclasses that need to resize structures as a result of this. * Should return true if underlying structures were resized. **/ - bool onAddDoc(DocId doc) override { (void) doc; return false; } + virtual bool onAddDoc(DocId doc) override { (void) doc; return false; } AddressSpace getMultiValueAddressSpaceUsage() const override; @@ -73,3 +74,4 @@ public: }; } // namespace search + diff --git a/searchlib/src/vespa/searchlib/attribute/numericbase.h b/searchlib/src/vespa/searchlib/attribute/numericbase.h index ee6effa810a..94bc5c1472d 100644 --- a/searchlib/src/vespa/searchlib/attribute/numericbase.h +++ b/searchlib/src/vespa/searchlib/attribute/numericbase.h @@ -3,9 +3,9 @@ #pragma once #include "attributevector.h" -#include "enumstorebase.h" -#include "loadedenumvalue.h" #include <vespa/searchlib/common/sort.h> +#include <vespa/searchlib/attribute/enumstorebase.h> +#include "loadedenumvalue.h" namespace search { @@ -28,7 +28,6 @@ protected: virtual void fillEnumIdx(ReaderBase &attrReader, const EnumIndexVector &eidxs, EnumVector &enumHist); virtual void fillPostingsFixupEnum(const attribute::LoadedEnumAttributeVector &loaded); virtual void fixupEnumRefCounts(const EnumVector &enumHist); - bool onAddDoc(DocId) override { return true; } template<typename T> class Equal @@ -58,7 +57,8 @@ protected: protected: Range(const QueryTermSimple & queryTerm, bool avoidUndefinedInRange=false); Int64Range getRange() const { - return Int64Range(static_cast<int64_t>(_low), static_cast<int64_t>(_high)); + return Int64Range(static_cast<int64_t>(_low), + static_cast<int64_t>(_high)); } bool isValid() const { return _valid; } bool match(T v) const { return (_low <= v) && (v <= _high); } @@ -75,7 +75,8 @@ protected: BaseType numMin = std::numeric_limits<BaseType>::min(); BaseType numMax = std::numeric_limits<BaseType>::max(); - if (isFloat) { + if (isFloat) + { if (_low <= (-numMax)) { low = -numMax; } @@ -101,3 +102,4 @@ public: }; } // namespace search + diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h index a835aa85896..1843bde4d54 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h @@ -2,7 +2,7 @@ #pragma once -#include "enumattribute.h" +#include <vespa/searchlib/attribute/enumattribute.h> #include <vespa/searchlib/common/rcuvector.h> namespace search { @@ -83,8 +83,7 @@ protected: } virtual void mergeMemoryStats(MemoryUsage & total) { (void) total; } - - void fillValues(LoadedVector & loaded) override; + virtual void fillValues(LoadedVector & loaded) override; void fillEnumIdx(ReaderBase &attrReader, const EnumStoreBase::IndexVector &eidxs, @@ -102,7 +101,7 @@ protected: * * Should return true if underlying structures were resized. **/ - bool onAddDoc(DocId doc) override; + virtual bool onAddDoc(DocId doc) override; public: SingleValueEnumAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & cfg); @@ -137,3 +136,4 @@ public: }; } // namespace search + diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp index 4b19f8d1af0..c798351211a 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp @@ -2,8 +2,8 @@ #pragma once -#include "singleenumattribute.h" -#include "enumattribute.hpp" +#include <vespa/searchlib/attribute/singleenumattribute.h> +#include <vespa/searchlib/attribute/enumattribute.hpp> #include "ipostinglistattributebase.h" #include "singleenumattributesaver.h" #include "load_utils.h" diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h index 369fbf77f0b..828c1434819 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h @@ -46,9 +46,9 @@ private: protected: // from SingleValueEnumAttribute - void considerUpdateAttributeChange(const Change & c) override; - void considerArithmeticAttributeChange(const Change & c, UniqueSet & newUniques) override; - void applyArithmeticValueChange(const Change & c, EnumStoreBase::IndexVector & unused) override; + virtual void considerUpdateAttributeChange(const Change & c); + virtual void considerArithmeticAttributeChange(const Change & c, UniqueSet & newUniques); + virtual void applyArithmeticValueChange(const Change & c, EnumStoreBase::IndexVector & unused); /* * Specialization of SearchContext @@ -92,10 +92,9 @@ public: const AttributeVector::Config & c = AttributeVector::Config(AttributeVector::BasicType::fromType(T()), attribute::CollectionType::SINGLE)); - ~SingleValueNumericEnumAttribute(); - void onCommit() override; - bool onLoad() override; + virtual void onCommit(); + virtual bool onLoad(); bool onLoadEnumerated(ReaderBase &attrReader); @@ -105,46 +104,46 @@ public: //------------------------------------------------------------------------- // Attribute read API //------------------------------------------------------------------------- - T get(DocId doc) const override { + virtual T get(DocId doc) const { return this->_enumStore.getValue(this->_enumIndices[doc]); } - largeint_t getInt(DocId doc) const override { + virtual largeint_t getInt(DocId doc) const { return static_cast<largeint_t>(get(doc)); } - double getFloat(DocId doc) const override { + virtual double getFloat(DocId doc) const { return static_cast<double>(get(doc)); } - uint32_t getAll(DocId doc, T * v, uint32_t sz) const override { + virtual uint32_t getAll(DocId doc, T * v, uint32_t sz) const { if (sz > 0) { v[0] = get(doc); } return 1; } - uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override { + virtual uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const { if (sz > 0) { v[0] = getInt(doc); } return 1; } - uint32_t get(DocId doc, double * v, uint32_t sz) const override { + virtual uint32_t get(DocId doc, double * v, uint32_t sz) const { if (sz > 0) { v[0] = getFloat(doc); } return 1; } - uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const override { + virtual uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const { if (sz > 0) { v[0] = Weighted(get(doc)); } return 1; } - uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { + virtual uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const { if (sz > 0) { v[0] = WeightedInt(getInt(doc)); } return 1; } - uint32_t get(DocId doc, WeightedFloat * v, uint32_t sz) const override { + virtual uint32_t get(DocId doc, WeightedFloat * v, uint32_t sz) const { if (sz > 0) { v[0] = WeightedFloat(getFloat(doc)); } diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp index 698bdbf82d4..fbf56440a08 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.hpp @@ -64,9 +64,6 @@ SingleValueNumericEnumAttribute(const vespalib::string & baseFileName, } template <typename B> -SingleValueNumericEnumAttribute<B>::~SingleValueNumericEnumAttribute() {} - -template <typename B> void SingleValueNumericEnumAttribute<B>::onCommit() { diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.h b/searchlib/src/vespa/searchlib/features/dotproductfeature.h index b94d1717ed1..4a30c0ecb1b 100644 --- a/searchlib/src/vespa/searchlib/features/dotproductfeature.h +++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.h @@ -156,8 +156,8 @@ public: protected: const A * _attribute; private: - size_t getAttributeValues(uint32_t docid, const AT * & count) override; - public: + virtual size_t getAttributeValues(uint32_t docid, const AT * & count) override; +public: DotProductExecutor(const A * attribute, const V & queryVector); ~DotProductExecutor(); }; diff --git a/searchlib/src/vespa/searchlib/features/raw_score_feature.h b/searchlib/src/vespa/searchlib/features/raw_score_feature.h index 2e37c43c8f7..ddae8848052 100644 --- a/searchlib/src/vespa/searchlib/features/raw_score_feature.h +++ b/searchlib/src/vespa/searchlib/features/raw_score_feature.h @@ -8,37 +8,39 @@ namespace search { namespace features { -class RawScoreExecutor : public fef::FeatureExecutor +class RawScoreExecutor : public search::fef::FeatureExecutor { private: - std::vector<fef::TermFieldHandle> _handles; + std::vector<search::fef::TermFieldHandle> _handles; const fef::MatchData *_md; - void handle_bind_match_data(fef::MatchData &md) override; + virtual void handle_bind_match_data(fef::MatchData &md) override; public: - RawScoreExecutor(const fef::IQueryEnvironment &env, uint32_t fieldId); - void execute(uint32_t docId) override; + RawScoreExecutor(const search::fef::IQueryEnvironment &env, uint32_t fieldId); + virtual void execute(uint32_t docId) override; }; //----------------------------------------------------------------------------- -class RawScoreBlueprint : public fef::Blueprint +class RawScoreBlueprint : public search::fef::Blueprint { private: - const fef::FieldInfo *_field; + const search::fef::FieldInfo *_field; public: RawScoreBlueprint() : Blueprint("rawScore"), _field(0) {} - void visitDumpFeatures(const fef::IIndexEnvironment &, - fef::IDumpFeatureVisitor &) const override {} - fef::Blueprint::UP createInstance() const override { + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &, + search::fef::IDumpFeatureVisitor &) const override {} + virtual search::fef::Blueprint::UP createInstance() const override { return Blueprint::UP(new RawScoreBlueprint()); } - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().field(); + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().field(); } - bool setup(const fef::IIndexEnvironment &env, const fef::ParameterList ¶ms) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + virtual bool setup(const search::fef::IIndexEnvironment &env, + const search::fef::ParameterList ¶ms) override; + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; } // namespace features } // namespace search + diff --git a/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h b/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h index 020cc25a2f9..7dad54e65d5 100644 --- a/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h +++ b/searchlib/src/vespa/searchlib/features/reverseproximityfeature.h @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <string> +#include <vector> #include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchlib/fef/featureexecutor.h> @@ -21,7 +23,7 @@ struct ReverseProximityConfig { /** * Implements the executor for reverse proximity. */ -class ReverseProximityExecutor : public fef::FeatureExecutor { +class ReverseProximityExecutor : public search::fef::FeatureExecutor { public: /** * Constructs an executor for reverse proximity. @@ -29,32 +31,48 @@ public: * @param env The query environment. * @param config The completeness config. */ - ReverseProximityExecutor(const fef::IQueryEnvironment &env, + ReverseProximityExecutor(const search::fef::IQueryEnvironment &env, const ReverseProximityConfig &config); - void execute(uint32_t docId) override; + virtual void execute(uint32_t docId) override; private: const ReverseProximityConfig &_config; // The proximity config. - fef::TermFieldHandle _termA; // Handle to the first query term. - fef::TermFieldHandle _termB; // Handle to the second query term. + search::fef::TermFieldHandle _termA; // Handle to the first query term. + search::fef::TermFieldHandle _termB; // Handle to the second query term. const fef::MatchData *_md; - void handle_bind_match_data(fef::MatchData &md) override; + virtual void handle_bind_match_data(fef::MatchData &md) override; }; /** * Implements the blueprint for proximity. */ -class ReverseProximityBlueprint : public fef::Blueprint { +class ReverseProximityBlueprint : public search::fef::Blueprint { public: + /** + * Constructs a blueprint for reverse proximity. + */ ReverseProximityBlueprint(); - void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override; - fef::Blueprint::UP createInstance() const override; - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().indexField(fef::ParameterCollection::ANY).number().number(); + + // Inherit doc from Blueprint. + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &env, + search::fef::IDumpFeatureVisitor &visitor) const override; + + // Inherit doc from Blueprint. + virtual search::fef::Blueprint::UP createInstance() const override; + + // Inherit doc from Blueprint. + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().indexField(search::fef::ParameterCollection::ANY).number().number(); } - bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + + // Inherit doc from Blueprint. + virtual bool setup(const search::fef::IIndexEnvironment & env, + const search::fef::ParameterList & params) override; + + // Inherit doc from Blueprint. + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + private: ReverseProximityConfig _config; }; diff --git a/searchlib/src/vespa/searchlib/features/subqueries_feature.h b/searchlib/src/vespa/searchlib/features/subqueries_feature.h index 0c882a9b24a..217548b3e96 100644 --- a/searchlib/src/vespa/searchlib/features/subqueries_feature.h +++ b/searchlib/src/vespa/searchlib/features/subqueries_feature.h @@ -8,33 +8,37 @@ namespace search { namespace features { -class SubqueriesExecutor : public fef::FeatureExecutor { - std::vector<fef::TermFieldHandle> _handles; - const fef::MatchData *_md; +class SubqueriesExecutor : public search::fef::FeatureExecutor { + std::vector<search::fef::TermFieldHandle> _handles; + const fef::MatchData *_md; + + virtual void handle_bind_match_data(fef::MatchData &md) override; - void handle_bind_match_data(fef::MatchData &md) override; public: - SubqueriesExecutor(const fef::IQueryEnvironment &env, uint32_t fieldId); - void execute(uint32_t docId) override; + SubqueriesExecutor(const search::fef::IQueryEnvironment &env, + uint32_t fieldId); + virtual void execute(uint32_t docId) override; }; //----------------------------------------------------------------------------- -class SubqueriesBlueprint : public fef::Blueprint +class SubqueriesBlueprint : public search::fef::Blueprint { private: - const fef::FieldInfo *_field; + const search::fef::FieldInfo *_field; public: SubqueriesBlueprint() : Blueprint("subqueries"), _field(nullptr) {} - void visitDumpFeatures(const fef::IIndexEnvironment &, fef::IDumpFeatureVisitor &) const override {} - fef::Blueprint::UP createInstance() const override { + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &, + search::fef::IDumpFeatureVisitor &) const override {} + virtual search::fef::Blueprint::UP createInstance() const override { return Blueprint::UP(new SubqueriesBlueprint); } - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().field(); + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().field(); } - bool setup(const fef::IIndexEnvironment &env, const fef::ParameterList ¶ms) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + virtual bool setup(const search::fef::IIndexEnvironment &env, + const search::fef::ParameterList ¶ms) override; + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; } // namespace features diff --git a/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h b/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h index 4f368a9e188..eba2a9f44ae 100644 --- a/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h +++ b/searchlib/src/vespa/searchlib/features/tensor_from_attribute_executor.h @@ -34,7 +34,7 @@ public: { _attrBuffer.allocate(_attribute->getMaxValueCount()); } - void execute(uint32_t docId) override; + virtual void execute(uint32_t docId) override; }; template <typename WeightedBufferType> diff --git a/searchlib/src/vespa/searchlib/features/term_field_md_feature.h b/searchlib/src/vespa/searchlib/features/term_field_md_feature.h index 6c574aa90b4..ef3d83de98d 100644 --- a/searchlib/src/vespa/searchlib/features/term_field_md_feature.h +++ b/searchlib/src/vespa/searchlib/features/term_field_md_feature.h @@ -16,14 +16,16 @@ namespace features { **/ class TermFieldMdExecutor : public fef::FeatureExecutor { - typedef std::pair<fef::TermFieldHandle, query::Weight> Element; + typedef std::pair<search::fef::TermFieldHandle, query::Weight> Element; std::vector<Element> _terms; const fef::MatchData *_md; - void execute(uint32_t docId) override; - void handle_bind_match_data(fef::MatchData &md) override; + virtual void execute(uint32_t docId) override; + virtual void handle_bind_match_data(fef::MatchData &md) override; + public: - TermFieldMdExecutor(const fef::IQueryEnvironment &env, uint32_t fieldId); + TermFieldMdExecutor(const search::fef::IQueryEnvironment &env, + uint32_t fieldId); }; @@ -31,18 +33,31 @@ public: * Implements the blueprint for the term field md executor. **/ class TermFieldMdBlueprint : public fef::Blueprint { - const fef::FieldInfo * _field; + const search::fef::FieldInfo * _field; public: TermFieldMdBlueprint(); - void visitDumpFeatures(const fef::IIndexEnvironment & env, fef::IDumpFeatureVisitor & visitor) const override; - fef::Blueprint::UP createInstance() const override; - fef::ParameterDescriptions getDescriptions() const override { + + // Inherit doc from Blueprint. + virtual void visitDumpFeatures(const fef::IIndexEnvironment & env, + fef::IDumpFeatureVisitor & visitor) const override; + + // Inherit doc from Blueprint. + virtual fef::Blueprint::UP createInstance() const override; + + // Inherit doc from Blueprint. + virtual fef::ParameterDescriptions getDescriptions() const override { return fef::ParameterDescriptions().desc().field(); } - bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment & env, vespalib::Stash &stash) const override; + + // Inherit doc from Blueprint. + virtual bool setup(const fef::IIndexEnvironment & env, + const fef::ParameterList & params) override; + + // Inherit doc from Blueprint. + virtual fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment & env, vespalib::Stash &stash) const override; }; } // namespace features } // namespace search + diff --git a/searchlib/src/vespa/searchlib/features/termdistancefeature.h b/searchlib/src/vespa/searchlib/features/termdistancefeature.h index 609ea6d1b63..ed79a51c199 100644 --- a/searchlib/src/vespa/searchlib/features/termdistancefeature.h +++ b/searchlib/src/vespa/searchlib/features/termdistancefeature.h @@ -23,7 +23,7 @@ struct TermDistanceParams { /** * Implements the executor for calculating min term distance (forward and reverse). **/ -class TermDistanceExecutor : public fef::FeatureExecutor +class TermDistanceExecutor : public search::fef::FeatureExecutor { private: const TermDistanceParams & _params; @@ -34,31 +34,44 @@ private: virtual void handle_bind_match_data(fef::MatchData &md) override; public: - TermDistanceExecutor(const fef::IQueryEnvironment & env, + TermDistanceExecutor(const search::fef::IQueryEnvironment & env, const TermDistanceParams & params); - void execute(uint32_t docId) override; - bool valid() const; + virtual void execute(uint32_t docId) override; + bool valid() const; }; /** * Implements the blueprint for the term distance executor. **/ -class TermDistanceBlueprint : public fef::Blueprint { +class TermDistanceBlueprint : public search::fef::Blueprint { private: TermDistanceParams _params; public: TermDistanceBlueprint(); - void visitDumpFeatures(const fef::IIndexEnvironment & env, fef::IDumpFeatureVisitor & visitor) const override; - fef::Blueprint::UP createInstance() const override; - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().indexField(fef::ParameterCollection::ANY).number().number(); + + // Inherit doc from Blueprint. + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment & env, + search::fef::IDumpFeatureVisitor & visitor) const override; + + // Inherit doc from Blueprint. + virtual search::fef::Blueprint::UP createInstance() const override; + + // Inherit doc from Blueprint. + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().indexField(search::fef::ParameterCollection::ANY).number().number(); } - bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + + // Inherit doc from Blueprint. + virtual bool setup(const search::fef::IIndexEnvironment & env, + const search::fef::ParameterList & params) override; + + // Inherit doc from Blueprint. + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; } // namespace features } // namespace search + diff --git a/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h b/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h index c7ef3d672fd..26faaae4b93 100644 --- a/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h +++ b/searchlib/src/vespa/searchlib/features/termeditdistancefeature.h @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <string> +#include <vector> #include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/common/feature.h> @@ -43,14 +45,14 @@ struct TermEditDistanceConfig { /** * Implements the executor for the term edit distance calculator. */ -class TermEditDistanceExecutor : public fef::FeatureExecutor { +class TermEditDistanceExecutor : public search::fef::FeatureExecutor { public: /** * Constructs a new executor for the term edit distance calculator. * * @param config The config for this executor. */ - TermEditDistanceExecutor(const fef::IQueryEnvironment &env, + TermEditDistanceExecutor(const search::fef::IQueryEnvironment &env, const TermEditDistanceConfig &config); @@ -78,7 +80,7 @@ public: * * @param docid local document id to be evaluated */ - void execute(uint32_t docId) override; + virtual void execute(uint32_t docId) override; private: /** @@ -89,11 +91,11 @@ private: */ void logRow(const std::vector<TedCell> &row, size_t numCols); - void handle_bind_match_data(fef::MatchData &md) override; + virtual void handle_bind_match_data(fef::MatchData &md) override; private: const TermEditDistanceConfig &_config; // The config for this executor. - std::vector<fef::TermFieldHandle> _fieldHandles; // The handles of all query terms. + std::vector<search::fef::TermFieldHandle> _fieldHandles; // The handles of all query terms. std::vector<feature_t> _termWeights; // The weights of all query terms. std::vector<TedCell> _prevRow; // Optimized representation of the cost table. std::vector<TedCell> _thisRow; // @@ -103,17 +105,26 @@ private: /** * Implements the blueprint for the term edit distance calculator. */ -class TermEditDistanceBlueprint : public fef::Blueprint { +class TermEditDistanceBlueprint : public search::fef::Blueprint { public: /** * Constructs a new blueprint for the term edit distance calculator. */ TermEditDistanceBlueprint(); - void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override; - fef::Blueprint::UP createInstance() const override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().indexField(fef::ParameterCollection::SINGLE); + + // Inherit doc from Blueprint. + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &env, + search::fef::IDumpFeatureVisitor &visitor) const override; + + // Inherit doc from Blueprint. + virtual search::fef::Blueprint::UP createInstance() const override; + + // Inherit doc from Blueprint. + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + + // Inherit doc from Blueprint. + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().indexField(search::fef::ParameterCollection::SINGLE); } /** @@ -132,10 +143,12 @@ public: * @param params A list of the parameters mentioned above. * @return Whether or not setup was possible. */ - bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; + virtual bool setup(const search::fef::IIndexEnvironment & env, + const search::fef::ParameterList & params) override; private: TermEditDistanceConfig _config; // The config for this blueprint. }; }} + diff --git a/searchlib/src/vespa/searchlib/features/termfeature.h b/searchlib/src/vespa/searchlib/features/termfeature.h index cd42333f44b..cb4b92dfc11 100644 --- a/searchlib/src/vespa/searchlib/features/termfeature.h +++ b/searchlib/src/vespa/searchlib/features/termfeature.h @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include <string> +#include <vector> #include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchlib/fef/featureexecutor.h> #include <vespa/searchlib/common/feature.h> @@ -11,7 +13,7 @@ namespace features { /** * Implements the executor for term feature. */ -class TermExecutor : public fef::FeatureExecutor { +class TermExecutor : public search::fef::FeatureExecutor { public: /** * Constructs an executor for term feature. @@ -19,32 +21,48 @@ public: * @param env The query environment. * @param termId The id of the query term to evaluate. */ - TermExecutor(const fef::IQueryEnvironment &env, uint32_t termId); - void execute(uint32_t docId) override; + TermExecutor(const search::fef::IQueryEnvironment &env, + uint32_t termId); + virtual void execute(uint32_t docId) override; private: - const fef::ITermData *_termData; - feature_t _connectedness; - feature_t _significance; + const search::fef::ITermData *_termData; + feature_t _connectedness; + feature_t _significance; }; /** * Implements the blueprint for term feature. */ -class TermBlueprint : public fef::Blueprint { +class TermBlueprint : public search::fef::Blueprint { public: + /** + * Constructs a blueprint for term feature. + */ TermBlueprint(); - void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override; - fef::Blueprint::UP createInstance() const override; - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().number(); + // Inherit doc from Blueprint. + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &env, + search::fef::IDumpFeatureVisitor &visitor) const override; + + // Inherit doc from Blueprint. + virtual search::fef::Blueprint::UP createInstance() const override; + + // Inherit doc from Blueprint. + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().number(); } - bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + + // Inherit doc from Blueprint. + virtual bool setup(const search::fef::IIndexEnvironment & env, + const search::fef::ParameterList & params) override; + + // Inherit doc from Blueprint. + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; private: uint32_t _termId; }; }} + diff --git a/searchlib/src/vespa/searchlib/features/terminfofeature.h b/searchlib/src/vespa/searchlib/features/terminfofeature.h index 962b35fc936..7f1d8b8a6e2 100644 --- a/searchlib/src/vespa/searchlib/features/terminfofeature.h +++ b/searchlib/src/vespa/searchlib/features/terminfofeature.h @@ -2,26 +2,30 @@ #pragma once +#include <string> +#include <vector> #include <vespa/searchlib/fef/blueprint.h> #include <vespa/searchlib/fef/featureexecutor.h> namespace search { namespace features { -class TermInfoBlueprint : public fef::Blueprint +class TermInfoBlueprint : public search::fef::Blueprint { private: uint32_t _termIdx; public: TermInfoBlueprint(); - void visitDumpFeatures(const fef::IIndexEnvironment &indexEnv, fef::IDumpFeatureVisitor &visitor) const override; - fef::Blueprint::UP createInstance() const override { return fef::Blueprint::UP(new TermInfoBlueprint()); } - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().number(); + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &indexEnv, + search::fef::IDumpFeatureVisitor &visitor) const override; + virtual search::fef::Blueprint::UP createInstance() const override { return search::fef::Blueprint::UP(new TermInfoBlueprint()); } + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().number(); } - bool setup(const fef::IIndexEnvironment & env, const fef::ParameterList & params) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &queryEnv, vespalib::Stash &stash) const override; + virtual bool setup(const search::fef::IIndexEnvironment & env, + const search::fef::ParameterList & params) override; + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &queryEnv, vespalib::Stash &stash) const override; }; } // namespace features diff --git a/searchlib/src/vespa/searchlib/features/text_similarity_feature.h b/searchlib/src/vespa/searchlib/features/text_similarity_feature.h index b47a7112a0c..084d1dd4b1c 100644 --- a/searchlib/src/vespa/searchlib/features/text_similarity_feature.h +++ b/searchlib/src/vespa/searchlib/features/text_similarity_feature.h @@ -2,6 +2,8 @@ #pragma once +#include <string> +#include <vector> #include <vespa/searchlib/fef/fef.h> #include <vespa/vespalib/util/priority_queue.h> @@ -10,7 +12,7 @@ namespace features { //----------------------------------------------------------------------------- -class TextSimilarityExecutor : public fef::FeatureExecutor +class TextSimilarityExecutor : public search::fef::FeatureExecutor { private: std::vector<fef::TermFieldHandle> _handles; @@ -19,11 +21,11 @@ private: struct Item { uint32_t idx; - fef::TermFieldMatchData::PositionsIterator pos; - fef::TermFieldMatchData::PositionsIterator end; + search::fef::TermFieldMatchData::PositionsIterator pos; + search::fef::TermFieldMatchData::PositionsIterator end; Item(uint32_t idx_in, - fef::TermFieldMatchData::PositionsIterator pos_in, - fef::TermFieldMatchData::PositionsIterator end_in) + search::fef::TermFieldMatchData::PositionsIterator pos_in, + search::fef::TermFieldMatchData::PositionsIterator end_in) : idx(idx_in), pos(pos_in), end(end_in) {} bool operator<(const Item &other) const { return (pos->getPosition() == other.pos->getPosition()) @@ -35,17 +37,17 @@ private: vespalib::PriorityQueue<Item> _queue; const fef::MatchData *_md; - void handle_bind_match_data(fef::MatchData &md) override; + virtual void handle_bind_match_data(fef::MatchData &md) override; public: - TextSimilarityExecutor(const fef::IQueryEnvironment &env, uint32_t field_id); - bool isPure() override { return _handles.empty(); } - void execute(uint32_t docId) override; + TextSimilarityExecutor(const search::fef::IQueryEnvironment &env, uint32_t field_id); + virtual bool isPure() override { return _handles.empty(); } + virtual void execute(uint32_t docId) override; }; //----------------------------------------------------------------------------- -class TextSimilarityBlueprint : public fef::Blueprint +class TextSimilarityBlueprint : public search::fef::Blueprint { private: static const vespalib::string score_output; @@ -58,13 +60,15 @@ private: public: TextSimilarityBlueprint(); - void visitDumpFeatures(const fef::IIndexEnvironment &env, fef::IDumpFeatureVisitor &visitor) const override; - fef::Blueprint::UP createInstance() const override; - fef::ParameterDescriptions getDescriptions() const override { - return fef::ParameterDescriptions().desc().indexField(fef::ParameterCollection::SINGLE); + virtual void visitDumpFeatures(const search::fef::IIndexEnvironment &env, + search::fef::IDumpFeatureVisitor &visitor) const override; + virtual search::fef::Blueprint::UP createInstance() const override; + virtual search::fef::ParameterDescriptions getDescriptions() const override { + return search::fef::ParameterDescriptions().desc().indexField(search::fef::ParameterCollection::SINGLE); } - bool setup(const fef::IIndexEnvironment &env, const fef::ParameterList ¶ms) override; - fef::FeatureExecutor &createExecutor(const fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; + virtual bool setup(const search::fef::IIndexEnvironment &env, + const search::fef::ParameterList ¶ms) override; + virtual search::fef::FeatureExecutor &createExecutor(const search::fef::IQueryEnvironment &env, vespalib::Stash &stash) const override; }; //----------------------------------------------------------------------------- diff --git a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h index 3d99b55f414..8130c35dc2c 100644 --- a/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h +++ b/searchlib/src/vespa/searchlib/queryeval/create_blueprint_visitor_helper.h @@ -113,30 +113,30 @@ public: void illegalVisit() {} - void visit(search::query::And &) override { illegalVisit(); } - void visit(search::query::AndNot &) override { illegalVisit(); } - void visit(search::query::Equiv &) override { illegalVisit(); } - void visit(search::query::Near &) override { illegalVisit(); } - void visit(search::query::ONear &) override { illegalVisit(); } - void visit(search::query::Or &) override { illegalVisit(); } - void visit(search::query::Rank &) override { illegalVisit(); } - void visit(search::query::WeakAnd &) override { illegalVisit(); } - - void visit(search::query::Phrase &n) override { + virtual void visit(search::query::And &) override { illegalVisit(); } + virtual void visit(search::query::AndNot &) override { illegalVisit(); } + virtual void visit(search::query::Equiv &) override { illegalVisit(); } + virtual void visit(search::query::Near &) override { illegalVisit(); } + virtual void visit(search::query::ONear &) override { illegalVisit(); } + virtual void visit(search::query::Or &) override { illegalVisit(); } + virtual void visit(search::query::Rank &) override { illegalVisit(); } + virtual void visit(search::query::WeakAnd &) override { illegalVisit(); } + + virtual void visit(search::query::Phrase &n) override { visitPhrase(n); } - void visit(search::query::WeightedSetTerm &n) override { visitWeightedSetTerm(n); } - void visit(search::query::DotProduct &n) override { visitDotProduct(n); } - void visit(search::query::WandTerm &n) override { visitWandTerm(n); } - - void visit(search::query::NumberTerm &n) override = 0; - void visit(search::query::LocationTerm &n) override = 0; - void visit(search::query::PrefixTerm &n) override = 0; - void visit(search::query::RangeTerm &n) override = 0; - void visit(search::query::StringTerm &n) override = 0; - void visit(search::query::SubstringTerm &n) override = 0; - void visit(search::query::SuffixTerm &n) override = 0; - void visit(search::query::RegExpTerm &n) override = 0; + virtual void visit(search::query::WeightedSetTerm &n) override { visitWeightedSetTerm(n); } + virtual void visit(search::query::DotProduct &n) override { visitDotProduct(n); } + virtual void visit(search::query::WandTerm &n) override { visitWandTerm(n); } + + virtual void visit(search::query::NumberTerm &n) override = 0; + virtual void visit(search::query::LocationTerm &n) override = 0; + virtual void visit(search::query::PrefixTerm &n) override = 0; + virtual void visit(search::query::RangeTerm &n) override = 0; + virtual void visit(search::query::StringTerm &n) override = 0; + virtual void visit(search::query::SubstringTerm &n) override = 0; + virtual void visit(search::query::SuffixTerm &n) override = 0; + virtual void visit(search::query::RegExpTerm &n) override = 0; }; } // namespace search::queryeval diff --git a/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp b/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp index 974d7fd1ca5..6732f37482d 100644 --- a/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/equivsearch.cpp @@ -1,6 +1,9 @@ // 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 "equivsearch.h" +#include <vespa/vespalib/objects/visit.h> +#include <vespa/searchlib/fef/termmatchdatamerger.h> namespace search { namespace queryeval { @@ -14,7 +17,7 @@ private: bool _valid; protected: - void doUnpack(uint32_t docid) override; + virtual void doUnpack(uint32_t docid) override; public: /** diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_search.h b/searchlib/src/vespa/searchlib/queryeval/fake_search.h index 020f045f49d..3ba3d2cf439 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_search.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_search.h @@ -34,11 +34,12 @@ public: { assert(_tfmda.size() == 1); } - void doSeek(uint32_t docid) override; - void doUnpack(uint32_t docid) override; - const PostingInfo *getPostingInfo() const override { return _result.postingInfo(); } - void visitMembers(vespalib::ObjectVisitor &visitor) const override; + virtual void doSeek(uint32_t docid) override; + virtual void doUnpack(uint32_t docid) override; + virtual const PostingInfo *getPostingInfo() const override { return _result.postingInfo(); } + virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override; }; } // namespace queryeval } // namespace search + diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp index 6aadb33c035..9e7e7ed6c9a 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/fake_searchable.cpp @@ -54,15 +54,15 @@ public: template <class TermNode> void visitTerm(TermNode &n); - void visit(NumberTerm &n) override { visitTerm(n); } - void visit(LocationTerm &n) override { visitTerm(n); } - void visit(PrefixTerm &n) override { visitTerm(n); } - void visit(RangeTerm &n) override { visitTerm(n); } - void visit(StringTerm &n) override { visitTerm(n); } - void visit(SubstringTerm &n) override { visitTerm(n); } - void visit(SuffixTerm &n) override { visitTerm(n); } - void visit(PredicateQuery &n) override { visitTerm(n); } - void visit(RegExpTerm &n) override { visitTerm(n); } + virtual void visit(NumberTerm &n) override { visitTerm(n); } + virtual void visit(LocationTerm &n) override { visitTerm(n); } + virtual void visit(PrefixTerm &n) override { visitTerm(n); } + virtual void visit(RangeTerm &n) override { visitTerm(n); } + virtual void visit(StringTerm &n) override { visitTerm(n); } + virtual void visit(SubstringTerm &n) override { visitTerm(n); } + virtual void visit(SuffixTerm &n) override { visitTerm(n); } + virtual void visit(PredicateQuery &n) override { visitTerm(n); } + virtual void visit(RegExpTerm &n) override { visitTerm(n); } }; template <class Map> diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_searchable.h b/searchlib/src/vespa/searchlib/queryeval/fake_searchable.h index 822cf439ad6..34b6e250797 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_searchable.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_searchable.h @@ -55,11 +55,12 @@ public: const vespalib::string &term, const FakeResult &result); + // inherited from Searchable using Searchable::createBlueprint; - Blueprint::UP createBlueprint(const IRequestContext & requestContext, - const FieldSpec &field, - const search::query::Node &term) override; - ~FakeSearchable(); + virtual Blueprint::UP createBlueprint(const IRequestContext & requestContext, + const FieldSpec &field, + const search::query::Node &term) override; + virtual ~FakeSearchable(); }; } // namespace search::queryeval diff --git a/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp b/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp index 95615c8b923..9a91bf6e2b8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/get_weight_from_node.cpp @@ -1,9 +1,15 @@ // 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/log/log.h> +LOG_SETUP(".get_weight_from_node"); + #include "get_weight_from_node.h" #include <vespa/searchlib/query/tree/intermediatenodes.h> +#include <vespa/searchlib/query/tree/node.h> #include <vespa/searchlib/query/tree/simplequery.h> #include <vespa/searchlib/query/tree/templatetermvisitor.h> +#include <vespa/searchlib/query/tree/termnodes.h> using search::query::Node; using search::query::SimpleQueryNodeTypes; @@ -25,7 +31,7 @@ struct WeightExtractor : public TemplateTermVisitor<WeightExtractor, } // Treat Equiv nodes as terms. - void visit(search::query::Equiv &n) override { visitTerm(n); } + virtual void visit(search::query::Equiv &n) override { visitTerm(n); } }; } // namespace search::queryeval::<unnamed> diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp index 65b1257b105..64776b99f16 100644 --- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp @@ -542,7 +542,7 @@ class FindSource : public Blueprint::IPredicate { public: FindSource(uint32_t sourceId) : _sourceId(sourceId) { } - bool check(const Blueprint & bp) const override { return bp.getSourceId() == _sourceId; } + virtual bool check(const Blueprint & bp) const override { return bp.getSourceId() == _sourceId; } private: uint32_t _sourceId; }; diff --git a/searchlib/src/vespa/searchlib/queryeval/monitoring_search_iterator.h b/searchlib/src/vespa/searchlib/queryeval/monitoring_search_iterator.h index c0b3c9a9ff6..d910499b463 100644 --- a/searchlib/src/vespa/searchlib/queryeval/monitoring_search_iterator.h +++ b/searchlib/src/vespa/searchlib/queryeval/monitoring_search_iterator.h @@ -81,14 +81,15 @@ public: vespalib::string toString() const { return _str; } - void openStruct(const vespalib::string &name, const vespalib::string &type) override; - void closeStruct() override; - void visitBool(const vespalib::string &name, bool value) override; - void visitInt(const vespalib::string &name, int64_t value) override; - void visitFloat(const vespalib::string &name, double value) override; - void visitString(const vespalib::string &name, const vespalib::string &value) override; - void visitNull(const vespalib::string &name) override; - void visitNotImplemented() override; + // Overrides ObjectVisitor + virtual void openStruct(const vespalib::string &name, const vespalib::string &type) override; + virtual void closeStruct() override; + virtual void visitBool(const vespalib::string &name, bool value) override; + virtual void visitInt(const vespalib::string &name, int64_t value) override; + virtual void visitFloat(const vespalib::string &name, double value) override; + virtual void visitString(const vespalib::string &name, const vespalib::string &value) override; + virtual void visitNull(const vespalib::string &name) override; + virtual void visitNotImplemented() override; }; typedef std::unique_ptr<MonitoringSearchIterator> UP; @@ -114,7 +115,7 @@ public: SearchIterator::initRange(_search->getDocId()+1, _search->getEndId()); } Trinary is_strict() const override { return _search->is_strict(); } - const PostingInfo *getPostingInfo() const override; + virtual const PostingInfo *getPostingInfo() const override; void visitMembers(vespalib::ObjectVisitor &visitor) const override; const SearchIterator &getIterator() const { return *_search; } diff --git a/searchlib/src/vespa/searchlib/queryeval/nearsearch.h b/searchlib/src/vespa/searchlib/queryeval/nearsearch.h index 96dd497fb7c..6ba631abb16 100644 --- a/searchlib/src/vespa/searchlib/queryeval/nearsearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/nearsearch.h @@ -77,8 +77,10 @@ public: uint32_t window, bool strict); - void visitMembers(vespalib::ObjectVisitor &visitor) const override; - void doSeek(uint32_t docId) override; + virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override; + + // Inherit doc from SearchIterator. + virtual void doSeek(uint32_t docId) override; }; /** @@ -95,7 +97,9 @@ private: }; std::vector<Matcher> _matchers; - bool match(uint32_t docId) override; + + // Inherit doc from NearSearchBase. + virtual bool match(uint32_t docId) override; public: /** @@ -127,7 +131,9 @@ private: }; std::vector<Matcher> _matchers; - bool match(uint32_t docId) override; + + // Inherit doc from NearSearchBase. + virtual bool match(uint32_t docId) override; public: /** diff --git a/searchlib/src/vespa/searchlib/queryeval/orlikesearch.h b/searchlib/src/vespa/searchlib/queryeval/orlikesearch.h index b1fae7c0bb2..5a62cc5dedb 100644 --- a/searchlib/src/vespa/searchlib/queryeval/orlikesearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/orlikesearch.h @@ -2,8 +2,8 @@ #pragma once -#include "orsearch.h" #include <vespa/vespalib/objects/visit.h> +#include "orsearch.h" namespace search { namespace queryeval { @@ -52,16 +52,16 @@ public: _unpacker(unpacker) { } private: - void onRemove(size_t index) override { + virtual void onRemove(size_t index) override { _unpacker.onRemove(index); } - void onInsert(size_t index) override { + virtual void onInsert(size_t index) override { _unpacker.onInsert(index); } - void doUnpack(uint32_t docid) override { + virtual void doUnpack(uint32_t docid) override { _unpacker.unpack(docid, *this); } - bool needUnpack(size_t index) const override { + virtual bool needUnpack(size_t index) const override { return _unpacker.needUnpack(index); } Unpack _unpacker; @@ -70,3 +70,4 @@ private: } // namespace queryeval } // namespace search + diff --git a/searchlib/src/vespa/searchlib/queryeval/orsearch.h b/searchlib/src/vespa/searchlib/queryeval/orsearch.h index bd3d0aa5e3f..e75776d7161 100644 --- a/searchlib/src/vespa/searchlib/queryeval/orsearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/orsearch.h @@ -27,9 +27,9 @@ public: protected: OrSearch(const Children & children) : MultiSearch(children) { } private: - - bool isOr() const override { return true; } + virtual bool isOr() const override { return true; } }; } // namespace queryeval } // namespace search + diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h index 46765f40fd6..2d1f09da9c8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h +++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h @@ -48,9 +48,10 @@ public: const fef::TermFieldMatchDataArray &childMatch, std::vector<uint32_t> eval_order, fef::TermFieldMatchData &tmd, bool strict); - void doSeek(uint32_t doc_id) override; - void doUnpack(uint32_t doc_id) override; - void visitMembers(vespalib::ObjectVisitor &visitor) const override; + + virtual void doSeek(uint32_t doc_id) override; + virtual void doUnpack(uint32_t doc_id) override; + virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override; SimplePhraseSearch & setDoom(const vespalib::Doom * doom) { _doom = doom; return *this; } }; diff --git a/searchlib/src/vespa/searchlib/queryeval/simplesearch.h b/searchlib/src/vespa/searchlib/queryeval/simplesearch.h index 53c22deb237..50553541e98 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simplesearch.h +++ b/searchlib/src/vespa/searchlib/queryeval/simplesearch.h @@ -23,8 +23,8 @@ private: SimpleSearch &operator=(const SimpleSearch &); protected: - void doSeek(uint32_t docid) override; - void doUnpack(uint32_t docid) override; + virtual void doSeek(uint32_t docid) override; + virtual void doUnpack(uint32_t docid) override; public: SimpleSearch(const SimpleResult &result); @@ -32,8 +32,8 @@ public: _tag = t; return *this; } - void visitMembers(vespalib::ObjectVisitor &visitor) const override; - ~SimpleSearch(); + virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override; + virtual ~SimpleSearch(); }; } // namespace queryeval diff --git a/searchlib/src/vespa/searchlib/queryeval/termasstring.cpp b/searchlib/src/vespa/searchlib/queryeval/termasstring.cpp index 8aa015dc752..07a7763d626 100644 --- a/searchlib/src/vespa/searchlib/queryeval/termasstring.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/termasstring.cpp @@ -78,28 +78,29 @@ struct TermAsStringVisitor : public QueryVisitor { isSet = false; } - void visit(And &) override {illegalVisit(); } - void visit(AndNot &) override {illegalVisit(); } - void visit(Equiv &) override {illegalVisit(); } - void visit(Near &) override {illegalVisit(); } - void visit(ONear &) override {illegalVisit(); } - void visit(Or &) override {illegalVisit(); } - void visit(Phrase &) override {illegalVisit(); } - void visit(Rank &) override {illegalVisit(); } - void visit(WeakAnd &) override {illegalVisit(); } - void visit(WeightedSetTerm &) override {illegalVisit(); } - void visit(DotProduct &) override {illegalVisit(); } - void visit(WandTerm &) override {illegalVisit(); } - - void visit(NumberTerm &n) override {visitTerm(n); } - void visit(LocationTerm &n) override {visitTerm(n); } - void visit(PrefixTerm &n) override {visitTerm(n); } - void visit(RangeTerm &n) override {visitTerm(n); } - void visit(StringTerm &n) override {visitTerm(n); } - void visit(SubstringTerm &n) override {visitTerm(n); } - void visit(SuffixTerm &n) override {visitTerm(n); } - void visit(RegExpTerm &n) override {visitTerm(n); } - void visit(PredicateQuery &) override {illegalVisit(); } + virtual void visit(And &) override { illegalVisit(); } + virtual void visit(AndNot &) override { illegalVisit(); } + virtual void visit(Equiv &) override { illegalVisit(); } + virtual void visit(Near &) override { illegalVisit(); } + virtual void visit(ONear &) override { illegalVisit(); } + virtual void visit(Or &) override { illegalVisit(); } + virtual void visit(Phrase &) override { illegalVisit(); } + virtual void visit(Rank &) override { illegalVisit(); } + virtual void visit(WeakAnd &) override { illegalVisit(); } + virtual void visit(WeightedSetTerm &) override { illegalVisit(); } + virtual void visit(DotProduct &) override { illegalVisit(); } + virtual void visit(WandTerm &) override { illegalVisit(); } + + virtual void visit(NumberTerm &n) override { visitTerm(n); } + virtual void visit(LocationTerm &n) override { visitTerm(n); } + virtual void visit(PrefixTerm &n) override { visitTerm(n); } + virtual void visit(RangeTerm &n) override { visitTerm(n); } + virtual void visit(StringTerm &n) override { visitTerm(n); } + virtual void visit(SubstringTerm &n) override { visitTerm(n); } + virtual void visit(SuffixTerm &n) override { visitTerm(n); } + virtual void visit(RegExpTerm &n) override { visitTerm(n); } + + virtual void visit(PredicateQuery &) override { illegalVisit(); } }; } // namespace diff --git a/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_search.h b/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_search.h index 3c1aba30bf7..1c3059913e8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_search.h +++ b/searchlib/src/vespa/searchlib/queryeval/wand/weak_and_search.h @@ -15,7 +15,7 @@ struct WeakAndSearch : SearchIterator { virtual wand::score_t get_max_score(size_t idx) const = 0; virtual const Terms &getTerms() const = 0; virtual uint32_t getN() const = 0; - void visitMembers(vespalib::ObjectVisitor &visitor) const override; + virtual void visitMembers(vespalib::ObjectVisitor &visitor) const override; static SearchIterator *createArrayWand(const Terms &terms, uint32_t n, bool strict); static SearchIterator *createHeapWand(const Terms &terms, uint32_t n, bool strict); static SearchIterator *create(const Terms &terms, uint32_t n, bool strict); diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp index 2b7b5398e1e..c1f9baedb17 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp @@ -788,8 +788,11 @@ class FakeEGCompr64SkipFilterOcc : public FakeEGCompr64FilterOcc { public: FakeEGCompr64SkipFilterOcc(const FakeWord &fw); - ~FakeEGCompr64SkipFilterOcc(); - search::queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + + ~FakeEGCompr64SkipFilterOcc(void); + + virtual search::queryeval::SearchIterator * + createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h index a2bd1ab1038..fb49bd22cda 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.h @@ -4,9 +4,11 @@ #include "fakeword.h" #include "fakeposting.h" -namespace search { +namespace search +{ -namespace fakedata { +namespace fakedata +{ /* * Old compressed posocc format. @@ -38,30 +40,70 @@ private: void setup(const FakeWord &fw); template <bool bigEndian> - void setupT(const FakeWord &fw); + void + setupT(const FakeWord &fw); public: FakeEGCompr64FilterOcc(const FakeWord &fw); - FakeEGCompr64FilterOcc(const FakeWord &fw, bool bigEndian, const char *nameSuffix); - - ~FakeEGCompr64FilterOcc(); - - static void forceLink(); - - size_t bitSize() const override; - bool hasWordPositions() const override; - size_t skipBitSize() const override; - size_t l1SkipBitSize() const override; - size_t l2SkipBitSize() const override; - size_t l3SkipBitSize() const override; - size_t l4SkipBitSize() const override; - int lowLevelSinglePostingScan() const override; - int lowLevelSinglePostingScanUnpack() const override; - int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; - int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + + FakeEGCompr64FilterOcc(const FakeWord &fw, + bool bigEndian, + const char *nameSuffix); + + ~FakeEGCompr64FilterOcc(void); + + static void + forceLink(void); + + /* + * Size of posting list, in bits. + */ + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + /* + * Size of posting skip list, in bits. + */ + size_t skipBitSize(void) const override; + size_t l1SkipBitSize(void) const override; + size_t l2SkipBitSize(void) const override; + size_t l3SkipBitSize(void) const override; + size_t l4SkipBitSize(void) const override; + + /* + * Single posting list performance, without feature unpack. + */ + virtual int + lowLevelSinglePostingScan(void) const override; + + /* + * Single posting list performance, with feature unpack. + */ + virtual int + lowLevelSinglePostingScanUnpack(void) const override; + + /* + * Two posting lists performance (same format) without feature unpack. + */ + virtual int + lowLevelAndPairPostingScan(const FakePosting &rhs) const override; + + /* + * Two posting lists performance (same format) with feature unpack. + */ + virtual int + lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; + + + /* + * Iterator factory, for current query evaluation framework. + */ + virtual search::queryeval::SearchIterator * + createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } // namespace fakedata } // namespace search + diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h index 2946f15c539..427110383fd 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakefilterocc.h @@ -4,9 +4,11 @@ #include "fakeword.h" #include "fakeposting.h" -namespace search { +namespace search +{ -namespace fakedata { +namespace fakedata +{ /* * Old posocc format. @@ -20,19 +22,51 @@ private: public: FakeFilterOcc(const FakeWord &fakeword); - ~FakeFilterOcc(); + ~FakeFilterOcc(void); + + static void + forceLink(void); + + /* + * Size of posting list, in bits. + */ + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; - static void forceLink(); + /* + * Single posting list performance, without feature unpack. + */ + virtual int + lowLevelSinglePostingScan(void) const override; - size_t bitSize() const override; - bool hasWordPositions(void) const override; - int lowLevelSinglePostingScan(void) const override; - int lowLevelSinglePostingScanUnpack(void) const override; - int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; - int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator * createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + /* + * Single posting list performance, with feature unpack. + */ + virtual int + lowLevelSinglePostingScanUnpack(void) const override; + + /* + * Two posting lists performance (same format) without feature unpack. + */ + virtual int + lowLevelAndPairPostingScan(const FakePosting &rhs) const override; + + /* + * Two posting lists performance (same format) with feature unpack. + */ + virtual int + lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; + + + /* + * Iterator factory, for current query evaluation framework. + */ + virtual search::queryeval::SearchIterator * + createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } // namespace fakedata } // namespace search + diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h index acc28217d09..c4f3e27c4ac 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h @@ -9,8 +9,11 @@ #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> -namespace search { -namespace fakedata { +namespace search +{ + +namespace fakedata +{ class FakeMemTreeOccMgr : public FakeWord::RandomizedWriter { @@ -35,9 +38,12 @@ public: PostingIdx(NodeAllocator &allocator) : _tree(), _iterator(_tree.getRoot(), allocator) - {} + { + } - void clear() { + void + clear(void) + { _tree.clear(_iterator.getAllocator()); _iterator = _tree.begin(_iterator.getAllocator()); } @@ -58,7 +64,8 @@ public: _features(), _removal(true), _seq(0) - {} + { + } PendingOp(uint32_t wordIdx, uint32_t docId, EntryRef features) : _wordIdx(wordIdx), @@ -66,15 +73,42 @@ public: _features(features), _removal(false), _seq(0) - {} + { + } - void setSeq(uint32_t seq) { _seq = seq; } - uint32_t getWordIdx(void) const { return _wordIdx; } - uint32_t getDocId(void) const { return _docId; } - EntryRef getFeatureRef(void) const { return _features; } - bool getRemove() const { return _removal; } + void + setSeq(uint32_t seq) + { + _seq = seq; + } + + uint32_t + getWordIdx(void) const + { + return _wordIdx; + } + + uint32_t + getDocId(void) const + { + return _docId; + } - bool operator<(const PendingOp &rhs) const { + EntryRef + getFeatureRef(void) const + { + return _features; + } + + bool + getRemove(void) const + { + return _removal; + } + + bool + operator<(const PendingOp &rhs) const + { if (_wordIdx != rhs._wordIdx) return _wordIdx < rhs._wordIdx; if (_docId != rhs._docId) @@ -91,19 +125,42 @@ public: FeatureStore _featureStore; FakeMemTreeOccMgr(const Schema &schema); - ~FakeMemTreeOccMgr(); - - void freeze(); - void transferHoldLists(); - void incGeneration(); - void trimHoldLists(); - void sync(); - void add(uint32_t wordIdx, index::DocIdAndFeatures &features) override; - void remove(uint32_t wordIdx, uint32_t docId) override; - void sortUnflushed(); - void flush(); - void compactTrees(); - void finalize(); + + virtual + ~FakeMemTreeOccMgr(void); + + void + freeze(void); + + void + transferHoldLists(void); + + void + incGeneration(void); + + void + trimHoldLists(void); + + void + sync(void); + + virtual void + add(uint32_t wordIdx, index::DocIdAndFeatures &features) override; + + virtual void + remove(uint32_t wordIdx, uint32_t docId) override; + + void + sortUnflushed(void); + + void + flush(void); + + void + compactTrees(void); + + void + finalize(void); }; @@ -117,22 +174,33 @@ public: FakeMemTreeOccMgr _mgr; FakeMemTreeOccFactory(const Schema &schema); - ~FakeMemTreeOccFactory(); - FakePosting::SP make(const FakeWord &fw) override; - void setup(const std::vector<const FakeWord *> &fws) override; + virtual + ~FakeMemTreeOccFactory(void); + + virtual FakePosting::SP + make(const FakeWord &fw) override; + + virtual void + setup(const std::vector<const FakeWord *> &fws) override; }; class FakeMemTreeOcc2Factory : public FakeMemTreeOccFactory { public: FakeMemTreeOcc2Factory(const Schema &schema); - ~FakeMemTreeOcc2Factory(); - FakePosting::SP make(const FakeWord &fw) override; - void setup(const std::vector<const FakeWord *> &fws) override; + virtual + ~FakeMemTreeOcc2Factory(void); + + virtual FakePosting::SP + make(const FakeWord &fw) override; + + virtual void + setup(const std::vector<const FakeWord *> &fws) override; }; + /* * Updateable memory tree format. */ @@ -167,18 +235,51 @@ public: const FakeMemTreeOccMgr &mgr, const char *suffix); - ~FakeMemTreeOcc(); + ~FakeMemTreeOcc(void); + + static void + forceLink(void); + + /* + * Size of posting list, in bits. + */ + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + /* + * Single posting list performance, without feature unpack. + */ + virtual int + lowLevelSinglePostingScan(void) const override; - static void forceLink(); - size_t bitSize() const override; - bool hasWordPositions() const override; - int lowLevelSinglePostingScan() const override; - int lowLevelSinglePostingScanUnpack() const override; - int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; - int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + /* + * Single posting list performance, with feature unpack. + */ + virtual int + lowLevelSinglePostingScanUnpack(void) const override; + + /* + * Two posting lists performance (same format) without feature unpack. + */ + virtual int + lowLevelAndPairPostingScan(const FakePosting &rhs) const override; + + /* + * Two posting lists performance (same format) with feature unpack. + */ + virtual int + lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; + + + /* + * Iterator factory, for current query evaluation framework. + */ + virtual search::queryeval::SearchIterator * + createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } // namespace fakedata } // namespace search + diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h index f88df381d92..5e146b5705a 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcbfilterocc.h @@ -4,9 +4,11 @@ #include "fakeword.h" #include "fakeposting.h" -namespace search { +namespace search +{ -namespace fakedata { +namespace fakedata +{ /* * YST style compression of docid list. @@ -20,19 +22,52 @@ private: size_t _bitSize; public: FakeZcbFilterOcc(const FakeWord &fw); - ~FakeZcbFilterOcc(); - static void forceLink(); + ~FakeZcbFilterOcc(void); + + static void + forceLink(void); + + /* + * Size of posting list, in bits. + */ + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + /* + * Single posting list performance, without feature unpack. + */ + virtual int + lowLevelSinglePostingScan(void) const override; - size_t bitSize() const override; - bool hasWordPositions() const override; - int lowLevelSinglePostingScan() const override; - int lowLevelSinglePostingScanUnpack() const override; - int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; - int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + /* + * Single posting list performance, with feature unpack. + */ + virtual int + lowLevelSinglePostingScanUnpack(void) const override; + + /* + * Two posting lists performance (same format) without feature unpack. + */ + virtual int + lowLevelAndPairPostingScan(const FakePosting &rhs) const override; + + /* + * Two posting lists performance (same format) with feature unpack. + */ + virtual int + lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; + + + /* + * Iterator factory, for current query evaluation framework. + */ + virtual search::queryeval::SearchIterator * + createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } // namespace fakedata } // namespace search + diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp index ee9bed6ba02..dfd47889513 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.cpp @@ -1,8 +1,16 @@ // 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/log/log.h> +LOG_SETUP(".fakezcfilterocc"); #include "fakezcfilterocc.h" -#include "fpfactory.h" +#include <vespa/searchlib/bitcompression/compression.h> +#include <vespa/searchlib/bitcompression/posocccompression.h> #include <vespa/searchlib/diskindex/zcposocciterators.h> +#include <vespa/searchlib/index/docidandfeatures.h> +#include <vespa/searchlib/index/postinglistcounts.h> +#include "fpfactory.h" + using search::fef::TermFieldMatchData; using search::fef::TermFieldMatchDataArray; @@ -18,9 +26,11 @@ using search::bitcompression::FeatureEncodeContext; using search::ComprFileWriteContext; using namespace search::diskindex; -namespace search { +namespace search +{ -namespace fakedata { +namespace fakedata +{ #define L1SKIPSTRIDE 16 @@ -759,8 +769,10 @@ class FakeZcSkipFilterOcc : public FakeZcFilterOcc public: FakeZcSkipFilterOcc(const FakeWord &fw); - ~FakeZcSkipFilterOcc(); - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + ~FakeZcSkipFilterOcc(void); + + virtual SearchIterator * + createIterator(const TermFieldMatchDataArray &matchData) const override; }; static FPFactoryInit @@ -1372,11 +1384,17 @@ class FakeEGCompr64PosOcc : public FakeZcFilterOcc { public: FakeEGCompr64PosOcc(const FakeWord &fw); - ~FakeEGCompr64PosOcc(); + + ~FakeEGCompr64PosOcc(void); + void setup(const FakeWord &fw); - size_t bitSize() const override; - bool hasWordPositions() const override; - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + virtual SearchIterator * + createIterator(const TermFieldMatchDataArray &matchData) const override; }; @@ -1470,7 +1488,7 @@ FakeEGCompr64PosOcc<bigEndian>::setup(const FakeWord &fw) template <bool bigEndian> size_t -FakeEGCompr64PosOcc<bigEndian>::bitSize() const +FakeEGCompr64PosOcc<bigEndian>::bitSize(void) const { return _compressedBits; } @@ -1478,7 +1496,7 @@ FakeEGCompr64PosOcc<bigEndian>::bitSize() const template <bool bigEndian> bool -FakeEGCompr64PosOcc<bigEndian>::hasWordPositions() const +FakeEGCompr64PosOcc<bigEndian>::hasWordPositions(void) const { return true; } @@ -1499,11 +1517,17 @@ class FakeEG2Compr64PosOcc : public FakeZcFilterOcc { public: FakeEG2Compr64PosOcc(const FakeWord &fw); - ~FakeEG2Compr64PosOcc(); + + ~FakeEG2Compr64PosOcc(void); + void setup(const FakeWord &fw); - size_t bitSize() const override; - bool hasWordPositions() const override; - SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + virtual SearchIterator * + createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; @@ -1626,11 +1650,15 @@ class FakeZcSkipPosOcc : public FakeZcFilterOcc search::index::PostingListCounts _counts; public: FakeZcSkipPosOcc(const FakeWord &fw); - ~FakeZcSkipPosOcc(); - size_t bitSize() const override; - bool hasWordPositions() const override; - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + ~FakeZcSkipPosOcc(void); + + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + virtual SearchIterator * + createIterator(const TermFieldMatchDataArray &matchData) const override; }; @@ -1645,14 +1673,14 @@ FakeZcSkipPosOcc<bigEndian>::FakeZcSkipPosOcc(const FakeWord &fw) template <bool bigEndian> -FakeZcSkipPosOcc<bigEndian>::~FakeZcSkipPosOcc() +FakeZcSkipPosOcc<bigEndian>::~FakeZcSkipPosOcc(void) { } template <bool bigEndian> size_t -FakeZcSkipPosOcc<bigEndian>::bitSize() const +FakeZcSkipPosOcc<bigEndian>::bitSize(void) const { return _compressedBits - _l1SkipSize - _l2SkipSize - _l3SkipSize - _l4SkipSize; @@ -1661,7 +1689,7 @@ FakeZcSkipPosOcc<bigEndian>::bitSize() const template <bool bigEndian> bool -FakeZcSkipPosOcc<bigEndian>::hasWordPositions() const +FakeZcSkipPosOcc<bigEndian>::hasWordPositions(void) const { return true; } @@ -1686,10 +1714,15 @@ class FakeZc2SkipPosOcc : public FakeZcFilterOcc search::index::PostingListCounts _counts; public: FakeZc2SkipPosOcc(const FakeWord &fw); - ~FakeZc2SkipPosOcc(); - size_t bitSize() const override; - bool hasWordPositions() const override; - SearchIterator *createIterator(const TermFieldMatchDataArray &matchData) const override; + + ~FakeZc2SkipPosOcc(void); + + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + virtual SearchIterator * + createIterator(const TermFieldMatchDataArray &matchData) const override; }; @@ -1704,14 +1737,14 @@ FakeZc2SkipPosOcc<bigEndian>::FakeZc2SkipPosOcc(const FakeWord &fw) template <bool bigEndian> -FakeZc2SkipPosOcc<bigEndian>::~FakeZc2SkipPosOcc() +FakeZc2SkipPosOcc<bigEndian>::~FakeZc2SkipPosOcc(void) { } template <bool bigEndian> size_t -FakeZc2SkipPosOcc<bigEndian>::bitSize() const +FakeZc2SkipPosOcc<bigEndian>::bitSize(void) const { return _compressedBits - _l1SkipSize - _l2SkipSize - _l3SkipSize - _l4SkipSize; @@ -1720,7 +1753,7 @@ FakeZc2SkipPosOcc<bigEndian>::bitSize() const template <bool bigEndian> bool -FakeZc2SkipPosOcc<bigEndian>::hasWordPositions() const +FakeZc2SkipPosOcc<bigEndian>::hasWordPositions(void) const { return true; } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h index 5d81e37001e..65ac3ead5d1 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakezcfilterocc.h @@ -1,14 +1,17 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once + #include "fakeword.h" #include "fakeposting.h" #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> -namespace search { +namespace search +{ -namespace fakedata { +namespace fakedata +{ /* * YST style compression of docid list. @@ -35,29 +38,70 @@ protected: void setup(const FakeWord &fw, bool doFeatures, bool dynamicK); template <bool bigEndian> - void setupT(const FakeWord &fw, bool doFeatures, bool dynamicK); + void + setupT(const FakeWord &fw, bool doFeatures, bool dynamicK); public: FakeZcFilterOcc(const FakeWord &fw); - FakeZcFilterOcc(const FakeWord &fw, bool bigEndian, const char *nameSuffix); - ~FakeZcFilterOcc(); - - static void forceLink(); - - size_t bitSize() const override; - bool hasWordPositions() const override; - size_t skipBitSize() const override; - size_t l1SkipBitSize() const override; - size_t l2SkipBitSize() const override; - size_t l3SkipBitSize() const override; - size_t l4SkipBitSize() const override; - int lowLevelSinglePostingScan() const override; - int lowLevelSinglePostingScanUnpack() const override; - int lowLevelAndPairPostingScan(const FakePosting &rhs) const override; - int lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; - queryeval::SearchIterator *createIterator(const fef::TermFieldMatchDataArray &matchData) const override; + + FakeZcFilterOcc(const FakeWord &fw, + bool bigEndian, + const char *nameSuffix); + + ~FakeZcFilterOcc(void); + + static void + forceLink(void); + + /* + * Size of posting list, in bits. + */ + size_t bitSize(void) const override; + + virtual bool hasWordPositions(void) const override; + + /* + * Size of posting skip list, in bits. + */ + size_t skipBitSize(void) const override; + size_t l1SkipBitSize(void) const override; + size_t l2SkipBitSize(void) const override; + size_t l3SkipBitSize(void) const override; + size_t l4SkipBitSize(void) const override; + + /* + * Single posting list performance, without feature unpack. + */ + virtual int + lowLevelSinglePostingScan(void) const override; + + /* + * Single posting list performance, with feature unpack. + */ + virtual int + lowLevelSinglePostingScanUnpack(void) const override; + + /* + * Two posting lists performance (same format) without feature unpack. + */ + virtual int + lowLevelAndPairPostingScan(const FakePosting &rhs) const override; + + /* + * Two posting lists performance (same format) with feature unpack. + */ + virtual int + lowLevelAndPairPostingScanUnpack(const FakePosting &rhs) const override; + + + /* + * Iterator factory, for current query evaluation framework. + */ + virtual search::queryeval::SearchIterator * + createIterator(const fef::TermFieldMatchDataArray &matchData) const override; }; } // namespace fakedata } // namespace search + diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fpfactory.h b/searchlib/src/vespa/searchlib/test/fakedata/fpfactory.h index aa67eb1b933..bf02e815da8 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fpfactory.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fpfactory.h @@ -41,7 +41,9 @@ public: (void) schema; } - FakePosting::SP make(const FakeWord &fw) override { + virtual FakePosting::SP + make(const FakeWord &fw) override + { return FakePosting::SP(new P(fw)); } }; diff --git a/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h b/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h index 9eccdbaff0e..a41b6c27c5d 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h +++ b/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h @@ -4,16 +4,24 @@ #include "syncproxy.h" -namespace search { -namespace transactionlog { +namespace search +{ +namespace transactionlog +{ class NoSyncProxy : public SyncProxy { public: - NoSyncProxy(); - ~NoSyncProxy(); - void sync(SerialNum syncTo) override; + NoSyncProxy(void); + + virtual + ~NoSyncProxy(void); + + virtual void + sync(SerialNum syncTo) override; }; } + } + diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogclient.h b/searchlib/src/vespa/searchlib/transactionlog/translogclient.h index 802933b7d81..e219f5cffbc 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogclient.h +++ b/searchlib/src/vespa/searchlib/transactionlog/translogclient.h @@ -66,10 +66,10 @@ public: Subscriber(const vespalib::string & domain, TransLogClient & tlc, Callback & callBack); bool subscribe(const SerialNum & from); - ~Subscriber(); - RPC::Result visit(const Packet & packet) override { return _callback.receive(packet); } - void inSync() override { _callback.inSync(); } - void eof() override { _callback.eof(); } + virtual ~Subscriber(); + virtual RPC::Result visit(const Packet & packet) override { return _callback.receive(packet); } + virtual void inSync() override { _callback.inSync(); } + virtual void eof() override { _callback.eof(); } private: Callback & _callback; }; diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h index 105a6ca643b..8e64b17ecb4 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h @@ -41,7 +41,7 @@ public: uint64_t setDomainPartSize(); DomainStats getDomainStats() const; - void commit(const vespalib::string & domainName, const Packet & packet) override; + virtual void commit(const vespalib::string & domainName, const Packet & packet) override; class Session @@ -56,8 +56,8 @@ public: }; private: - bool onStop() override; - void run() override; + virtual bool onStop() override; + virtual void run() override; void exportRPC(FRT_Supervisor & supervisor); void relayToThreadRPC(FRT_RPCRequest *req); diff --git a/searchlib/src/vespa/searchlib/util/rand48.h b/searchlib/src/vespa/searchlib/util/rand48.h index 6d27d179a74..d8bfa683f15 100644 --- a/searchlib/src/vespa/searchlib/util/rand48.h +++ b/searchlib/src/vespa/searchlib/util/rand48.h @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright (C) 2003 Fast Search & Transfer ASA +// Copyright (C) 2003 Overture Services Norway AS #pragma once -#include <cstdlib> -#include <cstdint> namespace search { @@ -26,14 +26,14 @@ public: { srand48(0x1234abcd); }; - void iterate() { + void iterate(void) { _state = (UINT64_C(0x5DEECE66D) * _state + 0xb) & UINT64_C(0xFFFFFFFFFFFF); } /* * Return value from 0 to 2^31 - 1 */ - long lrand48() { + long lrand48(void) { iterate(); return static_cast<long>(_state >> 17); } diff --git a/slobrok/src/apps/check_slobrok/check_slobrok.cpp b/slobrok/src/apps/check_slobrok/check_slobrok.cpp index 9d588eab39f..8e2a91c100d 100644 --- a/slobrok/src/apps/check_slobrok/check_slobrok.cpp +++ b/slobrok/src/apps/check_slobrok/check_slobrok.cpp @@ -1,12 +1,14 @@ // 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/log/log.h> +LOG_SETUP("check_slobrok"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + #include <string> #include <sstream> -#include <vespa/log/log.h> -LOG_SETUP("check_slobrok"); class Slobrok_Checker : public FastOS_Application { @@ -23,9 +25,10 @@ public: int usage(); void initRPC(const char *spec); void finiRPC(); - int Main() override; + virtual int Main() override; }; + Slobrok_Checker::~Slobrok_Checker() { LOG_ASSERT(_supervisor == NULL); diff --git a/slobrok/src/apps/sbcmd/sbcmd.cpp b/slobrok/src/apps/sbcmd/sbcmd.cpp index a96c4609137..60a3dfc779b 100644 --- a/slobrok/src/apps/sbcmd/sbcmd.cpp +++ b/slobrok/src/apps/sbcmd/sbcmd.cpp @@ -1,12 +1,14 @@ // 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/log/log.h> +LOG_SETUP("sb-cmd"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> + #include <string> #include <sstream> -#include <vespa/log/log.h> -LOG_SETUP("sb-cmd"); class Slobrok_CMD : public FastOS_Application { @@ -23,15 +25,17 @@ public: int usage(); void initRPC(const char *spec); void finiRPC(); - int Main() override; + virtual int Main() override; }; + Slobrok_CMD::~Slobrok_CMD() { LOG_ASSERT(_supervisor == NULL); LOG_ASSERT(_target == NULL); } + int Slobrok_CMD::usage() { diff --git a/slobrok/src/tests/mirrorapi/match_test.cpp b/slobrok/src/tests/mirrorapi/match_test.cpp index 94900daa202..d9ebcfd6f29 100644 --- a/slobrok/src/tests/mirrorapi/match_test.cpp +++ b/slobrok/src/tests/mirrorapi/match_test.cpp @@ -4,11 +4,12 @@ class MatchTester : public slobrok::api::IMirrorAPI { - SpecList lookup(const std::string &) const override { + virtual SpecList lookup(const std::string &) const override { return SpecList(); } - uint32_t updates() const override { return 0; } - bool ready() const override { return true; } + virtual uint32_t updates() const override { return 0; } + + virtual bool ready() const override { return true; } const std::string name; diff --git a/slobrok/src/tests/oldapi/mirror.h b/slobrok/src/tests/oldapi/mirror.h index b83392dec5e..1f0db564cae 100644 --- a/slobrok/src/tests/oldapi/mirror.h +++ b/slobrok/src/tests/oldapi/mirror.h @@ -1,5 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once +#ifndef Old_MIRROR_H +#define Old_MIRROR_H #include <vespa/fnet/frt/frt.h> #include <vespa/vespalib/util/gencnt.h> @@ -85,7 +86,10 @@ public: **/ ~MirrorOld(); + // Inherit doc from IMirrorOld. SpecList lookup(const std::string & pattern) const override; + + // Inherit doc from IMirrorOld. uint32_t updates() const override { return _updates.getAsInt(); } /** @@ -106,7 +110,10 @@ private: MirrorOld(const MirrorOld &); MirrorOld &operator=(const MirrorOld &); + /** from FNET_Task, polls slobrok **/ void PerformTask() override; + + /** from FRT_IRequestWait **/ void RequestDone(FRT_RPCRequest *req) override; FRT_Supervisor &_orb; @@ -124,3 +131,5 @@ private: } // namespace api } // namespace slobrok + +#endif diff --git a/slobrok/src/tests/startsome/rpc_info.cpp b/slobrok/src/tests/startsome/rpc_info.cpp index be5418ff1a8..76b578d4f88 100644 --- a/slobrok/src/tests/startsome/rpc_info.cpp +++ b/slobrok/src/tests/startsome/rpc_info.cpp @@ -1,7 +1,8 @@ // 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/log/log.h> +LOG_SETUP("rpc_info"); #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> class RPCInfo : public FastOS_Application { diff --git a/slobrok/src/tests/startsome/tstdst.cpp b/slobrok/src/tests/startsome/tstdst.cpp index 7d3fcef8695..e2f6ae070b3 100644 --- a/slobrok/src/tests/startsome/tstdst.cpp +++ b/slobrok/src/tests/startsome/tstdst.cpp @@ -1,11 +1,15 @@ // 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/log/log.h> +LOG_SETUP("testrpcserver"); #include <vespa/vespalib/util/host_name.h> +#include <vespa/fnet/fnet.h> #include <vespa/fnet/frt/frt.h> -#include <vespa/fastos/app.h> -#include <vespa/log/log.h> -LOG_SETUP("testrpcserver"); +#include <vector> +#include <string> +#include <sstream> class FNET_Transport; class FNET_Scheduler; diff --git a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp index 75092255f9e..ce21c918219 100644 --- a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp +++ b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp @@ -1,4 +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 <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/rusage.h> #include <vespa/vespalib/util/optimized.h> diff --git a/staging_vespalib/src/tests/array/allocinarray_test.cpp b/staging_vespalib/src/tests/array/allocinarray_test.cpp index c68cc3fa874..059fff91cec 100644 --- a/staging_vespalib/src/tests/array/allocinarray_test.cpp +++ b/staging_vespalib/src/tests/array/allocinarray_test.cpp @@ -1,10 +1,14 @@ // 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/log/log.h> #include <vespa/vespalib/util/array.h> #include <vespa/vespalib/util/allocinarray.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/testkit/testapp.h> #include <deque> +LOG_SETUP("array_test"); + using namespace vespalib; class Test : public TestApp diff --git a/staging_vespalib/src/tests/array/sort_benchmark.cpp b/staging_vespalib/src/tests/array/sort_benchmark.cpp index 29f1560e426..9e2b286e864 100644 --- a/staging_vespalib/src/tests/array/sort_benchmark.cpp +++ b/staging_vespalib/src/tests/array/sort_benchmark.cpp @@ -1,4 +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 <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/rusage.h> #include <vespa/vespalib/util/array.hpp> diff --git a/staging_vespalib/src/tests/benchmark/testbase.h b/staging_vespalib/src/tests/benchmark/testbase.h index beb485e6dab..02f11e21cac 100644 --- a/staging_vespalib/src/tests/benchmark/testbase.h +++ b/staging_vespalib/src/tests/benchmark/testbase.h @@ -45,7 +45,7 @@ public: private: typedef std::vector<int> Vector; size_t callByReference(const Vector & values) const __attribute__((noinline)); - size_t onRun() override; + virtual size_t onRun() override; }; class ParamByValueVectorInt : public Benchmark @@ -55,7 +55,7 @@ public: private: typedef std::vector<int> Vector; size_t callByValue(Vector values) const __attribute__((noinline)); - size_t onRun() override; + virtual size_t onRun() override; }; class ParamByReferenceVectorString : public Benchmark @@ -65,7 +65,7 @@ public: private: typedef std::vector<std::string> Vector; size_t callByReference(const Vector & values) const __attribute__((noinline)); - size_t onRun() override; + virtual size_t onRun() override; }; class ParamByValueVectorString : public Benchmark @@ -75,7 +75,7 @@ public: private: typedef std::vector<std::string> Vector; size_t callByValue(Vector values) const __attribute__((noinline)); - size_t onRun() override; + virtual size_t onRun() override; }; class ReturnByReferenceVectorString : public Benchmark @@ -85,7 +85,7 @@ public: private: typedef std::vector<std::string> Vector; const Vector & returnByReference(Vector & values) const __attribute__((noinline)); - size_t onRun() override; + virtual size_t onRun() override; }; class ReturnByValueVectorString : public Benchmark @@ -95,7 +95,7 @@ public: private: typedef std::vector<std::string> Vector; Vector returnByValue() const __attribute__((noinline)); - size_t onRun() override; + virtual size_t onRun() override; }; class ReturnByValueMultiVectorString : public Benchmark @@ -105,7 +105,7 @@ public: private: typedef std::vector<std::string> Vector; Vector returnByValue() const __attribute__((noinline)); - size_t onRun() override; + virtual size_t onRun() override; }; class CreateVespalibString : public Benchmark @@ -113,7 +113,7 @@ class CreateVespalibString : public Benchmark public: DECLARE_BENCHMARK(CreateVespalibString); private: - size_t onRun() override; + virtual size_t onRun() override; }; class ClockSystem : public Benchmark @@ -121,7 +121,7 @@ class ClockSystem : public Benchmark public: DECLARE_BENCHMARK(ClockSystem); private: - size_t onRun() override; + virtual size_t onRun() override; }; class ClockREALTIME : public Benchmark @@ -129,7 +129,7 @@ class ClockREALTIME : public Benchmark public: DECLARE_BENCHMARK(ClockREALTIME); private: - size_t onRun() override; + virtual size_t onRun() override; }; class ClockMONOTONIC : public Benchmark @@ -137,7 +137,7 @@ class ClockMONOTONIC : public Benchmark public: DECLARE_BENCHMARK(ClockMONOTONIC); private: - size_t onRun() override; + virtual size_t onRun() override; }; class ClockMONOTONIC_RAW : public Benchmark @@ -146,7 +146,7 @@ public: DECLARE_BENCHMARK(ClockMONOTONIC_RAW); ClockMONOTONIC_RAW(); private: - size_t onRun() override; + virtual size_t onRun() override; }; class ClockPROCESS_CPUTIME_ID : public Benchmark @@ -154,7 +154,7 @@ class ClockPROCESS_CPUTIME_ID : public Benchmark public: DECLARE_BENCHMARK(ClockPROCESS_CPUTIME_ID); private: - size_t onRun() override; + virtual size_t onRun() override; }; class ClockTHREAD_CPUTIME_ID : public Benchmark @@ -162,7 +162,8 @@ class ClockTHREAD_CPUTIME_ID : public Benchmark public: DECLARE_BENCHMARK(ClockTHREAD_CPUTIME_ID); private: - size_t onRun() override; + virtual size_t onRun() override; }; } + diff --git a/staging_vespalib/src/tests/bits/bits_test.cpp b/staging_vespalib/src/tests/bits/bits_test.cpp index 783651db366..f7b3ef1bf84 100644 --- a/staging_vespalib/src/tests/bits/bits_test.cpp +++ b/staging_vespalib/src/tests/bits/bits_test.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("bits_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/bits.h> #include <boost/crc.hpp> diff --git a/staging_vespalib/src/tests/clock/clock_test.cpp b/staging_vespalib/src/tests/clock/clock_test.cpp index 58a01a520b6..025d8766a29 100644 --- a/staging_vespalib/src/tests/clock/clock_test.cpp +++ b/staging_vespalib/src/tests/clock/clock_test.cpp @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/fastos/fastos.h> +#include <vespa/log/log.h> +LOG_SETUP("sharedptr_test"); #include <vespa/vespalib/util/clock.h> +#include <vespa/vespalib/testkit/testapp.h> using vespalib::Clock; using fastos::TimeStamp; diff --git a/staging_vespalib/src/tests/crc/crc_test.cpp b/staging_vespalib/src/tests/crc/crc_test.cpp index df8ac89db62..6a5a0779d8b 100644 --- a/staging_vespalib/src/tests/crc/crc_test.cpp +++ b/staging_vespalib/src/tests/crc/crc_test.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("crc_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/crc.h> #include <boost/crc.hpp> diff --git a/staging_vespalib/src/tests/databuffer/databuffer_test.cpp b/staging_vespalib/src/tests/databuffer/databuffer_test.cpp index 1a242e8eec4..7ec83e58b5c 100644 --- a/staging_vespalib/src/tests/databuffer/databuffer_test.cpp +++ b/staging_vespalib/src/tests/databuffer/databuffer_test.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP("databuffer_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/data/databuffer.h> diff --git a/staging_vespalib/src/tests/fileheader/fileheader_test.cpp b/staging_vespalib/src/tests/fileheader/fileheader_test.cpp index 55ca571cdac..f2a6c8402ee 100644 --- a/staging_vespalib/src/tests/fileheader/fileheader_test.cpp +++ b/staging_vespalib/src/tests/fileheader/fileheader_test.cpp @@ -1,8 +1,10 @@ // 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/log/log.h> +LOG_SETUP("fileheader_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/data/fileheader.h> -#include <vespa/fastos/file.h> #include <iostream> using namespace vespalib; @@ -27,9 +29,15 @@ private: void testRewriteErrors(); void testLayout(); - void testReadSize(bool mapped); - void testReadSizeErrors(bool mapped); - bool testReadSizeError(DataBuffer &buf, const std::string &expected, bool mapped); + void + testReadSize(bool mapped); + + void + testReadSizeErrors(bool mapped); + + bool + testReadSizeError(DataBuffer &buf, const std::string &expected, + bool mapped); public: int Main() override { diff --git a/staging_vespalib/src/tests/floatingpointtype/floatingpointtypetest.cpp b/staging_vespalib/src/tests/floatingpointtype/floatingpointtypetest.cpp index 19e52dbe885..98b6804ac8e 100644 --- a/staging_vespalib/src/tests/floatingpointtype/floatingpointtypetest.cpp +++ b/staging_vespalib/src/tests/floatingpointtype/floatingpointtypetest.cpp @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + // Include first to make sure it includes all it need. +#include <vespa/fastos/fastos.h> +#include <vespa/vespalib/objects/floatingpointtype.h> #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/objects/floatingpointtype.h> class Test : public vespalib::TestApp { diff --git a/staging_vespalib/src/tests/growablebytebuffer/growablebytebuffer_test.cpp b/staging_vespalib/src/tests/growablebytebuffer/growablebytebuffer_test.cpp index 1ba9c912344..aaf3f383c33 100644 --- a/staging_vespalib/src/tests/growablebytebuffer/growablebytebuffer_test.cpp +++ b/staging_vespalib/src/tests/growablebytebuffer/growablebytebuffer_test.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("guard_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/growablebytebuffer.h> diff --git a/staging_vespalib/src/tests/librarypool/librarypool_test.cpp b/staging_vespalib/src/tests/librarypool/librarypool_test.cpp index 87e04d3ffbd..665dbca8a86 100644 --- a/staging_vespalib/src/tests/librarypool/librarypool_test.cpp +++ b/staging_vespalib/src/tests/librarypool/librarypool_test.cpp @@ -1,7 +1,10 @@ // 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/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/librarypool.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/log/log.h> +LOG_SETUP("librarypool_test"); using namespace vespalib; diff --git a/staging_vespalib/src/tests/memorydatastore/memorydatastore.cpp b/staging_vespalib/src/tests/memorydatastore/memorydatastore.cpp index 5a1c0d7fb32..5430e8c1465 100644 --- a/staging_vespalib/src/tests/memorydatastore/memorydatastore.cpp +++ b/staging_vespalib/src/tests/memorydatastore/memorydatastore.cpp @@ -1,8 +1,11 @@ // 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/log/log.h> +LOG_SETUP("data_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/data/memorydatastore.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vector> using namespace vespalib; diff --git a/staging_vespalib/src/tests/objectdump/objectdump.cpp b/staging_vespalib/src/tests/objectdump/objectdump.cpp index 3bdbe2401e4..671e89b5011 100644 --- a/staging_vespalib/src/tests/objectdump/objectdump.cpp +++ b/staging_vespalib/src/tests/objectdump/objectdump.cpp @@ -1,5 +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 <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/objects/identifiable.h> #include <vespa/vespalib/objects/visit.hpp> @@ -22,7 +22,7 @@ IMPLEMENT_IDENTIFIABLE(Base, vespalib::Identifiable); struct Baz : public Base { DECLARE_IDENTIFIABLE(Baz); - Baz *clone() const override { return new Baz(*this); } + virtual Baz *clone() const override { return new Baz(*this); } }; IMPLEMENT_IDENTIFIABLE(Baz, Base); @@ -45,9 +45,9 @@ struct Bar : public Base _int32(-4), _uint32(4), _int64(-8), _uint64(8), _float(2.5), _double(2.75), _string("bla bla") {} - Bar *clone() const override { return new Bar(*this); } + virtual Bar *clone() const override { return new Bar(*this); } - void visitMembers(ObjectVisitor &v) const override { + virtual void visitMembers(ObjectVisitor &v) const override { visit(v, "_bool", _bool); visit(v, "_int8", _int8); visit(v, "_uint8", _uint8); diff --git a/staging_vespalib/src/tests/objects/identifiable_test.cpp b/staging_vespalib/src/tests/objects/identifiable_test.cpp index 5ef48b6e779..c60f33b9b55 100644 --- a/staging_vespalib/src/tests/objects/identifiable_test.cpp +++ b/staging_vespalib/src/tests/objects/identifiable_test.cpp @@ -1,5 +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 <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/objects/identifiable.hpp> #include <vespa/vespalib/objects/namedobject.h> @@ -40,7 +40,7 @@ class A : public Abstract public: DECLARE_IDENTIFIABLE(A); A() { } - void someAbstractVirtualMethod() override { }; + virtual void someAbstractVirtualMethod() override { } }; class B : public A diff --git a/staging_vespalib/src/tests/objectselection/objectselection.cpp b/staging_vespalib/src/tests/objectselection/objectselection.cpp index db696230082..27ecb068231 100644 --- a/staging_vespalib/src/tests/objectselection/objectselection.cpp +++ b/staging_vespalib/src/tests/objectselection/objectselection.cpp @@ -1,5 +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 <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/objects/identifiable.hpp> #include <vespa/vespalib/objects/objectpredicate.h> @@ -17,7 +17,7 @@ struct Foo : public Identifiable DECLARE_IDENTIFIABLE(Foo); virtual Foo *clone() const { return new Foo(*this); } - void selectMembers(const ObjectPredicate &p, ObjectOperation &o) override { + virtual void selectMembers(const ObjectPredicate &p, ObjectOperation &o) override { for (uint32_t i = 0; i < nodes.size(); ++i) { nodes[i]->select(p, o); } @@ -32,7 +32,7 @@ struct Bar : public Foo DECLARE_IDENTIFIABLE(Bar); Bar() : value(0) {} Bar(int v) { value = v; } - Bar *clone() const override { return new Bar(*this); } + virtual Bar *clone() const override { return new Bar(*this); } }; IMPLEMENT_IDENTIFIABLE(Bar, Identifiable); @@ -40,7 +40,7 @@ struct ObjectType : public ObjectPredicate { uint32_t cid; ObjectType(uint32_t id) : cid(id) {} - bool check(const Identifiable &obj) const override { + virtual bool check(const Identifiable &obj) const override { return (obj.getClass().id() == cid); } }; @@ -48,7 +48,7 @@ struct ObjectType : public ObjectPredicate struct ObjectCollect : public ObjectOperation { std::vector<Identifiable*> nodes; - void execute(Identifiable &obj) override { + virtual void execute(Identifiable &obj) override { nodes.push_back(&obj); } }; diff --git a/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp b/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp index a1c8a31729c..affb7287674 100644 --- a/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp +++ b/staging_vespalib/src/tests/polymorphicarray/polymorphicarray_test.cpp @@ -1,5 +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 <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/polymorphicarrays.h> @@ -112,7 +112,7 @@ class Factory : public ComplexArrayT<A>::Factory { public: A * create() override { return new Complex(); } - Factory * clone() const override { return new Factory(*this); } + virtual Factory * clone() const override { return new Factory(*this); } }; TEST("require that complex arrays conforms") { diff --git a/staging_vespalib/src/tests/programoptions/programoptions_test.cpp b/staging_vespalib/src/tests/programoptions/programoptions_test.cpp index 709f8a3b723..881954bfa3f 100644 --- a/staging_vespalib/src/tests/programoptions/programoptions_test.cpp +++ b/staging_vespalib/src/tests/programoptions/programoptions_test.cpp @@ -1,9 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/fastos/fastos.h> #include <vespa/vespalib/util/programoptions.h> #include <vespa/vespalib/util/programoptions_testutils.h> + #include <iostream> +#include <vespa/log/log.h> +#include <vespa/vespalib/testkit/testapp.h> + +LOG_SETUP("programoptions_test"); namespace vespalib { diff --git a/staging_vespalib/src/tests/rusage/rusage_test.cpp b/staging_vespalib/src/tests/rusage/rusage_test.cpp index 5094bd8b5c9..0367ab8c374 100644 --- a/staging_vespalib/src/tests/rusage/rusage_test.cpp +++ b/staging_vespalib/src/tests/rusage/rusage_test.cpp @@ -1,5 +1,8 @@ // 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 <stddef.h> +#include <vespa/log/log.h> +LOG_SETUP("alloc_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/rusage.h> diff --git a/staging_vespalib/src/tests/state_server/state_server_test.cpp b/staging_vespalib/src/tests/state_server/state_server_test.cpp index e15a3826669..f572dbcd8e1 100644 --- a/staging_vespalib/src/tests/state_server/state_server_test.cpp +++ b/staging_vespalib/src/tests/state_server/state_server_test.cpp @@ -1,5 +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 <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/net/state_server.h> #include <vespa/vespalib/net/simple_health_producer.h> @@ -52,8 +52,10 @@ vespalib::string getFull(int port, const vespalib::string &path) { return getPag struct DummyHandler : JsonGetHandler { vespalib::string result; DummyHandler(const vespalib::string &result_in) : result(result_in) {} - vespalib::string get(const vespalib::string &, const vespalib::string &, - const std::map<vespalib::string,vespalib::string> &) const override + virtual vespalib::string get(const vespalib::string &, + const vespalib::string &, + const std::map<vespalib::string,vespalib::string> &) + const override { return result; } @@ -111,8 +113,10 @@ TEST_FFFF("require that handler is selected based on longest matching url prefix } struct EchoHost : JsonGetHandler { - vespalib::string get(const vespalib::string &host, const vespalib::string &, - const std::map<vespalib::string,vespalib::string> &) const override + virtual vespalib::string get(const vespalib::string &host, + const vespalib::string &, + const std::map<vespalib::string,vespalib::string> &) + const override { return "[\"" + host + "\"]"; } @@ -312,11 +316,11 @@ TEST_FFFFF("require that custom handlers can be added to the state server", } struct EchoConsumer : MetricsProducer { - vespalib::string getMetrics(const vespalib::string &consumer) override { + virtual vespalib::string getMetrics(const vespalib::string &consumer) override { return "[\"" + consumer + "\"]"; } - vespalib::string getTotalMetrics(const vespalib::string &consumer) override { - return "[\"" + consumer + "\"]"; + virtual vespalib::string getTotalMetrics(const vespalib::string &consumer) override { + return "[\"" + consumer + "\"]"; } }; diff --git a/staging_vespalib/src/tests/timer/timer_test.cpp b/staging_vespalib/src/tests/timer/timer_test.cpp index 21b60b828cc..ad782f4089f 100644 --- a/staging_vespalib/src/tests/timer/timer_test.cpp +++ b/staging_vespalib/src/tests/timer/timer_test.cpp @@ -1,5 +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 <vespa/log/log.h> +LOG_SETUP("timer_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/timer.h> #include <vespa/vespalib/util/executor.h> diff --git a/staging_vespalib/src/tests/xmlserializable/xmlserializabletest.cpp b/staging_vespalib/src/tests/xmlserializable/xmlserializabletest.cpp index 90fcdb8f94f..1035c021f68 100644 --- a/staging_vespalib/src/tests/xmlserializable/xmlserializabletest.cpp +++ b/staging_vespalib/src/tests/xmlserializable/xmlserializabletest.cpp @@ -1,8 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/fastos/fastos.h> #include <vespa/vespalib/util/xmlserializable.h> +#include <vespa/vespalib/testkit/testapp.h> + namespace vespalib { class Test : public vespalib::TestApp diff --git a/staging_vespalib/src/vespa/vespalib/util/programoptions.h b/staging_vespalib/src/vespa/vespalib/util/programoptions.h index 9e25f960af7..58d1d133d04 100644 --- a/staging_vespalib/src/vespa/vespalib/util/programoptions.h +++ b/staging_vespalib/src/vespa/vespalib/util/programoptions.h @@ -23,10 +23,12 @@ #pragma once -#include <vespa/vespalib/util/exception.h> #include <map> #include <set> +#include <string> #include <vector> +#include <stdint.h> +#include <vespa/vespalib/util/exception.h> namespace vespalib { @@ -235,9 +237,9 @@ struct ProgramOptions::OptionParser { struct ProgramOptions::OptionHeader : public OptionParser { OptionHeader(const std::string& desc) : OptionParser("", 0, desc) {} - void set(const std::vector<std::string>&) override {} - void setDefault() override {} - bool isHeader() const override { return true; } + virtual void set(const std::vector<std::string>&) override {} + virtual void setDefault() override {} + virtual bool isHeader() const override { return true; } }; template<typename Number> @@ -260,45 +262,61 @@ struct ProgramOptions::NumberOptionParser : public OptionParser { : OptionParser(nameList, 1, getStringValue(defValue), desc), _number(number), _defaultValue(defValue) - {} - - void set(const std::vector<std::string>& arguments) override; - void setDefault() override { _number = _defaultValue; } - std::string getArgType(uint32_t /* index */) const override { - return getTypeName<Number>(); + { } + + virtual void set(const std::vector<std::string>& arguments) override; + + virtual void setDefault() override { _number = _defaultValue; } + + virtual std::string getArgType(uint32_t /* index */) const override + { return getTypeName<Number>(); } + }; struct ProgramOptions::BoolOptionParser : public OptionParser { bool& _value; bool _defaultValue; - BoolOptionParser(const std::string& nameList, bool& value, const std::string& description); - void set(const std::vector<std::string>&) override { _value = true; } - void setDefault() override { _value = false; } + BoolOptionParser(const std::string& nameList, bool& value, + const std::string& description); + + virtual void set(const std::vector<std::string>&) override { _value = true; } + + virtual void setDefault() override { _value = false; } }; struct ProgramOptions::FlagOptionParser : public OptionParser { bool& _value; bool _unsetValue; - FlagOptionParser(const std::string& nameList, bool& value, const std::string& description); - FlagOptionParser(const std::string& nameList, bool& value, const bool& unsetValue, const std::string& description); - void set(const std::vector<std::string>&) override { _value = !_unsetValue; } - void setDefault() override { _value = _unsetValue; } + FlagOptionParser(const std::string& nameList, bool& value, + const std::string& description); + FlagOptionParser(const std::string& nameList, bool& value, + const bool& unsetValue, const std::string& description); + + virtual void set(const std::vector<std::string>&) override { _value = !_unsetValue; } + + virtual void setDefault() override { _value = _unsetValue; } }; struct ProgramOptions::StringOptionParser : public OptionParser { std::string& _value; std::string _defaultValue; - StringOptionParser(const std::string& nameList, std::string& value, const std::string& description); + StringOptionParser(const std::string& nameList, std::string& value, + const std::string& description); + StringOptionParser(const std::string& nameList, std::string& value, const std::string& defVal, const std::string& desc); - void set(const std::vector<std::string>& arguments) override { _value = arguments[0]; } - void setDefault() override { _value = _defaultValue; } - std::string getArgType(uint32_t /* index */) const override { return "string"; } + virtual void set(const std::vector<std::string>& arguments) override + { _value = arguments[0]; } + + virtual void setDefault() override { _value = _defaultValue; } + + virtual std::string getArgType(uint32_t /* index */) const override + { return "string"; } }; struct ProgramOptions::MapOptionParser : public OptionParser { @@ -309,14 +327,14 @@ struct ProgramOptions::MapOptionParser : public OptionParser { std::map<std::string, std::string>& value, const std::string& description); - void set(const std::vector<std::string>& arguments) override { - _value[arguments[0]] = arguments[1]; - } + virtual void set(const std::vector<std::string>& arguments) override + { _value[arguments[0]] = arguments[1]; } - std::string getArgType(uint32_t /* index */) const override { return "string"; } + virtual std::string getArgType(uint32_t /* index */) const override + { return "string"; } - // Default of map is just an empty map. - void setDefault() override { _value.clear(); } + // Default of map is just an empty map. + virtual void setDefault() override { _value.clear(); } }; template<typename T> @@ -338,8 +356,9 @@ struct ProgramOptions::ListOptionParser : public OptionParser { void setEntryParser(OptionParser::UP entryParser) { _entryParser = std::move(entryParser); } - bool isRequired() const override { return false; } - void set(const std::vector<std::string>& arguments) override { + + virtual bool isRequired() const override { return false; } + virtual void set(const std::vector<std::string>& arguments) override { for (uint32_t i=0; i<arguments.size(); ++i) { std::vector<std::string> v; v.push_back(arguments[i]); @@ -347,10 +366,10 @@ struct ProgramOptions::ListOptionParser : public OptionParser { _value.push_back(_singleValue); } } - void setDefault() override { + virtual void setDefault() override { _value.clear(); } - std::string getArgType(uint32_t index) const override { + virtual std::string getArgType(uint32_t index) const override { return _entryParser->getArgType(index) + "[]"; } }; diff --git a/storage/src/tests/bucketdb/initializertest.cpp b/storage/src/tests/bucketdb/initializertest.cpp index 47e80f0c202..9aa7da92e36 100644 --- a/storage/src/tests/bucketdb/initializertest.cpp +++ b/storage/src/tests/bucketdb/initializertest.cpp @@ -423,8 +423,7 @@ struct FakePersistenceLayer : public StorageLink { } return 0; } - - bool onDown(const api::StorageMessage::SP& msg) override { + virtual bool onDown(const api::StorageMessage::SP& msg) override { fatalError = ""; if (messageCallback) { messageCallback->onMessage(*msg); diff --git a/storage/src/tests/bucketmover/bucketmovertest.cpp b/storage/src/tests/bucketmover/bucketmovertest.cpp index c233765ad27..3a844b6d1d8 100644 --- a/storage/src/tests/bucketmover/bucketmovertest.cpp +++ b/storage/src/tests/bucketmover/bucketmovertest.cpp @@ -1,5 +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/storage/bucketdb/storbucketdb.h> #include <vespa/storage/common/bucketmessages.h> #include <vespa/storage/bucketmover/bucketmover.h> diff --git a/storage/src/tests/common/metricstest.cpp b/storage/src/tests/common/metricstest.cpp index 15f0373e680..8dea2fad94f 100644 --- a/storage/src/tests/common/metricstest.cpp +++ b/storage/src/tests/common/metricstest.cpp @@ -67,8 +67,10 @@ namespace { { framework::Clock& _clock; MetricClock(framework::Clock& c) : _clock(c) {} - time_t getTime() const override { return _clock.getTimeInSeconds().getTime(); } - time_t getTimeInMilliSecs() const override { return _clock.getTimeInMillis().getTime(); } + virtual time_t getTime() const override + { return _clock.getTimeInSeconds().getTime(); } + virtual time_t getTimeInMilliSecs() const override + { return _clock.getTimeInMillis().getTime(); } }; } diff --git a/storage/src/tests/distributor/blockingoperationstartertest.cpp b/storage/src/tests/distributor/blockingoperationstartertest.cpp index 64f3dae8fbe..2ae8a819d7e 100644 --- a/storage/src/tests/distributor/blockingoperationstartertest.cpp +++ b/storage/src/tests/distributor/blockingoperationstartertest.cpp @@ -1,5 +1,9 @@ // 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/vdstestlib/cppunit/macros.h> +#include <string> +#include <sstream> +#include <memory> #include <vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h> #include <vespa/storage/distributor/blockingoperationstarter.h> #include <vespa/storage/distributor/pendingmessagetracker.h> diff --git a/storage/src/tests/distributor/bucketdatabasetest.cpp b/storage/src/tests/distributor/bucketdatabasetest.cpp index 5d1bb17a1c6..13a8aff239c 100644 --- a/storage/src/tests/distributor/bucketdatabasetest.cpp +++ b/storage/src/tests/distributor/bucketdatabasetest.cpp @@ -1,6 +1,9 @@ // 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 <tests/distributor/bucketdatabasetest.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> +#include <iostream> +#include <fstream> #include <iomanip> namespace storage { diff --git a/storage/src/tests/distributor/bucketdbupdatertest.cpp b/storage/src/tests/distributor/bucketdbupdatertest.cpp index e35f147d0c8..7ad083dc5a1 100644 --- a/storage/src/tests/distributor/bucketdbupdatertest.cpp +++ b/storage/src/tests/distributor/bucketdbupdatertest.cpp @@ -13,6 +13,7 @@ #include <iostream> #include <fstream> +#include <string> using namespace storage::api; using namespace storage::lib; diff --git a/storage/src/tests/distributor/bucketstateoperationtest.cpp b/storage/src/tests/distributor/bucketstateoperationtest.cpp index 58061def8ab..74a31de1541 100644 --- a/storage/src/tests/distributor/bucketstateoperationtest.cpp +++ b/storage/src/tests/distributor/bucketstateoperationtest.cpp @@ -28,10 +28,13 @@ private: void testBucketDbNotUpdatedOnFailure(); public: - void setUp() override { + void setUp() override + { createLinks(); } - void tearDown() override { + + void tearDown() override + { close(); } }; diff --git a/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp b/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp index 3e4e1d6da88..e7078f08d0a 100644 --- a/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp +++ b/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp @@ -6,6 +6,7 @@ #include <vespa/storage/distributor/min_replica_provider.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/io/fileutil.h> +#include <vespa/vespalib/util/jsonstream.h> #include <vespa/vespalib/testkit/test_kit.h> #include <tests/common/hostreporter/util.h> #include <vespa/vespalib/stllike/asciistream.h> diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp index 10b0d035770..fc09dc17c1f 100644 --- a/storage/src/tests/distributor/distributortest.cpp +++ b/storage/src/tests/distributor/distributortest.cpp @@ -1,5 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <iomanip> +#include <iostream> +#include <memory> #include <boost/assign/std/vector.hpp> // for 'operator+=()' #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storage/distributor/idealstatemetricsset.h> diff --git a/storage/src/tests/distributor/idealstatemanagertest.cpp b/storage/src/tests/distributor/idealstatemanagertest.cpp index e4fce6b9d6e..2b861d23c5e 100644 --- a/storage/src/tests/distributor/idealstatemanagertest.cpp +++ b/storage/src/tests/distributor/idealstatemanagertest.cpp @@ -11,6 +11,7 @@ #include <tests/distributor/distributortestutil.h> + namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/mapbucketdatabasetest.cpp b/storage/src/tests/distributor/mapbucketdatabasetest.cpp index 8af2a86e4c5..6892f522bba 100644 --- a/storage/src/tests/distributor/mapbucketdatabasetest.cpp +++ b/storage/src/tests/distributor/mapbucketdatabasetest.cpp @@ -1,6 +1,10 @@ // 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/vespalib/util/document_runnable.h> #include <vespa/vdstestlib/cppunit/macros.h> +#include <cppunit/extensions/HelperMacros.h> #include <vespa/storage/bucketdb/mapbucketdatabase.h> +#include <vespa/storage/storageutil/utils.h> #include <tests/distributor/bucketdatabasetest.h> namespace storage { @@ -8,7 +12,8 @@ namespace distributor { struct MapBucketDatabaseTest : public BucketDatabaseTest { MapBucketDatabase _db; - BucketDatabase& db() override { return _db; }; + + virtual BucketDatabase& db() override { return _db; } CPPUNIT_TEST_SUITE(MapBucketDatabaseTest); SETUP_DATABASE_TESTS(); diff --git a/storage/src/tests/distributor/mergeoperationtest.cpp b/storage/src/tests/distributor/mergeoperationtest.cpp index 1e317e20b74..875d16a42ed 100644 --- a/storage/src/tests/distributor/mergeoperationtest.cpp +++ b/storage/src/tests/distributor/mergeoperationtest.cpp @@ -1,4 +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 <boost/lexical_cast.hpp> #include <cppunit/extensions/HelperMacros.h> #include <iomanip> diff --git a/storage/src/tests/distributor/messagesenderstub.h b/storage/src/tests/distributor/messagesenderstub.h index 629c1c6e346..7b552ec6883 100644 --- a/storage/src/tests/distributor/messagesenderstub.h +++ b/storage/src/tests/distributor/messagesenderstub.h @@ -2,7 +2,6 @@ #pragma once #include <vespa/storage/distributor/distributormessagesender.h> -#include <cassert> namespace storage { @@ -21,11 +20,13 @@ struct MessageSenderStub : distributor::DistributorMessageSender replies.clear(); } - virtual void sendCommand(const std::shared_ptr<api::StorageCommand>& cmd) { + virtual void sendCommand(const std::shared_ptr<api::StorageCommand>& cmd) + { commands.push_back(cmd); } - virtual void sendReply(const std::shared_ptr<api::StorageReply>& reply) { + virtual void sendReply(const std::shared_ptr<api::StorageReply>& reply) + { replies.push_back(reply); } @@ -66,3 +67,4 @@ private: }; } + diff --git a/storage/src/tests/distributor/operationtargetresolvertest.cpp b/storage/src/tests/distributor/operationtargetresolvertest.cpp index d0dc8cedaf3..26144ac950e 100644 --- a/storage/src/tests/distributor/operationtargetresolvertest.cpp +++ b/storage/src/tests/distributor/operationtargetresolvertest.cpp @@ -1,5 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <iomanip> +#include <iostream> #include <vespa/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> diff --git a/storage/src/tests/distributor/pendingmessagetrackertest.cpp b/storage/src/tests/distributor/pendingmessagetrackertest.cpp index 618d7980c5b..6f4539d426e 100644 --- a/storage/src/tests/distributor/pendingmessagetrackertest.cpp +++ b/storage/src/tests/distributor/pendingmessagetrackertest.cpp @@ -1,4 +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 <vespa/document/base/testdocman.h> #include <vespa/storage/distributor/pendingmessagetracker.h> @@ -9,6 +10,13 @@ #include <tests/common/dummystoragelink.h> #include <vespa/vdslib/state/random.h> #include <vespa/vdstestlib/cppunit/macros.h> +#include <fstream> +#include <sstream> +#include <iomanip> +#include <iostream> +#include <memory> +#include <string> +#include <iterator> namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/simplemaintenancescannertest.cpp b/storage/src/tests/distributor/simplemaintenancescannertest.cpp index 342d346b398..100d5582006 100644 --- a/storage/src/tests/distributor/simplemaintenancescannertest.cpp +++ b/storage/src/tests/distributor/simplemaintenancescannertest.cpp @@ -1,11 +1,18 @@ // 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/vdstestlib/cppunit/macros.h> #include <vespa/storage/distributor/maintenance/simplemaintenancescanner.h> #include <vespa/storage/distributor/maintenance/simplebucketprioritydatabase.h> #include <vespa/storage/bucketdb/mapbucketdatabase.h> #include <tests/distributor/maintenancemocks.h> +#include <string> +#include <sstream> +#include <memory> +#include <algorithm> +#include <iterator> + namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/statusreporterdelegatetest.cpp b/storage/src/tests/distributor/statusreporterdelegatetest.cpp index d9f647a52a5..f136b00244a 100644 --- a/storage/src/tests/distributor/statusreporterdelegatetest.cpp +++ b/storage/src/tests/distributor/statusreporterdelegatetest.cpp @@ -1,5 +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 <vespa/vdstestlib/cppunit/macros.h> #include <tests/common/testhelper.h> #include <tests/distributor/distributortestutil.h> diff --git a/storage/src/tests/distributor/throttlingoperationstartertest.cpp b/storage/src/tests/distributor/throttlingoperationstartertest.cpp index 0414ad11da4..8e7d98005c1 100644 --- a/storage/src/tests/distributor/throttlingoperationstartertest.cpp +++ b/storage/src/tests/distributor/throttlingoperationstartertest.cpp @@ -1,5 +1,9 @@ // 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/vdstestlib/cppunit/macros.h> +#include <string> +#include <sstream> +#include <memory> #include <vespa/storage/distributor/throttlingoperationstarter.h> #include <tests/distributor/maintenancemocks.h> diff --git a/storage/src/tests/frameworkimpl/status/statustest.cpp b/storage/src/tests/frameworkimpl/status/statustest.cpp index 43d13acb28b..567f9192d34 100644 --- a/storage/src/tests/frameworkimpl/status/statustest.cpp +++ b/storage/src/tests/frameworkimpl/status/statustest.cpp @@ -1,12 +1,16 @@ // 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/document/util/stringutil.h> +#include <vespa/log/log.h> +#include <sstream> #include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> #include <vespa/storage/frameworkimpl/status/statuswebserver.h> #include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h> #include <tests/common/teststorageapp.h> #include <vespa/vdstestlib/cppunit/macros.h> -#include <vespa/document/util/stringutil.h> -#include <sstream> + +LOG_SETUP(".test.status"); namespace storage { @@ -43,13 +47,18 @@ namespace { : framework::HtmlStatusReporter(id, name), _headerAddition(headerAddition), _content(content) - {} + { + } - void reportHtmlHeaderAdditions(std::ostream& out, const framework::HttpUrlPath&) const override { + virtual void reportHtmlHeaderAdditions( + std::ostream& out, const framework::HttpUrlPath&) const override + { out << _headerAddition; } - void reportHtmlStatus(std::ostream& out, const framework::HttpUrlPath&) const override { + virtual void reportHtmlStatus( + std::ostream& out, const framework::HttpUrlPath&) const override + { out << _content; } }; @@ -57,9 +66,9 @@ namespace { struct XmlStatusReporter : public framework::XmlStatusReporter { XmlStatusReporter(const std::string& id, const std::string& name) : framework::XmlStatusReporter(id, name) {} - - vespalib::string reportXmlStatus(vespalib::xml::XmlOutputStream& xos, - const framework::HttpUrlPath&) const override + virtual vespalib::string reportXmlStatus( + vespalib::xml::XmlOutputStream& xos, + const framework::HttpUrlPath&) const override { xos << vespalib::xml::XmlTag("mytag") << vespalib::xml::XmlAttribute("foo", "bar") diff --git a/storage/src/tests/persistence/bucketownershipnotifiertest.cpp b/storage/src/tests/persistence/bucketownershipnotifiertest.cpp index 5f675c1d551..8553795db71 100644 --- a/storage/src/tests/persistence/bucketownershipnotifiertest.cpp +++ b/storage/src/tests/persistence/bucketownershipnotifiertest.cpp @@ -1,5 +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/vdstestlib/cppunit/macros.h> #include <tests/distributor/messagesenderstub.h> #include <tests/common/teststorageapp.h> diff --git a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp index e2f41aa5b3e..e21d367370b 100644 --- a/storage/src/tests/persistence/filestorage/filestormanagertest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormanagertest.cpp @@ -9,6 +9,7 @@ #include <vespa/document/select/parser.h> #include <vespa/vdslib/state/random.h> #include <vespa/vdslib/container/mutabledocumentlist.h> +#include <vespa/vdslib/container/operationlist.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/storageapi/message/bucket.h> @@ -17,17 +18,25 @@ #include <vespa/storageapi/message/persistence.h> #include <vespa/storageapi/message/removelocation.h> #include <vespa/storage/bucketdb/bucketmanager.h> +#include <vespa/storage/bucketdb/storbucketdb.h> +#include <vespa/storage/common/bucketmessages.h> +#include <vespa/storageframework/storageframework.h> #include <vespa/storage/persistence/persistencethread.h> +#include <vespa/storage/persistence/messages.h> #include <vespa/storage/persistence/filestorage/filestormanager.h> #include <vespa/storage/persistence/filestorage/modifiedbucketchecker.h> #include <tests/common/testhelper.h> #include <tests/common/storagelinktest.h> #include <tests/common/teststorageapp.h> +#include <tests/common/dummystoragelink.h> #include <tests/persistence/filestorage/forwardingmessagesender.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> #include <vespa/storageapi/message/batch.h> #include <vespa/storage/storageserver/statemanager.h> #include <vespa/fastos/file.h> +#include <fstream> +#include <memory> +#include <atomic> #include <vespa/log/log.h> LOG_SETUP(".filestormanagertest"); @@ -2355,8 +2364,10 @@ namespace { closeNextLink(); } - void print(std::ostream& out, bool, const std::string&) const override { out << "MidLink"; } - bool onUp(const std::shared_ptr<api::StorageMessage> & msg) override { + virtual void print(std::ostream& out, bool, const std::string&) const override + { out << "MidLink"; } + + virtual bool onUp(const std::shared_ptr<api::StorageMessage> & msg) override { if (!StorageLinkTest::callOnUp(_up, msg)) _up.sendUp(msg); return true; } @@ -2384,9 +2395,10 @@ namespace { _leftAddr(leftAddr), _rightAddr(rightAddr) {} - void print(std::ostream& out, bool, const std::string&) const override { out << "BinaryStorageLink"; } + virtual void print(std::ostream& out, bool, const std::string&) const override + { out << "BinaryStorageLink"; } - bool onDown(const std::shared_ptr<api::StorageMessage> & msg) override { + virtual bool onDown(const std::shared_ptr<api::StorageMessage> & msg) override { // LOG(debug, "onDown Received msg: ->%s, %s %llu\n", msg->getAddress() ? msg->getAddress()->toString().c_str() : "(null)", msg->toString().c_str(), msg->getMsgId()); vespalib::LockGuard lock(_lock); @@ -2420,7 +2432,7 @@ namespace { return true; } - bool onUp(const std::shared_ptr<api::StorageMessage> & msg) override { + virtual bool onUp(const std::shared_ptr<api::StorageMessage> & msg) override { // LOG(debug, "onUp Received msg: ->%s, %s %llu\n", msg->getAddress() ? msg->getAddress()->toString().c_str() : "(null)", msg->toString().c_str(), msg->getMsgId()); vespalib::LockGuard lock(_lock); diff --git a/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp b/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp index 1409445b96b..d608bef3307 100644 --- a/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp +++ b/storage/src/tests/persistence/filestorage/filestormodifiedbucketstest.cpp @@ -1,5 +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 <memory> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storage/persistence/filestorage/modifiedbucketchecker.h> diff --git a/storage/src/tests/persistence/filestorage/modifiedbucketcheckertest.cpp b/storage/src/tests/persistence/filestorage/modifiedbucketcheckertest.cpp index 58b4ae4d475..2dc60594c45 100644 --- a/storage/src/tests/persistence/filestorage/modifiedbucketcheckertest.cpp +++ b/storage/src/tests/persistence/filestorage/modifiedbucketcheckertest.cpp @@ -1,11 +1,14 @@ // 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/vdstestlib/cppunit/macros.h> #include <tests/common/testhelper.h> #include <tests/common/storagelinktest.h> #include <tests/common/teststorageapp.h> +#include <tests/common/dummystoragelink.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> #include <vespa/storage/persistence/filestorage/modifiedbucketchecker.h> +#include <vespa/storage/persistence/messages.h> namespace storage { diff --git a/storage/src/tests/persistence/legacyoperationhandlertest.cpp b/storage/src/tests/persistence/legacyoperationhandlertest.cpp index 353a8d24ec5..df262501299 100644 --- a/storage/src/tests/persistence/legacyoperationhandlertest.cpp +++ b/storage/src/tests/persistence/legacyoperationhandlertest.cpp @@ -1,12 +1,15 @@ // 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/document/base/testdocrepo.h> +#include <vespa/document/repo/documenttyperepo.h> #include <vespa/documentapi/loadtypes/loadtype.h> #include <vespa/storage/persistence/messages.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storageapi/message/multioperation.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> #include <tests/persistence/persistencetestutils.h> +#include <vespa/storage/persistence/types.h> using document::DocumentTypeRepo; using document::TestDocRepo; diff --git a/storage/src/tests/persistence/mergehandlertest.cpp b/storage/src/tests/persistence/mergehandlertest.cpp index 3f0623fbef0..8147992a516 100644 --- a/storage/src/tests/persistence/mergehandlertest.cpp +++ b/storage/src/tests/persistence/mergehandlertest.cpp @@ -3,13 +3,15 @@ #include <vespa/document/base/testdocman.h> #include <vespa/storage/persistence/mergehandler.h> #include <vespa/vdstestlib/cppunit/macros.h> +#include <vespa/storageapi/message/bucket.h> +#include <vespa/log/log.h> #include <tests/persistence/persistencetestutils.h> #include <tests/persistence/common/persistenceproviderwrapper.h> #include <tests/distributor/messagesenderstub.h> +#include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> #include <vespa/vespalib/objects/nbostream.h> #include <cmath> -#include <vespa/log/log.h> LOG_SETUP(".test.persistence.handler.merge"); namespace storage { diff --git a/storage/src/tests/persistence/providershutdownwrappertest.cpp b/storage/src/tests/persistence/providershutdownwrappertest.cpp index c7f60a39cc8..8b1ef88aa2c 100644 --- a/storage/src/tests/persistence/providershutdownwrappertest.cpp +++ b/storage/src/tests/persistence/providershutdownwrappertest.cpp @@ -1,8 +1,10 @@ // 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/vdstestlib/cppunit/macros.h> #include <tests/persistence/persistencetestutils.h> #include <tests/persistence/common/persistenceproviderwrapper.h> +#include <vespa/storage/persistence/providershutdownwrapper.h> namespace storage { diff --git a/storage/src/tests/storageserver/bouncertest.cpp b/storage/src/tests/storageserver/bouncertest.cpp index 751d6b535a3..e5b9a3e6092 100644 --- a/storage/src/tests/storageserver/bouncertest.cpp +++ b/storage/src/tests/storageserver/bouncertest.cpp @@ -1,7 +1,10 @@ // 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 <boost/pointer_cast.hpp> #include <cppunit/extensions/HelperMacros.h> +#include <iostream> +#include <string> #include <vespa/storageapi/message/bucket.h> #include <vespa/storageapi/message/state.h> #include <vespa/storageapi/message/stat.h> diff --git a/storage/src/tests/storageserver/bucketintegritycheckertest.cpp b/storage/src/tests/storageserver/bucketintegritycheckertest.cpp index f4eedc64971..d9a175f3b04 100644 --- a/storage/src/tests/storageserver/bucketintegritycheckertest.cpp +++ b/storage/src/tests/storageserver/bucketintegritycheckertest.cpp @@ -1,14 +1,18 @@ // 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 <boost/lexical_cast.hpp> #include <cppunit/extensions/HelperMacros.h> #include <vespa/log/log.h> #include <vespa/storage/bucketdb/bucketmanager.h> +#include <vespa/storage/bucketdb/storbucketdb.h> #include <vespa/storage/persistence/filestorage/filestormanager.h> #include <vespa/storage/storageserver/bucketintegritychecker.h> +#include <vespa/storageapi/message/bucket.h> #include <vespa/storageapi/message/persistence.h> #include <tests/common/testhelper.h> #include <tests/common/storagelinktest.h> +#include <tests/common/dummystoragelink.h> #include <vespa/vespalib/io/fileutil.h> #include <tests/common/teststorageapp.h> diff --git a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp index 89eaff0ab6e..8eb6b74a840 100644 --- a/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp +++ b/storage/src/tests/storageserver/changedbucketownershiphandlertest.cpp @@ -1,5 +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/document/base/testdocman.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storage/bucketdb/storbucketdb.h> @@ -14,6 +15,7 @@ #include <tests/common/testhelper.h> #include <tests/common/dummystoragelink.h> #include <vespa/storage/storageserver/changedbucketownershiphandler.h> +#include <memory> namespace storage { diff --git a/storage/src/tests/storageserver/priorityconvertertest.cpp b/storage/src/tests/storageserver/priorityconvertertest.cpp index ab6c27f48d6..ecbbd25b8b1 100644 --- a/storage/src/tests/storageserver/priorityconvertertest.cpp +++ b/storage/src/tests/storageserver/priorityconvertertest.cpp @@ -1,5 +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/documentapi/documentapi.h> #include <vespa/storage/storageserver/priorityconverter.h> #include <tests/common/testhelper.h> diff --git a/storage/src/tests/storageserver/statemanagertest.cpp b/storage/src/tests/storageserver/statemanagertest.cpp index f9c5c97e6bc..4244ce0c4ce 100644 --- a/storage/src/tests/storageserver/statemanagertest.cpp +++ b/storage/src/tests/storageserver/statemanagertest.cpp @@ -1,15 +1,19 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <boost/pointer_cast.hpp> #include <cppunit/extensions/HelperMacros.h> #include <vespa/metrics/metricmanager.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storageapi/message/state.h> +#include <vespa/vdslib/state/nodestate.h> #include <vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h> #include <vespa/storage/storageserver/statemanager.h> +#include <vespa/storage/common/hostreporter/hostinfo.h> #include <tests/common/teststorageapp.h> #include <tests/common/testhelper.h> #include <tests/common/dummystoragelink.h> #include <vespa/vespalib/data/slime/slime.h> +#include <iostream> using storage::lib::NodeState; using storage::lib::NodeType; @@ -134,7 +138,8 @@ namespace { MyStateListener(const NodeStateUpdater& upd) : updater(upd), current(*updater.getReportedNodeState()) {} - void handleNewState() override { + void handleNewState() override + { ost << current << " -> "; current = *updater.getReportedNodeState(); ost << current << "\n"; @@ -254,3 +259,4 @@ StateManagerTest::testClusterStateVersion() } } // storage + diff --git a/storage/src/tests/storageserver/statereportertest.cpp b/storage/src/tests/storageserver/statereportertest.cpp index 8a164361c88..265b9e95d83 100644 --- a/storage/src/tests/storageserver/statereportertest.cpp +++ b/storage/src/tests/storageserver/statereportertest.cpp @@ -18,8 +18,8 @@ namespace storage { class DummyApplicationGenerationFether : public ApplicationGenerationFetcher { public: - int64_t getGeneration() const override { return 1; } - std::string getComponentName() const override { return "component"; } + virtual int64_t getGeneration() const override { return 1; } + virtual std::string getComponentName() const override { return "component"; } }; struct StateReporterTest : public CppUnit::TestFixture { @@ -58,8 +58,10 @@ namespace { { framework::Clock& _clock; MetricClock(framework::Clock& c) : _clock(c) {} - time_t getTime() const override { return _clock.getTimeInSeconds().getTime(); } - time_t getTimeInMilliSecs() const override { return _clock.getTimeInMillis().getTime(); } + virtual time_t getTime() const override + { return _clock.getTimeInSeconds().getTime(); } + virtual time_t getTimeInMilliSecs() const override + { return _clock.getTimeInMillis().getTime(); } }; } diff --git a/storage/src/tests/storageutil/charttest.cpp b/storage/src/tests/storageutil/charttest.cpp index c7c1c43b000..4f83a9f26f4 100644 --- a/storage/src/tests/storageutil/charttest.cpp +++ b/storage/src/tests/storageutil/charttest.cpp @@ -1,13 +1,18 @@ // 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/storage/storageutil/piechart.h> -#include <vespa/vdstestlib/cppunit/macros.h> + #include <fstream> +#include <vespa/vdstestlib/cppunit/macros.h> namespace storage { struct PieChartTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} + void testWriteHtmlFile(); CPPUNIT_TEST_SUITE(PieChartTest); diff --git a/storage/src/tests/storageutil/palettetest.cpp b/storage/src/tests/storageutil/palettetest.cpp index 24eaee18996..e5a4e73d58a 100644 --- a/storage/src/tests/storageutil/palettetest.cpp +++ b/storage/src/tests/storageutil/palettetest.cpp @@ -1,11 +1,15 @@ // 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/storage/storageutil/palette.h> #include <vespa/vdstestlib/cppunit/macros.h> namespace storage { struct PaletteTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} + void testNormalUsage(); CPPUNIT_TEST_SUITE(PaletteTest); diff --git a/storage/src/tests/testrunner.cpp b/storage/src/tests/testrunner.cpp index 9bf86e3276a..5d8dc8d4c1f 100644 --- a/storage/src/tests/testrunner.cpp +++ b/storage/src/tests/testrunner.cpp @@ -1,12 +1,14 @@ // 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 <iostream> +#include <vespa/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("storagecppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/storage/src/tests/visiting/visitormanagertest.cpp b/storage/src/tests/visiting/visitormanagertest.cpp index 1824b976aea..8aa57b982db 100644 --- a/storage/src/tests/visiting/visitormanagertest.cpp +++ b/storage/src/tests/visiting/visitormanagertest.cpp @@ -1,11 +1,15 @@ // 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/document/datatype/datatype.h> #include <vespa/document/fieldvalue/intfieldvalue.h> #include <vespa/document/fieldvalue/stringfieldvalue.h> #include <vespa/document/fieldvalue/rawfieldvalue.h> +#include <vespa/log/log.h> #include <vespa/storageapi/message/datagram.h> #include <vespa/storageapi/message/persistence.h> +#include <vespa/storageapi/message/visitor.h> +#include <vector> #include <vespa/storage/persistence/filestorage/filestormanager.h> #include <vespa/storage/visiting/visitormanager.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> @@ -13,11 +17,16 @@ #include <tests/common/testhelper.h> #include <tests/common/dummystoragelink.h> #include <tests/storageserver/testvisitormessagesession.h> +#include <vespa/vdstestlib/cppunit/macros.h> +#include <vespa/vdslib/container/visitorordering.h> #include <vespa/documentapi/messagebus/messages/multioperationmessage.h> #include <vespa/documentapi/messagebus/messages/putdocumentmessage.h> #include <vespa/documentapi/messagebus/messages/removedocumentmessage.h> #include <vespa/vespalib/util/exceptions.h> + +LOG_SETUP(".visitormanagertest"); + namespace storage { namespace { typedef std::vector<api::StorageMessage::SP> msg_ptr_vector; @@ -104,6 +113,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(VisitorManagerTest); void VisitorManagerTest::initializeTest() { + LOG(debug, "Initializing test"); vdstestlib::DirConfig config(getStandardConfig(true)); config.getConfig("stor-visitor").set("visitorthreads", "1"); @@ -211,6 +221,7 @@ VisitorManagerTest::initializeTest() CPPUNIT_ASSERT_EQUAL(api::ReturnCode(api::ReturnCode::OK), reply->getResult()); } + LOG(debug, "Done initializing test"); } void diff --git a/storage/src/tests/visiting/visitortest.cpp b/storage/src/tests/visiting/visitortest.cpp index 84f1297b05f..e6a3542cbf2 100644 --- a/storage/src/tests/visiting/visitortest.cpp +++ b/storage/src/tests/visiting/visitortest.cpp @@ -6,17 +6,25 @@ #include <vespa/document/fieldvalue/rawfieldvalue.h> #include <vespa/storageapi/message/datagram.h> #include <vespa/storageapi/message/persistence.h> +#include <vespa/storageapi/message/visitor.h> #include <vespa/storage/persistence/filestorage/filestormanager.h> #include <vespa/storage/visiting/visitormanager.h> #include <tests/common/testhelper.h> #include <tests/common/teststorageapp.h> #include <tests/common/dummystoragelink.h> #include <tests/storageserver/testvisitormessagesession.h> +#include <vespa/vdstestlib/cppunit/macros.h> +#include <vespa/vdslib/container/visitorordering.h> #include <vespa/documentapi/messagebus/messages/multioperationmessage.h> #include <vespa/documentapi/messagebus/messages/putdocumentmessage.h> #include <vespa/documentapi/messagebus/messages/removedocumentmessage.h> #include <vespa/vespalib/util/exceptions.h> +#include <vector> #include <thread> +#include <chrono> + +#include <vespa/log/log.h> +LOG_SETUP(".visitortest"); using namespace std::chrono_literals; @@ -177,6 +185,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(VisitorTest); void VisitorTest::initializeTest(const TestParams& params) { + LOG(debug, "Initializing test"); vdstestlib::DirConfig config(getStandardConfig(true, "visitortest")); config.getConfig("stor-visitor").set("visitorthreads", "1"); config.getConfig("stor-visitor").set( @@ -264,6 +273,7 @@ VisitorTest::initializeTest(const TestParams& params) _documents.back()->setValue(type.getField("headerval"), document::IntFieldValue(i % 4)); } + LOG(debug, "Done initializing test"); } void diff --git a/storage/src/vespa/storage/bucketdb/bucketmanager.h b/storage/src/vespa/storage/bucketdb/bucketmanager.h index da8dcf1c1cd..64498386466 100644 --- a/storage/src/vespa/storage/bucketdb/bucketmanager.h +++ b/storage/src/vespa/storage/bucketdb/bucketmanager.h @@ -102,7 +102,8 @@ public: ~BucketManager(); void startWorkerThread(); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; /** Dump the whole database to the given output. Use for debugging. */ void dump(std::ostream& out) const; @@ -119,11 +120,11 @@ private: vespalib::string getReportContentType(const framework::HttpUrlPath&) const override; bool reportStatus(std::ostream&, const framework::HttpUrlPath&) const override; - /** Event saying node is up and running. We can start to build cache. */ - void onOpen() override; - void onDoneInit() override { _doneInitialized = true; } - void onClose() override; - void onFlush(bool downwards) override; + /** Event saying node is up and running. We can start to build cache. */ + virtual void onOpen() override; + virtual void onDoneInit() override { _doneInitialized = true; } + virtual void onClose() override; + virtual void onFlush(bool downwards) override; void updateMetrics(bool updateDocCount); void updateMetrics(const MetricLockGuard &) override { updateMetrics(true); } diff --git a/storage/src/vespa/storage/bucketdb/judyarray.h b/storage/src/vespa/storage/bucketdb/judyarray.h index e28d89967b2..b5d8a50cb16 100644 --- a/storage/src/vespa/storage/bucketdb/judyarray.h +++ b/storage/src/vespa/storage/bucketdb/judyarray.h @@ -83,7 +83,7 @@ public: data_type& operator[](key_type key); size_type getMemoryUsage() const; - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; class ConstIterator : public vespalib::Printable { @@ -101,7 +101,8 @@ public: key_type key() const { return _key; } data_type value() const { return *_data; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + protected: // For creating end() iterator ConstIterator(const JudyArray&); @@ -226,3 +227,4 @@ JudyArray::ConstIterator::operator==(const JudyArray::ConstIterator &cp) const } } // storage + diff --git a/storage/src/vespa/storage/bucketdb/lockablemap.h b/storage/src/vespa/storage/bucketdb/lockablemap.h index 3c40c214136..93dfb23c4db 100644 --- a/storage/src/vespa/storage/bucketdb/lockablemap.h +++ b/storage/src/vespa/storage/bucketdb/lockablemap.h @@ -168,7 +168,7 @@ public: const char* clientId, uint32_t chunkSize = DEFAULT_CHUNK_SIZE); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; /** * Returns all buckets in the bucket database that can contain the given diff --git a/storage/src/vespa/storage/bucketdb/mapbucketdatabase.cpp b/storage/src/vespa/storage/bucketdb/mapbucketdatabase.cpp index 10a6bb6bd24..a271803714a 100644 --- a/storage/src/vespa/storage/bucketdb/mapbucketdatabase.cpp +++ b/storage/src/vespa/storage/bucketdb/mapbucketdatabase.cpp @@ -1,4 +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 <vespa/storage/bucketdb/mapbucketdatabase.h> #include <vespa/storage/common/bucketoperationlogger.h> @@ -464,7 +465,7 @@ namespace { struct Writer : public BucketDatabase::EntryProcessor { std::ostream& _ost; Writer(std::ostream& ost) : _ost(ost) {} - bool process(const BucketDatabase::Entry& e) override { + virtual bool process(const BucketDatabase::Entry& e) override { _ost << e.toString() << "\n"; return true; } diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h index 4c87c39fdd2..6e9bef38672 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.h @@ -138,12 +138,12 @@ public: ServiceLayerComponentRegister&); ~StorageBucketDBInitializer(); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; - void onOpen() override; - void onClose() override; + virtual void onOpen() override; + virtual void onClose() override; - void run(framework::ThreadHandle&) override; + virtual void run(framework::ThreadHandle&) override; bool onDown(const std::shared_ptr<api::StorageMessage>&) override; bool onInternalReply(const std::shared_ptr<api::InternalReply>&) override; @@ -215,3 +215,4 @@ public: }; } // storage + diff --git a/storage/src/vespa/storage/bucketmover/run.h b/storage/src/vespa/storage/bucketmover/run.h index d05020e6ba5..a626960eec7 100644 --- a/storage/src/vespa/storage/bucketmover/run.h +++ b/storage/src/vespa/storage/bucketmover/run.h @@ -15,13 +15,12 @@ #pragma once - +#include <list> +#include <map> #include <vespa/storage/bucketmover/move.h> #include <vespa/storage/bucketmover/runstatistics.h> #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/state/nodestate.h> -#include <list> -#include <map> namespace storage { @@ -92,7 +91,8 @@ public: RunStatistics& getStatistics() { return _statistics; } const RunStatistics& getStatistics() const { return _statistics; } - void print(std::ostream&, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream&, bool verbose, const std::string& indent) const override; private: void removePending(Move&); void finalize(); @@ -100,3 +100,4 @@ private: } // bucketmover } // storage + diff --git a/storage/src/vespa/storage/common/messagesender.h b/storage/src/vespa/storage/common/messagesender.h index 332103e12db..025695dff29 100644 --- a/storage/src/vespa/storage/common/messagesender.h +++ b/storage/src/vespa/storage/common/messagesender.h @@ -16,7 +16,6 @@ #pragma once -#include <memory> namespace storage { namespace api { diff --git a/storage/src/vespa/storage/common/servicelayercomponent.h b/storage/src/vespa/storage/common/servicelayercomponent.h index 5b9db275b27..e54421b1ce3 100644 --- a/storage/src/vespa/storage/common/servicelayercomponent.h +++ b/storage/src/vespa/storage/common/servicelayercomponent.h @@ -25,7 +25,7 @@ #pragma once -#include "storagecomponent.h" +#include <vespa/storage/common/storagecomponent.h> namespace storage { @@ -54,10 +54,12 @@ class ServiceLayerComponent : public StorageComponent, StorBucketDatabase* _bucketDatabase; MinimumUsedBitsTracker* _minUsedBitsTracker; - // ServiceLayerManagedComponent implementation - void setDiskCount(uint16_t count) override { _diskCount = count; } - void setBucketDatabase(StorBucketDatabase& db) override { _bucketDatabase = &db; } - void setMinUsedBitsTracker(MinimumUsedBitsTracker& tracker) override { + // ServiceLayerManagedComponent implementation + virtual void setDiskCount(uint16_t count) override { _diskCount = count; } + virtual void setBucketDatabase(StorBucketDatabase& db) override { + _bucketDatabase = &db; + } + virtual void setMinUsedBitsTracker(MinimumUsedBitsTracker& tracker) override { _minUsedBitsTracker = &tracker; } public: @@ -89,3 +91,4 @@ public: }; } // storage + diff --git a/storage/src/vespa/storage/common/statusmetricconsumer.h b/storage/src/vespa/storage/common/statusmetricconsumer.h index 6a2c18f78bd..0027cef9cd0 100644 --- a/storage/src/vespa/storage/common/statusmetricconsumer.h +++ b/storage/src/vespa/storage/common/statusmetricconsumer.h @@ -9,11 +9,11 @@ #pragma once -#include "storagecomponent.h" #include <vespa/vespalib/util/document_runnable.h> #include <vespa/vespalib/util/sync.h> #include <map> #include <vespa/metrics/metrics.h> +#include <vespa/storage/common/storagecomponent.h> #include <vespa/storageframework/storageframework.h> namespace vespalib { diff --git a/storage/src/vespa/storage/common/storagelink.h b/storage/src/vespa/storage/common/storagelink.h index a9af5fa5622..e9ea8403321 100644 --- a/storage/src/vespa/storage/common/storagelink.h +++ b/storage/src/vespa/storage/common/storagelink.h @@ -19,11 +19,13 @@ #pragma once -#include "messagesender.h" -#include "storagecomponent.h" +#include <vespa/vespalib/util/printable.h> +#include <memory> #include <vespa/storageapi/messageapi/messagehandler.h> #include <vespa/storageapi/messageapi/storagemessage.h> -#include <vespa/vespalib/util/printable.h> +#include <string> +#include <vespa/storage/common/messagesender.h> +#include <vespa/storage/common/storagecomponent.h> namespace storage { @@ -82,10 +84,10 @@ public: void flush(); /** Send message down the storage chain. */ - void sendDown(const api::StorageMessage::SP&) override; + virtual void sendDown(const api::StorageMessage::SP&); /** Send message up the storage chain. */ - void sendUp(const api::StorageMessage::SP&) override; + virtual void sendUp(const api::StorageMessage::SP&); void printChain(std::ostream&, std::string indent = "") const; @@ -124,7 +126,8 @@ public: */ virtual bool onUp(const api::StorageMessage::SP&); - void print(std::ostream& out, bool, const std::string&) const override { + virtual void print(std::ostream& out, bool, + const std::string&) const { out << getName(); } @@ -185,3 +188,4 @@ private: std::ostream& operator<<(std::ostream& out, StorageLink& link); } + diff --git a/storage/src/vespa/storage/common/storagelinkqueued.h b/storage/src/vespa/storage/common/storagelinkqueued.h index c894b6196e8..cd7b91a7a68 100644 --- a/storage/src/vespa/storage/common/storagelinkqueued.h +++ b/storage/src/vespa/storage/common/storagelinkqueued.h @@ -14,11 +14,11 @@ #pragma once -#include "storagelink.h" -#include <vespa/storageframework/storageframework.h> #include <vespa/vespalib/util/document_runnable.h> #include <deque> #include <limits> +#include <vespa/storageframework/storageframework.h> +#include <vespa/storage/common/storagelink.h> namespace storage { @@ -40,13 +40,13 @@ public: void dispatchUp(const std::shared_ptr<api::StorageMessage>&); /** Remember to call this method if you override it. */ - void onClose() override { + virtual void onClose() override { _commandDispatcher.flush(); _closeState |= 1; } /** Remember to call this method if you override it. */ - void onFlush(bool downwards) override { + virtual void onFlush(bool downwards) override { if (downwards) { _commandDispatcher.flush(); _closeState |= 2; @@ -79,7 +79,7 @@ private: public: Dispatcher(StorageLinkQueued& parent, unsigned int maxQueueSize, bool replyDispatcher); - ~Dispatcher(); + virtual ~Dispatcher(); void start(); void run(framework::ThreadHandle&) override; @@ -106,7 +106,7 @@ private: void send(const std::shared_ptr<api::StorageMessage> & reply) override { _parent.sendUp(reply); } - ~ReplyDispatcher() { terminate(); } + virtual ~ReplyDispatcher() { terminate(); } }; class CommandDispatcher : public Dispatcher<api::StorageMessage> @@ -117,7 +117,7 @@ private: parent, std::numeric_limits<unsigned int>::max(), false) { } - ~CommandDispatcher() { terminate(); } + virtual ~CommandDispatcher() { terminate(); } void send(const std::shared_ptr<api::StorageMessage> & command) override { _parent.sendDown(command); } @@ -132,6 +132,7 @@ private: protected: ReplyDispatcher& getReplyDispatcher() { return _replyDispatcher; } + }; } diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.h b/storage/src/vespa/storage/distributor/bucketdbupdater.h index a8f76c2c7a0..b87f0e5f898 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.h +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.h @@ -49,14 +49,23 @@ public: const std::shared_ptr<api::RequestBucketInfoReply> & repl) override; bool onMergeBucketReply(const std::shared_ptr<api::MergeBucketReply>& reply) override; + bool onNotifyBucketChange(const std::shared_ptr<api::NotifyBucketChangeCommand>&) override; + void resendDelayedMessages(); + void storageDistributionChanged(const lib::Distribution&); - vespalib::string reportXmlStatus(vespalib::xml::XmlOutputStream&, const framework::HttpUrlPath&) const; - vespalib::string getReportContentType(const framework::HttpUrlPath&) const override; + vespalib::string reportXmlStatus(vespalib::xml::XmlOutputStream&, + const framework::HttpUrlPath&) const; + + vespalib::string getReportContentType( + const framework::HttpUrlPath&) const override; bool reportStatus(std::ostream&, const framework::HttpUrlPath&) const override; - void print(std::ostream& out, bool verbose, const std::string& indent) const; + + virtual void print(std::ostream& out, bool verbose, + const std::string& indent) const; + DistributorComponent& getDistributorComponent() { return _bucketSpaceComponent; } /** @@ -231,8 +240,12 @@ private: _upStates(upStates) {} ~NodeRemover(); - bool process(BucketDatabase::Entry& e) override; - void logRemove(const document::BucketId& bucketId, const char* msg) const; + + virtual bool process(BucketDatabase::Entry& e) override; + + void logRemove(const document::BucketId& bucketId, + const char* msg) const; + bool distributorOwnsBucket(const document::BucketId&) const; const std::vector<document::BucketId>& getBucketsToRemove() const { @@ -253,7 +266,8 @@ private: const char* _upStates; }; - std::deque<std::pair<framework::MilliSecTime, BucketRequest> > _delayedRequests; + std::deque<std::pair<framework::MilliSecTime, + BucketRequest> > _delayedRequests; std::map<uint64_t, BucketRequest> _sentMessages; std::unique_ptr<PendingClusterState> _pendingClusterState; std::list<PendingClusterState::Summary> _history; @@ -266,3 +280,4 @@ private: } } + diff --git a/storage/src/vespa/storage/distributor/distributor.h b/storage/src/vespa/storage/distributor/distributor.h index 182988104a9..40d6ee76e07 100644 --- a/storage/src/vespa/storage/distributor/distributor.h +++ b/storage/src/vespa/storage/distributor/distributor.h @@ -2,6 +2,7 @@ #pragma once + #include "idealstatemanager.h" #include "bucketdbupdater.h" #include "pendingmessagetracker.h" @@ -21,6 +22,7 @@ #include <vespa/storageframework/generic/thread/tickingthread.h> #include <vespa/config/config.h> #include <vespa/vespalib/util/sync.h> + #include <unordered_map> namespace storage { @@ -55,12 +57,16 @@ public: ~Distributor(); void onOpen() override; + void onClose() override; + bool onDown(const std::shared_ptr<api::StorageMessage>&) override; + void sendUp(const std::shared_ptr<api::StorageMessage>&) override; + void sendDown(const std::shared_ptr<api::StorageMessage>&) override; - ChainedMessageSender& getMessageSender() override { + virtual ChainedMessageSender& getMessageSender() override { return (_messageSender == 0 ? *this : *_messageSender); } @@ -93,7 +99,8 @@ public: bool handleReply(const std::shared_ptr<api::StorageReply>& reply) override; // StatusReporter implementation - vespalib::string getReportContentType(const framework::HttpUrlPath&) const override; + vespalib::string getReportContentType( + const framework::HttpUrlPath&) const override; bool reportStatus(std::ostream&, const framework::HttpUrlPath&) const override; bool handleStatusRequest(const DelegatedStatusRequest& request) const override; @@ -110,7 +117,8 @@ public: * Checks whether a bucket needs to be split, and sends a split * if so. */ - void checkBucketForSplit(const BucketDatabase::Entry& e, uint8_t priority) override; + void checkBucketForSplit(const BucketDatabase::Entry& e, + uint8_t priority) override; const lib::Distribution& getDistribution() const override; @@ -122,9 +130,8 @@ public: * @return Returns the states in which the distributors consider * storage nodes to be up. */ - const char* getStorageNodeUpStates() const override { - return _initializingIsUp ? "uri" : "ur"; - } + const char* getStorageNodeUpStates() const override + { return _initializingIsUp ? "uri" : "ur"; } /** * Called by bucket db updater after a merge has finished, and all the @@ -147,10 +154,13 @@ public: } int getDistributorIndex() const override; + const std::string& getClusterName() const override; + const PendingMessageTracker& getPendingMessageTracker() const override; - void sendCommand(const std::shared_ptr<api::StorageCommand>&) override; - void sendReply(const std::shared_ptr<api::StorageReply>&) override; + + virtual void sendCommand(const std::shared_ptr<api::StorageCommand>&) override; + virtual void sendReply(const std::shared_ptr<api::StorageReply>&) override; const BucketGcTimeCalculator::BucketIdHasher& getBucketIdHasher() const override { diff --git a/storage/src/vespa/storage/distributor/operations/external/getoperation.h b/storage/src/vespa/storage/distributor/operations/external/getoperation.h index 57a7c55fb81..ecdfb1e677a 100644 --- a/storage/src/vespa/storage/distributor/operations/external/getoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/getoperation.h @@ -6,11 +6,15 @@ #include <vespa/storage/bucketdb/bucketcopy.h> #include <vespa/storageapi/messageapi/storagemessage.h> -namespace document { class Document; } +namespace document { +class Document; +} namespace storage { -namespace api { class GetCommand; } +namespace api { +class GetCommand; +} class PersistenceOperationMetricSet; @@ -26,9 +30,13 @@ public: PersistenceOperationMetricSet& metric); void onClose(DistributorMessageSender& sender) override; + void onStart(DistributorMessageSender& sender) override; + void onReceive(DistributorMessageSender& sender, const std::shared_ptr<api::StorageReply> & msg) override; + const char* getName() const override { return "get"; } + std::string getStatus() const override { return ""; } bool hasConsistentCopies() const; @@ -40,9 +48,13 @@ private: GroupId(const document::BucketId& id, uint32_t checksum, int node); bool operator<(const GroupId& other) const; + bool operator==(const GroupId& other) const; + const document::BucketId& getBucketId() const { return _id; } + int getNode() const { return _node; } + private: document::BucketId _id; uint32_t _checksum; @@ -53,8 +65,7 @@ private: public: BucketChecksumGroup(const BucketCopy& c) : copy(c), - sent(0), received(false), returnCode(api::ReturnCode::OK) - {} + sent(0), received(false), returnCode(api::ReturnCode::OK) {}; BucketCopy copy; api::StorageMessage::Id sent; @@ -94,4 +105,8 @@ private: }; } + + } + + diff --git a/storage/src/vespa/storage/distributor/operations/external/putoperation.h b/storage/src/vespa/storage/distributor/operations/external/putoperation.h index 6ba9e9c3dbf..5043fed307f 100644 --- a/storage/src/vespa/storage/distributor/operations/external/putoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/putoperation.h @@ -28,9 +28,14 @@ public: PersistenceOperationMetricSet& metric); void onStart(DistributorMessageSender& sender) override; - const char* getName() const override { return "put"; }; - std::string getStatus() const override { return ""; }; - void onReceive(DistributorMessageSender& sender, const std::shared_ptr<api::StorageReply> &) override; + + const char* getName() const override { return "put"; } + + std::string getStatus() const override { return ""; } + + void onReceive(DistributorMessageSender& sender, + const std::shared_ptr<api::StorageReply> &) override; + void onClose(DistributorMessageSender& sender) override; /** @@ -66,9 +71,11 @@ private: const uint16_t node, std::vector<PersistenceMessageTracker::ToSend>& putBatch); - bool shouldImplicitlyActivateReplica(const OperationTargetList& targets) const; + bool shouldImplicitlyActivateReplica( + const OperationTargetList& targets) const; std::shared_ptr<api::PutCommand> _msg; + DistributorComponent& _manager; }; diff --git a/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h b/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h index dce744b6648..25cc0825b7d 100644 --- a/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.h @@ -7,7 +7,9 @@ namespace storage { -namespace api { class GetBucketListCommand; } +namespace api { +class GetBucketListCommand; +} namespace distributor { @@ -21,21 +23,22 @@ public: const MaintenanceOperationGenerator& generator, uint16_t distributorIndex, const std::shared_ptr<api::GetBucketListCommand>& cmd); - ~StatBucketListOperation() {} + virtual ~StatBucketListOperation() {} - const char* getName() const override { return "statBucketList"; } - std::string getStatus() const override { return ""; } + virtual const char* getName() const override { return "statBucketList"; } + virtual std::string getStatus() const override { return ""; } - void onStart(DistributorMessageSender& sender) override; - void onReceive(DistributorMessageSender&, const std::shared_ptr<api::StorageReply>&) override - { + virtual void onStart(DistributorMessageSender& sender) override; + virtual void onReceive(DistributorMessageSender&, const std::shared_ptr<api::StorageReply>&) override { // Never called. assert(false); } - void onClose(DistributorMessageSender&) override {} + void onClose(DistributorMessageSender&) override { + } private: - void getBucketStatus(const BucketDatabase::Entry& entry, std::ostream& os) const; + void getBucketStatus(const BucketDatabase::Entry& entry, + std::ostream& os) const; const BucketDatabase& _bucketDb; const MaintenanceOperationGenerator& _generator; @@ -45,3 +48,4 @@ private: } // distributor } // storage + diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp index 7b1ff03b8af..15f8d06965a 100644 --- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp @@ -52,24 +52,24 @@ struct IntermediateMessageSender : DistributorMessageSender { DistributorMessageSender & fwd); ~IntermediateMessageSender(); - void sendCommand(const std::shared_ptr<api::StorageCommand>& cmd) override { + virtual void sendCommand(const std::shared_ptr<api::StorageCommand>& cmd) override { msgMap.insert(cmd->getMsgId(), callback); forward.sendCommand(cmd); }; - void sendReply(const std::shared_ptr<api::StorageReply>& reply) override { + virtual void sendReply(const std::shared_ptr<api::StorageReply>& reply) override { _reply = reply; } - int getDistributorIndex() const override { + virtual int getDistributorIndex() const override { return forward.getDistributorIndex(); } - const std::string& getClusterName() const override { + virtual const std::string& getClusterName() const override { return forward.getClusterName(); } - const PendingMessageTracker& getPendingMessageTracker() const override { + virtual const PendingMessageTracker& getPendingMessageTracker() const override { return forward.getPendingMessageTracker(); } }; diff --git a/storage/src/vespa/storage/distributor/operations/external/updateoperation.h b/storage/src/vespa/storage/distributor/operations/external/updateoperation.h index fef9c01efa9..0a2a9e564a0 100644 --- a/storage/src/vespa/storage/distributor/operations/external/updateoperation.h +++ b/storage/src/vespa/storage/distributor/operations/external/updateoperation.h @@ -25,9 +25,14 @@ public: PersistenceOperationMetricSet& metric); void onStart(DistributorMessageSender& sender) override; - const char* getName() const override { return "update"; }; - std::string getStatus() const override { return ""; }; - void onReceive(DistributorMessageSender& sender, const std::shared_ptr<api::StorageReply> & msg) override; + + const char* getName() const override { return "update"; } + + std::string getStatus() const override { return ""; } + + void onReceive(DistributorMessageSender& sender, + const std::shared_ptr<api::StorageReply> & msg) override; + void onClose(DistributorMessageSender& sender) override; std::pair<document::BucketId, uint16_t> getNewestTimestampLocation() const { @@ -60,3 +65,4 @@ private: } } + diff --git a/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h b/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h index fd133674bd1..802bb0f4bac 100644 --- a/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h +++ b/storage/src/vespa/storage/distributor/operationtargetresolverimpl.h @@ -2,8 +2,8 @@ #pragma once -#include "operationtargetresolver.h" #include <vespa/storage/bucketdb/bucketdatabase.h> +#include <vespa/storage/distributor/operationtargetresolver.h> #include <vespa/vdslib/distribution/idealnodecalculator.h> namespace storage { @@ -91,20 +91,23 @@ public: _idealNodeCalculator(idealNodeCalc), _minUsedBucketBits(minUsedBucketBits), _redundancy(redundancy) - {} + { + } BucketInstanceList getAllInstances(OperationType type, const document::BucketId& id); - BucketInstanceList getInstances(OperationType type, const document::BucketId& id) { + BucketInstanceList getInstances(OperationType type, const document::BucketId& id) + { BucketInstanceList result(getAllInstances(type, id)); result.limitToRedundancyCopies(_redundancy); return result; } - OperationTargetList getTargets(OperationType type, const document::BucketId& id) override { - return getInstances(type, id).createTargets(); - } + virtual OperationTargetList getTargets(OperationType type, + const document::BucketId& id) override + { return getInstances(type, id).createTargets(); } }; } // distributor } // storage + diff --git a/storage/src/vespa/storage/distributor/statecheckers.h b/storage/src/vespa/storage/distributor/statecheckers.h index dbd9503f9f2..0113749f2fd 100644 --- a/storage/src/vespa/storage/distributor/statecheckers.h +++ b/storage/src/vespa/storage/distributor/statecheckers.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "idealstatemanager.h" +#include <vespa/storage/distributor/idealstatemanager.h> namespace storage { @@ -11,7 +11,9 @@ class SynchronizeAndMoveStateChecker : public StateChecker { public: std::string getStatusText() const override { return "Synchronization and moving"; } + Result check(Context& c) override; + const char* getName() const override { return "SynchronizeAndMove"; } }; @@ -19,7 +21,9 @@ class DeleteExtraCopiesStateChecker : public StateChecker { public: std::string getStatusText() const override { return "Delete extra copies"; } + Result check(Context& c) override; + const char* getName() const override { return "DeleteExtraCopies"; } private: @@ -45,7 +49,9 @@ class JoinBucketsStateChecker : public StateChecker { public: std::string getStatusText() const override { return "Join buckets"; } + Result check(Context& c) override; + const char* getName() const override { return "JoinBuckets"; } private: uint64_t getTotalUsedFileSize(const Context& c) const; @@ -63,9 +69,13 @@ class SplitBucketStateChecker : public StateChecker { public: std::string getStatusText() const override { return "Split buckets"; } + Result check(Context& c) override; + const char* getName() const override { return "SplitBucket"; } + private: + Result generateMinimumBucketSplitOperation(Context& c); Result generateMaxSizeExceededSplitOperation(Context& c); @@ -76,8 +86,11 @@ private: class SplitInconsistentStateChecker : public StateChecker { public: - std::string getStatusText() const override { return "Fix inconsistently split buckets"; } + std::string getStatusText() const override + { return "Fix inconsistently split buckets"; } + Result check(Context& c) override; + const char* getName() const override { return "SplitInconsistentBuckets"; } private: @@ -102,7 +115,9 @@ class BucketStateStateChecker : public StateChecker const StateChecker::Context& c) const; public: std::string getStatusText() const override { return "Set bucket copy state"; } + Result check(Context& c) override; + const char* getName() const override { return "SetBucketState"; } }; @@ -110,11 +125,15 @@ class GarbageCollectionStateChecker : public StateChecker { public: std::string getStatusText() const override { return "Garbage collection"; } + bool needsGarbageCollection(const Context& c) const; + Result check(Context& c) override; + const char* getName() const override { return "GarbageCollection"; } }; } } + diff --git a/storage/src/vespa/storage/distributor/statusreporterdelegate.h b/storage/src/vespa/storage/distributor/statusreporterdelegate.h index 93a1fe1cd48..0c836910765 100644 --- a/storage/src/vespa/storage/distributor/statusreporterdelegate.h +++ b/storage/src/vespa/storage/distributor/statusreporterdelegate.h @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "delegatedstatusrequest.h" -#include "statusdelegator.h" #include <vespa/storageframework/storageframework.h> +#include <vespa/storage/distributor/delegatedstatusrequest.h> +#include <vespa/storage/distributor/statusdelegator.h> namespace storage { namespace distributor { @@ -20,7 +20,9 @@ public: const framework::StatusReporter& target); void registerStatusPage(); - vespalib::string getReportContentType(const framework::HttpUrlPath&) const override; + + vespalib::string getReportContentType( + const framework::HttpUrlPath&) const override; bool reportStatus(std::ostream&, const framework::HttpUrlPath&) const override; }; diff --git a/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h b/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h index 90ddb71d678..2cf0255bf9f 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h +++ b/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h @@ -7,10 +7,10 @@ */ #pragma once -#include "storagecomponentregisterimpl.h" #include <vespa/storage/bucketdb/mapbucketdatabase.h> #include <vespa/storage/common/distributorcomponent.h> #include <vespa/storage/common/nodestateupdater.h> +#include <vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h> namespace storage { namespace lib { @@ -36,13 +36,18 @@ public: DistributorComponentRegisterImpl(); ~DistributorComponentRegisterImpl(); - void registerDistributorComponent(DistributorManagedComponent&) override; + virtual void registerDistributorComponent(DistributorManagedComponent&) override; + void setTimeCalculator(UniqueTimeCalculator& calc); void setDistributorConfig(const DistributorConfig&); void setVisitorConfig(const VisitorConfig&); + private: - void handleNewState() override; - void setNodeStateUpdater(NodeStateUpdater& updater) override; + virtual void handleNewState() override; + + virtual void setNodeStateUpdater(NodeStateUpdater& updater) override; }; } // storage + + diff --git a/storage/src/vespa/storage/frameworkimpl/component/servicelayercomponentregisterimpl.h b/storage/src/vespa/storage/frameworkimpl/component/servicelayercomponentregisterimpl.h index d071ba8ba3e..7d322f027d5 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/servicelayercomponentregisterimpl.h +++ b/storage/src/vespa/storage/frameworkimpl/component/servicelayercomponentregisterimpl.h @@ -7,10 +7,10 @@ */ #pragma once -#include "storagecomponentregisterimpl.h" #include <vespa/storage/bucketdb/minimumusedbitstracker.h> #include <vespa/storage/bucketdb/storbucketdb.h> #include <vespa/storage/common/servicelayercomponent.h> +#include <vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h> namespace storage { @@ -35,8 +35,11 @@ public: return _minUsedBitsTracker; } - void registerServiceLayerComponent(ServiceLayerManagedComponent&) override; + virtual void registerServiceLayerComponent(ServiceLayerManagedComponent&) override; + void setDiskCount(uint16_t count); }; } // storage + + diff --git a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp index 4f2ed2bfc25..51a30d26def 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp +++ b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp @@ -14,9 +14,9 @@ StorageComponentRegisterImpl::StorageComponentRegisterImpl() _index(0xffff), _loadTypes(new documentapi::LoadTypeSet), _nodeStateUpdater(0) -{ } +{ -StorageComponentRegisterImpl::~StorageComponentRegisterImpl() { } +} void StorageComponentRegisterImpl::registerStorageComponent(StorageComponent& smc) diff --git a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h index 38773be167f..cf9abbb6864 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h +++ b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h @@ -40,7 +40,6 @@ public: typedef std::unique_ptr<StorageComponentRegisterImpl> UP; StorageComponentRegisterImpl(); - ~StorageComponentRegisterImpl(); const vespalib::string& getClusterName() const { return _clusterName; } const lib::NodeType& getNodeType() const @@ -48,12 +47,13 @@ public: uint16_t getIndex() const { return _index; } document::DocumentTypeRepo::SP getTypeRepo() { return _docTypeRepo; } documentapi::LoadTypeSet::SP getLoadTypes() { return _loadTypes; } - const document::BucketIdFactory& getBucketIdFactory() { return _bucketIdFactory; } + const document::BucketIdFactory& getBucketIdFactory() + { return _bucketIdFactory; } lib::Distribution::SP getDistribution() { return _distribution; } NodeStateUpdater& getNodeStateUpdater() { assert(_nodeStateUpdater != 0); return *_nodeStateUpdater; } - void registerStorageComponent(StorageComponent&) override; + virtual void registerStorageComponent(StorageComponent&) override; void setNodeInfo(vespalib::stringref clusterName, const lib::NodeType& nodeType, @@ -68,3 +68,5 @@ public: }; } // storage + + diff --git a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp index 18e0f2280f8..12e2c31068a 100644 --- a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp +++ b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp @@ -236,7 +236,7 @@ StatusWebServer::WebServer::onGetRequest(const string & tmpurl, const string &se namespace { class IndexPageReporter : public framework::HtmlStatusReporter { std::ostringstream ost; - void reportHtmlStatus(std::ostream& out,const framework::HttpUrlPath&) const override{ + virtual void reportHtmlStatus(std::ostream& out, const framework::HttpUrlPath&) const override { out << ost.str(); } diff --git a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h index d1a0a33da95..c89c286387b 100644 --- a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h +++ b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h @@ -10,12 +10,13 @@ #pragma once +#include <vespa/vespalib/stllike/string.h> +#include <vespa/fastlib/net/httpserver.h> +#include <list> #include <vespa/storage/config/config-stor-status.h> #include <vespa/storageframework/storageframework.h> #include <vespa/config/config.h> #include <vespa/config/helper/configfetcher.h> -#include <vespa/fastlib/net/httpserver.h> -#include <list> namespace storage { @@ -29,7 +30,7 @@ class StatusWebServer : private config::IFetcherCallback<vespa::config::content: public: WebServer(StatusWebServer&, uint16_t port); - void onGetRequest(const string & url, + virtual void onGetRequest(const string & url, const string & serverSpec, Fast_HTTPConnection& conn) override; const vespalib::string &getServerSpec() const { @@ -68,12 +69,16 @@ public: virtual ~StatusWebServer(); void handlePage(const framework::HttpUrlPath&, std::ostream& out); + static vespalib::string getServerSpec(const vespalib::string &requestSpec, const vespalib::string &serverSpec); + private: - void configure(std::unique_ptr<vespa::config::content::core::StorStatusConfig> config) override; + virtual void configure(std::unique_ptr<vespa::config::content::core::StorStatusConfig> config) override; void getPage(const char* url, Fast_HTTPConnection& conn); - void run(framework::ThreadHandle&) override; + virtual void run(framework::ThreadHandle&) override; + }; } + diff --git a/storage/src/vespa/storage/frameworkimpl/thread/appkiller.h b/storage/src/vespa/storage/frameworkimpl/thread/appkiller.h index 437927ccaf1..b785c98e505 100644 --- a/storage/src/vespa/storage/frameworkimpl/thread/appkiller.h +++ b/storage/src/vespa/storage/frameworkimpl/thread/appkiller.h @@ -22,7 +22,7 @@ struct AppKiller { }; struct RealAppKiller : public AppKiller { - void kill() override; + virtual void kill(); }; } // storage diff --git a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp index 2861ab904ff..5d58a092053 100644 --- a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp +++ b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp @@ -2,6 +2,8 @@ #include "deadlockdetector.h" #include <vespa/storage/bucketdb/storbucketdb.h> +#include <vespa/storageframework/storageframework.h> +#include <vespa/vdslib/state/nodetype.h> #include <vespa/storage/bucketmover/htmltable.h> #include <vespa/vespalib/stllike/asciistream.h> @@ -144,10 +146,10 @@ namespace { ThreadChecker(DeadLockDetector& d, const framework::MilliSecTime& time) : _detector(d), _currentTime(time) {} - void visitThread(const vespalib::string& id, - const framework::ThreadProperties& tp, - const framework::ThreadTickData& tick, - DeadLockDetector::State& state) override + virtual void visitThread(const vespalib::string& id, + const framework::ThreadProperties& tp, + const framework::ThreadTickData& tick, + DeadLockDetector::State& state) override { // In case we just got a new tick, ignore the thread if (tick._lastTickMs > _currentTime.getTime()) return; diff --git a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h index c8cb3f35ddf..146d0ccb751 100644 --- a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h +++ b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h @@ -12,9 +12,9 @@ #pragma once -#include "appkiller.h" #include <vespa/storage/common/distributorcomponent.h> #include <vespa/storage/common/servicelayercomponent.h> +#include <vespa/storage/frameworkimpl/thread/appkiller.h> #include <vespa/storageframework/storageframework.h> #include <vespa/vespalib/util/sync.h> #include <map> @@ -88,9 +88,13 @@ private: StorageComponent* _component; framework::Thread::UP _thread; - void run(framework::ThreadHandle&) override; - void reportHtmlStatus(std::ostream& out, const framework::HttpUrlPath&) const override; + virtual void run(framework::ThreadHandle&) override; + + // Status implementation + virtual void reportHtmlStatus(std::ostream& out, + const framework::HttpUrlPath&) const override; vespalib::string getBucketLockInfo() const; }; } + diff --git a/storage/src/vespa/storage/persistence/diskthread.h b/storage/src/vespa/storage/persistence/diskthread.h index a1af83a65ef..3626bbb2c70 100644 --- a/storage/src/vespa/storage/persistence/diskthread.h +++ b/storage/src/vespa/storage/persistence/diskthread.h @@ -60,7 +60,7 @@ public: bool operator==(const OperationCount& c) const { return (count == c.count && pending == c.pending); } - void print(std::ostream& out, bool, const std::string&) const override + void print(std::ostream& out, bool, const std::string&) const { out << "OperationCount(" << count << (pending ? ", pending" : "") << ")"; diff --git a/storage/src/vespa/storage/persistence/filestorage/filestorhandler.h b/storage/src/vespa/storage/persistence/filestorage/filestorhandler.h index b549aca35b6..e658599a3dc 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestorhandler.h +++ b/storage/src/vespa/storage/persistence/filestorage/filestorhandler.h @@ -13,9 +13,9 @@ #pragma once -#include "mergestatus.h" #include <vespa/document/bucket/bucketid.h> #include <ostream> +#include <vespa/storage/persistence/filestorage/mergestatus.h> #include <vespa/storage/storageutil/resumeguard.h> #include <vespa/storage/common/messagesender.h> diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h index 39d9a60a950..a6942102c42 100644 --- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h +++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h @@ -8,8 +8,6 @@ #pragma once -#include "filestorhandler.h" -#include "filestormetrics.h" #include <vespa/vespalib/util/document_runnable.h> #include <vespa/vespalib/util/sync.h> #include <vespa/document/bucket/bucketid.h> @@ -22,7 +20,8 @@ #include <vespa/storage/common/storagelinkqueued.h> #include <vespa/config-stor-filestor.h> #include <vespa/storage/persistence/diskthread.h> - +#include <vespa/storage/persistence/filestorage/filestorhandler.h> +#include <vespa/storage/persistence/filestorage/filestormetrics.h> #include <vespa/storage/persistence/providershutdownwrapper.h> #include <vespa/storageframework/storageframework.h> #include <vespa/storage/common/nodestateupdater.h> @@ -105,7 +104,7 @@ public: ServiceLayerComponentRegister&); ~FileStorManager(); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; // Return true if we are currently merging the given bucket. bool isMerging(const document::BucketId& bucket) const; @@ -123,7 +122,8 @@ public: private: void configure(std::unique_ptr<vespa::config::content::StorFilestorConfig> config) override; - void replyWithBucketNotFound(api::StorageMessage&, const document::BucketId&); + void replyWithBucketNotFound(api::StorageMessage&, + const document::BucketId&); void replyDroppedOperation(api::StorageMessage& msg, const document::BucketId& bucket, @@ -135,12 +135,17 @@ private: api::StorageMessage& msg, const char* callerId); - bool validateApplyDiffCommandBucket(api::StorageMessage& msg, const StorBucketDatabase::WrappedEntry&); - bool validateDiffReplyBucket(const StorBucketDatabase::WrappedEntry&, const document::BucketId&); + bool validateApplyDiffCommandBucket(api::StorageMessage& msg, + const StorBucketDatabase::WrappedEntry&); + bool validateDiffReplyBucket(const StorBucketDatabase::WrappedEntry&, + const document::BucketId&); - StorBucketDatabase::WrappedEntry mapOperationToDisk(api::StorageMessage&, const document::BucketId&); - StorBucketDatabase::WrappedEntry mapOperationToBucketAndDisk(api::BucketCommand&, const document::DocumentId*); - bool handlePersistenceMessage(const std::shared_ptr<api::StorageMessage>&, uint16_t disk); + StorBucketDatabase::WrappedEntry mapOperationToDisk( + api::StorageMessage&, const document::BucketId&); + StorBucketDatabase::WrappedEntry mapOperationToBucketAndDisk( + api::BucketCommand&, const document::DocumentId*); + bool handlePersistenceMessage(const std::shared_ptr<api::StorageMessage>&, + uint16_t disk); // Document operations bool onPut(const std::shared_ptr<api::PutCommand>&) override; @@ -170,15 +175,23 @@ private: bool onInternal(const std::shared_ptr<api::InternalCommand>&) override; bool onInternalReply(const std::shared_ptr<api::InternalReply>&) override; - void handleAbortBucketOperations(const std::shared_ptr<AbortBucketOperationsCommand>&); + void handleAbortBucketOperations( + const std::shared_ptr<AbortBucketOperationsCommand>&); + void sendCommand(const std::shared_ptr<api::StorageCommand>&) override; void sendReply(const std::shared_ptr<api::StorageReply>&) override; + void sendUp(const std::shared_ptr<api::StorageMessage>&) override; + void onClose() override; void onFlush(bool downwards) override; - void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; - void storageDistributionChanged() override; + + virtual void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; + + virtual void storageDistributionChanged() override; + void updateState(); }; } // storage + diff --git a/storage/src/vespa/storage/persistence/filestorage/mergestatus.h b/storage/src/vespa/storage/persistence/filestorage/mergestatus.h index ff7e9e5dfb4..9967fc24c7d 100644 --- a/storage/src/vespa/storage/persistence/filestorage/mergestatus.h +++ b/storage/src/vespa/storage/persistence/filestorage/mergestatus.h @@ -41,7 +41,7 @@ public: const std::vector<api::ApplyBucketDiffCommand::Entry>& part, uint16_t hasMask); void print(std::ostream& out, bool verbose, - const std::string& indent) const override; + const std::string& indent) const; bool isFirstNode() const { return (reply.get() != 0); } }; diff --git a/storage/src/vespa/storage/persistence/persistencethread.h b/storage/src/vespa/storage/persistence/persistencethread.h index d2c4dba3a5f..f4c70353fab 100644 --- a/storage/src/vespa/storage/persistence/persistencethread.h +++ b/storage/src/vespa/storage/persistence/persistencethread.h @@ -2,15 +2,15 @@ #pragma once -#include "diskthread.h" -#include "processallhandler.h" -#include "mergehandler.h" -#include "diskmoveoperationhandler.h" -#include "persistenceutil.h" -#include "providershutdownwrapper.h" +#include <vespa/storage/common/statusmessages.h> +#include <vespa/storage/persistence/diskthread.h> +#include <vespa/storage/persistence/processallhandler.h> +#include <vespa/storage/persistence/mergehandler.h> +#include <vespa/storage/persistence/diskmoveoperationhandler.h> #include <vespa/storageframework/storageframework.h> #include <vespa/storage/common/storagecomponent.h> -#include <vespa/storage/common/statusmessages.h> +#include <vespa/storage/persistence/persistenceutil.h> +#include <vespa/storage/persistence/providershutdownwrapper.h> namespace storage { @@ -35,7 +35,7 @@ public: bool isMerging(const BucketId& bucket) const; - framework::Thread& getThread() override { return *_thread; } + virtual framework::Thread& getThread() override { return *_thread; } MessageTracker::UP handlePut(api::PutCommand& cmd); MessageTracker::UP handleRemove(api::RemoveCommand& cmd); @@ -99,8 +99,10 @@ private: void processMessages(FileStorHandler::LockedMessage & lock); // Thread main loop - void run(framework::ThreadHandle&) override; + virtual void run(framework::ThreadHandle&) override; + bool checkForError(const spi::Result& response, MessageTracker& tracker); + spi::Bucket getBucket(const DocumentId& id, const BucketId& bucket) const; void flushAllReplies(const document::BucketId& bucketId, @@ -112,3 +114,4 @@ private: }; } // storage + diff --git a/storage/src/vespa/storage/persistence/processallhandler.cpp b/storage/src/vespa/storage/persistence/processallhandler.cpp index c08b19a9e45..2095e19261c 100644 --- a/storage/src/vespa/storage/persistence/processallhandler.cpp +++ b/storage/src/vespa/storage/persistence/processallhandler.cpp @@ -2,6 +2,7 @@ #include "processallhandler.h" #include "bucketprocessor.h" +#include <vespa/storage/common/bucketmessages.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/log/log.h> diff --git a/storage/src/vespa/storage/persistence/splitbitdetector.cpp b/storage/src/vespa/storage/persistence/splitbitdetector.cpp index 62039f36133..8d816760815 100644 --- a/storage/src/vespa/storage/persistence/splitbitdetector.cpp +++ b/storage/src/vespa/storage/persistence/splitbitdetector.cpp @@ -1,5 +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/storage/persistence/splitbitdetector.h> #include <vespa/storage/persistence/bucketprocessor.h> #include <vespa/document/bucket/bucketidfactory.h> diff --git a/storage/src/vespa/storage/storageserver/CMakeLists.txt b/storage/src/vespa/storage/storageserver/CMakeLists.txt index 79ce0206005..17638f55b3a 100644 --- a/storage/src/vespa/storage/storageserver/CMakeLists.txt +++ b/storage/src/vespa/storage/storageserver/CMakeLists.txt @@ -8,7 +8,6 @@ vespa_add_library(storage_storageserver fnetlistener.cpp rpcrequestwrapper.cpp communicationmanager.cpp - communicationmanagermetrics.cpp statemanager.cpp documentapiconverter.cpp opslogger.cpp @@ -21,7 +20,6 @@ vespa_add_library(storage_storageserver distributornode.cpp servicelayernode.cpp statereporter.cpp - storagemetricsset.cpp changedbucketownershiphandler.cpp INSTALL lib64 DEPENDS diff --git a/storage/src/vespa/storage/storageserver/applicationgenerationfetcher.h b/storage/src/vespa/storage/storageserver/applicationgenerationfetcher.h index 7d5b64c1d17..0e33c8c86c6 100644 --- a/storage/src/vespa/storage/storageserver/applicationgenerationfetcher.h +++ b/storage/src/vespa/storage/storageserver/applicationgenerationfetcher.h @@ -9,14 +9,11 @@ #pragma once -#include <cstdint> -#include <string> - namespace storage { class ApplicationGenerationFetcher { public: - virtual ~ApplicationGenerationFetcher() {} + virtual ~ApplicationGenerationFetcher() {}; virtual int64_t getGeneration() const = 0; virtual std::string getComponentName() const = 0; diff --git a/storage/src/vespa/storage/storageserver/bucketintegritychecker.h b/storage/src/vespa/storage/storageserver/bucketintegritychecker.h index fd9516a85aa..6b87be804d0 100644 --- a/storage/src/vespa/storage/storageserver/bucketintegritychecker.h +++ b/storage/src/vespa/storage/storageserver/bucketintegritychecker.h @@ -112,29 +112,47 @@ public: ServiceLayerComponentRegister&); ~BucketIntegrityChecker(); - void onClose() override; - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void onClose() override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + SchedulingOptions& getSchedulingOptions() { return _scheduleOptions; } + bool isWorkingOnCycle() const; + uint32_t getCycleCount() const; /** Give thread a bump by signalling it. */ void bump() const; - void setMaxThreadWaitTime(framework::MilliSecTime milliSecs) { _maxThreadWaitTime = milliSecs; } + void setMaxThreadWaitTime(framework::MilliSecTime milliSecs) + { _maxThreadWaitTime = milliSecs; } framework::Clock& getClock() { return _component.getClock(); } private: - void configure(std::unique_ptr<vespa::config::content::core::StorIntegritycheckerConfig>) override; + virtual void configure(std::unique_ptr<vespa::config::content::core::StorIntegritycheckerConfig>) override; + void onDoneInit() override; + bool onInternalReply(const std::shared_ptr<api::InternalReply>&) override; bool onSetSystemState(const std::shared_ptr<api::SetSystemStateCommand>&) override; - bool onNotifyBucketChangeReply(const std::shared_ptr<api::NotifyBucketChangeReply>&) override { return true; } - SchedulingOptions::RunState getCurrentRunState(framework::SecondTime time) const; - void run(framework::ThreadHandle&) override; + bool onNotifyBucketChangeReply( + const std::shared_ptr<api::NotifyBucketChangeReply>&) override + { return true; } + + SchedulingOptions::RunState getCurrentRunState( + framework::SecondTime time) const; + + virtual void run(framework::ThreadHandle&) override; + uint32_t getTotalPendingCount() const; - void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; + + // Status::Reporter implementation + virtual void reportHtmlStatus(std::ostream&, + const framework::HttpUrlPath&) const override; + }; } + diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.h b/storage/src/vespa/storage/storageserver/communicationmanager.h index 3cae63d3586..31100de78d1 100644 --- a/storage/src/vespa/storage/storageserver/communicationmanager.h +++ b/storage/src/vespa/storage/storageserver/communicationmanager.h @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. /** - * @class CommunicationManager + + +* @class CommunicationManager * @ingroup storageserver * * @brief Class used for sending messages over the network. @@ -10,26 +12,26 @@ #pragma once -#include <vespa/documentapi/documentapi.h> -#include "communicationmanagermetrics.h" -#include "messageallocationtypes.h" -#include "documentapiconverter.h" -#include <vespa/storage/common/storagelink.h> -#include <vespa/storage/config/config-stor-communicationmanager.h> -#include <vespa/storageframework/storageframework.h> -#include <vespa/storageframework/storageframework.h> -#include <vespa/storageapi/messageapi/storagecommand.h> -#include <vespa/storageapi/messageapi/storagemessage.h> -#include <vespa/storageapi/mbusprot/storagecommand.h> -#include <vespa/storageapi/mbusprot/storagereply.h> -#include <vespa/messagebus/rpcmessagebus.h> -#include <vespa/metrics/metrics.h> #include <vespa/vespalib/util/document_runnable.h> #include <map> #include <memory> #include <queue> #include <vector> #include <atomic> +#include <vespa/metrics/metrics.h> +#include <vespa/messagebus/rpcmessagebus.h> +#include <vespa/storageframework/storageframework.h> +#include <vespa/storage/common/storagelink.h> +#include <vespa/storage/config/config-stor-communicationmanager.h> +#include <vespa/storageapi/messageapi/storagecommand.h> +#include <vespa/storageapi/messageapi/storagemessage.h> +#include <vespa/storageapi/mbusprot/storagecommand.h> +#include <vespa/storageapi/mbusprot/storagereply.h> +#include <vespa/documentapi/documentapi.h> +#include <vespa/storage/storageserver/communicationmanagermetrics.h> +#include <vespa/storage/storageserver/messageallocationtypes.h> +#include "documentapiconverter.h" +#include <vespa/storageframework/storageframework.h> namespace storage { @@ -187,32 +189,43 @@ private: public: CommunicationManager(StorageComponentRegister& compReg, const config::ConfigUri & configUri); - ~CommunicationManager(); + virtual ~CommunicationManager(); void enqueue(const std::shared_ptr<api::StorageMessage> & msg); + mbus::RPCMessageBus& getMessageBus() { assert(_mbus.get()); return *_mbus; } + const PriorityConverter& getPriorityConverter() const { return _docApiConverter.getPriorityConverter(); } /** * From StorageLink. Called when messages arrive from storage * modules. Will convert and dispatch messages to MessageServer */ - bool onUp(const std::shared_ptr<api::StorageMessage>&) override; + virtual bool onUp(const std::shared_ptr<api::StorageMessage>&) override; + bool sendCommand(const std::shared_ptr<api::StorageCommand>& command); + bool sendReply(const std::shared_ptr<api::StorageReply>& reply); void sendDirectRPCReply(RPCRequestWrapper& request, const std::shared_ptr<api::StorageReply>& reply); void sendMessageBusReply(StorageTransportContext& context, const std::shared_ptr<api::StorageReply>& reply); // Pump thread void run(framework::ThreadHandle&) override; - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + /** Get messages from messagebus. */ void handleMessage(std::unique_ptr<mbus::Message> msg) override; + void sendMessageBusMessage(const std::shared_ptr<api::StorageCommand>& msg, - std::unique_ptr<mbus::Message> mbusMsg, const mbus::Route& route); + std::unique_ptr<mbus::Message> mbusMsg, const mbus::Route& route); + /** Get replies from messagebus. */ void handleReply(std::unique_ptr<mbus::Reply> msg) override; + void updateMessagebusProtocol(const document::DocumentTypeRepo::SP &repo); + }; } // storage + diff --git a/storage/src/vespa/storage/storageserver/communicationmanagermetrics.cpp b/storage/src/vespa/storage/storageserver/communicationmanagermetrics.cpp deleted file mode 100644 index d1e71b6e8a5..00000000000 --- a/storage/src/vespa/storage/storageserver/communicationmanagermetrics.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "communicationmanagermetrics.h" -#include <vespa/documentapi/loadtypes/loadtypeset.h> - -using namespace metrics; -namespace storage { - -CommunicationManagerMetrics::CommunicationManagerMetrics(const LoadTypeSet& loadTypes, MetricSet* owner) - : MetricSet("communication", "", "Metrics for the communication manager", owner), - queueSize("messagequeue", "", "Size of input message queue.", this), - messageProcessTime(loadTypes, - DoubleAverageMetric("messageprocesstime", "", - "Time transport thread uses to process a single message"), - this), - exceptionMessageProcessTime(loadTypes, - DoubleAverageMetric("exceptionmessageprocesstime", "", - "Time transport thread uses to process a single message " - "that fails with an exception thrown into communication manager"), - this), - failedDueToTooLittleMemory("toolittlememory", "", "Number of messages failed due to too little memory available", this), - convertToStorageAPIFailures("convertfailures", "", - "Number of messages that failed to get converted to storage API messages", this), - sendCommandLatency("sendcommandlatency", "", "Average ms used to send commands to MBUS", this), - sendReplyLatency("sendreplylatency", "", "Average ms used to send replies to MBUS", this) -{ -} - -CommunicationManagerMetrics::~CommunicationManagerMetrics() { } - -} - diff --git a/storage/src/vespa/storage/storageserver/communicationmanagermetrics.h b/storage/src/vespa/storage/storageserver/communicationmanagermetrics.h index 40c3646647e..4b580f79904 100644 --- a/storage/src/vespa/storage/storageserver/communicationmanagermetrics.h +++ b/storage/src/vespa/storage/storageserver/communicationmanagermetrics.h @@ -9,6 +9,7 @@ #pragma once #include <vespa/metrics/metrics.h> +#include <vespa/documentapi/loadtypes/loadtypeset.h> namespace storage { @@ -21,8 +22,34 @@ struct CommunicationManagerMetrics : public metrics::MetricSet { metrics::DoubleAverageMetric sendCommandLatency; metrics::DoubleAverageMetric sendReplyLatency; - CommunicationManagerMetrics(const metrics::LoadTypeSet& loadTypes, metrics::MetricSet* owner = 0); - ~CommunicationManagerMetrics(); + CommunicationManagerMetrics(const metrics::LoadTypeSet& loadTypes, + metrics::MetricSet* owner = 0) + : metrics::MetricSet("communication", "", + "Metrics for the communication manager", owner), + queueSize("messagequeue", "", "Size of input message queue.", this), + messageProcessTime(loadTypes, metrics::DoubleAverageMetric( + "messageprocesstime", "", + "Time transport thread uses to process a single message"), + this), + exceptionMessageProcessTime(loadTypes, metrics::DoubleAverageMetric( + "exceptionmessageprocesstime", "", + "Time transport thread uses to process a single message " + "that fails with an exception thrown into communication " + "manager"), + this), + failedDueToTooLittleMemory("toolittlememory", "", + "Number of messages failed due to too little memory " + "available", this), + convertToStorageAPIFailures("convertfailures", "", + "Number of messages that failed to get converted to " + "storage API messages", this), + sendCommandLatency("sendcommandlatency", "", + "Average ms used to send commands to MBUS", this), + sendReplyLatency("sendreplylatency", "", + "Average ms used to send replies to MBUS", this) + { + } + }; } diff --git a/storage/src/vespa/storage/storageserver/distributornode.h b/storage/src/vespa/storage/storageserver/distributornode.h index 31fe8fe7878..03792d8fb56 100644 --- a/storage/src/vespa/storage/storageserver/distributornode.h +++ b/storage/src/vespa/storage/storageserver/distributornode.h @@ -8,9 +8,9 @@ #pragma once -#include "distributornodecontext.h" -#include "storagenode.h" #include <vespa/storage/common/distributorcomponent.h> +#include <vespa/storage/storageserver/distributornodecontext.h> +#include <vespa/storage/storageserver/storagenode.h> #include <vespa/storageframework/generic/thread/tickingthread.h> namespace storage { @@ -41,16 +41,19 @@ public: StorageLink::UP communicationManager = StorageLink::UP()); ~DistributorNode(); - const lib::NodeType& getNodeType() const override { return lib::NodeType::DISTRIBUTOR; } - ResumeGuard pause() override; + virtual const lib::NodeType& getNodeType() const override + { return lib::NodeType::DISTRIBUTOR; } + + virtual ResumeGuard pause() override; void handleConfigChange(vespa::config::content::core::StorDistributormanagerConfig&); void handleConfigChange(vespa::config::content::core::StorVisitordispatcherConfig&); private: - void initializeNodeSpecific() override; - StorageLink::UP createChain() override; - api::Timestamp getUniqueTimestamp() override; + virtual void initializeNodeSpecific() override; + virtual StorageLink::UP createChain() override; + + virtual api::Timestamp getUniqueTimestamp() override; /** * Shut down necessary distributor-specific components before shutting @@ -60,3 +63,4 @@ private: }; } // storage + diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.cpp b/storage/src/vespa/storage/storageserver/mergethrottler.cpp index 577fedb58e1..ebfa10fe814 100644 --- a/storage/src/vespa/storage/storageserver/mergethrottler.cpp +++ b/storage/src/vespa/storage/storageserver/mergethrottler.cpp @@ -1,12 +1,15 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "mergethrottler.h" -#include "storagemetricsset.h" +#include <vespa/fastos/fastos.h> +#include <vespa/storage/storageserver/mergethrottler.h> + #include <iostream> #include <sstream> +#include <iterator> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/storage/common/nodestateupdater.h> #include <vespa/storage/persistence/messages.h> +#include <vespa/storage/storageserver/storagemetricsset.h> #include <vespa/log/log.h> LOG_SETUP(".mergethrottler"); @@ -43,71 +46,6 @@ const mbus::string DummyMbusMessage<Base>::NAME = "SkyNet"; } -MergeThrottler::ChainedMergeState::ChainedMergeState() - : _cmd(), - _cmdString(), - _clusterStateVersion(0), - _inCycle(false), - _executingLocally(false), - _unwinding(false), - _cycleBroken(false), - _aborted(false) -{ } - -MergeThrottler::ChainedMergeState::ChainedMergeState(const api::StorageMessage::SP& cmd, bool executing) - : _cmd(cmd), - _cmdString(cmd->toString()), - _clusterStateVersion(static_cast<const api::MergeBucketCommand&>(*cmd).getClusterStateVersion()), - _inCycle(false), - _executingLocally(executing), - _unwinding(false), - _cycleBroken(false), - _aborted(false) -{ } -MergeThrottler::ChainedMergeState::~ChainedMergeState() {} - -MergeThrottler::Metrics::Metrics(metrics::MetricSet* owner) - : metrics::MetricSet("mergethrottler", "", "", owner), - averageQueueWaitingTime("averagequeuewaitingtime", "", "Average time a merge spends in the throttler queue", this), - chaining("mergechains", this), - local("locallyexecutedmerges", this) -{ } -MergeThrottler::Metrics::~Metrics() {} - -MergeThrottler::MergeFailureMetrics::MergeFailureMetrics(metrics::MetricSet* owner) - : metrics::MetricSet("failures", "", "Detailed failure statistics", owner), - sum("total", "", "Sum of all failures", this), - notready("notready", "", "The number of merges discarded because distributor was not ready", this), - timeout("timeout", "", "The number of merges that failed because they timed out towards storage", this), - aborted("aborted", "", "The number of merges that failed because the storage node was (most likely) shutting down", this), - wrongdistribution("wrongdistribution", "", "The number of merges that were discarded (flushed) because they were initiated at an older cluster state than the current", this), - bucketnotfound("bucketnotfound", "", "The number of operations that failed because the bucket did not exist", this), - busy("busy", "", "The number of merges that failed because the storage node was busy", this), - exists("exists", "", "The number of merges that were rejected due to a merge operation for their bucket already being processed", this), - rejected("rejected", "", "The number of merges that were rejected", this), - other("other", "", "The number of other failures", this) -{ - sum.addMetricToSum(notready); - sum.addMetricToSum(timeout); - sum.addMetricToSum(aborted); - sum.addMetricToSum(wrongdistribution); - sum.addMetricToSum(bucketnotfound); - sum.addMetricToSum(busy); - sum.addMetricToSum(exists); - sum.addMetricToSum(rejected); - sum.addMetricToSum(other); -} -MergeThrottler::MergeFailureMetrics::~MergeFailureMetrics() { } - - -MergeThrottler::MergeOperationMetrics::MergeOperationMetrics(const std::string& name, metrics::MetricSet* owner) - : metrics::MetricSet(name, "", vespalib::make_string("Statistics for %s", name.c_str()), owner), - ok("ok", "", vespalib::make_string("The number of successful merges for '%s'", name.c_str()), this), - failures(this) -{ -} -MergeThrottler::MergeOperationMetrics::~MergeOperationMetrics() { } - MergeThrottler::MergeNodeSequence::MergeNodeSequence( const api::MergeBucketCommand& cmd, uint16_t thisIndex) diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.h b/storage/src/vespa/storage/storageserver/mergethrottler.h index 74ffe095d7c..8ee4ca7be71 100644 --- a/storage/src/vespa/storage/storageserver/mergethrottler.h +++ b/storage/src/vespa/storage/storageserver/mergethrottler.h @@ -7,6 +7,11 @@ */ #pragma once +#include <map> +#include <utility> +#include <vector> +#include <set> +#include <memory> #include <vespa/vespalib/util/document_runnable.h> #include <vespa/storage/config/config-stor-server.h> #include <vespa/storage/common/storagelink.h> @@ -43,8 +48,37 @@ public: metrics::LongCountMetric rejected; metrics::LongCountMetric other; - MergeFailureMetrics(metrics::MetricSet* owner); - ~MergeFailureMetrics(); + MergeFailureMetrics(metrics::MetricSet* owner) + : metrics::MetricSet("failures", "", "Detailed failure statistics", owner), + sum("total", "", "Sum of all failures", this), + notready("notready", "", "The number of merges discarded " + "because distributor was not ready", this), + timeout("timeout", "", "The number of merges that failed because " + "they timed out towards storage", this), + aborted("aborted", "", "The number of merges that failed " + "because the storage node was (most likely) shutting down", this), + wrongdistribution("wrongdistribution", "", "The number of merges that " + "were discarded (flushed) because they were initiated at an " + "older cluster state than the current", this), + bucketnotfound("bucketnotfound", "", "The number of operations that failed " + "because the bucket did not exist", this), + busy("busy", "", "The number of merges that failed because the " + "storage node was busy", this), + exists("exists", "", "The number of merges that were rejected due to a " + "merge operation for their bucket already being processed", this), + rejected("rejected", "", "The number of merges that were rejected", this), + other("other", "", "The number of other failures", this) + { + sum.addMetricToSum(notready); + sum.addMetricToSum(timeout); + sum.addMetricToSum(aborted); + sum.addMetricToSum(wrongdistribution); + sum.addMetricToSum(bucketnotfound); + sum.addMetricToSum(busy); + sum.addMetricToSum(exists); + sum.addMetricToSum(rejected); + sum.addMetricToSum(other); + } }; class MergeOperationMetrics : public metrics::MetricSet @@ -53,8 +87,12 @@ public: metrics::LongCountMetric ok; MergeFailureMetrics failures; - MergeOperationMetrics(const std::string& name, metrics::MetricSet* owner); - ~MergeOperationMetrics(); + MergeOperationMetrics(const std::string& name, metrics::MetricSet* owner) + : metrics::MetricSet(name, "", vespalib::make_string("Statistics for %s", name.c_str()), owner), + ok("ok", "", vespalib::make_string("The number of successful merges for '%s'", name.c_str()), this), + failures(this) + { + } }; class Metrics : public metrics::MetricSet @@ -64,8 +102,15 @@ public: MergeOperationMetrics chaining; MergeOperationMetrics local; - Metrics(metrics::MetricSet* owner = 0); - ~Metrics(); + Metrics(metrics::MetricSet* owner = 0) + : metrics::MetricSet("mergethrottler", "", "", owner), + averageQueueWaitingTime( + "averagequeuewaitingtime", "", "Average time a merge spends in " + "the throttler queue", this), + chaining("mergechains", this), + local("locallyexecutedmerges", this) + { + } }; private: @@ -106,9 +151,30 @@ private: bool _cycleBroken; bool _aborted; - ChainedMergeState(); - ChainedMergeState(const api::StorageMessage::SP& cmd, bool executing = false); - ~ChainedMergeState(); + ChainedMergeState() + : _cmd(), + _cmdString(), + _clusterStateVersion(0), + _inCycle(false), + _executingLocally(false), + _unwinding(false), + _cycleBroken(false), + _aborted(false) + { + } + + ChainedMergeState(const api::StorageMessage::SP& cmd, bool executing = false) + : _cmd(cmd), + _cmdString(cmd->toString()), + _clusterStateVersion(static_cast<const api::MergeBucketCommand&>( + *cmd).getClusterStateVersion()), + _inCycle(false), + _executingLocally(executing), + _unwinding(false), + _cycleBroken(false), + _aborted(false) + { + } // Use default copy-constructor/assignment operator bool isExecutingLocally() const { return _executingLocally; } @@ -173,7 +239,9 @@ public: * windowSizeIncrement used for allowing unit tests to start out with more * than 1 as their window size. */ - MergeThrottler(const config::ConfigUri & configUri, StorageComponentRegister&); + MergeThrottler(const config::ConfigUri & configUri, + StorageComponentRegister&); + ~MergeThrottler(); /** Implements document::Runnable::run */ @@ -199,8 +267,12 @@ public: vespalib::Lock& getStateLock() { return _stateLock; } Metrics& getMetrics() { return *_metrics; } + std::size_t getMaxQueueSize() const { return _maxQueueSize; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + // HtmlStatusReporter implementation void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; private: friend class ThreadRendezvousGuard; // impl in .cpp file @@ -213,7 +285,9 @@ private: std::size_t _sortedIndex; // Index of current storage node in the sorted node sequence const uint16_t _thisIndex; // Index of the current storage node - MergeNodeSequence(const api::MergeBucketCommand& cmd, uint16_t thisIndex); + MergeNodeSequence( + const api::MergeBucketCommand& cmd, + uint16_t thisIndex); std::size_t getSortedIndex() const { return _sortedIndex; } const std::vector<api::MergeBucketCommand::Node>& getSortedNodes() const { @@ -258,8 +332,13 @@ private: // NOTE: unless explicitly specified, all the below functions require // _sync lock to be held upon call (usually implicitly via MessageGuard) - void handleMessageDown(const std::shared_ptr<api::StorageMessage>& msg, MessageGuard& msgGuard); - void handleMessageUp(const std::shared_ptr<api::StorageMessage>& msg, MessageGuard& msgGuard); + void handleMessageDown( + const std::shared_ptr<api::StorageMessage>& msg, + MessageGuard& msgGuard); + + void handleMessageUp( + const std::shared_ptr<api::StorageMessage>& msg, + MessageGuard& msgGuard); /** * Handle the receival of MergeBucketReply, be it from another node @@ -293,13 +372,17 @@ private: * * Precondition: no existing merge state exists for msg's bucketid. */ - void processNewMergeCommand(const api::StorageMessage::SP& msg, MessageGuard& msgGuard); + void processNewMergeCommand( + const api::StorageMessage::SP& msg, + MessageGuard& msgGuard); /** * Precondition: an existing merge state exists for msg's bucketid. * @return true if message was handled, false otherwise (see onUp/onDown). */ - bool processCycledMergeCommand(const api::StorageMessage::SP& msg, MessageGuard& msgGuard); + bool processCycledMergeCommand( + const api::StorageMessage::SP& msg, + MessageGuard& msgGuard); /** * Forwards the given MergeBucketCommand to the storage node given @@ -320,7 +403,10 @@ private: * @return Highest priority waiting merge or null SP if queue is empty */ api::StorageMessage::SP getNextQueuedMerge(); - void enqueueMerge(const api::StorageMessage::SP& msg, MessageGuard& msgGuard); + + void enqueueMerge( + const api::StorageMessage::SP& msg, + MessageGuard& msgGuard); /** * @return true if throttle policy says at least one additional @@ -348,15 +434,25 @@ private: * Immediately reject all queued merges whose cluster state version is * less than that of rejectLessThanVersion */ - void rejectOutdatedQueuedMerges(MessageGuard& msgGuard, uint32_t rejectLessThanVersion); + void rejectOutdatedQueuedMerges(MessageGuard& msgGuard, + uint32_t rejectLessThanVersion); + bool attemptProcessNextQueuedMerge(MessageGuard& msgGuard); + bool processQueuedMerges(MessageGuard& msgGuard); + void handleRendezvous(vespalib::MonitorGuard& guard); + void rendezvousWithWorkerThread(vespalib::MonitorGuard&); + void releaseWorkerThreadRendezvous(vespalib::MonitorGuard&); + bool isDiffCommand(const api::StorageMessage& msg) const; + bool isMergeCommand(const api::StorageMessage& msg) const; + bool isMergeReply(const api::StorageMessage& msg) const; + bool bucketIsUnknownOrAborted(const document::BucketId& bucket) const; std::shared_ptr<api::StorageMessage> makeAbortReply( @@ -364,7 +460,8 @@ private: vespalib::stringref reason) const; void handleOutdatedMerges(const api::SetSystemStateCommand&); - void rejectOperationsInThreadQueue(MessageGuard&, uint32_t minimumStateVersion); + void rejectOperationsInThreadQueue(MessageGuard&, + uint32_t minimumStateVersion); void markActiveMergesAsAborted(uint32_t minimumStateVersion); // const function, but metrics are mutable @@ -374,3 +471,4 @@ private: }; } // namespace storage + diff --git a/storage/src/vespa/storage/storageserver/opslogger.h b/storage/src/vespa/storage/storageserver/opslogger.h index 905c0fd4e85..57f304a04aa 100644 --- a/storage/src/vespa/storage/storageserver/opslogger.h +++ b/storage/src/vespa/storage/storageserver/opslogger.h @@ -27,15 +27,20 @@ public: ~OpsLogger(); void onClose() override; - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + bool onPutReply(const std::shared_ptr<api::PutReply>& msg) override; bool onUpdateReply(const std::shared_ptr<api::UpdateReply>& msg) override; bool onRemoveReply(const std::shared_ptr<api::RemoveReply>& msg) override; bool onGetReply(const std::shared_ptr<api::GetReply>& msg) override; /** Ignore all replies on the way down the storage chain. */ - bool onDown(const std::shared_ptr<api::StorageMessage>&) override { return false; }; + bool onDown(const std::shared_ptr<api::StorageMessage>&) override + { return false; }; + void configure(std::unique_ptr<vespa::config::content::core::StorOpsloggerConfig> config) override; + private: vespalib::Lock _lock; std::string _fileName; @@ -46,3 +51,4 @@ private: }; } + diff --git a/storage/src/vespa/storage/storageserver/statemanager.h b/storage/src/vespa/storage/storageserver/statemanager.h index 974b8ca2393..028168937b5 100644 --- a/storage/src/vespa/storage/storageserver/statemanager.h +++ b/storage/src/vespa/storage/storageserver/statemanager.h @@ -72,19 +72,23 @@ public: void tick(); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; - void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; - lib::NodeState::CSP getReportedNodeState() const override; - lib::NodeState::CSP getCurrentNodeState() const override; - lib::ClusterState::CSP getSystemState() const override; + /** Implementation of HtmlStatusReporter */ + virtual void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; - void addStateListener(StateListener&) override; - void removeStateListener(StateListener&) override; + virtual lib::NodeState::CSP getReportedNodeState() const override; + virtual lib::NodeState::CSP getCurrentNodeState() const override; + virtual lib::ClusterState::CSP getSystemState() const override; + + virtual void addStateListener(StateListener&) override; + virtual void removeStateListener(StateListener&) override; + + virtual Lock::SP grabStateChangeLock() override; + virtual void setReportedNodeState(const lib::NodeState& state) override; - Lock::SP grabStateChangeLock() override; - void setReportedNodeState(const lib::NodeState& state) override; void setClusterState(const lib::ClusterState& c); + HostInfo& getHostInfo() { return *_hostInfo; } private: @@ -132,7 +136,10 @@ private: */ std::string getNodeInfo() const; - void run(framework::ThreadHandle&) override; + virtual void run(framework::ThreadHandle&) override; + }; } // storage + + diff --git a/storage/src/vespa/storage/storageserver/statereporter.h b/storage/src/vespa/storage/storageserver/statereporter.h index c46a878ef40..51a9e93a197 100644 --- a/storage/src/vespa/storage/storageserver/statereporter.h +++ b/storage/src/vespa/storage/storageserver/statereporter.h @@ -10,11 +10,11 @@ #pragma once -#include "applicationgenerationfetcher.h" -#include <vespa/storage/common/storagecomponent.h> -#include <vespa/storageframework/storageframework.h> #include <vespa/metrics/metrics.h> #include <vespa/metrics/state_api_adapter.h> +#include <vespa/storage/common/storagecomponent.h> +#include <vespa/storage/storageserver/applicationgenerationfetcher.h> +#include <vespa/storageframework/storageframework.h> #include <vespa/vespalib/net/metrics_producer.h> #include <vespa/vespalib/net/state_api.h> @@ -37,8 +37,11 @@ public: const std::string& name = "status"); ~StateReporter(); - vespalib::string getReportContentType(const framework::HttpUrlPath&) const override; - bool reportStatus(std::ostream& out, const framework::HttpUrlPath& path) const override; + vespalib::string getReportContentType( + const framework::HttpUrlPath&) const override; + bool reportStatus(std::ostream& out, + const framework::HttpUrlPath& path) const override; + private: metrics::MetricManager &_manager; metrics::StateApiAdapter _metricsAdapter; @@ -47,10 +50,16 @@ private: ApplicationGenerationFetcher& _generationFetcher; std::string _name; - vespalib::string getMetrics(const vespalib::string &consumer) override; - vespalib::string getTotalMetrics(const vespalib::string &consumer) override; - Health getHealth() const override; - void getComponentConfig(Consumer &consumer) override; + // Implements vespalib::MetricsProducer + virtual vespalib::string getMetrics(const vespalib::string &consumer) override; + virtual vespalib::string getTotalMetrics(const vespalib::string &consumer) override; + + // Implements vespalib::HealthProducer + virtual Health getHealth() const override; + + // Implements vespalib::ComponentConfigProducer + virtual void getComponentConfig(Consumer &consumer) override; }; } // storage + diff --git a/storage/src/vespa/storage/storageserver/storagemetricsset.cpp b/storage/src/vespa/storage/storageserver/storagemetricsset.cpp deleted file mode 100644 index aa57e3ebcd5..00000000000 --- a/storage/src/vespa/storage/storageserver/storagemetricsset.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "storagemetricsset.h" -#include <vespa/document/fieldvalue/serializablearray.h> - -namespace storage { - -MessageMemoryUseMetricSet::MessageMemoryUseMetricSet(metrics::MetricSet* owner) - : metrics::MetricSet("message_memory_use", "memory", "Message use from storage messages", owner), - total("total", "memory", "Message use from storage messages", this), - lowpri("lowpri", "memory", "Message use from low priority storage messages", this), - normalpri("normalpri", "memory", "Message use from normal priority storage messages", this), - highpri("highpri", "memory", "Message use from high priority storage messages", this), - veryhighpri("veryhighpri", "memory", "Message use from very high priority storage messages", this) -{ } -MessageMemoryUseMetricSet::~MessageMemoryUseMetricSet() {} - -DocumentSerializationMetricSet::DocumentSerializationMetricSet(metrics::MetricSet* owner) - : metrics::MetricSet("document_serialization", "docserialization", - "Counts of document serialization of various types", owner), - usedCachedSerializationCount( - "cached_serialization_count", "docserialization", - "Number of times we didn't need to serialize the document as " - "we already had serialized version cached", this), - compressedDocumentCount( - "compressed_serialization_count", "docserialization", - "Number of times we compressed document when serializing", - this), - compressionDidntHelpCount( - "compressed_didnthelp_count", "docserialization", - "Number of times we compressed document when serializing, but " - "the compressed version was bigger, so it was dumped", this), - uncompressableCount( - "uncompressable_serialization_count", "docserialization", - "Number of times we didn't attempt compression as document " - "had already been tagged uncompressable", this), - serializedUncompressed( - "uncompressed_serialization_count", "docserialization", - "Number of times we serialized a document uncompressed", this), - inputWronglySerialized( - "input_wrongly_serialized_count", "docserialization", - "Number of times we reserialized a document because the " - "compression it had in cache did not match what was configured", - this) -{ } -DocumentSerializationMetricSet::~DocumentSerializationMetricSet() { } - -StorageMetricSet::StorageMetricSet() - : metrics::MetricSet("server", "memory", - "Metrics for VDS applications"), - memoryUse("memoryusage", "memory", "", this), - memoryUse_messages(this), - memoryUse_visiting("memoryusage_visiting", "memory", - "Message use from visiting", this), - documentSerialization(this) -{ } -StorageMetricSet::~StorageMetricSet() { } - -void StorageMetricSet::updateMetrics() { - document::SerializableArray::Statistics stats( - document::SerializableArray::getStatistics()); - - documentSerialization.usedCachedSerializationCount.set( - stats._usedCachedSerializationCount); - documentSerialization.compressedDocumentCount.set( - stats._compressedDocumentCount); - documentSerialization.compressionDidntHelpCount.set( - stats._compressionDidntHelpCount); - documentSerialization.uncompressableCount.set( - stats._uncompressableCount); - documentSerialization.serializedUncompressed.set( - stats._serializedUncompressed); - documentSerialization.inputWronglySerialized.set( - stats._inputWronglySerialized); -} - -} // storage diff --git a/storage/src/vespa/storage/storageserver/storagemetricsset.h b/storage/src/vespa/storage/storageserver/storagemetricsset.h index f7083705763..18be3e21ada 100644 --- a/storage/src/vespa/storage/storageserver/storagemetricsset.h +++ b/storage/src/vespa/storage/storageserver/storagemetricsset.h @@ -3,6 +3,7 @@ #pragma once #include <vespa/metrics/metrics.h> +#include <vespa/document/fieldvalue/serializablearray.h> namespace storage { @@ -15,8 +16,22 @@ public: metrics::LongValueMetric highpri; metrics::LongValueMetric veryhighpri; - MessageMemoryUseMetricSet(metrics::MetricSet* owner); - ~MessageMemoryUseMetricSet(); + MessageMemoryUseMetricSet(metrics::MetricSet* owner) + : metrics::MetricSet("message_memory_use", "memory", + "Message use from storage messages", owner), + total("total", "memory", + "Message use from storage messages", this), + lowpri("lowpri", "memory", + "Message use from low priority storage messages", this), + normalpri("normalpri", "memory", + "Message use from normal priority storage messages", this), + highpri("highpri", "memory", + "Message use from high priority storage messages", this), + veryhighpri("veryhighpri", "memory", + "Message use from very high priority storage messages", this) + { + } + }; struct DocumentSerializationMetricSet : public metrics::MetricSet @@ -28,8 +43,36 @@ struct DocumentSerializationMetricSet : public metrics::MetricSet metrics::LongCountMetric serializedUncompressed; metrics::LongCountMetric inputWronglySerialized; - DocumentSerializationMetricSet(metrics::MetricSet* owner); - ~DocumentSerializationMetricSet(); + DocumentSerializationMetricSet(metrics::MetricSet* owner) + : metrics::MetricSet("document_serialization", "docserialization", + "Counts of document serialization of various types", owner), + usedCachedSerializationCount( + "cached_serialization_count", "docserialization", + "Number of times we didn't need to serialize the document as " + "we already had serialized version cached", this), + compressedDocumentCount( + "compressed_serialization_count", "docserialization", + "Number of times we compressed document when serializing", + this), + compressionDidntHelpCount( + "compressed_didnthelp_count", "docserialization", + "Number of times we compressed document when serializing, but " + "the compressed version was bigger, so it was dumped", this), + uncompressableCount( + "uncompressable_serialization_count", "docserialization", + "Number of times we didn't attempt compression as document " + "had already been tagged uncompressable", this), + serializedUncompressed( + "uncompressed_serialization_count", "docserialization", + "Number of times we serialized a document uncompressed", this), + inputWronglySerialized( + "input_wrongly_serialized_count", "docserialization", + "Number of times we reserialized a document because the " + "compression it had in cache did not match what was configured", + this) + { + } + }; struct StorageMetricSet : public metrics::MetricSet @@ -39,9 +82,34 @@ struct StorageMetricSet : public metrics::MetricSet metrics::LongValueMetric memoryUse_visiting; DocumentSerializationMetricSet documentSerialization; - StorageMetricSet(); - ~StorageMetricSet(); - void updateMetrics(); + StorageMetricSet() + : metrics::MetricSet("server", "memory", + "Metrics for VDS applications"), + memoryUse("memoryusage", "memory", "", this), + memoryUse_messages(this), + memoryUse_visiting("memoryusage_visiting", "memory", + "Message use from visiting", this), + documentSerialization(this) + { + } + + void updateMetrics() { + document::SerializableArray::Statistics stats( + document::SerializableArray::getStatistics()); + + documentSerialization.usedCachedSerializationCount.set( + stats._usedCachedSerializationCount); + documentSerialization.compressedDocumentCount.set( + stats._compressedDocumentCount); + documentSerialization.compressionDidntHelpCount.set( + stats._compressionDidntHelpCount); + documentSerialization.uncompressableCount.set( + stats._uncompressableCount); + documentSerialization.serializedUncompressed.set( + stats._serializedUncompressed); + documentSerialization.inputWronglySerialized.set( + stats._inputWronglySerialized); + } }; } // storage diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h index 5eea62a17ad..5df29191489 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.h +++ b/storage/src/vespa/storage/storageserver/storagenode.h @@ -12,10 +12,9 @@ #pragma once -#include "storagemetricsset.h" -#include "storagenodecontext.h" -#include "applicationgenerationfetcher.h" #include <vespa/document/bucket/bucketidfactory.h> +#include <memory> +#include <string> #include <vespa/storage/config/config-stor-server.h> #include <vespa/config/helper/legacysubscriber.h> @@ -35,6 +34,9 @@ #include <vespa/storageframework/defaultimplementation/memory/memorymanager.h> #include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h> #include <vespa/storage/frameworkimpl/memory/memorystatusviewer.h> +#include <vespa/storage/storageserver/applicationgenerationfetcher.h> +#include <vespa/storage/storageserver/storagenodecontext.h> +#include <vespa/storage/storageserver/storagemetricsset.h> #include <vespa/storage/visiting/visitormessagesessionfactory.h> #include <vespa/storageframework/storageframework.h> #include <vespa/storage/storageutil/resumeguard.h> @@ -76,9 +78,12 @@ public: virtual ~StorageNode(); virtual const lib::NodeType& getNodeType() const = 0; + bool attemptedStopped() const; - void notifyDoneInitializing() override; + + virtual void notifyDoneInitializing() override; void waitUntilInitialized(uint32_t timeoutSeconds = 15); + void updateMetrics(const MetricLockGuard & guard) override; /** Updates the document type repo. */ @@ -89,12 +94,17 @@ public: * is alive, no calls will be made towards the persistence provider. */ virtual ResumeGuard pause() = 0; + void requestShutdown(vespalib::stringref reason) override; - void notifyPartitionDown(int partId, vespalib::stringref reason); + + void + notifyPartitionDown(int partId, vespalib::stringref reason); + DoneInitializeHandler& getDoneInitializeHandler() { return *this; } - // For testing + // For testing StorageLink* getChain() { return _chain.get(); } + virtual void initializeStatusWebServer(); private: @@ -130,10 +140,10 @@ private: std::unique_ptr<StorageLink> _chain; /** Implementation of config callbacks. */ - void configure(std::unique_ptr<vespa::config::content::core::StorServerConfig> config) override; - void configure(std::unique_ptr<vespa::config::content::UpgradingConfig> config) override; - void configure(std::unique_ptr<vespa::config::content::StorDistributionConfig> config) override; - void configure(std::unique_ptr<vespa::config::content::core::StorPrioritymappingConfig>) override; + virtual void configure(std::unique_ptr<vespa::config::content::core::StorServerConfig> config) override; + virtual void configure(std::unique_ptr<vespa::config::content::UpgradingConfig> config) override; + virtual void configure(std::unique_ptr<vespa::config::content::StorDistributionConfig> config) override; + virtual void configure(std::unique_ptr<vespa::config::content::core::StorPrioritymappingConfig>) override; virtual void configure(std::unique_ptr<document::DocumenttypesConfig> config, bool hasChanged, int64_t generation); void updateUpgradeFlag(const vespa::config::content::UpgradingConfig&); @@ -174,6 +184,8 @@ protected: virtual void handleLiveConfigUpdate(); void shutdown(); virtual void removeConfigSubscriptions(); + }; } // storage + diff --git a/storage/src/vespa/storage/storageutil/palette.h b/storage/src/vespa/storage/storageutil/palette.h index 338d8a3add7..fe42eae0d31 100644 --- a/storage/src/vespa/storage/storageutil/palette.h +++ b/storage/src/vespa/storage/storageutil/palette.h @@ -11,8 +11,6 @@ #pragma once #include <vector> -#include <cstdint> -#include <iosfwd> namespace storage { diff --git a/storage/src/vespa/storage/tools/throttlingsim.h b/storage/src/vespa/storage/tools/throttlingsim.h index a7384d0f362..b583a7d2533 100644 --- a/storage/src/vespa/storage/tools/throttlingsim.h +++ b/storage/src/vespa/storage/tools/throttlingsim.h @@ -75,7 +75,7 @@ public: double max_diff; virtual void returnMessage(const Message& m) = 0; - void run() override; + virtual void run() override; virtual void print(double timenow); Client(Messaging& msgng, double windowSize, int to); @@ -91,15 +91,17 @@ class FixedClient : public Client { public: FixedClient(Messaging& msgng, int winsize, int to) : Client(msgng, winsize, to) {}; - void returnMessage(const Message& m) override; + + virtual void returnMessage(const Message& m) override; }; class LoadBalancingClient : public Client { public: LoadBalancingClient(Messaging& msgng, int winsize, int to); - void returnMessage(const Message& m) override; - void run() override; - void print(double timenow) override; + + virtual void returnMessage(const Message& m) override; + virtual void run() override; + virtual void print(double timenow) override; std::vector<double> weights; }; @@ -107,9 +109,10 @@ public: class BusyCounterBalancingClient : public Client { public: BusyCounterBalancingClient(Messaging& msgng, int winsize, int to); - void returnMessage(const Message& m) override; - void run() override; - void print(double timenow) override; + + virtual void returnMessage(const Message& m) override; + virtual void run() override; + virtual void print(double timenow) override; std::vector<int> busyCount; }; @@ -123,7 +126,8 @@ public: DynamicClient(Messaging& msgng, int maxWinSize, double to) : Client(msgng, 1, static_cast<int>(to)), maxwinsize(maxWinSize), threshold(maxWinSize / 2), lastFailTimestamp(0) {}; - void returnMessage(const Message& m) override; + + virtual void returnMessage(const Message& m) override; }; class LatencyControlClient : public Client { @@ -133,8 +137,10 @@ public: LatencyControlClient(Messaging& msgng, double to) : Client(msgng, 1, static_cast<int>(to)), count(0){}; - void returnMessage(const Message& m) override; - void print(double timenow) override; + + virtual void returnMessage(const Message& m) override; + + virtual void print(double timenow) override; }; @@ -148,4 +154,5 @@ public: ThrottlingApp() {}; int Main() override; + }; diff --git a/storage/src/vespa/storage/visiting/commandqueue.h b/storage/src/vespa/storage/visiting/commandqueue.h index ba0141add45..07677fdcd38 100644 --- a/storage/src/vespa/storage/visiting/commandqueue.h +++ b/storage/src/vespa/storage/visiting/commandqueue.h @@ -22,189 +22,229 @@ namespace storage { -template<class Command> -class CommandQueue : public vespalib::Printable -{ -public: - struct CommandEntry { - typedef typename Command::Priority PriorityType; - std::shared_ptr<Command> _command; - uint64_t _time; - uint64_t _sequenceId; - PriorityType _priority; - - CommandEntry(const std::shared_ptr<Command>& cmd, - uint64_t time, - uint64_t sequenceId, - PriorityType priority) - : _command(cmd), _time(time), _sequenceId(sequenceId), _priority(priority) - {} - - // Sort on both priority and sequence ID - bool operator<(const CommandEntry& entry) const { - if (_priority != entry._priority) { - return (_priority < entry._priority); + template<class Command> + class CommandQueue : public vespalib::Printable + { + public: + struct CommandEntry { + typedef typename Command::Priority PriorityType; + std::shared_ptr<Command> _command; + uint64_t _time; + uint64_t _sequenceId; + PriorityType _priority; + + CommandEntry(const std::shared_ptr<Command>& cmd, + uint64_t time, + uint64_t sequenceId, + PriorityType priority) + : _command(cmd), _time(time), _sequenceId(sequenceId), _priority(priority) + {} + + // Sort on both priority and sequence ID + bool operator<(const CommandEntry& entry) const { + if (_priority != entry._priority) { + return (_priority < entry._priority); + } + return (_sequenceId < entry._sequenceId); } - return (_sequenceId < entry._sequenceId); + }; + + private: + typedef boost::multi_index::multi_index_container< + CommandEntry, + boost::multi_index::indexed_by< + boost::multi_index::ordered_unique< + boost::multi_index::identity<CommandEntry> + >, + boost::multi_index::ordered_non_unique< + boost::multi_index::member<CommandEntry, uint64_t, &CommandEntry::_time> + > + > + > CommandList; + typedef typename boost::multi_index + ::nth_index<CommandList, 1>::type timelist; + + framework::Clock& _clock; + mutable CommandList _commands; + uint64_t _sequenceId; + + public: + typedef typename CommandList::iterator iterator; + typedef typename CommandList::reverse_iterator reverse_iterator; + typedef typename CommandList::const_iterator const_iterator; + typedef typename CommandList::const_reverse_iterator const_reverse_iterator; + typedef typename timelist::const_iterator const_titerator; + + CommandQueue(framework::Clock& clock) + : _clock(clock), + _sequenceId(0) {} + + const framework::Clock& getTimer() const { return _clock; } + + iterator begin() { return _commands.begin(); } + iterator end() { return _commands.end(); } + + const_iterator begin() const { return _commands.begin(); } + const_iterator end() const { return _commands.end(); } + + const_titerator tbegin() const { + timelist& tl = boost::multi_index::get<1>(_commands); + return tl.begin(); + } + const_titerator tend() const { + timelist& tl = boost::multi_index::get<1>(_commands); + return tl.end(); } - }; -private: - typedef boost::multi_index::multi_index_container< - CommandEntry, - boost::multi_index::indexed_by< - boost::multi_index::ordered_unique< - boost::multi_index::identity<CommandEntry> - >, - boost::multi_index::ordered_non_unique< - boost::multi_index::member<CommandEntry, uint64_t, &CommandEntry::_time> - > - > - > CommandList; - typedef typename boost::multi_index - ::nth_index<CommandList, 1>::type timelist; + bool empty() const; + + uint32_t size() const; + + std::pair<std::shared_ptr<Command>, time_t> releaseNextCommand(); - framework::Clock& _clock; - mutable CommandList _commands; - uint64_t _sequenceId; + std::shared_ptr<Command> peekNextCommand() const; -public: - typedef typename CommandList::iterator iterator; - typedef typename CommandList::reverse_iterator reverse_iterator; - typedef typename CommandList::const_iterator const_iterator; - typedef typename CommandList::const_reverse_iterator const_reverse_iterator; - typedef typename timelist::const_iterator const_titerator; + void add(const std::shared_ptr<Command>& msg); - CommandQueue(framework::Clock& clock) - : _clock(clock), - _sequenceId(0) {} + void erase(iterator it); - const framework::Clock& getTimer() const { return _clock; } + std::list<CommandEntry> releaseTimedOut(); - iterator begin() { return _commands.begin(); } - iterator end() { return _commands.end(); } + std::pair<std::shared_ptr<Command>, time_t> + releaseLowestPriorityCommand(); - const_iterator begin() const { return _commands.begin(); } - const_iterator end() const { return _commands.end(); } + std::shared_ptr<Command> peekLowestPriorityCommand() const; - const_titerator tbegin() const { - timelist& tl = boost::multi_index::get<1>(_commands); - return tl.begin(); + void clear(); + + void print(std::ostream& out, bool verbose, + const std::string& indent) const; + }; + + template<class Command> + inline bool + CommandQueue<Command>::empty() const + { + return _commands.empty(); } - const_titerator tend() const { - timelist& tl = boost::multi_index::get<1>(_commands); - return tl.end(); + + template<class Command> + inline uint32_t + CommandQueue<Command>::size() const + { + return _commands.size(); } - bool empty() const { return _commands.empty(); } - uint32_t size() const { return _commands.size(); } - std::pair<std::shared_ptr<Command>, time_t> releaseNextCommand(); - std::shared_ptr<Command> peekNextCommand() const; - void add(const std::shared_ptr<Command>& msg); - void erase(iterator it) { _commands.erase(it); } - std::list<CommandEntry> releaseTimedOut(); - std::pair<std::shared_ptr<Command>, time_t> releaseLowestPriorityCommand(); - - std::shared_ptr<Command> peekLowestPriorityCommand() const; - void clear() { return _commands.clear(); } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; -}; - - -template<class Command> -std::pair<std::shared_ptr<Command>, time_t> -CommandQueue<Command>::releaseNextCommand() -{ - std::pair<std::shared_ptr<Command>, time_t> retVal( - std::shared_ptr<Command>(), 0); - if (!_commands.empty()) { - iterator first = _commands.begin(); - retVal.first = first->_command; - retVal.second = first->_time; - _commands.erase(first); + template<class Command> + inline std::pair<std::shared_ptr<Command>, time_t> + CommandQueue<Command>::releaseNextCommand() + { + std::pair<std::shared_ptr<Command>, time_t> retVal( + std::shared_ptr<Command>(), 0); + if (!_commands.empty()) { + iterator first = _commands.begin(); + retVal.first = first->_command; + retVal.second = first->_time; + _commands.erase(first); + } + return retVal; } - return retVal; -} - -template<class Command> -std::shared_ptr<Command> -CommandQueue<Command>::peekNextCommand() const -{ - if (!_commands.empty()) { - const_iterator first = _commands.begin(); - return first->_command; - } else { - return std::shared_ptr<Command>(); + + template<class Command> + inline std::shared_ptr<Command> + CommandQueue<Command>::peekNextCommand() const + { + if (!_commands.empty()) { + const_iterator first = _commands.begin(); + return first->_command; + } else { + return std::shared_ptr<Command>(); + } + } + + template<class Command> + inline void + CommandQueue<Command>::add( + const std::shared_ptr<Command>& cmd) + { + framework::MicroSecTime time(_clock.getTimeInMicros() + + framework::MicroSecTime(cmd->getQueueTimeout() * 1000000)); + _commands.insert(CommandEntry(cmd, time.getTime(), ++_sequenceId, cmd->getPriority())); } -} - -template<class Command> -void -CommandQueue<Command>::add( - const std::shared_ptr<Command>& cmd) -{ - framework::MicroSecTime time(_clock.getTimeInMicros() - + framework::MicroSecTime(cmd->getQueueTimeout() * 1000000)); - _commands.insert(CommandEntry(cmd, time.getTime(), ++_sequenceId, cmd->getPriority())); -} - -template<class Command> -std::list<typename CommandQueue<Command>::CommandEntry> -CommandQueue<Command>::releaseTimedOut() -{ - std::list<CommandEntry> mylist; - framework::MicroSecTime time(_clock.getTimeInMicros()); - while (!empty() && tbegin()->_time <= time.getTime()) { - mylist.push_back(*tbegin()); - timelist& tl = boost::multi_index::get<1>(_commands); - tl.erase(tbegin()); + + template<class Command> + inline void + CommandQueue<Command>::erase(iterator it) + { + _commands.erase(it); + } + + template<class Command> + inline std::list<typename CommandQueue<Command>::CommandEntry> + CommandQueue<Command>::releaseTimedOut() + { + std::list<CommandEntry> mylist; + framework::MicroSecTime time(_clock.getTimeInMicros()); + while (!empty() && tbegin()->_time <= time.getTime()) { + mylist.push_back(*tbegin()); + timelist& tl = boost::multi_index::get<1>(_commands); + tl.erase(tbegin()); + } + return mylist; } - return mylist; -} - -template <class Command> -std::pair<std::shared_ptr<Command>, time_t> -CommandQueue<Command>::releaseLowestPriorityCommand() -{ - if (!_commands.empty()) { - iterator last = (++_commands.rbegin()).base(); - time_t time = last->_time; - std::shared_ptr<Command> cmd(last->_command); - _commands.erase(last); - return std::pair<std::shared_ptr<Command>, time_t>(cmd, time); - } else { - return std::pair<std::shared_ptr<Command>, time_t>( - std::shared_ptr<Command>(), 0); + + template <class Command> + inline std::pair<std::shared_ptr<Command>, time_t> + CommandQueue<Command>::releaseLowestPriorityCommand() + { + if (!_commands.empty()) { + iterator last = (++_commands.rbegin()).base(); + time_t time = last->_time; + std::shared_ptr<Command> cmd(last->_command); + _commands.erase(last); + return std::pair<std::shared_ptr<Command>, time_t>(cmd, time); + } else { + return std::pair<std::shared_ptr<Command>, time_t>( + std::shared_ptr<Command>(), 0); + } } -} - -template <class Command> -std::shared_ptr<Command> -CommandQueue<Command>::peekLowestPriorityCommand() const -{ - if (!_commands.empty()) { - const_reverse_iterator last = _commands.rbegin(); - return last->_command; - } else { - return std::shared_ptr<Command>(); + + template <class Command> + inline std::shared_ptr<Command> + CommandQueue<Command>::peekLowestPriorityCommand() const + { + if (!_commands.empty()) { + const_reverse_iterator last = _commands.rbegin(); + return last->_command; + } else { + return std::shared_ptr<Command>(); + } } -} - -template<class Command> -void -CommandQueue<Command>::print(std::ostream& out, bool verbose, const std::string& indent) const -{ - (void) verbose; - out << "Insert order:\n"; - for (const_iterator it = begin(); it != end(); ++it) { - out << indent << *it->_command << ", priority " << it->_priority - << ", time " << it->_time << "\n"; + + template<class Command> + inline void + CommandQueue<Command>::clear() + { + _commands.clear(); } - out << indent << "Time order:"; - for (const_titerator it = tbegin(); it != tend(); ++it) { - out << "\n" << indent << *it->_command << ", priority " << it->_priority - << ", time " << it->_time; + + template<class Command> + inline void + CommandQueue<Command>::print(std::ostream& out, bool verbose, + const std::string& indent) const + { + (void) verbose; + out << "Insert order:\n"; + for (const_iterator it = begin(); it != end(); ++it) { + out << indent << *it->_command << ", priority " << it->_priority + << ", time " << it->_time << "\n"; + } + out << indent << "Time order:"; + for (const_titerator it = tbegin(); it != tend(); ++it) { + out << "\n" << indent << *it->_command << ", priority " << it->_priority + << ", time " << it->_time; + } } -} } // storage + diff --git a/storage/src/vespa/storage/visiting/countvisitor.h b/storage/src/vespa/storage/visiting/countvisitor.h index 814cba9501b..ecf51035a03 100644 --- a/storage/src/vespa/storage/visiting/countvisitor.h +++ b/storage/src/vespa/storage/visiting/countvisitor.h @@ -9,7 +9,7 @@ */ #pragma once -#include "visitor.h" +#include <vespa/storage/visiting/visitor.h> namespace storage { diff --git a/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp b/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp index acafa30ef9d..a36ace1d427 100644 --- a/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp +++ b/storage/src/vespa/storage/visiting/dumpvisitorsingle.cpp @@ -3,10 +3,12 @@ #include "dumpvisitorsingle.h" #include <vespa/documentapi/messagebus/messages/multioperationmessage.h> #include <vespa/document/update/documentupdate.h> +#include <vespa/log/log.h> +#include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/documentapi/messagebus/messages/putdocumentmessage.h> #include <vespa/documentapi/messagebus/messages/removedocumentmessage.h> +#include <memory> -#include <vespa/log/log.h> LOG_SETUP(".visitor.instance.dumpvisitorsingle"); namespace storage { diff --git a/storage/src/vespa/storage/visiting/dumpvisitorsingle.h b/storage/src/vespa/storage/visiting/dumpvisitorsingle.h index b0fd4b2b9f0..d7f7b63d851 100644 --- a/storage/src/vespa/storage/visiting/dumpvisitorsingle.h +++ b/storage/src/vespa/storage/visiting/dumpvisitorsingle.h @@ -9,7 +9,7 @@ */ #pragma once -#include "visitor.h" +#include <vespa/storage/visiting/visitor.h> namespace storage { @@ -19,7 +19,8 @@ public: const vdslib::Parameters& params); private: - void handleDocuments(const document::BucketId&, std::vector<spi::DocEntry::UP>&, HitCounter&) override; + void handleDocuments(const document::BucketId&, + std::vector<spi::DocEntry::UP>&, HitCounter&) override; }; struct DumpVisitorSingleFactory : public VisitorFactory { @@ -30,10 +31,14 @@ struct DumpVisitorSingleFactory : public VisitorFactory { }; Visitor* - - makeVisitor(StorageComponent& c, VisitorEnvironment&, const vdslib::Parameters& params) override { + makeVisitor(StorageComponent& c, + VisitorEnvironment&, const vdslib::Parameters& params) override + { return new DumpVisitorSingle(c, params); } }; } + + + diff --git a/storage/src/vespa/storage/visiting/messages.h b/storage/src/vespa/storage/visiting/messages.h index b79fae0575f..d646355895f 100644 --- a/storage/src/vespa/storage/visiting/messages.h +++ b/storage/src/vespa/storage/visiting/messages.h @@ -29,9 +29,11 @@ public: _config(config) {} std::unique_ptr<api::StorageReply> makeReply() override; + const vespa::config::content::core::StorVisitorConfig& getConfig() const { return _config; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override { + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override + { out << "PropagateVisitorConfig()"; if (verbose) { @@ -51,8 +53,12 @@ public: PropagateVisitorConfigReply(const PropagateVisitorConfig& cmd) : api::InternalReply(ID, cmd) - {} - void print(std::ostream& out, bool verbose, const std::string& indent) const override { + { + } + + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override + { out << "PropagateVisitorConfigReply()"; if (verbose) { @@ -70,3 +76,4 @@ PropagateVisitorConfig::makeReply() } } // storage + diff --git a/storage/src/vespa/storage/visiting/recoveryvisitor.h b/storage/src/vespa/storage/visiting/recoveryvisitor.h index b9f54a5d0ea..dac6996028b 100644 --- a/storage/src/vespa/storage/visiting/recoveryvisitor.h +++ b/storage/src/vespa/storage/visiting/recoveryvisitor.h @@ -9,7 +9,7 @@ */ #pragma once -#include "visitor.h" +#include <vespa/storage/visiting/visitor.h> #include <vespa/storageapi/message/datagram.h> namespace documentapi { diff --git a/storage/src/vespa/storage/visiting/testvisitor.h b/storage/src/vespa/storage/visiting/testvisitor.h index db4e1d60939..c2740b11d56 100644 --- a/storage/src/vespa/storage/visiting/testvisitor.h +++ b/storage/src/vespa/storage/visiting/testvisitor.h @@ -8,7 +8,7 @@ */ #pragma once -#include "visitor.h" +#include <vespa/storage/visiting/visitor.h> namespace storage { @@ -30,9 +30,10 @@ private: } void completedVisiting(HitCounter& hitCounter) override; + void abortedVisiting() override; - // Send datagram with message back to client + // Send datagram with message back to client void report(const std::string& message); std::string _params; @@ -54,3 +55,6 @@ struct TestVisitorFactory : public VisitorFactory { }; } + + + diff --git a/storage/src/vespa/storage/visiting/visitor.h b/storage/src/vespa/storage/visiting/visitor.h index 918d2d0e339..3d5e9fc2c53 100644 --- a/storage/src/vespa/storage/visiting/visitor.h +++ b/storage/src/vespa/storage/visiting/visitor.h @@ -174,7 +174,8 @@ private: bool hasPendingIterators() const { return _pendingIterators > 0; } - void print(std::ostream& out, bool, const std::string& ) const override { + void print(std::ostream& out, bool, const std::string& /*indent*/) const override + { out << "BucketIterationState(" << _bucketId << ", pending GetIters: " << _pendingIterators diff --git a/storage/src/vespa/storage/visiting/visitormanager.h b/storage/src/vespa/storage/visiting/visitormanager.h index b966526ad7a..9b750e3af4f 100644 --- a/storage/src/vespa/storage/visiting/visitormanager.h +++ b/storage/src/vespa/storage/visiting/visitormanager.h @@ -19,18 +19,19 @@ #pragma once -#include "commandqueue.h" -#include "visitor.h" -#include "visitormetrics.h" -#include "visitorthread.h" -#include "config-stor-visitor.h" -#include <vespa/storageframework/storageframework.h> -#include <vespa/storage/common/storagelink.h> +#include <vespa/vespalib/util/document_runnable.h> #include <vespa/storageapi/message/datagram.h> #include <vespa/storageapi/message/internal.h> #include <vespa/storageapi/message/visitor.h> +#include <vespa/storage/common/storagelink.h> +#include <vespa/storage/visiting/commandqueue.h> +#include <vespa/storage/visiting/config-stor-visitor.h> +#include <vespa/storage/visiting/visitor.h> +#include <vespa/storage/visiting/visitormetrics.h> +#include <vespa/storage/visiting/visitorthread.h> +#include <vespa/storageframework/storageframework.h> +#include <vespa/storageframework/storageframework.h> #include <vespa/config/config.h> -#include <vespa/vespalib/util/document_runnable.h> namespace storage { namespace api { @@ -89,11 +90,14 @@ public: VisitorManager(const config::ConfigUri & configUri, StorageComponentRegister&, VisitorMessageSessionFactory&, const VisitorFactory::Map& external = VisitorFactory::Map()); - ~VisitorManager(); + virtual ~VisitorManager(); + + virtual void onClose() override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; - void onClose() override; - void print(std::ostream& out, bool verbose, const std::string& indent) const override; uint32_t getActiveVisitorCount() const; + void setTimeBetweenTicks(uint32_t time); void setMaxConcurrentVisitors(uint32_t count) { // Used in unit testing @@ -122,7 +126,7 @@ public: private: void configure(std::unique_ptr<vespa::config::content::core::StorVisitorConfig>) override; - void run(framework::ThreadHandle&) override; + virtual void run(framework::ThreadHandle&) override; /** * Schedules a visitor for running. onCreateVisitor will typically call @@ -153,12 +157,13 @@ private: */ bool attemptScheduleQueuedVisitor(vespalib::MonitorGuard& visitorLock); - // VisitorMessageHandler implementation + // VisitorMessageHandler implementation void send(const std::shared_ptr<api::StorageCommand>& cmd, Visitor& visitor) override; void send(const std::shared_ptr<api::StorageReply>& reply) override; void closed(api::VisitorId id) override; - void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; + // Status::Reporter implementation + virtual void reportHtmlStatus(std::ostream&, const framework::HttpUrlPath&) const override; /** * The maximum amount of concurrent visitors for a priority is given @@ -174,3 +179,4 @@ private: }; } + diff --git a/storage/src/vespa/storage/visiting/visitorthread.h b/storage/src/vespa/storage/visiting/visitorthread.h index 5f9d8897d9f..2f0a125d6ce 100644 --- a/storage/src/vespa/storage/visiting/visitorthread.h +++ b/storage/src/vespa/storage/visiting/visitorthread.h @@ -13,17 +13,17 @@ #pragma once -#include "visitor.h" -#include "visitormetrics.h" -#include "visitormessagesessionfactory.h" -#include <vespa/storageframework/storageframework.h> -#include <vespa/storage/persistence/messages.h> -#include <vespa/storage/common/storagecomponent.h> -#include <vespa/storageapi/messageapi/messagehandler.h> -#include <vespa/metrics/metrictimer.h> +#include <deque> #include <vespa/vespalib/util/document_runnable.h> +#include <vespa/metrics/metrictimer.h> +#include <vespa/storageapi/messageapi/messagehandler.h> #include <vespa/vespalib/util/sync.h> -#include <deque> +#include <vespa/storage/common/storagecomponent.h> +#include <vespa/storage/persistence/messages.h> +#include <vespa/storage/visiting/visitor.h> +#include <vespa/storage/visiting/visitormetrics.h> +#include <vespa/storage/visiting/visitormessagesessionfactory.h> +#include <vespa/storageframework/storageframework.h> namespace storage { @@ -36,7 +36,8 @@ class VisitorThread : public framework::Runnable, typedef std::map<api::VisitorId, std::shared_ptr<Visitor> > VisitorMap; VisitorMap _visitors; - std::deque<std::pair<api::VisitorId, framework::SecondTime> > _recentlyCompleted; + std::deque<std::pair<api::VisitorId, + framework::SecondTime> > _recentlyCompleted; struct Event { enum Type { @@ -99,9 +100,13 @@ public: VisitorMessageHandler& sender); ~VisitorThread(); - void processMessage(api::VisitorId visitorId, const std::shared_ptr<api::StorageMessage>& msg); + void processMessage(api::VisitorId visitorId, + const std::shared_ptr<api::StorageMessage>& msg); + void shutdown(); + void setTimeBetweenTicks(uint32_t time) { _timeBetweenTicks = time; } + void handleMessageBusReply(std::unique_ptr<mbus::Reply> reply, Visitor& visitor); /** For unit tests needing to pause thread. */ @@ -112,7 +117,7 @@ public: } private: - void run(framework::ThreadHandle&) override; + virtual void run(framework::ThreadHandle&) override; /** * Attempt to fetch an event from the visitor thread's queue. If an event * was available, pop it from the queue and return it. If not, return @@ -122,11 +127,12 @@ private: Event popNextQueuedEventIfAvailable(); void tick(); void trimRecentlyCompletedList(framework::SecondTime currentTime); - void handleNonExistingVisitorCall(const Event& entry, api::ReturnCode& code); + void handleNonExistingVisitorCall(const Event& entry, + api::ReturnCode& code); std::shared_ptr<Visitor> createVisitor(const vespalib::stringref & libName, - const vdslib::Parameters& params, - vespalib::asciistream & error); + const vdslib::Parameters& params, + vespalib::asciistream & error); bool onCreateVisitor(const std::shared_ptr<api::CreateVisitorCommand>&) override; @@ -136,9 +142,12 @@ private: /** Deletes a visitor instance. */ void close(); - void getStatus(vespalib::asciistream & out, const framework::HttpUrlPath& path) const; + void getStatus(vespalib::asciistream & out, + const framework::HttpUrlPath& path) const; + void updateMetrics(const MetricLockGuard &) override; }; } // storage + diff --git a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp index ed59b49ff04..bc71429032e 100644 --- a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp +++ b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp @@ -1,5 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/document/base/testdocman.h> +#include <vespa/document/document.h> +#include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/update/fieldpathupdates.h> +#include <iomanip> +#include <sstream> #include <vespa/storageapi/message/persistence.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storageapi/message/bucketsplitting.h> @@ -10,16 +16,10 @@ #include <vespa/storageapi/mbusprot/storageprotocol.h> #include <vespa/storageapi/mbusprot/storagecommand.h> #include <vespa/storageapi/mbusprot/storagereply.h> -#include <vespa/storageapi/message/visitor.h> -#include <vespa/document/base/testdocman.h> -#include <vespa/document/document.h> -#include <vespa/document/repo/documenttyperepo.h> -#include <vespa/document/update/fieldpathupdates.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/util/growablebytebuffer.h> +#include <vespa/storageapi/message/visitor.h> #include <vespa/vespalib/objects/nbostream.h> -#include <iomanip> -#include <sstream> using std::shared_ptr; using document::ByteBuffer; @@ -837,7 +837,8 @@ namespace { api::StorageReply::UP makeReply() override; - void print(std::ostream& out, bool verbose, const std::string& indent) const override { + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override + { out << "MyCommand()"; if (verbose) { out << " : "; @@ -849,7 +850,8 @@ namespace { struct MyReply : public api::InternalReply { MyReply(const MyCommand& cmd) : InternalReply(102, cmd) {} - void print(std::ostream& out, bool verbose, const std::string& indent) const override { + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override + { out << "MyReply()"; if (verbose) { out << " : "; diff --git a/storageapi/src/tests/testrunner.cpp b/storageapi/src/tests/testrunner.cpp index 05fb3184c04..9a07796a3f4 100644 --- a/storageapi/src/tests/testrunner.cpp +++ b/storageapi/src/tests/testrunner.cpp @@ -1,12 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <vespa/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("storageapicppunittestrunner"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h index 17ad75aa851..692cc171250 100644 --- a/storageapi/src/vespa/storageapi/buckets/bucketinfo.h +++ b/storageapi/src/vespa/storageapi/buckets/bucketinfo.h @@ -13,6 +13,7 @@ #pragma once +#include <stdint.h> #include <vespa/storageapi/defs.h> #include <vespa/vespalib/util/printable.h> #include <vespa/vespalib/util/xmlserializable.h> @@ -76,10 +77,13 @@ public: bool empty() const { return _metaCount == 0 && _usedFileSize == 0 && _checksum == 0; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override { + + void print(std::ostream& out, bool verbose, + const std::string& indent) const override + { vespalib::AsciiPrintable::print(out, verbose, indent); } - void print(vespalib::asciistream&, const PrintProperties&) const override; + virtual void print(vespalib::asciistream&, const PrintProperties&) const override; void printXml(vespalib::XmlOutputStream&) const; }; diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.h index f44de9700b7..9fa125b1159 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.h +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization4_2.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "protocolserialization.h" +#include <vespa/storageapi/mbusprot/protocolserialization.h> namespace storage { namespace mbusprot { @@ -11,29 +11,29 @@ public: ProtocolSerialization4_2(const document::DocumentTypeRepo::SP&); protected: - void onEncode(GBBuf&, const api::GetCommand&) const override; - void onEncode(GBBuf&, const api::RemoveCommand&) const override; - void onEncode(GBBuf&, const api::RevertCommand&) const override; - void onEncode(GBBuf&, const api::CreateBucketCommand&) const override; - void onEncode(GBBuf&, const api::MergeBucketCommand&) const override; - void onEncode(GBBuf&, const api::GetBucketDiffCommand&) const override; - void onEncode(GBBuf&, const api::ApplyBucketDiffCommand&) const override; - void onEncode(GBBuf&, const api::RequestBucketInfoReply&) const override; - void onEncode(GBBuf&, const api::NotifyBucketChangeCommand&) const override; - void onEncode(GBBuf&, const api::NotifyBucketChangeReply&) const override; - void onEncode(GBBuf&, const api::SplitBucketCommand&) const override; - void onEncode(GBBuf&, const api::MultiOperationCommand&) const override; - void onEncode(GBBuf&, const api::CreateVisitorCommand&) const override; - void onEncode(GBBuf&, const api::DestroyVisitorCommand&) const override; - void onEncode(GBBuf&, const api::DestroyVisitorReply&) const override; - void onEncode(GBBuf&, const api::RemoveLocationCommand&) const override; - void onEncode(GBBuf&, const api::RemoveLocationReply&) const override; + virtual void onEncode(GBBuf&, const api::GetCommand&) const override; + virtual void onEncode(GBBuf&, const api::RemoveCommand&) const override; + virtual void onEncode(GBBuf&, const api::RevertCommand&) const override; + virtual void onEncode(GBBuf&, const api::CreateBucketCommand&) const override; + virtual void onEncode(GBBuf&, const api::MergeBucketCommand&) const override; + virtual void onEncode(GBBuf&, const api::GetBucketDiffCommand&) const override; + virtual void onEncode(GBBuf&, const api::ApplyBucketDiffCommand&) const override; + virtual void onEncode(GBBuf&, const api::RequestBucketInfoReply&) const override; + virtual void onEncode(GBBuf&, const api::NotifyBucketChangeCommand&) const override; + virtual void onEncode(GBBuf&, const api::NotifyBucketChangeReply&) const override; + virtual void onEncode(GBBuf&, const api::SplitBucketCommand&) const override; + virtual void onEncode(GBBuf&, const api::MultiOperationCommand&) const override; + virtual void onEncode(GBBuf&, const api::CreateVisitorCommand&) const override; + virtual void onEncode(GBBuf&, const api::DestroyVisitorCommand&) const override; + virtual void onEncode(GBBuf&, const api::DestroyVisitorReply&) const override; + virtual void onEncode(GBBuf&, const api::RemoveLocationCommand&) const override; + virtual void onEncode(GBBuf&, const api::RemoveLocationReply&) const override; // Not supported on 4.2, but implemented here for simplicity. - void onEncode(GBBuf&, const api::BatchPutRemoveCommand&) const override; - void onEncode(GBBuf&, const api::BatchPutRemoveReply&) const override; - void onEncode(GBBuf&, const api::SetBucketStateCommand&) const override; - void onEncode(GBBuf&, const api::SetBucketStateReply&) const override; + virtual void onEncode(GBBuf&, const api::BatchPutRemoveCommand&) const override; + virtual void onEncode(GBBuf&, const api::BatchPutRemoveReply&) const override; + virtual void onEncode(GBBuf&, const api::SetBucketStateCommand&) const override; + virtual void onEncode(GBBuf&, const api::SetBucketStateReply&) const override; virtual void onEncodeBucketInfoCommand(GBBuf&, const api::BucketInfoCommand&) const; virtual void onEncodeBucketInfoReply(GBBuf&, const api::BucketInfoReply&) const = 0; @@ -42,29 +42,29 @@ protected: virtual void onEncodeDiffEntry(GBBuf&, const api::GetBucketDiffCommand::Entry&) const; virtual void onEncode(GBBuf&, const api::ReturnCode&) const; - SCmd::UP onDecodeGetCommand(BBuf&) const override; - SCmd::UP onDecodeRemoveCommand(BBuf&) const override; - SCmd::UP onDecodeRevertCommand(BBuf&) const override; - SCmd::UP onDecodeCreateBucketCommand(BBuf&) const override; - SCmd::UP onDecodeMergeBucketCommand(BBuf&) const override; - SCmd::UP onDecodeGetBucketDiffCommand(BBuf&) const override; - SCmd::UP onDecodeApplyBucketDiffCommand(BBuf&) const override; - SRep::UP onDecodeRequestBucketInfoReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeNotifyBucketChangeCommand(BBuf&) const override; - SRep::UP onDecodeNotifyBucketChangeReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeSplitBucketCommand(BBuf&) const override; - SCmd::UP onDecodeSetBucketStateCommand(BBuf&) const override; - SRep::UP onDecodeSetBucketStateReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeMultiOperationCommand(BBuf&) const override; - SCmd::UP onDecodeCreateVisitorCommand(BBuf&) const override; - SCmd::UP onDecodeDestroyVisitorCommand(BBuf&) const override; - SRep::UP onDecodeDestroyVisitorReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeRemoveLocationCommand(BBuf&) const override; - SRep::UP onDecodeRemoveLocationReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeGetCommand(BBuf&) const override; + virtual SCmd::UP onDecodeRemoveCommand(BBuf&) const override; + virtual SCmd::UP onDecodeRevertCommand(BBuf&) const override; + virtual SCmd::UP onDecodeCreateBucketCommand(BBuf&) const override; + virtual SCmd::UP onDecodeMergeBucketCommand(BBuf&) const override; + virtual SCmd::UP onDecodeGetBucketDiffCommand(BBuf&) const override; + virtual SCmd::UP onDecodeApplyBucketDiffCommand(BBuf&) const override; + virtual SRep::UP onDecodeRequestBucketInfoReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeNotifyBucketChangeCommand(BBuf&) const override; + virtual SRep::UP onDecodeNotifyBucketChangeReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeSplitBucketCommand(BBuf&) const override; + virtual SCmd::UP onDecodeSetBucketStateCommand(BBuf&) const override; + virtual SRep::UP onDecodeSetBucketStateReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeMultiOperationCommand(BBuf&) const override; + virtual SCmd::UP onDecodeCreateVisitorCommand(BBuf&) const override; + virtual SCmd::UP onDecodeDestroyVisitorCommand(BBuf&) const override; + virtual SRep::UP onDecodeDestroyVisitorReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeRemoveLocationCommand(BBuf&) const override; + virtual SRep::UP onDecodeRemoveLocationReply(const SCmd&, BBuf&) const override; // Not supported on 4.2, but implemented here for simplicity. - SCmd::UP onDecodeBatchPutRemoveCommand(BBuf&) const override; - SRep::UP onDecodeBatchPutRemoveReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeBatchPutRemoveCommand(BBuf&) const override; + virtual SRep::UP onDecodeBatchPutRemoveReply(const SCmd&, BBuf&) const override; virtual void onDecodeBucketInfoCommand(BBuf&, api::BucketInfoCommand&) const; virtual void onDecodeBucketInfoReply(BBuf&, api::BucketInfoReply&) const = 0; diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h index 826700584da..c5a26987a08 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_0.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "protocolserialization4_2.h" +#include <vespa/storageapi/mbusprot/protocolserialization4_2.h> #include <vespa/documentapi/loadtypes/loadtypeset.h> namespace storage { @@ -15,64 +15,66 @@ public: ProtocolSerialization5_0(const document::DocumentTypeRepo::SP&, const documentapi::LoadTypeSet& loadTypes); - api::BucketInfo getBucketInfo(document::ByteBuffer& buf) const override; - void putBucketInfo(const api::BucketInfo& info, vespalib::GrowableByteBuffer& buf) const override; + virtual api::BucketInfo getBucketInfo(document::ByteBuffer& buf) const override; + virtual void putBucketInfo(const api::BucketInfo& info, + vespalib::GrowableByteBuffer& buf) const override; - void onEncode(GBBuf&, const api::PutCommand&) const override; - void onEncode(GBBuf&, const api::PutReply&) const override; - void onEncode(GBBuf&, const api::UpdateCommand&) const override; - void onEncode(GBBuf&, const api::UpdateReply&) const override; - void onEncode(GBBuf&, const api::GetReply&) const override; - void onEncode(GBBuf&, const api::RemoveReply&) const override; - void onEncode(GBBuf&, const api::RevertReply&) const override; - void onEncode(GBBuf&, const api::CreateBucketReply&) const override; - void onEncode(GBBuf&, const api::DeleteBucketCommand&) const override; - void onEncode(GBBuf&, const api::DeleteBucketReply&) const override; - void onEncode(GBBuf&, const api::MergeBucketCommand&) const override; - void onEncode(GBBuf&, const api::MergeBucketReply&) const override; - void onEncode(GBBuf&, const api::GetBucketDiffReply&) const override; - void onEncode(GBBuf&, const api::ApplyBucketDiffReply&) const override; - void onEncode(GBBuf&, const api::SplitBucketReply&) const override; - void onEncode(GBBuf&, const api::MultiOperationReply&) const override; - void onEncode(GBBuf&, const api::JoinBucketsCommand&) const override; - void onEncode(GBBuf&, const api::JoinBucketsReply&) const override; - void onEncode(GBBuf&, const api::RequestBucketInfoCommand&) const override; + virtual void onEncode(GBBuf&, const api::PutCommand&) const override; + virtual void onEncode(GBBuf&, const api::PutReply&) const override; + virtual void onEncode(GBBuf&, const api::UpdateCommand&) const override; + virtual void onEncode(GBBuf&, const api::UpdateReply&) const override; + virtual void onEncode(GBBuf&, const api::GetReply&) const override; + virtual void onEncode(GBBuf&, const api::RemoveReply&) const override; + virtual void onEncode(GBBuf&, const api::RevertReply&) const override; + virtual void onEncode(GBBuf&, const api::CreateBucketReply&) const override; + virtual void onEncode(GBBuf&, const api::DeleteBucketCommand&) const override; + virtual void onEncode(GBBuf&, const api::DeleteBucketReply&) const override; + virtual void onEncode(GBBuf&, const api::MergeBucketCommand&) const override; + virtual void onEncode(GBBuf&, const api::MergeBucketReply&) const override; + virtual void onEncode(GBBuf&, const api::GetBucketDiffReply&) const override; + virtual void onEncode(GBBuf&, const api::ApplyBucketDiffReply&) const override; + virtual void onEncode(GBBuf&, const api::SplitBucketReply&) const override; + virtual void onEncode(GBBuf&, const api::MultiOperationReply&) const override; + virtual void onEncode(GBBuf&, const api::JoinBucketsCommand&) const override; + virtual void onEncode(GBBuf&, const api::JoinBucketsReply&) const override; + virtual void onEncode(GBBuf&, const api::RequestBucketInfoCommand&) const override; - void onEncodeBucketInfoReply(GBBuf&, const api::BucketInfoReply&) const override; + virtual void onEncodeBucketInfoReply(GBBuf&, const api::BucketInfoReply&) const override; virtual void onEncodeBucketReply(GBBuf&, const api::BucketReply&) const; - void onEncode(GBBuf&, const api::CreateVisitorCommand& msg) const override; - void onEncode(GBBuf&, const api::CreateVisitorReply& msg) const override; - void onEncodeCommand(GBBuf&, const api::StorageCommand&) const override; - void onEncodeReply(GBBuf&, const api::StorageReply&) const override; + virtual void onEncode(GBBuf&, const api::CreateVisitorCommand& msg) const override; + virtual void onEncode(GBBuf&, const api::CreateVisitorReply& msg) const override; + virtual void onEncodeCommand(GBBuf&, const api::StorageCommand&) const override; + virtual void onEncodeReply(GBBuf&, const api::StorageReply&) const override; - SCmd::UP onDecodePutCommand(BBuf&) const override; - SRep::UP onDecodePutReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeUpdateCommand(BBuf&) const override; - SRep::UP onDecodeUpdateReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeGetReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeRemoveReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeRevertReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeCreateBucketReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeDeleteBucketCommand(BBuf&) const override; - SRep::UP onDecodeDeleteBucketReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeMergeBucketCommand(BBuf&) const override; - SRep::UP onDecodeMergeBucketReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeGetBucketDiffReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeApplyBucketDiffReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeSplitBucketReply(const SCmd&, BBuf&) const override; - SRep::UP onDecodeMultiOperationReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeJoinBucketsCommand(BBuf& buf) const override; - SRep::UP onDecodeJoinBucketsReply(const SCmd& cmd, BBuf& buf) const override; - SCmd::UP onDecodeCreateVisitorCommand(BBuf&) const override; - SCmd::UP onDecodeRequestBucketInfoCommand(BBuf& buf) const override; + virtual SCmd::UP onDecodePutCommand(BBuf&) const override; + virtual SRep::UP onDecodePutReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeUpdateCommand(BBuf&) const override; + virtual SRep::UP onDecodeUpdateReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeGetReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeRemoveReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeRevertReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeCreateBucketReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeDeleteBucketCommand(BBuf&) const override; + virtual SRep::UP onDecodeDeleteBucketReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeMergeBucketCommand(BBuf&) const override; + virtual SRep::UP onDecodeMergeBucketReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeGetBucketDiffReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeApplyBucketDiffReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeSplitBucketReply(const SCmd&, BBuf&) const override; + virtual SRep::UP onDecodeMultiOperationReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeJoinBucketsCommand(BBuf& buf) const override; + virtual SRep::UP onDecodeJoinBucketsReply(const SCmd& cmd, BBuf& buf) const override; + virtual SCmd::UP onDecodeCreateVisitorCommand(BBuf&) const override; + virtual SCmd::UP onDecodeRequestBucketInfoCommand(BBuf& buf) const override; - void onDecodeBucketInfoReply(BBuf&, api::BucketInfoReply&) const override; + virtual void onDecodeBucketInfoReply(BBuf&, api::BucketInfoReply&) const override; virtual void onDecodeBucketReply(BBuf&, api::BucketReply&) const; - SRep::UP onDecodeCreateVisitorReply(const SCmd& cmd, BBuf& buf) const override; - void onDecodeCommand(BBuf& buf, api::StorageCommand& msg) const override; - void onDecodeReply(BBuf&, api::StorageReply&) const override; + virtual SRep::UP onDecodeCreateVisitorReply(const SCmd& cmd, BBuf& buf) const override; + virtual void onDecodeCommand(BBuf& buf, api::StorageCommand& msg) const override; + virtual void onDecodeReply(BBuf&, api::StorageReply&) const override; }; } // mbusprot } // storage + diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h index 92e559f5de9..393596046c2 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_1.h @@ -1,7 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "protocolserialization5_0.h" +#include <vespa/storageapi/mbusprot/protocolserialization5_0.h> +#include <vespa/documentapi/loadtypes/loadtypeset.h> namespace storage { namespace mbusprot { @@ -16,22 +17,24 @@ public: ProtocolSerialization5_1(const document::DocumentTypeRepo::SP&, const documentapi::LoadTypeSet& loadTypes); - api::BucketInfo getBucketInfo(document::ByteBuffer& buf) const override; - void putBucketInfo(const api::BucketInfo& info, vespalib::GrowableByteBuffer& buf) const override; + virtual api::BucketInfo getBucketInfo(document::ByteBuffer& buf) const override; + virtual void putBucketInfo(const api::BucketInfo& info, + vespalib::GrowableByteBuffer& buf) const override; protected: - void onEncode(GBBuf&, const api::SetBucketStateCommand&) const override; - void onEncode(GBBuf&, const api::SetBucketStateReply&) const override; - void onEncode(GBBuf&, const api::GetCommand&) const override; - void onEncode(GBBuf&, const api::CreateVisitorCommand&) const override; - void onEncode(GBBuf&, const api::CreateBucketCommand&) const override; - - SCmd::UP onDecodeSetBucketStateCommand(BBuf&) const override; - SRep::UP onDecodeSetBucketStateReply(const SCmd&, BBuf&) const override; - SCmd::UP onDecodeGetCommand(BBuf&) const override; - SCmd::UP onDecodeCreateVisitorCommand(BBuf&) const override; - SCmd::UP onDecodeCreateBucketCommand(BBuf&) const override; + virtual void onEncode(GBBuf&, const api::SetBucketStateCommand&) const override; + virtual void onEncode(GBBuf&, const api::SetBucketStateReply&) const override; + virtual void onEncode(GBBuf&, const api::GetCommand&) const override; + virtual void onEncode(GBBuf&, const api::CreateVisitorCommand&) const override; + virtual void onEncode(GBBuf&, const api::CreateBucketCommand&) const override; + + virtual SCmd::UP onDecodeSetBucketStateCommand(BBuf&) const override; + virtual SRep::UP onDecodeSetBucketStateReply(const SCmd&, BBuf&) const override; + virtual SCmd::UP onDecodeGetCommand(BBuf&) const override; + virtual SCmd::UP onDecodeCreateVisitorCommand(BBuf&) const override; + virtual SCmd::UP onDecodeCreateBucketCommand(BBuf&) const override; }; } // mbusprot } // storage + diff --git a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h index 552d9ee3508..35af05d192b 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h +++ b/storageapi/src/vespa/storageapi/mbusprot/protocolserialization5_2.h @@ -3,8 +3,9 @@ #pragma once -#include "protocolserialization5_1.h" #include <vespa/vespalib/util/growablebytebuffer.h> +#include <vespa/documentapi/loadtypes/loadtypeset.h> +#include <vespa/storageapi/mbusprot/protocolserialization5_1.h> #include <vespa/storageapi/message/persistence.h> namespace storage { @@ -13,19 +14,20 @@ namespace mbusprot { class ProtocolSerialization5_2 : public ProtocolSerialization5_1 { public: - ProtocolSerialization5_2(const document::DocumentTypeRepo::SP& repo, - const documentapi::LoadTypeSet & loadTypes) + ProtocolSerialization5_2( + const document::DocumentTypeRepo::SP& repo, + const documentapi::LoadTypeSet & loadTypes) : ProtocolSerialization5_1(repo, loadTypes) - {} + {} protected: - void onEncode(GBBuf &, const api::PutCommand &) const override; - void onEncode(GBBuf &, const api::RemoveCommand &) const override; - void onEncode(GBBuf &, const api::UpdateCommand &) const override; + virtual void onEncode(GBBuf &, const api::PutCommand &) const override; + virtual void onEncode(GBBuf &, const api::RemoveCommand &) const override; + virtual void onEncode(GBBuf &, const api::UpdateCommand &) const override; - SCmd::UP onDecodePutCommand(BBuf &) const override; - SCmd::UP onDecodeRemoveCommand(BBuf &) const override; - SCmd::UP onDecodeUpdateCommand(BBuf &) const override; + virtual SCmd::UP onDecodePutCommand(BBuf &) const override; + virtual SCmd::UP onDecodeRemoveCommand(BBuf &) const override; + virtual SCmd::UP onDecodeUpdateCommand(BBuf &) const override; static void decodeTasCondition(api::StorageCommand & cmd, BBuf & buf); static void encodeTasCondition(GBBuf & buf, const api::StorageCommand & cmd); diff --git a/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h b/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h index d6d95e2b1fe..8549df6077f 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h +++ b/storageapi/src/vespa/storageapi/mbusprot/storagecommand.h @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "storagemessage.h" -#include "storageprotocol.h" #include <vespa/messagebus/message.h> +#include <vespa/storageapi/mbusprot/storagemessage.h> +#include <vespa/storageapi/mbusprot/storageprotocol.h> #include <vespa/storageapi/messageapi/storagecommand.h> namespace storage { @@ -16,13 +16,15 @@ public: StorageCommand(const storage::api::StorageCommand::SP&); const mbus::string & getProtocol() const override { return StorageProtocol::NAME; } + uint32_t getType() const override { return _cmd->getType().getId(); } + const api::StorageCommand::SP& getCommand() { return _cmd; } api::StorageCommand::CSP getCommand() const { return _cmd; } - api::StorageMessage::SP getInternalMessage() override { return _cmd; } - api::StorageMessage::CSP getInternalMessage() const override { return _cmd; } + virtual api::StorageMessage::SP getInternalMessage() override { return _cmd; } + virtual api::StorageMessage::CSP getInternalMessage() const override { return _cmd; } - uint8_t priority() const override { + virtual uint8_t priority() const override { return ((getInternalMessage()->getPriority()) / 255) * 16; } @@ -32,3 +34,4 @@ private: } // mbusprot } // storage + diff --git a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h index e1bcff1b27c..8c10ab1dfe1 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h +++ b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.h @@ -1,8 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "protocolserialization5_2.h" #include <vespa/messagebus/iprotocol.h> +#include <string> +#include <vespa/storageapi/mbusprot/protocolserialization5_0.h> +#include <vespa/storageapi/mbusprot/protocolserialization5_1.h> +#include <vespa/storageapi/mbusprot/protocolserialization5_2.h> +#include <vespa/documentapi/loadtypes/loadtypeset.h> namespace storage { namespace mbusprot { @@ -17,10 +21,17 @@ public: StorageProtocol(const document::DocumentTypeRepo::SP, const documentapi::LoadTypeSet& loadTypes); + // Implements IProtocol. const mbus::string& getName() const override { return NAME; } + + // Implements IProtocol. mbus::IRoutingPolicy::UP createPolicy(const mbus::string& name, const mbus::string& param) const override; + + // Implements IProtocol. mbus::Blob encode(const vespalib::Version&, const mbus::Routable&) const override; + + // Implements IProtocol. mbus::Routable::UP decode(const vespalib::Version&, mbus::BlobRef) const override; private: @@ -31,3 +42,6 @@ private: } // mbusprot } // storage + + + diff --git a/storageapi/src/vespa/storageapi/mbusprot/storagereply.h b/storageapi/src/vespa/storageapi/mbusprot/storagereply.h index 2e7dafc505f..aa7c827a32a 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/storagereply.h +++ b/storageapi/src/vespa/storageapi/mbusprot/storagereply.h @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "storagemessage.h" -#include "storageprotocol.h" #include <vespa/messagebus/reply.h> +#include <vespa/storageapi/mbusprot/storagemessage.h> +#include <vespa/storageapi/mbusprot/storageprotocol.h> #include <vespa/storageapi/messageapi/storagereply.h> namespace storage { @@ -20,19 +20,21 @@ public: StorageReply(const mbus::BlobRef& data, const ProtocolSerialization&); StorageReply(const api::StorageReply::SP& reply); - ~StorageReply(); + virtual ~StorageReply(); - const mbus::string& getProtocol() const override { return StorageProtocol::NAME; } + virtual const mbus::string& getProtocol() const override + { return StorageProtocol::NAME; } uint32_t getType() const override { return _mbusType; } const api::StorageReply::SP& getReply() { deserialize(); return _reply; } api::StorageReply::CSP getReply() const { deserialize(); return _reply; } + virtual api::StorageMessage::SP getInternalMessage() override + { deserialize(); return _reply; } + virtual api::StorageMessage::CSP getInternalMessage() const override + { deserialize(); return _reply; } - api::StorageMessage::SP getInternalMessage() override { deserialize(); return _reply; } - api::StorageMessage::CSP getInternalMessage() const override { deserialize(); return _reply; } - - uint8_t priority() const override { + virtual uint8_t priority() const override { if (_reply.get()) { return _reply->getPriority(); } @@ -46,3 +48,4 @@ private: } // mbusprot } // storage + diff --git a/storageapi/src/vespa/storageapi/message/batch.h b/storageapi/src/vespa/storageapi/message/batch.h index c2bb8b816b8..85e7a8df9ee 100644 --- a/storageapi/src/vespa/storageapi/message/batch.h +++ b/storageapi/src/vespa/storageapi/message/batch.h @@ -156,13 +156,14 @@ public: @return Returns a list of the updates to be performed. */ const UpdateList& getUpdates() const { return _updates; }; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; /** Returns a bucket id suitable for routing this message. */ document::BucketId getBucketId() const override { return _bucketId; } - bool hasSingleBucketId() const override { return true; } + virtual bool hasSingleBucketId() const override { return true; } DECLARE_STORAGECOMMAND(BatchDocumentUpdateCommand, onBatchDocumentUpdate) @@ -182,12 +183,18 @@ class BatchDocumentUpdateReply : public StorageReply { std::vector<bool> _documentsNotFound; public: explicit BatchDocumentUpdateReply(const BatchDocumentUpdateCommand&); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + const std::vector<bool>& getDocumentsNotFound() const { return _documentsNotFound; } std::vector<bool>& getDocumentsNotFound() { return _documentsNotFound; } DECLARE_STORAGEREPLY(BatchDocumentUpdateReply, onBatchDocumentUpdateReply) }; + + } } + + diff --git a/storageapi/src/vespa/storageapi/message/bucket.h b/storageapi/src/vespa/storageapi/message/bucket.h index 31948852840..c78591eca61 100644 --- a/storageapi/src/vespa/storageapi/message/bucket.h +++ b/storageapi/src/vespa/storageapi/message/bucket.h @@ -7,14 +7,14 @@ #pragma once +#include <vespa/document/base/globalid.h> +#include <vespa/vdslib/state/clusterstate.h> +#include <vespa/storageapi/defs.h> #include <vespa/storageapi/messageapi/bucketcommand.h> #include <vespa/storageapi/messageapi/bucketreply.h> #include <vespa/storageapi/messageapi/bucketinfocommand.h> #include <vespa/storageapi/messageapi/bucketinforeply.h> #include <vespa/storageapi/messageapi/maintenancecommand.h> -#include <vespa/document/base/globalid.h> -#include <vespa/vdslib/state/clusterstate.h> -#include <vespa/storageapi/defs.h> namespace document { class DocumentTypeRepo; } @@ -32,9 +32,12 @@ class CreateBucketCommand : public MaintenanceCommand { public: explicit CreateBucketCommand(const document::BucketId& id); + void setActive(bool active) { _active = active; } bool getActive() const { return _active; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(CreateBucketCommand, onCreateBucket) }; @@ -47,7 +50,9 @@ public: class CreateBucketReply : public BucketInfoReply { public: explicit CreateBucketReply(const CreateBucketCommand& cmd); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(CreateBucketReply, onCreateBucketReply); }; @@ -64,7 +69,9 @@ public: const BucketInfo& getBucketInfo() const { return _info; } void setBucketInfo(const BucketInfo& info) { _info = info; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(DeleteBucketCommand, onDeleteBucket) }; @@ -77,7 +84,9 @@ public: class DeleteBucketReply : public BucketInfoReply { public: explicit DeleteBucketReply(const DeleteBucketCommand& cmd); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(DeleteBucketReply, onDeleteBucketReply) }; @@ -127,10 +136,14 @@ public: const std::vector<Node>& getNodes() const { return _nodes; } Timestamp getMaxTimestamp() const { return _maxTimestamp; } const std::vector<uint16_t>& getChain() const { return _chain; } + uint32_t getClusterStateVersion() const { return _clusterStateVersion; } + void setClusterStateVersion(uint32_t version) { _clusterStateVersion = version; } void setChain(const std::vector<uint16_t>& chain) { _chain = chain; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(MergeBucketCommand, onMergeBucket) }; @@ -160,7 +173,8 @@ public: Timestamp getMaxTimestamp() const { return _maxTimestamp; } const std::vector<uint16_t>& getChain() const { return _chain; } uint32_t getClusterStateVersion() const { return _clusterStateVersion; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(MergeBucketReply, onMergeBucketReply) }; @@ -184,7 +198,8 @@ public: uint16_t _hasMask; Entry(); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; bool operator==(const Entry&) const; bool operator<(const Entry& e) const { return (_timestamp < e._timestamp); } @@ -204,7 +219,7 @@ public: const std::vector<Entry>& getDiff() const { return _diff; } std::vector<Entry>& getDiff() { return _diff; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(GetBucketDiffCommand, onGetBucketDiff) }; @@ -232,7 +247,8 @@ public: Timestamp getMaxTimestamp() const { return _maxTimestamp; } const std::vector<Entry>& getDiff() const { return _diff; } std::vector<Entry>& getDiff() { return _diff; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(GetBucketDiffReply, onGetBucketDiffReply) }; @@ -258,7 +274,8 @@ public: Entry(const GetBucketDiffCommand::Entry&); bool filled() const; - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; bool operator==(const Entry&) const; }; private: @@ -279,7 +296,8 @@ public: const std::vector<Entry>& getDiff() const { return _diff; } std::vector<Entry>& getDiff() { return _diff; } uint32_t getMaxBufferSize() const { return _maxBufferSize; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(ApplyBucketDiffCommand, onApplyBucketDiff) }; @@ -308,7 +326,7 @@ public: std::vector<Entry>& getDiff() { return _diff; } uint32_t getMaxBufferSize() const { return _maxBufferSize; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(ApplyBucketDiffReply, onApplyBucketDiffReply) }; @@ -341,11 +359,13 @@ public: RequestBucketInfoCommand(uint16_t distributor, const lib::ClusterState& state); - const std::vector<document::BucketId>& getBuckets() const { return _buckets; } + const std::vector<document::BucketId>& getBuckets() const + { return _buckets; } bool hasSystemState() const { return (_state.get() != 0); } uint16_t getDistributor() const { return _distributor; } - const lib::ClusterState& getSystemState() const { return *_state; } + const lib::ClusterState& getSystemState() const + { return *_state; } const vespalib::string& getDistributionHash() const { return _distributionHash; } @@ -382,10 +402,14 @@ public: explicit RequestBucketInfoReply(const RequestBucketInfoCommand& cmd); ~RequestBucketInfoReply(); + const EntryVector & getBucketInfo() const { return _buckets; } EntryVector & getBucketInfo() { return _buckets; } + uint32_t getMemoryFootprint() const override; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(RequestBucketInfoReply, onRequestBucketInfoReply) }; @@ -402,11 +426,15 @@ public: */ class NotifyBucketChangeCommand : public BucketCommand { BucketInfo _info; + public: NotifyBucketChangeCommand(const document::BucketId& bucket, const BucketInfo& bucketInfo); + const BucketInfo& getBucketInfo() const { return _info; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(NotifyBucketChangeCommand, onNotifyBucketChange) }; @@ -423,7 +451,9 @@ public: class NotifyBucketChangeReply : public BucketReply { public: explicit NotifyBucketChangeReply(const NotifyBucketChangeCommand& cmd); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(NotifyBucketChangeReply, onNotifyBucketChangeReply) }; @@ -444,13 +474,16 @@ public: private: BUCKET_STATE _state; public: - SetBucketStateCommand(const document::BucketId& bucket, BUCKET_STATE state); + SetBucketStateCommand(const document::BucketId& bucket, + BUCKET_STATE state); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + BUCKET_STATE getState() const { return _state; } + DECLARE_STORAGECOMMAND(SetBucketStateCommand, onSetBucketState) private: - - vespalib::string getSummary() const override; + virtual vespalib::string getSummary() const override; }; /** @@ -463,9 +496,12 @@ class SetBucketStateReply : public BucketInfoReply { public: explicit SetBucketStateReply(const SetBucketStateCommand&); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(SetBucketStateReply, onSetBucketStateReply) }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/bucketsplitting.h b/storageapi/src/vespa/storageapi/message/bucketsplitting.h index 4e7c9397716..6188a7cc44f 100644 --- a/storageapi/src/vespa/storageapi/message/bucketsplitting.h +++ b/storageapi/src/vespa/storageapi/message/bucketsplitting.h @@ -57,7 +57,7 @@ public: void setMinByteSize(uint32_t v) { _minByteSize = v; } void setMinDocCount(uint32_t v) { _minDocCount = v; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(SplitBucketCommand, onSplitBucket) }; @@ -71,14 +71,19 @@ public: class SplitBucketReply : public BucketReply { public: typedef std::pair<document::BucketId, BucketInfo> Entry; + +private: + std::vector<Entry> _result; + +public: explicit SplitBucketReply(const SplitBucketCommand& cmd); + std::vector<Entry>& getSplitInfo() { return _result; } const std::vector<Entry>& getSplitInfo() const { return _result; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(SplitBucketReply, onSplitBucketReply) -private: - std::vector<Entry> _result; }; /** @@ -92,13 +97,19 @@ private: class JoinBucketsCommand : public MaintenanceCommand { std::vector<document::BucketId> _sources; uint8_t _minJoinBits; + public: explicit JoinBucketsCommand(const document::BucketId& target); + std::vector<document::BucketId>& getSourceBuckets() { return _sources; } - const std::vector<document::BucketId>& getSourceBuckets() const { return _sources; } + const std::vector<document::BucketId>& getSourceBuckets() const + { return _sources; } + void setMinJoinBits(uint8_t minJoinBits) { _minJoinBits = minJoinBits; } uint8_t getMinJoinBits() const { return _minJoinBits; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(JoinBucketsCommand, onJoinBuckets) }; @@ -110,13 +121,20 @@ public: */ class JoinBucketsReply : public BucketInfoReply { std::vector<document::BucketId> _sources; + public: explicit JoinBucketsReply(const JoinBucketsCommand& cmd); + JoinBucketsReply(const JoinBucketsCommand& cmd, const BucketInfo& bucketInfo); - const std::vector<document::BucketId>& getSourceBuckets() const { return _sources; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + const std::vector<document::BucketId>& getSourceBuckets() const + { return _sources; } + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(JoinBucketsReply, onJoinBucketsReply) }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/datagram.h b/storageapi/src/vespa/storageapi/message/datagram.h index 642caa8e12a..040f925f98a 100644 --- a/storageapi/src/vespa/storageapi/message/datagram.h +++ b/storageapi/src/vespa/storageapi/message/datagram.h @@ -1,11 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "visitor.h" +#include <vespa/document/bucket/bucketid.h> +#include <vespa/vdslib/container/documentlist.h> #include <vespa/storageapi/messageapi/storagecommand.h> #include <vespa/storageapi/messageapi/storagereply.h> #include <vespa/storageapi/defs.h> -#include <vespa/vdslib/container/documentlist.h> +#include <vespa/storageapi/message/visitor.h> namespace storage { namespace api { @@ -32,11 +33,16 @@ public: { assert(_docBlock.getBufferSize() > 0); return _docBlock; } const vdslib::DocumentList& getDocumentBlock() const { assert(_docBlock.getBufferSize() > 0); return _docBlock; } - void setDocumentBlock(vdslib::DocumentList& block) { _docBlock = block; } + + void setDocumentBlock(vdslib::DocumentList& block) { + _docBlock = block; + } document::BucketId getBucketId() const override { return _bucketId; } - bool hasSingleBucketId() const override { return true; } + virtual bool hasSingleBucketId() const override { return true; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + bool keepTimeStamps() const { return _keepTimeStamps; } void keepTimeStamps(bool keepTime) { _keepTimeStamps = keepTime; } @@ -52,7 +58,9 @@ public: class DocBlockReply : public StorageReply { public: explicit DocBlockReply(const DocBlockCommand&); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(DocBlockReply, onDocBlockReply) }; @@ -68,11 +76,15 @@ public: */ class MapVisitorCommand : public StorageCommand { vdslib::Parameters _statistics; + public: MapVisitorCommand(); + vdslib::Parameters& getData() { return _statistics; }; const vdslib::Parameters& getData() const { return _statistics; }; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(MapVisitorCommand, onMapVisitor) }; @@ -85,7 +97,9 @@ public: class MapVisitorReply : public StorageReply { public: explicit MapVisitorReply(const MapVisitorCommand&); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(MapVisitorReply, onMapVisitorReply) }; @@ -106,6 +120,7 @@ public: bool _removeEntry; Entry() : _doc(), _lastModified(0), _removeEntry(false) {} + Entry(const document::Document::SP& doc, int64_t lastModified, bool removeEntry) : _doc(doc), @@ -117,13 +132,18 @@ public: private: document::BucketId _bucketId; std::vector<Entry> _documents; + public: DocumentListCommand(const document::BucketId& bid); + const document::BucketId& getBucketId() { return _bucketId; } std::vector<Entry>& getDocuments() { return _documents; } const std::vector<Entry>& getDocuments() const { return _documents; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(DocumentListCommand, onDocumentList) + }; std::ostream& operator<<(std::ostream& out, const DocumentListCommand::Entry& e); @@ -137,7 +157,9 @@ std::ostream& operator<<(std::ostream& out, const DocumentListCommand::Entry& e) class DocumentListReply : public StorageReply { public: explicit DocumentListReply(const DocumentListCommand&); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(DocumentListReply, onDocumentListReply) }; @@ -154,11 +176,18 @@ public: */ class EmptyBucketsCommand : public StorageCommand { std::vector<document::BucketId> _buckets; + public: EmptyBucketsCommand(const std::vector<document::BucketId>&); - const std::vector<document::BucketId>& getBuckets() const { return _buckets; } + + const std::vector<document::BucketId>& getBuckets() const + { return _buckets; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(EmptyBucketsCommand, onEmptyBuckets) + +private: }; /** @@ -170,9 +199,12 @@ public: class EmptyBucketsReply : public StorageReply { public: explicit EmptyBucketsReply(const EmptyBucketsCommand&); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(EmptyBucketsReply, onEmptyBucketsReply) }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/documentsummary.h b/storageapi/src/vespa/storageapi/message/documentsummary.h index d9f943afc07..b32723c6ddb 100644 --- a/storageapi/src/vespa/storageapi/message/documentsummary.h +++ b/storageapi/src/vespa/storageapi/message/documentsummary.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "visitor.h" #include <vespa/vdslib/container/documentsummary.h> +#include <vespa/storageapi/message/visitor.h> namespace storage { namespace api { @@ -18,10 +18,13 @@ class DocumentSummaryCommand : public StorageCommand, { public: explicit DocumentSummaryCommand(); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + uint32_t getMemoryFootprint() const override { return getSerializedSize(); } + DECLARE_STORAGECOMMAND(DocumentSummaryCommand, onDocumentSummary) }; @@ -34,9 +37,12 @@ public: class DocumentSummaryReply : public StorageReply { public: explicit DocumentSummaryReply(const DocumentSummaryCommand& command); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(DocumentSummaryReply, onDocumentSummaryReply) }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/persistence.h b/storageapi/src/vespa/storageapi/message/persistence.h index 251750eed60..470acca566b 100644 --- a/storageapi/src/vespa/storageapi/message/persistence.h +++ b/storageapi/src/vespa/storageapi/message/persistence.h @@ -67,9 +67,12 @@ public: uint32_t getMemoryFootprint() const override { return (_doc.get() ? 4096 : 0) + 20; } + vespalib::string getSummary() const override; + void print(std::ostream& out, bool verbose, const std::string& indent) const override; - StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; + + virtual StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; DECLARE_STORAGECOMMAND(PutCommand, onPut); }; @@ -137,7 +140,8 @@ public: vespalib::string getSummary() const override; void print(std::ostream& out, bool verbose, const std::string& indent) const override; - StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; + + virtual StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; DECLARE_STORAGECOMMAND(UpdateCommand, onUpdate); }; @@ -199,7 +203,9 @@ public: GetCommand(const document::BucketId&, const document::DocumentId&, const vespalib::stringref & fieldSet, Timestamp before = MAX_TIMESTAMP); ~GetCommand(); + void setBeforeTimestamp(Timestamp ts) { _beforeTimestamp = ts; } + const document::DocumentId& getDocumentId() const { return _docId; } Timestamp getBeforeTimestamp() const { return _beforeTimestamp; } const vespalib::string& getFieldSet() const { return _fieldSet; } @@ -208,7 +214,7 @@ public: vespalib::string getSummary() const override; void print(std::ostream& out, bool verbose, const std::string& indent) const override; - StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; + virtual StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; DECLARE_STORAGECOMMAND(GetCommand, onGet) }; @@ -240,10 +246,13 @@ public: Timestamp getBeforeTimestamp() const { return _beforeTimestamp; } bool wasFound() const { return (_doc.get() != 0); } + uint32_t getMemoryFootprint() const override { return (_doc.get() ? 4096 : 0) + 30; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(GetReply, onGetReply) }; @@ -258,15 +267,20 @@ class RemoveCommand : public TestAndSetCommand { Timestamp _timestamp; public: - RemoveCommand(const document::BucketId&, const document::DocumentId& docId, Timestamp timestamp); + RemoveCommand(const document::BucketId&, const document::DocumentId& docId, + Timestamp timestamp); ~RemoveCommand(); void setTimestamp(Timestamp ts) { _timestamp = ts; } + const document::DocumentId& getDocumentId() const override { return _docId; } Timestamp getTimestamp() const { return _timestamp; } + vespalib::string getSummary() const override; void print(std::ostream& out, bool verbose, const std::string& indent) const override; - StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; + + virtual StorageCommand::UP createCopyToForward(const document::BucketId& bucket, uint64_t timestamp) const override; + DECLARE_STORAGECOMMAND(RemoveCommand, onRemove) }; @@ -280,6 +294,7 @@ class RemoveReply : public BucketInfoReply { document::DocumentId _docId; Timestamp _timestamp; Timestamp _oldTimestamp; + public: explicit RemoveReply(const RemoveCommand& cmd, Timestamp oldTimestamp = 0); ~RemoveReply(); @@ -287,9 +302,13 @@ public: const document::DocumentId& getDocumentId() const { return _docId; } Timestamp getTimestamp() { return _timestamp; }; Timestamp getOldTimestamp() const { return _oldTimestamp; } + void setOldTimestamp(Timestamp oldTimestamp) { _oldTimestamp = oldTimestamp; } + bool wasFound() const { return (_oldTimestamp != 0); } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(RemoveReply, onRemoveReply) }; @@ -301,12 +320,16 @@ public: */ class RevertCommand : public BucketInfoCommand { std::vector<Timestamp> _tokens; + public: RevertCommand(const document::BucketId& bucket, const std::vector<Timestamp>& revertTokens); ~RevertCommand(); + const std::vector<Timestamp>& getRevertTokens() const { return _tokens; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(RevertCommand, onRevert) }; @@ -318,13 +341,19 @@ public: */ class RevertReply : public BucketInfoReply { std::vector<Timestamp> _tokens; + public: explicit RevertReply(const RevertCommand& cmd); ~RevertReply(); + const std::vector<Timestamp>& getRevertTokens() const { return _tokens; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(RevertReply, onRevertReply) }; } // api } // storage + + diff --git a/storageapi/src/vespa/storageapi/message/queryresult.h b/storageapi/src/vespa/storageapi/message/queryresult.h index 282a45ee43b..8020fa22dea 100644 --- a/storageapi/src/vespa/storageapi/message/queryresult.h +++ b/storageapi/src/vespa/storageapi/message/queryresult.h @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "visitor.h" #include <vespa/vdslib/container/searchresult.h> #include <vespa/vdslib/container/documentsummary.h> +#include <vespa/storageapi/message/visitor.h> namespace storage { namespace api { @@ -43,9 +43,12 @@ private: class QueryResultReply : public StorageReply { public: explicit QueryResultReply(const QueryResultCommand& command); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(QueryResultReply, onQueryResultReply) }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/removelocation.h b/storageapi/src/vespa/storageapi/message/removelocation.h index 6232ddece90..08b5663e2d6 100644 --- a/storageapi/src/vespa/storageapi/message/removelocation.h +++ b/storageapi/src/vespa/storageapi/message/removelocation.h @@ -5,6 +5,7 @@ #include <vespa/storageapi/messageapi/storagecommand.h> #include <vespa/storageapi/messageapi/bucketinforeply.h> + namespace storage { namespace api { @@ -14,12 +15,17 @@ public: RemoveLocationCommand(const vespalib::stringref & documentSelection, const document::BucketId&); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + void print(std::ostream& out, bool verbose, + const std::string& indent) const override; + uint32_t getMemoryFootprint() const override { return _documentSelection.length(); } + const vespalib::string& getDocumentSelection() const { return _documentSelection; } + DECLARE_STORAGECOMMAND(RemoveLocationCommand, onRemoveLocation); + private: vespalib::string _documentSelection; }; @@ -28,8 +34,10 @@ class RemoveLocationReply : public BucketInfoReply { public: RemoveLocationReply(const RemoveLocationCommand& cmd); + DECLARE_STORAGEREPLY(RemoveLocationReply, onRemoveLocationReply) }; } } + diff --git a/storageapi/src/vespa/storageapi/message/searchresult.h b/storageapi/src/vespa/storageapi/message/searchresult.h index 220f48a5973..b2662800a9d 100644 --- a/storageapi/src/vespa/storageapi/message/searchresult.h +++ b/storageapi/src/vespa/storageapi/message/searchresult.h @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "visitor.h" #include <vespa/vdslib/container/searchresult.h> +#include <vespa/storageapi/message/visitor.h> namespace storage { namespace api { @@ -16,8 +16,13 @@ namespace api { class SearchResultCommand : public StorageCommand, public vdslib::SearchResult { public: SearchResultCommand(); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; - uint32_t getMemoryFootprint() const override { return getSerializedSize(); } + + uint32_t getMemoryFootprint() const override { + return getSerializedSize(); + } + DECLARE_STORAGECOMMAND(SearchResultCommand, onSearchResult) }; @@ -30,9 +35,12 @@ public: class SearchResultReply : public StorageReply { public: explicit SearchResultReply(const SearchResultCommand& command); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(SearchResultReply, onSearchResultReply) }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/stat.h b/storageapi/src/vespa/storageapi/message/stat.h index 071f3e8ebdd..3ee4afbb4ba 100644 --- a/storageapi/src/vespa/storageapi/message/stat.h +++ b/storageapi/src/vespa/storageapi/message/stat.h @@ -20,22 +20,30 @@ namespace api { class StatBucketCommand : public BucketCommand { private: vespalib::string _docSelection; + public: StatBucketCommand(const document::BucketId& bucket, const vespalib::stringref & documentSelection); const vespalib::string& getDocumentSelection() const { return _docSelection; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; - StorageCommand::UP createCopyToForward(const document::BucketId&, uint64_t timestamp) const override; + + virtual StorageCommand::UP createCopyToForward(const document::BucketId&, uint64_t timestamp) const override; + DECLARE_STORAGECOMMAND(StatBucketCommand, onStatBucket); }; class StatBucketReply : public BucketReply { vespalib::string _results; + public: StatBucketReply(const StatBucketCommand&, const vespalib::stringref & results = ""); + const vespalib::string& getResults() { return _results; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(StatBucketReply, onStatBucketReply) }; @@ -52,7 +60,9 @@ public: class GetBucketListCommand : public BucketCommand { public: GetBucketListCommand(const document::BucketId& bucket); + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGECOMMAND(GetBucketListCommand, onGetBucketList); }; @@ -66,7 +76,8 @@ public: const vespalib::stringref & bucketInformation) : _bucket(id), _bucketInformation(bucketInformation) - {} + { + } bool operator==(const BucketInfo& other) const { return (_bucket == other._bucket @@ -79,9 +90,12 @@ private: public: GetBucketListReply(const GetBucketListCommand&); + std::vector<BucketInfo>& getBuckets() { return _buckets; } const std::vector<BucketInfo>& getBuckets() const { return _buckets; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; + DECLARE_STORAGEREPLY(GetBucketListReply, onGetBucketListReply) }; @@ -90,3 +104,4 @@ std::ostream& operator<<(std::ostream& out, const GetBucketListReply::BucketInfo } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/state.h b/storageapi/src/vespa/storageapi/message/state.h index 86830f86e7b..12a357c1b40 100644 --- a/storageapi/src/vespa/storageapi/message/state.h +++ b/storageapi/src/vespa/storageapi/message/state.h @@ -1,5 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +/** + * @file state.h + * + * State commands. + */ #pragma once #include <vespa/storageapi/messageapi/storagecommand.h> @@ -21,7 +25,9 @@ class GetNodeStateCommand : public StorageCommand { public: explicit GetNodeStateCommand(lib::NodeState::UP expectedState); - const lib::NodeState* getExpectedState() const { return _expectedState.get(); } + const lib::NodeState* getExpectedState() const + { return _expectedState.get(); } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(GetNodeStateCommand, onGetNodeState) @@ -65,7 +71,9 @@ class SetSystemStateCommand : public StorageCommand { public: explicit SetSystemStateCommand(const lib::ClusterState&); + const lib::ClusterState& getSystemState() const { return _state; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGECOMMAND(SetSystemStateCommand, onSetSystemState) @@ -85,6 +93,7 @@ public: // Not serialized. Available locally const lib::ClusterState& getSystemState() const { return _state; } + void print(std::ostream& out, bool verbose, const std::string& indent) const override; DECLARE_STORAGEREPLY(SetSystemStateReply, onSetSystemStateReply) @@ -92,3 +101,4 @@ public: } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/message/visitor.h b/storageapi/src/vespa/storageapi/message/visitor.h index c1d0bb637a0..a9d1de402da 100644 --- a/storageapi/src/vespa/storageapi/message/visitor.h +++ b/storageapi/src/vespa/storageapi/message/visitor.h @@ -108,11 +108,14 @@ public: void setVisitorOrdering(document::OrderingSpecification::Order ordering) { _ordering = ordering; } document::OrderingSpecification::Order getVisitorOrdering() const { return _ordering; } - void setMaxBucketsPerVisitor(uint32_t max) { _maxBucketsPerVisitor = max; } - uint32_t getMaxBucketsPerVisitor() const { return _maxBucketsPerVisitor; } + void setMaxBucketsPerVisitor(uint32_t max) + { _maxBucketsPerVisitor = max; } + uint32_t getMaxBucketsPerVisitor() const + { return _maxBucketsPerVisitor; } void print(std::ostream& out, bool verbose, const std::string& indent) const override; - StorageCommand::UP createCopyToForward(const document::BucketId&, uint64_t timestamp) const override; + + virtual StorageCommand::UP createCopyToForward(const document::BucketId&, uint64_t timestamp) const override; DECLARE_STORAGECOMMAND(CreateVisitorCommand, onCreateVisitor) }; diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h index 95b2284661a..7c078b9545a 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h +++ b/storageapi/src/vespa/storageapi/messageapi/bucketcommand.h @@ -8,7 +8,8 @@ #pragma once -#include "storagecommand.h" +#include <vespa/document/bucket/bucketid.h> +#include <vespa/storageapi/messageapi/storagecommand.h> namespace storage { namespace api { @@ -31,9 +32,13 @@ public: document::BucketId getBucketId() const override { return _bucket; } bool hasBeenRemapped() const { return (_originalBucket.getRawId() != 0); } - const document::BucketId& getOriginalBucketId() const { return _originalBucket; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; - bool hasSingleBucketId() const override { return true; } + const document::BucketId& getOriginalBucketId() const + { return _originalBucket; } + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual bool hasSingleBucketId() const override { return true; } + }; } // api diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h index d9d924bc338..62171a9e3c0 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h +++ b/storageapi/src/vespa/storageapi/messageapi/bucketinfocommand.h @@ -12,7 +12,7 @@ #pragma once -#include "bucketcommand.h" +#include <vespa/storageapi/messageapi/bucketcommand.h> namespace storage { namespace api { @@ -24,7 +24,8 @@ protected: public: DECLARE_POINTER_TYPEDEFS(BucketInfoCommand); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; } // api diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h index d5b174e4f2e..d39a6a5eaf8 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h +++ b/storageapi/src/vespa/storageapi/messageapi/bucketinforeply.h @@ -12,9 +12,9 @@ #pragma once -#include "bucketreply.h" -#include "bucketinfocommand.h" #include <vespa/storageapi/buckets/bucketinfo.h> +#include <vespa/storageapi/messageapi/bucketreply.h> +#include <vespa/storageapi/messageapi/bucketinfocommand.h> namespace storage { namespace api { @@ -31,8 +31,11 @@ public: const BucketInfo& getBucketInfo() const { return _result; }; void setBucketInfo(const BucketInfo& info) { _result = info; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + /** Overload this to get more descriptive message output. */ + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h index 0cd2c2065fe..833f1396c49 100644 --- a/storageapi/src/vespa/storageapi/messageapi/bucketreply.h +++ b/storageapi/src/vespa/storageapi/messageapi/bucketreply.h @@ -8,7 +8,8 @@ #pragma once -#include "storagereply.h" +#include <vespa/document/bucket/bucketid.h> +#include <vespa/storageapi/messageapi/storagereply.h> namespace storage { namespace api { @@ -38,8 +39,10 @@ public: if (_originalBucket.getRawId() == 0) _originalBucket = _bucket; _bucket = bucket; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/messageapi/messagehandler.h b/storageapi/src/vespa/storageapi/messageapi/messagehandler.h index 131ee8d2400..66873dfba27 100644 --- a/storageapi/src/vespa/storageapi/messageapi/messagehandler.h +++ b/storageapi/src/vespa/storageapi/messageapi/messagehandler.h @@ -13,7 +13,6 @@ #pragma once -#include <memory> namespace storage { namespace api { diff --git a/storageapi/src/vespa/storageapi/messageapi/returncode.cpp b/storageapi/src/vespa/storageapi/messageapi/returncode.cpp index e2d10487431..f11d91b7079 100644 --- a/storageapi/src/vespa/storageapi/messageapi/returncode.cpp +++ b/storageapi/src/vespa/storageapi/messageapi/returncode.cpp @@ -1,6 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "returncode.h" +#include <vespa/messagebus/errorcode.h> + +#include <vespa/document/util/bytebuffer.h> +#include <vespa/fnet/frt/error.h> #include <ostream> namespace storage { diff --git a/storageapi/src/vespa/storageapi/messageapi/returncode.h b/storageapi/src/vespa/storageapi/messageapi/returncode.h index 0aa87c64012..a7be570e8f4 100644 --- a/storageapi/src/vespa/storageapi/messageapi/returncode.h +++ b/storageapi/src/vespa/storageapi/messageapi/returncode.h @@ -14,6 +14,7 @@ #include <vespa/document/util/serializable.h> #include <vespa/documentapi/messagebus/documentprotocol.h> #include <iosfwd> +#include <string> namespace document { class ByteBuffer; @@ -67,7 +68,9 @@ public: private: Result _result; vespalib::string _message; - void onDeserialize(const document::DocumentTypeRepo &repo, document::ByteBuffer& buffer) override; + + void onDeserialize(const document::DocumentTypeRepo &repo, + document::ByteBuffer& buffer) override; void onSerialize(document::ByteBuffer& buffer) const override; public: @@ -120,3 +123,4 @@ public: } // api } // storage + diff --git a/storageapi/src/vespa/storageapi/messageapi/storagecommand.h b/storageapi/src/vespa/storageapi/messageapi/storagecommand.h index d67cbcf2bcb..00f17458e6a 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagecommand.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagecommand.h @@ -12,7 +12,7 @@ #pragma once -#include "storagemessage.h" +#include <vespa/storageapi/messageapi/storagemessage.h> namespace storage { namespace api { @@ -46,7 +46,7 @@ public: void setNewId() { StorageMessage::setNewMsgId(); } /** Overload this to get more descriptive message output. */ - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; /** * A way for someone to make a reply to a storage message without diff --git a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h index 8801916c14b..47dd93a9535 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagemessage.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagemessage.h @@ -11,11 +11,11 @@ #pragma once -#include "messagehandler.h" #include <map> #include <vespa/vespalib/util/printable.h> #include <vespa/messagebus/routing/route.h> #include <vespa/vespalib/util/sync.h> +#include <vespa/storageapi/messageapi/messagehandler.h> #include <vespa/vdslib/state/nodetype.h> #include <vespa/messagebus/trace.h> #include <vespa/documentapi/loadtypes/loadtype.h> @@ -42,8 +42,9 @@ namespace vespalib { public: \ DECLARE_POINTER_TYPEDEFS(reply) \ private: \ - bool callHandler(MessageHandler& h, \ - const std::shared_ptr<StorageMessage>& m) const override \ + virtual bool callHandler( \ + MessageHandler& h, \ + const std::shared_ptr<StorageMessage>& m) const override \ { \ return h.callback(std::static_pointer_cast<reply>(m)); \ } @@ -65,7 +66,7 @@ public: \ #define IMPLEMENT_COMMAND(command, reply) \ IMPLEMENT_COMMON(command) \ std::unique_ptr<storage::api::StorageReply> \ - storage::api::command::makeReply() \ + storage::api::command::makeReply() \ { \ return std::unique_ptr<storage::api::StorageReply>(new reply(*this)); \ } diff --git a/storageapi/src/vespa/storageapi/messageapi/storagereply.h b/storageapi/src/vespa/storageapi/messageapi/storagereply.h index 4d185ea7a29..eab6470f463 100644 --- a/storageapi/src/vespa/storageapi/messageapi/storagereply.h +++ b/storageapi/src/vespa/storageapi/messageapi/storagereply.h @@ -12,8 +12,8 @@ #pragma once -#include "returncode.h" -#include "storagemessage.h" +#include <vespa/storageapi/messageapi/returncode.h> +#include <vespa/storageapi/messageapi/storagemessage.h> namespace storage { namespace api { @@ -34,7 +34,9 @@ public: void setResult(const ReturnCode& r) { _result = r; } void setResult(ReturnCode::Result r) { _result = ReturnCode(r); } const ReturnCode& getResult() const { return _result; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; + + /** Overload this to get more descriptive output. */ + virtual void print(std::ostream& out, bool verbose, const std::string& indent) const override; }; } // api diff --git a/storageframework/src/tests/clock/timetest.cpp b/storageframework/src/tests/clock/timetest.cpp index d0367449fe1..ae07559e095 100644 --- a/storageframework/src/tests/clock/timetest.cpp +++ b/storageframework/src/tests/clock/timetest.cpp @@ -10,6 +10,9 @@ namespace defaultimplementation { struct TimeTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} + void testBasics(); void testCreatedFromClock(); void canAssignMicrosecondResolutionTimeToFakeClock(); diff --git a/storageframework/src/tests/memory/memorymanagertest.cpp b/storageframework/src/tests/memory/memorymanagertest.cpp index 8b1868a6bd4..885ae86e832 100644 --- a/storageframework/src/tests/memory/memorymanagertest.cpp +++ b/storageframework/src/tests/memory/memorymanagertest.cpp @@ -155,7 +155,8 @@ MemoryManagerTest::testBasics() struct ReduceI : public framework::ReduceMemoryUsageInterface { framework::MemoryToken::UP _token; - uint64_t reduceMemoryConsumption(const MemoryToken& token, uint64_t reduceBy) override { + virtual uint64_t reduceMemoryConsumption(const MemoryToken& token, uint64_t reduceBy) override + { assert(&token == _token.get()); (void) &token; assert(_token->getSize() >= reduceBy); diff --git a/storageframework/src/tests/memory/memorystatetest.cpp b/storageframework/src/tests/memory/memorystatetest.cpp index 5a047a5c790..40d102199d6 100644 --- a/storageframework/src/tests/memory/memorystatetest.cpp +++ b/storageframework/src/tests/memory/memorystatetest.cpp @@ -2,6 +2,7 @@ #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storageframework/defaultimplementation/memory/memorystate.h> +#include <vespa/storageframework/generic/memory/memorymanagerinterface.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/util/exceptions.h> @@ -11,6 +12,8 @@ namespace defaultimplementation { struct MemoryStateTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} void testBasics(); @@ -27,15 +30,15 @@ private: std::map<std::string, framework::MemoryAllocationType> _types; public: - void setMaximumMemoryUsage(uint64_t max) override { (void) max; } + virtual void setMaximumMemoryUsage(uint64_t max) override { (void) max; } - const framework::MemoryAllocationType& + virtual const framework::MemoryAllocationType& registerAllocationType(const framework::MemoryAllocationType& type) override { _types[type.getName()] = type; return _types[type.getName()]; } - const framework::MemoryAllocationType& + virtual const framework::MemoryAllocationType& getAllocationType(const std::string& name) const override { std::map<std::string, framework::MemoryAllocationType>::const_iterator iter = _types.find(name); @@ -47,7 +50,8 @@ public: return iter->second; } - std::vector<const MemoryAllocationType*> getAllocationTypes() const override { + virtual std::vector<const MemoryAllocationType*> getAllocationTypes() const override + { std::vector<const MemoryAllocationType*> types; for(std::map<std::string, framework::MemoryAllocationType> ::const_iterator it = _types.begin(); it != _types.end(); ++it) diff --git a/storageframework/src/tests/testrunner.cpp b/storageframework/src/tests/testrunner.cpp index 5baa0f60b6e..0d40a0429d9 100644 --- a/storageframework/src/tests/testrunner.cpp +++ b/storageframework/src/tests/testrunner.cpp @@ -6,7 +6,7 @@ LOG_SETUP("persistencecppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/storageframework/src/tests/thread/taskthreadtest.cpp b/storageframework/src/tests/thread/taskthreadtest.cpp index a6698be3676..bca5c81ef01 100644 --- a/storageframework/src/tests/thread/taskthreadtest.cpp +++ b/storageframework/src/tests/thread/taskthreadtest.cpp @@ -34,7 +34,7 @@ namespace { struct MyThread : public TaskThread<Task> { MyThread(ThreadLock& lock) : TaskThread<Task>(lock) {} - ThreadWaitInfo doNonCriticalTick(ThreadIndex) override { + virtual ThreadWaitInfo doNonCriticalTick(ThreadIndex) override { return ThreadWaitInfo::NO_MORE_CRITICAL_WORK_KNOWN; } }; diff --git a/storageframework/src/tests/thread/tickingthreadtest.cpp b/storageframework/src/tests/thread/tickingthreadtest.cpp index c9d54fe557a..c65b809e5da 100644 --- a/storageframework/src/tests/thread/tickingthreadtest.cpp +++ b/storageframework/src/tests/thread/tickingthreadtest.cpp @@ -13,6 +13,9 @@ namespace defaultimplementation { struct TickingThreadTest : public CppUnit::TestFixture { + void setUp() override {} + void tearDown() override {} + void testTicksBeforeWaitBasic(); void testTicksBeforeWaitLiveUpdate(); void testDestroyWithoutStarting(); @@ -59,7 +62,7 @@ struct MyApp : public TickingThread { void start(ThreadPool& p) { _threadPool->start(p); } - ThreadWaitInfo doCriticalTick(ThreadIndex index) override { + virtual ThreadWaitInfo doCriticalTick(ThreadIndex index) override { assert(index < _context.size()); Context& c(_context[index]); if (_doCritOverlapTest) { @@ -71,12 +74,13 @@ struct MyApp : public TickingThread { ++c._critTickCount; return ThreadWaitInfo::NO_MORE_CRITICAL_WORK_KNOWN; } - ThreadWaitInfo doNonCriticalTick(ThreadIndex index) override { + virtual ThreadWaitInfo doNonCriticalTick(ThreadIndex index) override { assert(index < _context.size()); Context& c(_context[index]); ++c._nonCritTickCount; return ThreadWaitInfo::NO_MORE_CRITICAL_WORK_KNOWN; } + uint64_t getMinCritTick() { uint64_t min = std::numeric_limits<uint64_t>().max(); for (uint32_t i=0; i<_context.size(); ++i) { @@ -310,7 +314,7 @@ struct BroadcastApp : public TickingThread { void start(ThreadPool& p) { _threadPool->start(p); } - ThreadWaitInfo doCriticalTick(ThreadIndex) override { + virtual ThreadWaitInfo doCriticalTick(ThreadIndex) override { if (!_queue.empty()) { for (uint32_t i=0; i<_queue.size(); ++i) { printTaskInfo(_queue[i], "activating"); @@ -321,7 +325,7 @@ struct BroadcastApp : public TickingThread { } return ThreadWaitInfo::NO_MORE_CRITICAL_WORK_KNOWN; } - ThreadWaitInfo doNonCriticalTick(ThreadIndex) override { + virtual ThreadWaitInfo doNonCriticalTick(ThreadIndex) override { if (!_active.empty()) { for (uint32_t i=0; i<_active.size(); ++i) { printTaskInfo(_queue[i], "processing"); diff --git a/storageserver/src/tests/testrunner.cpp b/storageserver/src/tests/testrunner.cpp index 70c4b4cdb5c..5d8dc8d4c1f 100644 --- a/storageserver/src/tests/testrunner.cpp +++ b/storageserver/src/tests/testrunner.cpp @@ -1,11 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vdstestlib/cppunit/cppunittestrunner.h> +#include <vespa/fastos/fastos.h> +#include <iostream> #include <vespa/log/log.h> +#include <vespa/vdstestlib/cppunit/cppunittestrunner.h> + LOG_SETUP("storagecppunittests"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/vbench/src/apps/dumpurl/dumpurl.cpp b/vbench/src/apps/dumpurl/dumpurl.cpp index 44ebc1d2ac2..706dd061763 100644 --- a/vbench/src/apps/dumpurl/dumpurl.cpp +++ b/vbench/src/apps/dumpurl/dumpurl.cpp @@ -1,9 +1,8 @@ // 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 <vbench/http/http_result_handler.h> #include <vbench/http/server_spec.h> #include <vbench/http/http_client.h> -#include <vespa/fastos/app.h> using namespace vbench; @@ -14,14 +13,14 @@ public: }; struct MyHttpHandler : public HttpResultHandler { - void handleHeader(const string &name, const string &value) override { + virtual void handleHeader(const string &name, const string &value) override { fprintf(stderr, "got header: '%s': '%s'\n", name.c_str(), value.c_str()); } - void handleContent(const Memory &data) override { + virtual void handleContent(const Memory &data) override { fprintf(stderr, "got data: %zu bytes\n", data.size); fwrite(data.data, 1, data.size, stdout); } - void handleFailure(const string &reason) override { + virtual void handleFailure(const string &reason) override { fprintf(stderr, "got FAILURE: '%s'\n", reason.c_str()); } }; diff --git a/vbench/src/apps/vbench/vbench.cpp b/vbench/src/apps/vbench/vbench.cpp index fa6bc91e035..32af3d70c3d 100644 --- a/vbench/src/apps/vbench/vbench.cpp +++ b/vbench/src/apps/vbench/vbench.cpp @@ -1,10 +1,13 @@ // 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/vespalib/util/signalhandler.h> #include <vespa/vespalib/util/programoptions.h> #include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/util/thread.h> #include <vespa/vespalib/util/runnable_pair.h> #include <vbench/vbench/vbench.h> +#include <vespa/vespalib/data/slime/slime.h> +#include <string> #include <iostream> using namespace vbench; @@ -14,7 +17,7 @@ typedef vespalib::SignalHandler SIG; struct NotifyDone : public vespalib::Runnable { vespalib::Gate &done; NotifyDone(vespalib::Gate &d) : done(d) {} - void run() override { + virtual void run() override { done.countDown(); } }; diff --git a/vbench/src/tests/dispatcher/dispatcher_test.cpp b/vbench/src/tests/dispatcher/dispatcher_test.cpp index 0a278508d55..284f7c55d8a 100644 --- a/vbench/src/tests/dispatcher/dispatcher_test.cpp +++ b/vbench/src/tests/dispatcher/dispatcher_test.cpp @@ -7,14 +7,14 @@ using namespace vbench; struct MyHandler : public Handler<int> { int value; MyHandler() : value(-1) {} - void handle(std::unique_ptr<int> v) override { value = (v.get() != 0) ? *v : 0; } + virtual void handle(std::unique_ptr<int> v) override { value = (v.get() != 0) ? *v : 0; } }; struct Fetcher : public vespalib::Runnable { Provider<int> &provider; Handler<int> &handler; Fetcher(Provider<int> &p, Handler<int> &h) : provider(p), handler(h) {} - void run() override { handler.handle(provider.provide()); } + virtual void run() override { handler.handle(provider.provide()); } }; TEST("dispatcher") { diff --git a/vbench/src/tests/handler_thread/handler_thread_test.cpp b/vbench/src/tests/handler_thread/handler_thread_test.cpp index e8816e1cc96..a21bda82b6a 100644 --- a/vbench/src/tests/handler_thread/handler_thread_test.cpp +++ b/vbench/src/tests/handler_thread/handler_thread_test.cpp @@ -6,7 +6,7 @@ using namespace vbench; struct MyHandler : Handler<int> { std::vector<int> values; - void handle(std::unique_ptr<int> value) override { + virtual void handle(std::unique_ptr<int> value) override { values.push_back(*value); vespalib::Thread::sleep(10); // for improved coverage } diff --git a/vbench/src/tests/socket/socket_test.cpp b/vbench/src/tests/socket/socket_test.cpp index 56499a089b6..21c410f382e 100644 --- a/vbench/src/tests/socket/socket_test.cpp +++ b/vbench/src/tests/socket/socket_test.cpp @@ -34,7 +34,7 @@ struct Agent { struct Client : public Agent, public vespalib::Runnable { Client(Stream::UP s) : Agent(std::move(s)) {} - void run() override { + virtual void run() override { TEST_THREAD("client"); write("client-"); read("server-"); @@ -43,7 +43,7 @@ struct Client : public Agent, public vespalib::Runnable { struct Server : public Agent, public vespalib::Runnable { Server(Stream::UP s) : Agent(std::move(s)) {} - void run() override { + virtual void run() override { TEST_THREAD("server"); read("client-"); write("server-"); diff --git a/vbench/src/vbench/core/handler.h b/vbench/src/vbench/core/handler.h index 3959688d949..962e6c09ad7 100644 --- a/vbench/src/vbench/core/handler.h +++ b/vbench/src/vbench/core/handler.h @@ -17,3 +17,4 @@ struct Handler }; } // namespace vbench + diff --git a/vbench/src/vbench/core/input_file_reader.h b/vbench/src/vbench/core/input_file_reader.h index 5883faab9aa..410f0819d3b 100644 --- a/vbench/src/vbench/core/input_file_reader.h +++ b/vbench/src/vbench/core/input_file_reader.h @@ -4,9 +4,9 @@ #include "string.h" #include "taintable.h" -#include "line_reader.h" #include <vespa/vespalib/io/mapped_file_input.h> #include <vespa/vespalib/data/input_reader.h> +#include "line_reader.h" namespace vbench { @@ -34,7 +34,7 @@ public: **/ bool readLine(string &dst); - const Taint &tainted() const override { return _taint; } + virtual const Taint &tainted() const override { return _taint; } }; } // namespace vbench diff --git a/vbench/src/vbench/core/socket.cpp b/vbench/src/vbench/core/socket.cpp index e11acdb864c..7306d25cf32 100644 --- a/vbench/src/vbench/core/socket.cpp +++ b/vbench/src/vbench/core/socket.cpp @@ -40,8 +40,6 @@ Socket::Socket(const string &host, int port) } } -Socket::~Socket() { } - Memory Socket::obtain() { diff --git a/vbench/src/vbench/core/socket.h b/vbench/src/vbench/core/socket.h index a447dd4d592..e961994c37a 100644 --- a/vbench/src/vbench/core/socket.h +++ b/vbench/src/vbench/core/socket.h @@ -29,13 +29,12 @@ private: public: Socket(vespalib::SocketHandle socket); Socket(const string &host, int port); - ~Socket(); - bool eof() const override { return _eof; } - Memory obtain() override; - Input &evict(size_t bytes) override; - WritableMemory reserve(size_t bytes) override; - Output &commit(size_t bytes) override; - const Taint &tainted() const override { return _taint; } + virtual bool eof() const override { return _eof; } + virtual Memory obtain() override; + virtual Input &evict(size_t bytes) override; + virtual WritableMemory reserve(size_t bytes) override; + virtual Output &commit(size_t bytes) override; + virtual const Taint &tainted() const override { return _taint; } }; struct ServerSocket { @@ -54,3 +53,4 @@ struct ServerSocket { }; } // namespace vbench + diff --git a/vbench/src/vbench/core/string.h b/vbench/src/vbench/core/string.h index 592e63e9cbf..61a2b3b442c 100644 --- a/vbench/src/vbench/core/string.h +++ b/vbench/src/vbench/core/string.h @@ -10,8 +10,6 @@ #include <string> #endif -#include <vector> - namespace vbench { // define which string class to use diff --git a/vbench/src/vbench/core/taintable.cpp b/vbench/src/vbench/core/taintable.cpp index 34d65513ca7..23e2745999a 100644 --- a/vbench/src/vbench/core/taintable.cpp +++ b/vbench/src/vbench/core/taintable.cpp @@ -1,5 +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 "taintable.h" namespace vbench { @@ -8,9 +9,8 @@ namespace { struct Untaintable : Taintable { Taint taint; - - const Taint &tainted() const override { return taint; } - ~Untaintable() {} + virtual const Taint &tainted() const override { return taint; } + virtual ~Untaintable() {} }; Untaintable untaintable; diff --git a/vbench/src/vbench/http/benchmark_headers.cpp b/vbench/src/vbench/http/benchmark_headers.cpp index c42af2a79c7..e4bea82023d 100644 --- a/vbench/src/vbench/http/benchmark_headers.cpp +++ b/vbench/src/vbench/http/benchmark_headers.cpp @@ -1,5 +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 "benchmark_headers.h" #include <map> @@ -75,7 +77,7 @@ BenchmarkHeaders::toString() const struct HeaderToString : benchmark_headers::HeaderTraverser { string &str; HeaderToString(string &s) : str(s) {} - void header(const string &name, double value) override { + virtual void header(const string &name, double value) override { str += strfmt(" %s: %g\n", name.c_str(), value); } } headerToString(str); diff --git a/vbench/src/vbench/http/http_result_handler.h b/vbench/src/vbench/http/http_result_handler.h index 18e8955b65e..85c230fefb8 100644 --- a/vbench/src/vbench/http/http_result_handler.h +++ b/vbench/src/vbench/http/http_result_handler.h @@ -1,5 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once #include <vbench/core/string.h> @@ -22,3 +23,4 @@ struct HttpResultHandler }; } // namespace vbench + diff --git a/vbench/src/vbench/test/request_receptor.h b/vbench/src/vbench/test/request_receptor.h index 0692c3735f6..2de39e528e4 100644 --- a/vbench/src/vbench/test/request_receptor.h +++ b/vbench/src/vbench/test/request_receptor.h @@ -1,5 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once #include <vbench/core/handler.h> @@ -10,7 +11,7 @@ namespace vbench { struct RequestReceptor : public Handler<Request> { Request::UP request; RequestReceptor() : request() {} - void handle(Request::UP req) override; + virtual void handle(Request::UP req) override; }; } // namespace vbench diff --git a/vbench/src/vbench/vbench/analyzer.h b/vbench/src/vbench/vbench/analyzer.h index f206130cc0b..e1bd8e23919 100644 --- a/vbench/src/vbench/vbench/analyzer.h +++ b/vbench/src/vbench/vbench/analyzer.h @@ -1,10 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "request.h" +#include <memory> #include <vbench/core/handler.h> +#include "request.h" + namespace vbench { struct Analyzer : public Handler<Request> @@ -15,3 +18,4 @@ struct Analyzer : public Handler<Request> }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/dropped_tagger.h b/vbench/src/vbench/vbench/dropped_tagger.h index a3fd7a65b99..eb64d4b4be4 100644 --- a/vbench/src/vbench/vbench/dropped_tagger.h +++ b/vbench/src/vbench/vbench/dropped_tagger.h @@ -1,10 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "request.h" #include <vbench/core/handler.h> +#include "request.h" + namespace vbench { /** @@ -17,7 +19,8 @@ private: public: DroppedTagger(Handler<Request> &next); - void handle(Request::UP request) override; + virtual void handle(Request::UP request) override; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/generator.h b/vbench/src/vbench/vbench/generator.h index 51309eaf9b6..5eb8e056265 100644 --- a/vbench/src/vbench/vbench/generator.h +++ b/vbench/src/vbench/vbench/generator.h @@ -1,10 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include <vbench/core/taintable.h> -#include <vespa/vespalib/util/runnable.h> #include <memory> +#include <vespa/vespalib/util/runnable.h> +#include <vbench/core/taintable.h> namespace vbench { diff --git a/vbench/src/vbench/vbench/ignore_before.h b/vbench/src/vbench/vbench/ignore_before.h index a2786a0c340..d74a398efd8 100644 --- a/vbench/src/vbench/vbench/ignore_before.h +++ b/vbench/src/vbench/vbench/ignore_before.h @@ -1,10 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once +#include <vbench/core/handler.h> #include "request.h" #include "analyzer.h" -#include <vbench/core/handler.h> namespace vbench { @@ -21,8 +22,9 @@ private: public: IgnoreBefore(double time, Handler<Request> &next); - void handle(Request::UP request) override; - void report() override; + virtual void handle(Request::UP request) override; + virtual void report() override; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/latency_analyzer.cpp b/vbench/src/vbench/vbench/latency_analyzer.cpp index baefa0ab138..32cd6387722 100644 --- a/vbench/src/vbench/vbench/latency_analyzer.cpp +++ b/vbench/src/vbench/vbench/latency_analyzer.cpp @@ -1,5 +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 "latency_analyzer.h" #include <cmath> diff --git a/vbench/src/vbench/vbench/latency_analyzer.h b/vbench/src/vbench/vbench/latency_analyzer.h index 162fa93a0a3..499f6f3b991 100644 --- a/vbench/src/vbench/vbench/latency_analyzer.h +++ b/vbench/src/vbench/vbench/latency_analyzer.h @@ -1,7 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once +#include <vbench/core/handler.h> +#include <vbench/core/string.h> +#include "request.h" #include "analyzer.h" namespace vbench { @@ -35,10 +39,11 @@ public: string toString() const; }; LatencyAnalyzer(Handler<Request> &next); - void handle(Request::UP request) override; - void report() override; + virtual void handle(Request::UP request) override; + virtual void report() override; void addLatency(double latency); Stats getStats() const; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/qps_analyzer.h b/vbench/src/vbench/vbench/qps_analyzer.h index 10625a89762..4b4b4997f62 100644 --- a/vbench/src/vbench/vbench/qps_analyzer.h +++ b/vbench/src/vbench/vbench/qps_analyzer.h @@ -1,7 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once +#include <vbench/core/handler.h> +#include "request.h" #include "analyzer.h" namespace vbench { @@ -21,9 +24,10 @@ private: public: QpsAnalyzer(Handler<Request> &next); - void handle(Request::UP request) override; - void report() override; + virtual void handle(Request::UP request) override; + virtual void report() override; void addEndTime(double end); }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/qps_tagger.h b/vbench/src/vbench/vbench/qps_tagger.h index 492ae324dc0..452ee8fb827 100644 --- a/vbench/src/vbench/vbench/qps_tagger.h +++ b/vbench/src/vbench/vbench/qps_tagger.h @@ -1,9 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "tagger.h" +#include <vbench/core/handler.h> + #include "request.h" +#include "tagger.h" namespace vbench { @@ -19,7 +22,8 @@ private: public: QpsTagger(double qps, Handler<Request> &next); - void handle(Request::UP request) override; + virtual void handle(Request::UP request) override; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/request.h b/vbench/src/vbench/vbench/request.h index c3eab1ab75b..4951c96fbab 100644 --- a/vbench/src/vbench/vbench/request.h +++ b/vbench/src/vbench/vbench/request.h @@ -1,5 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once #include <vbench/core/string.h> @@ -67,9 +68,9 @@ public: double latency() const { return (_endTime - _startTime); } - void handleHeader(const string &name, const string &value) override; - void handleContent(const Memory &data) override; - void handleFailure(const string &reason) override; + virtual void handleHeader(const string &name, const string &value) override; + virtual void handleContent(const Memory &data) override; + virtual void handleFailure(const string &reason) override; const BenchmarkHeaders &headers() const { return _headers; } @@ -77,3 +78,4 @@ public: }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/request_dumper.h b/vbench/src/vbench/vbench/request_dumper.h index a06e7224c4f..aede956477c 100644 --- a/vbench/src/vbench/vbench/request_dumper.h +++ b/vbench/src/vbench/vbench/request_dumper.h @@ -1,7 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once +#include <vbench/core/handler.h> + +#include "request.h" #include "analyzer.h" namespace vbench { @@ -17,8 +21,9 @@ private: public: RequestDumper(Handler<Request> &_next); - void handle(Request::UP request) override; - void report() override; + virtual void handle(Request::UP request) override; + virtual void report() override; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/request_generator.h b/vbench/src/vbench/vbench/request_generator.h index ac2b18cf928..38f2c7ad7f8 100644 --- a/vbench/src/vbench/vbench/request_generator.h +++ b/vbench/src/vbench/vbench/request_generator.h @@ -1,12 +1,16 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "generator.h" -#include "request.h" +#include <vespa/vespalib/util/runnable.h> #include <vbench/core/input_file_reader.h> +#include <vbench/core/taintable.h> #include <vbench/core/handler.h> +#include "request.h" +#include "generator.h" + namespace vbench { /** @@ -21,10 +25,12 @@ private: bool _aborted; public: - RequestGenerator(const string &inputFile, Handler<Request> &next); + RequestGenerator(const string &inputFile, + Handler<Request> &next); void abort() override; - void run() override; - const Taint &tainted() const override { return _input.tainted(); } + virtual void run() override; + virtual const Taint &tainted() const override { return _input.tainted(); } }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/request_scheduler.h b/vbench/src/vbench/vbench/request_scheduler.h index 60fe4af12fc..1de61073d35 100644 --- a/vbench/src/vbench/vbench/request_scheduler.h +++ b/vbench/src/vbench/vbench/request_scheduler.h @@ -1,14 +1,23 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "worker.h" -#include "dropped_tagger.h" +#include <memory> + +#include <vespa/vespalib/util/sync.h> +#include <vespa/vespalib/util/thread.h> +#include <vespa/vespalib/util/runnable.h> +#include <vespa/vespalib/util/active.h> + +#include <vbench/core/handler.h> #include <vbench/core/time_queue.h> #include <vbench/core/dispatcher.h> #include <vbench/core/handler_thread.h> -#include <vespa/vespalib/util/sync.h> -#include <vespa/vespalib/util/active.h> + +#include "request.h" +#include "worker.h" +#include "dropped_tagger.h" namespace vbench { @@ -31,15 +40,16 @@ private: HttpConnectionPool _connectionPool; std::vector<Worker::UP> _workers; - void run() override; + virtual void run() override; public: typedef std::unique_ptr<RequestScheduler> UP; RequestScheduler(Handler<Request> &next, size_t numWorkers); void abort(); - void handle(Request::UP request) override; - void start() override; - RequestScheduler &stop() override; - void join() override; + virtual void handle(Request::UP request) override; + virtual void start() override; + virtual RequestScheduler &stop() override; + virtual void join() override; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/request_sink.h b/vbench/src/vbench/vbench/request_sink.h index 9c9d46775e5..37c6ce71fcc 100644 --- a/vbench/src/vbench/vbench/request_sink.h +++ b/vbench/src/vbench/vbench/request_sink.h @@ -1,5 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once #include "analyzer.h" @@ -14,8 +15,9 @@ class RequestSink : public Analyzer { public: RequestSink(); - void handle(Request::UP request) override; - void report() override; + virtual void handle(Request::UP request) override; + virtual void report() override; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/server_tagger.h b/vbench/src/vbench/vbench/server_tagger.h index 5e760dc02e5..6115873bb0c 100644 --- a/vbench/src/vbench/vbench/server_tagger.h +++ b/vbench/src/vbench/vbench/server_tagger.h @@ -1,9 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "tagger.h" #include <vbench/http/server_spec.h> +#include <vbench/core/handler.h> + +#include "request.h" +#include "tagger.h" namespace vbench { @@ -17,8 +21,10 @@ private: Handler<Request> &_next; public: - ServerTagger(const ServerSpec &server, Handler<Request> &next); - void handle(Request::UP request) override; + ServerTagger(const ServerSpec &server, + Handler<Request> &next); + virtual void handle(Request::UP request) override; }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/tagger.h b/vbench/src/vbench/vbench/tagger.h index 225b83d5433..c19319e39e2 100644 --- a/vbench/src/vbench/vbench/tagger.h +++ b/vbench/src/vbench/vbench/tagger.h @@ -1,10 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "request.h" +#include <memory> #include <vbench/core/handler.h> +#include "request.h" + namespace vbench { struct Tagger : public Handler<Request> @@ -14,3 +17,4 @@ struct Tagger : public Handler<Request> }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/vbench.h b/vbench/src/vbench/vbench/vbench.h index 186bdeeac17..5796b3dab76 100644 --- a/vbench/src/vbench/vbench/vbench.h +++ b/vbench/src/vbench/vbench/vbench.h @@ -1,7 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once +#include <memory> + +#include <vespa/vespalib/util/runnable.h> +#include <vbench/core/taintable.h> +#include <vespa/vespalib/data/slime/slime.h> + #include "analyzer.h" #include "generator.h" #include "latency_analyzer.h" @@ -13,8 +20,6 @@ #include "request_sink.h" #include "server_tagger.h" #include "tagger.h" -#include <vbench/core/taintable.h> -#include <vespa/vespalib/data/slime/slime.h> namespace vbench { @@ -37,8 +42,9 @@ private: public: VBench(const vespalib::Slime &cfg); void abort(); - void run() override; - const Taint &tainted() const override { return _taint; } + virtual void run() override; + virtual const Taint &tainted() const override { return _taint; } }; } // namespace vbench + diff --git a/vbench/src/vbench/vbench/worker.h b/vbench/src/vbench/vbench/worker.h index 8e9a5119f31..cdadaf87cd3 100644 --- a/vbench/src/vbench/vbench/worker.h +++ b/vbench/src/vbench/vbench/worker.h @@ -1,15 +1,20 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + #pragma once -#include "request.h" -#include <vbench/core/provider.h> -#include <vbench/core/handler.h> -#include <vbench/http/http_connection_pool.h> +#include <memory> + #include <vespa/vespalib/util/runnable.h> #include <vespa/vespalib/util/thread.h> #include <vespa/vespalib/util/joinable.h> +#include <vbench/core/provider.h> +#include <vbench/core/handler.h> +#include <vbench/http/http_connection_pool.h> + +#include "request.h" + namespace vbench { /** @@ -28,12 +33,13 @@ private: HttpConnectionPool &_pool; Timer &_timer; - void run() override; + virtual void run() override; public: typedef std::unique_ptr<Worker> UP; Worker(Provider<Request> &provider, Handler<Request> &next, HttpConnectionPool &pool, Timer &timer); - void join() override { _thread.join(); } + virtual void join() override { _thread.join(); } }; } // namespace vbench + diff --git a/vdslib/src/tests/bucketdistribution/bucketdistributiontest.cpp b/vdslib/src/tests/bucketdistribution/bucketdistributiontest.cpp index 89879ef9d7a..589d7b66e96 100644 --- a/vdslib/src/tests/bucketdistribution/bucketdistributiontest.cpp +++ b/vdslib/src/tests/bucketdistribution/bucketdistributiontest.cpp @@ -1,4 +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 <vespa/log/log.h> +LOG_SETUP(".bucketdistributiontest"); #include <cppunit/extensions/HelperMacros.h> #include <vespa/vdslib/bucketdistribution.h> @@ -7,6 +10,8 @@ using namespace vdslib; class BucketDistributionTest : public CppUnit::TestFixture { public: + void setUp() override { } + void tearDown() override { } void testDistribution(); void testNumBucketBits(); @@ -24,6 +29,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(BucketDistributionTest); void BucketDistributionTest::testDistribution() { + LOG(info, "testDistribution"); const uint32_t expected4[] = { 10, 11, 9, 6, 4, 8, 14, 1, 13, 2, 12, 3, 5, 7, 15, 0 }; assertDistribution(16, 4, expected4); diff --git a/vdslib/src/tests/testrunner.cpp b/vdslib/src/tests/testrunner.cpp index 0c5dcd1d00a..fef61af9a17 100644 --- a/vdslib/src/tests/testrunner.cpp +++ b/vdslib/src/tests/testrunner.cpp @@ -1,12 +1,13 @@ // 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/log/log.h> #include <vespa/vdstestlib/cppunit/cppunittestrunner.h> -#include <vespa/log/log.h> LOG_SETUP("vdslibcppunittestrunner"); int -main(int argc, const char *argv[]) +main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/vdslib/src/tests/thread/taskschedulertest.cpp b/vdslib/src/tests/thread/taskschedulertest.cpp index a48f9d20214..22529a9f37a 100644 --- a/vdslib/src/tests/thread/taskschedulertest.cpp +++ b/vdslib/src/tests/thread/taskschedulertest.cpp @@ -1,5 +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/thread/taskscheduler.h> #include <vespa/vdstestlib/cppunit/macros.h> diff --git a/vdstestlib/src/tests/cppunit/testrunner.cpp b/vdstestlib/src/tests/cppunit/testrunner.cpp index c25bee698d5..1ba7be7790e 100644 --- a/vdstestlib/src/tests/cppunit/testrunner.cpp +++ b/vdstestlib/src/tests/cppunit/testrunner.cpp @@ -1,8 +1,9 @@ // 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/vdstestlib/cppunit/cppunittestrunner.h> -int main(int argc, const char *argv[]) +int main(int argc, char **argv) { vdstestlib::CppUnitTestRunner testRunner; return testRunner.run(argc, argv); diff --git a/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp b/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp index 73f6f3cc600..e00815241f0 100644 --- a/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp +++ b/vdstestlib/src/tests/dirconfig/dirconfigtest.cpp @@ -1,10 +1,15 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/testkit/testapp.h> -#include <vespa/vespalib/util/exceptions.h> +#include <vespa/fastos/fastos.h> #include <vespa/vdstestlib/cppunit/dirconfig.h> + #include <fstream> #include <iostream> +#include <vespa/log/log.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/exceptions.h> + +LOG_SETUP("dirconfig_test"); using namespace vdstestlib; diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.cpp b/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.cpp index fb692bd8e8f..7af156bbc2a 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.cpp +++ b/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.cpp @@ -1,9 +1,11 @@ // 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/vdstestlib/cppunit/cppunittestrunner.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <cppunit/ui/text/TestRunner.h> +#include <cppunit/TestSuite.h> #include <cppunit/TextTestProgressListener.h> #include <vespa/log/log.h> #include <iostream> @@ -20,7 +22,7 @@ namespace { std::vector<std::string> _wanted; bool _includeStressTests; - WantedTestList(int argc, const char *argv[], + WantedTestList(int argc, const char * const * argv, bool includeStressTests) : _wanted(), _includeStressTests(includeStressTests) @@ -64,7 +66,7 @@ namespace { return (s[s.size() - 1] == '$'); } - bool include(const std::string& name) const override { + virtual bool include(const std::string& name) const override { if ((name.find("stress") != std::string::npos || name.find("Stress") != std::string::npos) && !_includeStressTests) @@ -88,11 +90,11 @@ namespace { struct LogHook : public CppUnit::TextTestProgressListener::TestStartHook { std::string lastTest; - void startedTest(const std::string& testName) override { + virtual void startedTest(const std::string& testName) override { LOG(info, "Starting test: %s", testName.c_str()); lastTest = testName; } - void stoppedTest() override { + virtual void stoppedTest() override { LOG(info, "Stopped test: %s", lastTest.c_str()); } }; @@ -110,7 +112,7 @@ CppUnitTestRunner::CppUnitTestRunner() } int -CppUnitTestRunner::run(int argc, const char *argv[]) +CppUnitTestRunner::run(int argc, const char * const * argv) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry& registry( diff --git a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.h b/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.h index 204cfff0cb8..e8ee1700927 100644 --- a/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.h +++ b/vdstestlib/src/vespa/vdstestlib/cppunit/cppunittestrunner.h @@ -50,7 +50,7 @@ public: CppUnitTestRunner(); void listTests(const CppUnit::TestSuite *tests); - int run(int argc, const char * argv[]); + int run(int argc, const char * const * argv); }; diff --git a/vespaclient/src/vespa/vespaclient/spoolmaster/application.h b/vespaclient/src/vespa/vespaclient/spoolmaster/application.h index 2a20dd1b290..87f628e631c 100644 --- a/vespaclient/src/vespa/vespaclient/spoolmaster/application.h +++ b/vespaclient/src/vespa/vespaclient/spoolmaster/application.h @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/fastos/app.h> #include <string> #include <vector> +#include <vespa/fastos/app.h> namespace spoolmaster { /** @@ -23,9 +23,19 @@ private: bool findOutboxes(); void moveLinks(); public: + /** + * Constructs a new spoolmaster object. + */ Application(); - ~Application(); + + /** + * Destructor. Frees any allocated resources. + */ + virtual ~Application(); + + // Implements FastOS_Application. int Main() override; }; } + diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.h b/vespaclient/src/vespa/vespaclient/vespadoclocator/application.h index fdb4129a188..2e50ffde2c0 100644 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.h +++ b/vespaclient/src/vespa/vespaclient/vespadoclocator/application.h @@ -17,6 +17,7 @@ private: bool printDocumentLocation(Locator &locator, const std::string &docId); public: + // Implements FastOS_Application. int Main() override; }; diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.h b/vespaclient/src/vespa/vespaclient/vesparoute/application.h index e77b70f1454..e7eefb7f16d 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.h +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.h @@ -64,9 +64,13 @@ private: std::vector<std::string> &oos, std::set<std::string> &errors) const; public: + /** Null member variables. */ Application(); ~Application(); + + // Inherit doc from FastOS_Application. int Main() override; }; } + diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/mynetwork.h b/vespaclient/src/vespa/vespaclient/vesparoute/mynetwork.h index 4c50ec9cb38..f9737d1de9a 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/mynetwork.h +++ b/vespaclient/src/vespa/vespaclient/vesparoute/mynetwork.h @@ -21,7 +21,11 @@ public: // Overrides RPCNetwork. bool allocServiceAddress(mbus::RoutingNode &recipient) override; + + // Overrides RPCNetwork. void freeServiceAddress(mbus::RoutingNode &recipient) override; + + // Overrides RPCNetwork. void send(const mbus::Message &msg, const std::vector<mbus::RoutingNode*> &recipients) override; /** @@ -39,3 +43,4 @@ public: */ void removeNodes(std::vector<mbus::RoutingNode*> &nodes); }; + diff --git a/vespalib/src/vespa/vespalib/util/closure.h b/vespalib/src/vespa/vespalib/util/closure.h index a494c8d97df..81ea8430609 100644 --- a/vespalib/src/vespa/vespalib/util/closure.h +++ b/vespalib/src/vespa/vespalib/util/closure.h @@ -102,7 +102,9 @@ class Closure0_2 : public Closure0<R> { T1 _arg1; T2 _arg2; - R call() override { return _func(std::move(_arg1), std::move(_arg2)); } + virtual R call() override + { return _func(std::move(_arg1), std::move(_arg2)); } + public: Closure0_2(Func func, T1 &&arg1, T2 &&arg2) : _func(func), _arg1(std::move(arg1)), _arg2(std::move(arg2)) {} @@ -118,7 +120,8 @@ class Closure0_3 : public Closure0<R> { T2 _arg2; T3 _arg3; - R call() override { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3)); } + virtual R call() override + { return _func(std::move(_arg1), std::move(_arg2), std::move(_arg3)); } public: Closure0_3(Func func, T1 &&arg1, T2 &&arg2, T3 &&arg3) diff --git a/vespalib/src/vespa/vespalib/util/exception.h b/vespalib/src/vespa/vespalib/util/exception.h index 1ea1a9e5e61..af2f1bc225a 100644 --- a/vespalib/src/vespa/vespalib/util/exception.h +++ b/vespalib/src/vespa/vespalib/util/exception.h @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/macro.h> #include <vespa/vespalib/util/error.h> #include <vespa/vespalib/util/stringfmt.h> +#include <string> #include <exception> #define VESPALIB_EXCEPTION_USEBACKTRACES diff --git a/vespalog/src/logger/llreader.h b/vespalog/src/logger/llreader.h index 70b28d3996a..27b39d23df7 100644 --- a/vespalog/src/logger/llreader.h +++ b/vespalog/src/logger/llreader.h @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include <stdexcept> +#include <vespa/log/log.h> +#include <vespa/log/log-target.h> #include <vespa/log/llparser.h> -#include <stdexcept> namespace ns_log { @@ -16,6 +18,7 @@ public: const char *what() const throw() override { return _string; } }; + class InputBuf { private: diff --git a/vespalog/src/test/threads/testthreads.cpp b/vespalog/src/test/threads/testthreads.cpp index a708777f350..515fa10c11f 100644 --- a/vespalog/src/test/threads/testthreads.cpp +++ b/vespalog/src/test/threads/testthreads.cpp @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/app.h> -#include <vespa/fastos/time.h> +#include <vespa/fastos/fastos.h> #include <vespa/log/log.h> #include <iostream> +#include <string> using std::string; @@ -15,7 +15,7 @@ class FileThread : public FastOS_Runnable string _file; public: FileThread(string file) : _done(false), _file(file) {} - void Run(FastOS_ThreadInterface *thread, void *arg) override; + virtual void Run(FastOS_ThreadInterface *thread, void *arg) override; void stop() {_done = true; } }; @@ -25,10 +25,13 @@ class LoggerThread : public FastOS_Runnable public: bool _useLogBuffer; LoggerThread() : _done(false), _useLogBuffer(false) {} - void Run(FastOS_ThreadInterface *thread, void *arg) override; + virtual void Run(FastOS_ThreadInterface *thread, void *arg) override; void stop() {_done = true; } }; + + + void FileThread::Run(FastOS_ThreadInterface *, void *) { diff --git a/vespamalloc/src/tests/allocfree/allocfree.cpp b/vespamalloc/src/tests/allocfree/allocfree.cpp index 0806d3a8453..cdb471e35d2 100644 --- a/vespamalloc/src/tests/allocfree/allocfree.cpp +++ b/vespamalloc/src/tests/allocfree/allocfree.cpp @@ -19,7 +19,7 @@ public: FreeWorker(uint32_t maxQueue, bool inverse) : Consumer (maxQueue, inverse) {} private: - void consume(void * p) override { free(p); } + virtual void consume(void * p) override { free(p); } }; //----------------------------------------------------------------------------- @@ -30,7 +30,7 @@ public: : Producer(cnt, target), _size(size) {} private: uint32_t _size; - void * produce() override { return malloc(_size); } + virtual void * produce() override { return malloc(_size); } }; //----------------------------------------------------------------------------- @@ -41,9 +41,8 @@ public: : ProducerConsumer(cnt, inverse), _size(size) { } private: uint32_t _size; - - void * produce() override { return malloc(_size); } - void consume(void * p) override { free(p); } + virtual void * produce() override { return malloc(_size); } + virtual void consume(void * p) override { free(p); } }; //----------------------------------------------------------------------------- diff --git a/vespamalloc/src/tests/allocfree/linklist.cpp b/vespamalloc/src/tests/allocfree/linklist.cpp index ff33fca4661..06acfa8df8a 100644 --- a/vespamalloc/src/tests/allocfree/linklist.cpp +++ b/vespamalloc/src/tests/allocfree/linklist.cpp @@ -61,7 +61,7 @@ public: LinkIn(List::AtomicHeadPtr & list, uint32_t maxQueue, bool inverse); private: List::AtomicHeadPtr & _head; - void consume(void * p) override { + virtual void consume(void * p) override { List * l((List *) p); if ( ! ((l >= &globalList[0]) && (l < &globalList[NumBlocks]))) { abort(); } List::linkIn(_head, l, l); @@ -82,7 +82,7 @@ public: : Producer(cnt, target), _head(list) {} private: List::AtomicHeadPtr & _head; - void * produce() override { + virtual void * produce() override { void *p = List::linkOut(_head); List *l((List *)p); if ( ! ((l >= &globalList[0]) && (l < &globalList[NumBlocks]))) { abort(); } @@ -98,13 +98,13 @@ public: : ProducerConsumer(cnt, inverse), _head(list) { } private: List::AtomicHeadPtr & _head; - void * produce() override { + virtual void * produce() override { void *p = List::linkOut(_head); List *l((List *)p); if ( !((l >= &globalList[0]) && (l < &globalList[NumBlocks]))) { abort(); } return p; } - void consume(void * p) override { + virtual void consume(void * p) override { List * l((List *) p); if ( !((l >= &globalList[0]) && (l < &globalList[NumBlocks]))) { abort(); } List::linkIn(_head, l, l); diff --git a/vespamalloc/src/tests/doubledelete/expectsignal.cpp b/vespamalloc/src/tests/doubledelete/expectsignal.cpp index 2811da01c09..3237339fb97 100644 --- a/vespamalloc/src/tests/doubledelete/expectsignal.cpp +++ b/vespamalloc/src/tests/doubledelete/expectsignal.cpp @@ -9,8 +9,7 @@ class Test : public TestApp public: int Main() override; private: - bool useProcessStarter() const override { return true; } - + virtual bool useProcessStarter() const override { return true; } }; int Test::Main() diff --git a/vespamalloc/src/tests/test.cpp b/vespamalloc/src/tests/test.cpp index 960114b1bc1..9f5bd826a6b 100644 --- a/vespamalloc/src/tests/test.cpp +++ b/vespamalloc/src/tests/test.cpp @@ -1,5 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - +#include <stdio.h> +#include <stdlib.h> #include <vespa/fastos/thread.h> namespace vespamalloc { diff --git a/vespamalloc/src/tests/thread/racemanythreads.cpp b/vespamalloc/src/tests/thread/racemanythreads.cpp index acfefceee15..8f366acea3a 100644 --- a/vespamalloc/src/tests/thread/racemanythreads.cpp +++ b/vespamalloc/src/tests/thread/racemanythreads.cpp @@ -1,7 +1,17 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/testkit/testapp.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <pthread.h> +#include <stdint.h> +#include <errno.h> #include <vespa/vespalib/util/atomic.h> +#include <sys/resource.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/log/log.h> + +LOG_SETUP("thread_test"); using namespace vespalib; diff --git a/vespamalloc/src/tests/thread/thread.cpp b/vespamalloc/src/tests/thread/thread.cpp index 9053a435d11..6261a0f8eb6 100644 --- a/vespamalloc/src/tests/thread/thread.cpp +++ b/vespamalloc/src/tests/thread/thread.cpp @@ -1,7 +1,17 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/vespalib/testkit/testapp.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <pthread.h> +#include <stdint.h> +#include <errno.h> #include <vespa/vespalib/util/atomic.h> +#include <sys/resource.h> +#include <vespa/vespalib/testkit/testapp.h> +#include <vespa/log/log.h> + +LOG_SETUP("thread_test"); using namespace vespalib; @@ -11,7 +21,7 @@ public: ~Test(); int Main() override; private: - bool useIPCHelper() const override { return true; } + virtual bool useIPCHelper() const override { return true; } }; Test::~Test() |