diff options
128 files changed, 707 insertions, 685 deletions
diff --git a/build_settings.cmake b/build_settings.cmake index 417fd2fa695..a6be947f888 100644 --- a/build_settings.cmake +++ b/build_settings.cmake @@ -53,12 +53,15 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") endif() # Find ccache and use it if it is found -find_program(CCACHE_EXECUTABLE ccache) +find_program(CCACHE_EXECUTABLE time) if(CCACHE_EXECUTABLE) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_EXECUTABLE}) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_EXECUTABLE}) endif() +set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE /usr/bin/time) +set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK /usr/bin/time) + # Check for valgrind and set flags find_program(VALGRIND_EXECUTABLE valgrind) if(VALGRIND_EXECUTABLE) diff --git a/config/src/tests/configgen/configgen.cpp b/config/src/tests/configgen/configgen.cpp index bd8aea0a89a..25915293310 100644 --- a/config/src/tests/configgen/configgen.cpp +++ b/config/src/tests/configgen/configgen.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 <vespa/log/log.h> -LOG_SETUP("configgen"); + #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/config/config.h> +#include <vespa/config/helper/configgetter.hpp> #include "config-motd.h" using namespace config; diff --git a/config/src/tests/configmanager/configmanager.cpp b/config/src/tests/configmanager/configmanager.cpp index 38d6aa85065..d0e8f5444e0 100644 --- a/config/src/tests/configmanager/configmanager.cpp +++ b/config/src/tests/configmanager/configmanager.cpp @@ -1,11 +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("configmanager"); + #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/noncopyable.hpp> #include <vespa/config/common/configmanager.h> #include <vespa/config/common/exceptions.h> +#include <vespa/config/common/timingvalues.h> #include <vespa/config/subscription/sourcespec.h> #include <vespa/config/raw/rawsource.h> #include "config-my.h" @@ -41,7 +40,6 @@ namespace { { _data->numGetConfig++; if (_data->respond) { - LOG(info, "put into holder"); _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(), true, _data->generation))); } } diff --git a/config/src/tests/getconfig/getconfig.cpp b/config/src/tests/getconfig/getconfig.cpp index 77e2f57dbc8..4ffd8b5e806 100644 --- a/config/src/tests/getconfig/getconfig.cpp +++ b/config/src/tests/getconfig/getconfig.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 <vespa/config/config.h> +#include <vespa/config/helper/configgetter.hpp> #include <vespa/config/raw/rawsource.h> #include "config-my.h" diff --git a/config/src/tests/print/print.cpp b/config/src/tests/print/print.cpp index 761a3b32f73..b8b2d7cd5ef 100644 --- a/config/src/tests/print/print.cpp +++ b/config/src/tests/print/print.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/vespalib/testkit/test_kit.h> #include <vespa/config/config.h> #include <vespa/config/print.h> #include <vespa/config/print/fileconfigreader.h> #include <vespa/config/print/istreamconfigreader.h> +#include <vespa/config/helper/configgetter.hpp> #include "config-my.h" #include "config-motd.h" diff --git a/config/src/vespa/config/common/timingvalues.h b/config/src/vespa/config/common/timingvalues.h index 244e80540c4..2f2c5842c82 100644 --- a/config/src/vespa/config/common/timingvalues.h +++ b/config/src/vespa/config/common/timingvalues.h @@ -3,6 +3,7 @@ #pragma once #include <cstdint> + namespace config { static const uint64_t DEFAULT_NEXTCONFIG_TIMEOUT = 55000; diff --git a/config/src/vespa/config/helper/configgetter.h b/config/src/vespa/config/helper/configgetter.h index ee0cba1988c..da683fe542b 100644 --- a/config/src/vespa/config/helper/configgetter.h +++ b/config/src/vespa/config/helper/configgetter.h @@ -1,14 +1,15 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/config/config.h> + +#include <vespa/config/subscription/sourcespec.h> #include <vespa/config/common/timingvalues.h> -#include <vespa/config/subscription/confighandle.h> -#include <vespa/vespalib/util/threadstackexecutor.h> #include "ifetchercallback.h" namespace config { +class IConfigContext; + /** * A config fetcher subscribes to a config and notifies a callback when done */ @@ -17,13 +18,11 @@ class ConfigGetter { public: static std::unique_ptr<ConfigType> getConfig(int64_t &generation, const std::string & configId, const SourceSpec & spec = ServerSpec()); - static std::unique_ptr<ConfigType> getConfig(int64_t &generation, const std::string & configId, const IConfigContext::SP & context, uint64_t subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT); + static std::unique_ptr<ConfigType> getConfig(int64_t &generation, const std::string & configId, const std::shared_ptr<IConfigContext> & context, uint64_t subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT); static std::unique_ptr<ConfigType> getConfig(const std::string & configId, const SourceSpec & spec = ServerSpec()); - static std::unique_ptr<ConfigType> getConfig(const std::string & configId, const IConfigContext::SP & context, uint64_t subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT); + static std::unique_ptr<ConfigType> getConfig(const std::string & configId, const std::shared_ptr<IConfigContext> & context, uint64_t subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT); }; } // namespace config -#include "configgetter.hpp" - diff --git a/config/src/vespa/config/helper/configgetter.hpp b/config/src/vespa/config/helper/configgetter.hpp index 5452908a144..b0612768aae 100644 --- a/config/src/vespa/config/helper/configgetter.hpp +++ b/config/src/vespa/config/helper/configgetter.hpp @@ -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 "configgetter.h" +#include <vespa/config/subscription/configsubscriber.h> namespace config { template <typename ConfigType> diff --git a/config/src/vespa/config/subscription/configinstancespec.h b/config/src/vespa/config/subscription/configinstancespec.h index 0ba861eb90c..a75f7eea3de 100644 --- a/config/src/vespa/config/subscription/configinstancespec.h +++ b/config/src/vespa/config/subscription/configinstancespec.h @@ -3,6 +3,7 @@ #pragma once #include "sourcespec.h" +#include <vespa/config/common/configkey.h> #include <vespa/vespalib/stllike/asciistream.h> namespace config { @@ -14,7 +15,7 @@ class ConfigInstanceSpec : public SourceSpec { public: ConfigInstanceSpec(const ConfigInstance & instance); - SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const; + std::unique_ptr<SourceFactory> createSourceFactory(const TimingValues & timingValues) const; private: const ConfigKey _key; vespalib::asciistream _buffer; diff --git a/config/src/vespa/config/subscription/configsubscriptionset.cpp b/config/src/vespa/config/subscription/configsubscriptionset.cpp index 91635a33222..2884a1a4507 100644 --- a/config/src/vespa/config/subscription/configsubscriptionset.cpp +++ b/config/src/vespa/config/subscription/configsubscriptionset.cpp @@ -2,8 +2,8 @@ #include "configsubscriptionset.h" #include <vespa/config/common/exceptions.h> +#include <vespa/config/common/misc.h> #include <thread> -#include <chrono> #include <vespa/log/log.h> LOG_SETUP(".config.subscription.configsubscriptionset"); diff --git a/config/src/vespa/config/subscription/configsubscriptionset.h b/config/src/vespa/config/subscription/configsubscriptionset.h index 3c425baf26c..ec696a6e3ac 100644 --- a/config/src/vespa/config/subscription/configsubscriptionset.h +++ b/config/src/vespa/config/subscription/configsubscriptionset.h @@ -1,15 +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 <memory> -#include <map> + #include <vespa/config/common/iconfigholder.h> #include <vespa/config/common/configcontext.h> #include "confighandle.h" #include "subscriptionid.h" #include "configsubscription.h" #include "configprovider.h" -#include <vespa/vespalib/util/sync.h> -#include <vespa/vespalib/util/priority_queue.h> namespace config { diff --git a/config/src/vespa/config/subscription/sourcespec.cpp b/config/src/vespa/config/subscription/sourcespec.cpp index 2b4c71b8c21..5537533c05f 100644 --- a/config/src/vespa/config/subscription/sourcespec.cpp +++ b/config/src/vespa/config/subscription/sourcespec.cpp @@ -6,18 +6,19 @@ #include <vespa/config/file/filesourcefactory.h> #include <vespa/config/frt/frtsourcefactory.h> #include <vespa/config/frt/frtconnectionpool.h> -#include <vespa/config/frt/protocol.h> -#include <vespa/config/frt/connectionfactory.h> #include <vespa/config/set/configsetsourcefactory.h> #include <vespa/config/set/configinstancesourcefactory.h> #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/config/print/asciiconfigwriter.h> -#include <vespa/log/log.h> -LOG_SETUP(".config.subscription.sourcespec"); namespace config { +class BuilderMap : public std::map<ConfigKey, ConfigInstance *> { + using Parent = std::map<ConfigKey, ConfigInstance *>; + using Parent::Parent; +}; + RawSpec::RawSpec(const vespalib::string & config) : _config(config) { diff --git a/config/src/vespa/config/subscription/sourcespec.h b/config/src/vespa/config/subscription/sourcespec.h index c6cc8ed38c5..d58b8f9a7f5 100644 --- a/config/src/vespa/config/subscription/sourcespec.h +++ b/config/src/vespa/config/subscription/sourcespec.h @@ -2,16 +2,15 @@ #pragma once -#include <vespa/vespalib/stllike/hash_fun.h> #include <vespa/vespalib/stllike/string.h> -#include <vespa/config/common/sourcefactory.h> -#include <vespa/config/common/timingvalues.h> #include <vespa/config/common/compressiontype.h> -#include <vespa/config/set/configsetsourcefactory.h> -#include <vespa/config/configgen/configinstance.h> namespace config { +class ConfigInstance; +class SourceFactory; +class TimingValues; + typedef vespalib::string SourceSpecKey; /** @@ -21,7 +20,8 @@ typedef vespalib::string SourceSpecKey; class SourceSpec { public: - typedef std::unique_ptr<SourceSpec> UP; /// Convenience typedef + using SourceFactorySP = std::unique_ptr<SourceFactory>; + using UP = std::unique_ptr<SourceSpec>; /// Convenience typedef /** * Creates a source factory from which to create config sources for new @@ -34,7 +34,7 @@ public: * @param timingValues Timing values to be used for this source. * @return An std::unique_ptr<Source> that can be used to ask for config. */ - virtual SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const = 0; + virtual SourceFactorySP createSourceFactory(const TimingValues & timingValues) const = 0; virtual ~SourceSpec() { } }; @@ -53,7 +53,7 @@ public: RawSpec(const vespalib::string & config); // Implements SourceSpec - SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const; + SourceFactorySP createSourceFactory(const TimingValues & timingValues) const; /** * Returns the string representation of this config. @@ -88,7 +88,7 @@ public: const vespalib::string & getFileName() const { return _fileName; } // Implements SourceSpec - SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const; + SourceFactorySP createSourceFactory(const TimingValues & timingValues) const; private: void verifyName(const vespalib::string & fileName); vespalib::string _fileName; @@ -116,7 +116,7 @@ public: const vespalib::string & getDirName() const { return _dirName; } // Implements SourceSpec - SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const; + SourceFactorySP createSourceFactory(const TimingValues & timingValues) const; private: vespalib::string _dirName; }; @@ -153,7 +153,7 @@ public: ServerSpec(const vespalib::string & hostSpec); // Implements SourceSpec - virtual SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const; + virtual SourceFactorySP createSourceFactory(const TimingValues & timingValues) const; /** * Add another host to this source spec, allowing failover. @@ -205,15 +205,16 @@ private: * A ConfigSet gives the ability to serve config from a set of ConfigInstance * builders. */ + +class BuilderMap; + class ConfigSet : public SourceSpec { public: /// Constructs a new empty ConfigSet ConfigSet(); - /// Mapping of config keys to builders - typedef ConfigSetSourceFactory::BuilderMap BuilderMap; - typedef ConfigSetSourceFactory::BuilderMapSP BuilderMapSP; + using BuilderMapSP = std::shared_ptr<BuilderMap>; /** * Add a builder to serve config from. The builder must be of a * 'ConfigType'Builder, and the configId must be the id to which you want to @@ -227,7 +228,7 @@ public: void addBuilder(const vespalib::string & configId, ConfigInstance * builder); // Implements SourceSpec - SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const; + SourceFactorySP createSourceFactory(const TimingValues & timingValues) const; private: BuilderMapSP _builderMap; }; diff --git a/configutil/src/lib/modelinspect.cpp b/configutil/src/lib/modelinspect.cpp index 69fd2b804df..fb728caced0 100644 --- a/configutil/src/lib/modelinspect.cpp +++ b/configutil/src/lib/modelinspect.cpp @@ -1,13 +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 <ctype.h> -#include <vespa/log/log.h> -LOG_SETUP("vespa-model-inspect"); #include <iostream> #include "modelinspect.h" -#include <set> #include <lib/tags.h> +#include <vespa/config/helper/configgetter.hpp> + using configdefinitions::tagsContain; using configdefinitions::upcase; @@ -20,8 +17,7 @@ ModelInspect::ModelInspect(Flags flags, const config::ConfigUri uri, std::ostrea } try { - _cfg = config::ConfigGetter<cloud::config::ModelConfig>::getConfig(uri.getConfigId(), - uri.getContext()); + _cfg = config::ConfigGetter<cloud::config::ModelConfig>::getConfig(uri.getConfigId(), uri.getContext()); } catch(config::ConfigRuntimeException &e) { std::cerr << e.getMessage() << "\n"; } diff --git a/documentapi/src/tests/policies/policies_test.cpp b/documentapi/src/tests/policies/policies_test.cpp index ea82c43a596..ba5cc280bce 100644 --- a/documentapi/src/tests/policies/policies_test.cpp +++ b/documentapi/src/tests/policies/policies_test.cpp @@ -21,6 +21,9 @@ #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/routing/routingcontext.h> +#include <vespa/messagebus/routing/routingnode.h> +#include <vespa/messagebus/routing/routingtable.h> +#include <vespa/messagebus/routing/policydirective.h> #include <vespa/messagebus/testlib/testserver.h> #include <vespa/vdslib/container/mutabledocumentlist.h> #include <vespa/vdslib/state/clusterstate.h> diff --git a/documentapi/src/vespa/documentapi/loadtypes/loadtypeset.cpp b/documentapi/src/vespa/documentapi/loadtypes/loadtypeset.cpp index 20b01ae59c9..4f0f3508d20 100644 --- a/documentapi/src/vespa/documentapi/loadtypes/loadtypeset.cpp +++ b/documentapi/src/vespa/documentapi/loadtypes/loadtypeset.cpp @@ -4,6 +4,8 @@ #include <vespa/config-load-type.h> #include <vespa/config/config.h> #include <vespa/vespalib/stllike/hash_map.hpp> +#include <vespa/config/helper/configgetter.hpp> + namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp index 5819e5f6cd3..61c6648aee6 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp @@ -1,20 +1,20 @@ // 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(".documentrouteselectorpolicy"); #include "documentrouteselectorpolicy.h" #include <vespa/document/bucket/bucketidfactory.h> #include <vespa/document/select/parser.h> #include <vespa/documentapi/messagebus/documentprotocol.h> #include <vespa/documentapi/messagebus/messages/batchdocumentupdatemessage.h> -#include <vespa/documentapi/messagebus/messages/feedmessage.h> #include <vespa/documentapi/messagebus/messages/multioperationmessage.h> #include <vespa/documentapi/messagebus/messages/putdocumentmessage.h> #include <vespa/documentapi/messagebus/messages/updatedocumentmessage.h> #include <vespa/documentapi/messagebus/messages/documentignoredreply.h> #include <vespa/messagebus/emptyreply.h> -#include <vespa/messagebus/routing/routingcontext.h> +#include <vespa/messagebus/routing/routingtable.h> +#include <vespa/messagebus/messagebus.h> + +#include <vespa/log/log.h> +LOG_SETUP(".documentrouteselectorpolicy"); using document::select::Result; diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.cpp index a4cd9f2d25b..6f4c17431bf 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.cpp @@ -1,16 +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(".localservicepolicy"); +#include "localservicepolicy.h" #include <vespa/documentapi/messagebus/documentprotocol.h> -#include <vespa/messagebus/errorcode.h> -#include <vespa/messagebus/routing/route.h> -#include <vespa/messagebus/routing/routingcontext.h> #include <vespa/messagebus/routing/verbatimdirective.h> +#include <vespa/messagebus/messagebus.h> #include <vespa/vespalib/util/hashmap.h> #include <vespa/vespalib/util/stringfmt.h> -#include "localservicepolicy.h" +#include <vespa/log/log.h> +LOG_SETUP(".localservicepolicy"); namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.h index ccdc67c9291..49b8d195740 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/localservicepolicy.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 <vespa/documentapi/common.h> #include <vespa/messagebus/routing/hop.h> #include <vespa/messagebus/routing/iroutingpolicy.h> -#include <string> -#include <vector> #include <vespa/vespalib/util/sync.h> +#include <vector> +#include <map> namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.cpp index 634dd9d4d48..5e8a6856f9e 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.cpp @@ -1,16 +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(".subsetservicepolicy"); +#include "subsetservicepolicy.h" #include <vespa/documentapi/messagebus/documentprotocol.h> -#include <vespa/messagebus/errorcode.h> -#include <vespa/messagebus/routing/route.h> -#include <vespa/messagebus/routing/routingcontext.h> #include <vespa/messagebus/routing/verbatimdirective.h> +#include <vespa/messagebus/messagebus.h> #include <vespa/vespalib/util/hashmap.h> #include <vespa/vespalib/util/stringfmt.h> -#include "subsetservicepolicy.h" +#include <vespa/log/log.h> +LOG_SETUP(".subsetservicepolicy"); namespace documentapi { diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.h index 5103904df65..03f5165eed3 100644 --- a/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.h +++ b/documentapi/src/vespa/documentapi/messagebus/policies/subsetservicepolicy.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 <vespa/documentapi/common.h> #include <vespa/messagebus/routing/hop.h> #include <vespa/messagebus/routing/iroutingpolicy.h> -#include <string> +#include <vespa/vespalib/util/sync.h> #include <vector> +#include <map> namespace documentapi { diff --git a/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp b/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp index 26f12cba578..516d846790f 100644 --- a/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp +++ b/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp @@ -1,11 +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 "filedistributorrpc.h" - -#include <boost/optional.hpp> -#include <vespa/log/log.h> -LOG_SETUP(".filedistributorrpc"); +#include "filedistributorrpc.h" +#include <mutex> #include <vespa/fnet/frt/frt.h> #include <vespa/frtstream/frtserverstream.h> @@ -13,6 +9,8 @@ LOG_SETUP(".filedistributorrpc"); #include "fileprovider.h" #include <vespa/filedistribution/model/filedbmodel.h> +#include <vespa/log/log.h> +LOG_SETUP(".filedistributorrpc"); using filedistribution::FileDistributorRPC; using filedistribution::FileProvider; diff --git a/fnet/src/tests/connect_thread/connect_thread_test.cpp b/fnet/src/tests/connect_thread/connect_thread_test.cpp index f8492d147a6..b5304cf9b9e 100644 --- a/fnet/src/tests/connect_thread/connect_thread_test.cpp +++ b/fnet/src/tests/connect_thread/connect_thread_test.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/fnet/connect_thread.h> +#include <vespa/fnet/ext_connectable.h> struct MyConn : public fnet::ExtConnectable { bool connected = false; diff --git a/fnet/src/vespa/fnet/connect_thread.h b/fnet/src/vespa/fnet/connect_thread.h index 9782fa50a75..e963187f99d 100644 --- a/fnet/src/vespa/fnet/connect_thread.h +++ b/fnet/src/vespa/fnet/connect_thread.h @@ -3,6 +3,7 @@ #pragma once +#include "ext_connectable.h" #include <vespa/vespalib/util/arrayqueue.hpp> #include <thread> #include <mutex> @@ -11,17 +12,6 @@ namespace fnet { /** - * Interface implemented by objects that want to perform synchronous - * connect initiated by an external thread. - **/ -class ExtConnectable { -protected: - virtual ~ExtConnectable() {} -public: - virtual void ext_connect() = 0; -}; - -/** * An object encapsulating a thread responsible for doing synchronous * external connect. **/ diff --git a/fnet/src/vespa/fnet/connection.h b/fnet/src/vespa/fnet/connection.h index 7b4ba82b90c..16ef66f0cf4 100644 --- a/fnet/src/vespa/fnet/connection.h +++ b/fnet/src/vespa/fnet/connection.h @@ -2,8 +2,7 @@ #pragma once -#include "connect_thread.h" - +#include "ext_connectable.h" /** * Interface implemented by objects that want to perform connection * cleanup. Use the SetCleanupHandler method to register with a diff --git a/fnet/src/vespa/fnet/ext_connectable.h b/fnet/src/vespa/fnet/ext_connectable.h new file mode 100644 index 00000000000..4b1c6e1629c --- /dev/null +++ b/fnet/src/vespa/fnet/ext_connectable.h @@ -0,0 +1,17 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +namespace fnet { +/** + * Interface implemented by objects that want to perform synchronous + * connect initiated by an external thread. + **/ +class ExtConnectable { +protected: + virtual ~ExtConnectable() {} +public: + virtual void ext_connect() = 0; +}; + +} diff --git a/fnet/src/vespa/fnet/transport.cpp b/fnet/src/vespa/fnet/transport.cpp index f82819a49de..2eebc12c150 100644 --- a/fnet/src/vespa/fnet/transport.cpp +++ b/fnet/src/vespa/fnet/transport.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/fastos.h> -#include <vespa/fnet/fnet.h> + +#include "fnet.h" +#include "connect_thread.h" #include <vespa/vespalib/xxhash/xxhash.h> -#include <chrono> namespace { @@ -22,7 +22,7 @@ struct HashState { FNET_Transport::FNET_Transport(size_t num_threads) : _threads(), - _connect_thread() + _connect_thread(std::make_unique<fnet::ConnectThread>()) { assert(num_threads >= 1); for (size_t i = 0; i < num_threads; ++i) { @@ -30,6 +30,12 @@ FNET_Transport::FNET_Transport(size_t num_threads) } } +FNET_Transport::~FNET_Transport() { } + +void FNET_Transport::connect_later(fnet::ExtConnectable *conn) { + _connect_thread->connect_later(conn); +} + FNET_TransportThread * FNET_Transport::select_thread(const void *key, size_t key_len) const { diff --git a/fnet/src/vespa/fnet/transport.h b/fnet/src/vespa/fnet/transport.h index fee94c9d2a5..e3ef3edf4bc 100644 --- a/fnet/src/vespa/fnet/transport.h +++ b/fnet/src/vespa/fnet/transport.h @@ -2,7 +2,12 @@ #pragma once -#include "connect_thread.h" +#include "ext_connectable.h" + +namespace fnet { + class ConnectThread; + class ExtConnectable; +} /** * This class represents the transport layer and handles a collection @@ -16,7 +21,7 @@ private: using Threads = std::vector<Thread>; Threads _threads; - fnet::ConnectThread _connect_thread; + std::unique_ptr<fnet::ConnectThread> _connect_thread; public: /** @@ -27,13 +32,14 @@ public: * be called for single-threaded transports. **/ FNET_Transport(size_t num_threads = 1); + ~FNET_Transport(); /** * Calling this function gives away 1 reference to 'conn' and * ensures that the 'ext_connect' function will be called on it * from another thread some time in the future. **/ - void connect_later(fnet::ExtConnectable *conn) { _connect_thread.connect_later(conn); } + void connect_later(fnet::ExtConnectable *conn); /** * Select one of the underlying transport threads. The selection diff --git a/memfilepersistence/src/tests/tools/dumpslotfiletest.cpp b/memfilepersistence/src/tests/tools/dumpslotfiletest.cpp index 112f8840e72..fe56855a894 100644 --- a/memfilepersistence/src/tests/tools/dumpslotfiletest.cpp +++ b/memfilepersistence/src/tests/tools/dumpslotfiletest.cpp @@ -1,13 +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/config/subscription/configuri.h> #include <vespa/document/base/testdocrepo.h> #include <vespa/memfilepersistence/tools/dumpslotfile.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/util/programoptions_testutils.h> #include <tests/spi/memfiletestutils.h> - +#include <vespa/config/helper/configgetter.hpp> #include <vespa/document/config/config-documenttypes.h> namespace storage { diff --git a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp index 5afc70179b4..ff4c91026f2 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/common/environment.cpp @@ -4,7 +4,7 @@ #include "environment.h" #include <vespa/vespalib/util/random.h> #include <vespa/vespalib/util/vstringfmt.h> -#include <vespa/config/config.h> +#include <vespa/config/helper/configgetter.hpp> #include <vespa/vespalib/stllike/asciistream.h> using config::ConfigGetter; diff --git a/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp b/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp index 7b0954aaa5b..d415604991b 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/spi/memfilepersistenceprovider.cpp @@ -1,11 +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/document/fieldset/fieldsetrepo.h> #include <vespa/memfilepersistence/spi/memfilepersistenceprovider.h> #include <vespa/memfilepersistence/common/exceptions.h> #include <vespa/document/fieldvalue/document.h> #include <vespa/document/update/documentupdate.h> +#include <vespa/config/helper/configgetter.hpp> + #include <vespa/log/log.h> LOG_SETUP(".memfilepersistenceprovider"); diff --git a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp index a44aa81d3ab..1893dc041b2 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/tools/dumpslotfile.cpp @@ -1,25 +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 <vespa/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/document.h> -#include <vespa/log/log.h> #include <vespa/memfilepersistence/common/environment.h> -#include <vespa/memfilepersistence/device/devicemanager.h> #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 <string> -#include <vespa/persistence/spi/bucketinfo.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h> #include <vespa/storageframework/defaultimplementation/memory/nomemorymanager.h> #include <vespa/vespalib/util/programoptions.h> +#include <vespa/config/helper/configgetter.hpp> +#include <sstream> -LOG_SETUP(".vds.dumpslotfile"); using config::ConfigGetter; using document::DocumenttypesConfig; @@ -171,7 +168,6 @@ namespace { _compReg.setClock(_clock); _compReg.setMemoryManager(_memoryMan); _cache.reset(new MemFileCache(_compReg, _metrics._cache)); - LOG(debug, "Setting up document repo"); if (documentConfigId == 0) { _repo.reset(new DocumentTypeRepo(_docType)); } else { diff --git a/messagebus/src/tests/routingspec/routingspec.cpp b/messagebus/src/tests/routingspec/routingspec.cpp index d5317dc3bb0..32d235c0a11 100644 --- a/messagebus/src/tests/routingspec/routingspec.cpp +++ b/messagebus/src/tests/routingspec/routingspec.cpp @@ -1,7 +1,4 @@ // 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("routingspec_test"); #include <vespa/config/config.h> #include <vespa/messagebus/configagent.h> @@ -9,6 +6,8 @@ LOG_SETUP("routingspec_test"); #include <vespa/messagebus/routing/routingspec.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/messagebus/config-messagebus.h> +#include <vespa/config/helper/configgetter.hpp> + using namespace mbus; using namespace messagebus; diff --git a/messagebus/src/vespa/messagebus/context.h b/messagebus/src/vespa/messagebus/context.h index 087d41f8b80..359f32a35ec 100644 --- a/messagebus/src/vespa/messagebus/context.h +++ b/messagebus/src/vespa/messagebus/context.h @@ -2,8 +2,8 @@ #pragma once -#include <string.h> -#include <stdint.h> +#include <cstring> +#include <cstdint> namespace mbus { diff --git a/messagebus/src/vespa/messagebus/messagebus.cpp b/messagebus/src/vespa/messagebus/messagebus.cpp index c9067ef0aa4..f5a30c86d45 100644 --- a/messagebus/src/vespa/messagebus/messagebus.cpp +++ b/messagebus/src/vespa/messagebus/messagebus.cpp @@ -1,14 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/messagebus/routing/routingnode.h> -#include <vespa/messagebus/routing/routingspec.h> -#include <vespa/vespalib/util/exceptions.h> -#include <vespa/vespalib/util/vstringfmt.h> #include "messagebus.h" -#include "imessagehandler.h" +#include "messenger.h" #include "emptyreply.h" #include "errorcode.h" #include "sendproxy.h" +#include "protocolrepository.h" +#include <vespa/messagebus/network/inetwork.h> +#include <vespa/vespalib/util/exceptions.h> #include <vespa/log/log.h> LOG_SETUP(".messagebus"); @@ -61,9 +60,7 @@ public: _msn(msn), _done(done), _gate(gate) - { - // empty - } + { } ~ShutdownTask() { _gate.countDown(); @@ -88,8 +85,8 @@ MessageBus::MessageBus(INetwork &net, ProtocolSet protocols) : _lock("mbus::MessageBus::_lock", false), _routingTables(), _sessions(), - _protocolRepository(), - _msn(), + _protocolRepository(std::make_unique<ProtocolRepository>()), + _msn(std::make_unique<Messenger>()), _resender(), _maxPendingCount(0), _maxPendingSize(0), @@ -111,8 +108,8 @@ MessageBus::MessageBus(INetwork &net, const MessageBusParams ¶ms) : _lock("mbus::MessageBus::_lock", false), _routingTables(), _sessions(), - _protocolRepository(), - _msn(), + _protocolRepository(std::make_unique<ProtocolRepository>()), + _msn(std::make_unique<Messenger>()), _resender(), _maxPendingCount(params.getMaxPendingCount()), _maxPendingSize(params.getMaxPendingSize()), @@ -126,14 +123,14 @@ MessageBus::~MessageBus() { // all sessions must have been destroyed prior to this, // so no more traffic from clients - _msn.discardRecurrentTasks(); // no more traffic from recurrent tasks + _msn->discardRecurrentTasks(); // no more traffic from recurrent tasks _network.shutdown(); // no more traffic from network bool done = false; while (!done) { vespalib::Gate gate; - Messenger::ITask::UP task(new ShutdownTask(_network, _msn, done, gate)); - _msn.enqueue(std::move(task)); + Messenger::ITask::UP task(new ShutdownTask(_network, *_msn, done, gate)); + _msn->enqueue(std::move(task)); gate.await(); } } @@ -143,7 +140,7 @@ MessageBus::setup(const MessageBusParams ¶ms) { // Add all known protocols to the repository. for (uint32_t i = 0, len = params.getNumProtocols(); i < len; ++i) { - _protocolRepository.putProtocol(params.getProtocol(i)); + _protocolRepository->putProtocol(params.getProtocol(i)); } // Attach and start network. @@ -161,9 +158,9 @@ MessageBus::setup(const MessageBusParams ¶ms) _resender.reset(new Resender(retryPolicy)); Messenger::ITask::UP task(new ResenderTask(*_resender)); - _msn.addRecurrentTask(std::move(task)); + _msn->addRecurrentTask(std::move(task)); } - if (!_msn.start()) { + if (!_msn->start()) { throw vespalib::NetworkSetupFailureException("Failed to start messenger."); } } @@ -260,13 +257,13 @@ MessageBus::getRoutingPolicy(const string &protocolName, const string &policyName, const string &policyParam) { - return _protocolRepository.getRoutingPolicy(protocolName, policyName, policyParam); + return _protocolRepository->getRoutingPolicy(protocolName, policyName, policyParam); } void MessageBus::sync() { - _msn.sync(); + _msn->sync(); _network.sync(); // should not be necessary, as msn is intermediate } @@ -279,7 +276,7 @@ MessageBus::handleMessage(Message::UP msg) return; } SendProxy &proxy = *(new SendProxy(*this, _network, _resender.get())); // deletes self - _msn.deliverMessage(std::move(msg), proxy); + _msn->deliverMessage(std::move(msg), proxy); } bool @@ -301,20 +298,20 @@ MessageBus::setupRouting(const RoutingSpec &spec) LockGuard guard(_lock); std::swap(_routingTables, rtm); } - _protocolRepository.clearPolicyCache(); + _protocolRepository->clearPolicyCache(); return true; } IProtocol::SP MessageBus::getProtocol(const string &name) { - return _protocolRepository.getProtocol(name); + return _protocolRepository->getProtocol(name); } IProtocol::SP MessageBus::putProtocol(const IProtocol::SP & protocol) { - return _protocolRepository.putProtocol(protocol); + return _protocolRepository->putProtocol(protocol); } bool @@ -373,16 +370,16 @@ MessageBus::deliverMessage(Message::UP msg, const string &session) } if (msgHandler == NULL) { deliverError(std::move(msg), ErrorCode::UNKNOWN_SESSION, - vespalib::make_vespa_string( + vespalib::make_string( "Session '%s' does not exist.", session.c_str())); } else if (!checkPending(*msg)) { deliverError(std::move(msg), ErrorCode::SESSION_BUSY, - vespalib::make_vespa_string( + vespalib::make_string( "Session '%s' is busy, try again later.", session.c_str())); } else { - _msn.deliverMessage(std::move(msg), *msgHandler); + _msn->deliverMessage(std::move(msg), *msgHandler); } } @@ -400,7 +397,7 @@ MessageBus::deliverError(Message::UP msg, uint32_t errCode, const string &errMsg void MessageBus::deliverReply(Reply::UP reply, IReplyHandler &handler) { - _msn.deliverReply(std::move(reply), handler); + _msn->deliverReply(std::move(reply), handler); } const string diff --git a/messagebus/src/vespa/messagebus/messagebus.h b/messagebus/src/vespa/messagebus/messagebus.h index 483915eee25..bc4a08123a4 100644 --- a/messagebus/src/vespa/messagebus/messagebus.h +++ b/messagebus/src/vespa/messagebus/messagebus.h @@ -1,27 +1,28 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <map> -#include <vespa/messagebus/network/inetworkowner.h> -#include <vespa/messagebus/routing/resender.h> -#include <vespa/messagebus/routing/routingspec.h> -#include <vespa/messagebus/routing/routingtable.h> -#include <vespa/vespalib/util/sync.h> #include "destinationsession.h" #include "iconfighandler.h" #include "idiscardhandler.h" #include "intermediatesession.h" #include "messagebusparams.h" -#include "messenger.h" #include "protocolset.h" -#include "protocolrepository.h" #include "sourcesession.h" +#include <vespa/messagebus/network/inetworkowner.h> +#include <vespa/messagebus/routing/routingspec.h> +#include <vespa/vespalib/util/sync.h> +#include <map> #include <string> #include <atomic> namespace mbus { class SendProxy; +class Messenger; +class Resender; +class INetwork; +class RoutingTable; +class ProtocolRepository; /** * A MessageBus object combined with an INetwork implementation makes up the central part of a messagebus setup. It is @@ -35,17 +36,18 @@ class MessageBus : public IMessageHandler, public IReplyHandler { private: - INetwork &_network; - vespalib::Lock _lock; - std::map<string, RoutingTable::SP> _routingTables; - std::map<string, IMessageHandler*> _sessions; - ProtocolRepository _protocolRepository; - Messenger _msn; - Resender::UP _resender; - std::atomic<uint32_t> _maxPendingCount; - std::atomic<uint32_t> _maxPendingSize; - std::atomic<uint32_t> _pendingCount; - std::atomic<uint32_t> _pendingSize; + using RoutingTableSP = std::shared_ptr<RoutingTable>; + INetwork &_network; + vespalib::Lock _lock; + std::map<string, RoutingTableSP> _routingTables; + std::map<string, IMessageHandler*> _sessions; + std::unique_ptr<ProtocolRepository> _protocolRepository; + std::unique_ptr<Messenger> _msn; + std::unique_ptr<Resender> _resender; + std::atomic<uint32_t> _maxPendingCount; + std::atomic<uint32_t> _maxPendingSize; + std::atomic<uint32_t> _pendingCount; + std::atomic<uint32_t> _pendingSize; /** * This method performs the common constructor tasks. @@ -185,7 +187,7 @@ public: * @return shared pointer to routing table * @param protocol the protocol name **/ - RoutingTable::SP getRoutingTable(const string &protocol); + RoutingTableSP getRoutingTable(const string &protocol); /** * Returns a routing policy that corresponds to the argument protocol name, policy name and policy parameter. This @@ -279,7 +281,7 @@ public: * * @return The underlying {@link Messenger} object. */ - Messenger & getMessenger() { return _msn; } + Messenger & getMessenger() { return *_msn; } // Implements IReplyHandler. void handleReply(Reply::UP reply); diff --git a/messagebus/src/vespa/messagebus/network/inetwork.h b/messagebus/src/vespa/messagebus/network/inetwork.h index b218a0689a2..5070f3c6ca3 100644 --- a/messagebus/src/vespa/messagebus/network/inetwork.h +++ b/messagebus/src/vespa/messagebus/network/inetwork.h @@ -2,12 +2,13 @@ #pragma once #include <memory> -#include <vespa/messagebus/routing/routingnode.h> #include <vespa/slobrok/imirrorapi.h> #include "inetworkowner.h" namespace mbus { +class RoutingNode; + /** * This interface is used to hide away the implementation details of the network * code from the rest of the messagebus implementation. The methods defined in diff --git a/messagebus/src/vespa/messagebus/network/inetworkowner.h b/messagebus/src/vespa/messagebus/network/inetworkowner.h index 493f121783f..8205b04817c 100644 --- a/messagebus/src/vespa/messagebus/network/inetworkowner.h +++ b/messagebus/src/vespa/messagebus/network/inetworkowner.h @@ -2,11 +2,14 @@ #pragma once #include <memory> -#include <vespa/messagebus/iprotocol.h> -#include <vespa/messagebus/ireplyhandler.h> +#include <vespa/messagebus/common.h> namespace mbus { + class Reply; + class IProtocol; + class IReplyHandler; + class Message; /** * A network owner is the object that instantiates and uses a network. The API to send messages * across the network is part of the Network interface, whereas this interface exposes the required @@ -26,7 +29,7 @@ public: * @param name The name of the protocol to return. * @return The named protocol. */ - virtual IProtocol::SP getProtocol(const string &name) = 0; + virtual std::shared_ptr<IProtocol> getProtocol(const string &name) = 0; /** * All messages that arrive in the network layer is passed to its owner through this function. @@ -34,7 +37,7 @@ public: * @param message The message that just arrived from the network. * @param session The name of the session that is the recipient of the request. */ - virtual void deliverMessage(Message::UP message, const string &session) = 0; + virtual void deliverMessage(std::unique_ptr<Message> message, const string &session) = 0; /** * All replies that arrive in the network layer is passed through this to unentangle it from the network thread. @@ -42,7 +45,7 @@ public: * @param reply The reply that just arrived from the network. * @param handler The handler that is to receive the reply. */ - virtual void deliverReply(Reply::UP reply, IReplyHandler &handler) = 0; + virtual void deliverReply(std::unique_ptr<Reply> reply, IReplyHandler &handler) = 0; }; } // namespace mbus diff --git a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp index b0101753452..a5caaa127c3 100644 --- a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp +++ b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp @@ -1,12 +1,11 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "inetworkowner.h" #include "rpcnetwork.h" -#include "rpcsendv1.h" -#include "rpcservice.h" #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/iprotocol.h> #include <vespa/messagebus/tracelevel.h> +#include <vespa/messagebus/routing/routingnode.h> #include <vespa/slobrok/sbregister.h> #include <vespa/slobrok/sbmirror.h> #include <vespa/log/log.h> diff --git a/messagebus/src/vespa/messagebus/routing/routingcontext.cpp b/messagebus/src/vespa/messagebus/routing/routingcontext.cpp index 8732ed4fc08..f671890c0c1 100644 --- a/messagebus/src/vespa/messagebus/routing/routingcontext.cpp +++ b/messagebus/src/vespa/messagebus/routing/routingcontext.cpp @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "route.h" #include "routingnode.h" +#include "policydirective.h" +#include <vespa/messagebus/network/inetwork.h> namespace mbus { diff --git a/messagebus/src/vespa/messagebus/routing/routingcontext.h b/messagebus/src/vespa/messagebus/routing/routingcontext.h index 9edcd5aa014..e2e2dcf0cca 100644 --- a/messagebus/src/vespa/messagebus/routing/routingcontext.h +++ b/messagebus/src/vespa/messagebus/routing/routingcontext.h @@ -1,17 +1,18 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once +#include "routingnodeiterator.h" #include <vespa/messagebus/context.h> -#include <vespa/messagebus/messagebus.h> #include <vespa/slobrok/imirrorapi.h> #include <set> -#include "hop.h" -#include "policydirective.h" -#include "routingnodeiterator.h" namespace mbus { class RoutingNode; +class PolicyDirective; +class MessageBus; +class Message; +class Error; /** * This context object is what is seen by {@link RoutingPolicy} when doing both select() and merge(). It @@ -192,7 +193,7 @@ public: * @param reply The reply to set. * @return This, to allow chaining. */ - RoutingContext &setReply(Reply::UP reply); + RoutingContext &setReply(std::unique_ptr<Reply> reply); /** * This is a convenience method to call {@link #setError(Error)}. diff --git a/messagebus/src/vespa/messagebus/routing/routingnode.cpp b/messagebus/src/vespa/messagebus/routing/routingnode.cpp index 7bfb31c2e68..00922d76759 100644 --- a/messagebus/src/vespa/messagebus/routing/routingnode.cpp +++ b/messagebus/src/vespa/messagebus/routing/routingnode.cpp @@ -1,14 +1,15 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "routingnode.h" #include "errordirective.h" -#include "policydirective.h" #include "routedirective.h" +#include "routingtable.h" +#include "policydirective.h" #include <vespa/messagebus/emptyreply.h> #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/tracelevel.h> -#include <stack> #include <vespa/vespalib/util/atomic.h> -#include <vespa/vespalib/util/vstringfmt.h> +#include <vespa/messagebus/network/inetwork.h> +#include <stack> namespace mbus { diff --git a/messagebus/src/vespa/messagebus/routing/routingnode.h b/messagebus/src/vespa/messagebus/routing/routingnode.h index 92a4b835ba1..aa854dce5ef 100644 --- a/messagebus/src/vespa/messagebus/routing/routingnode.h +++ b/messagebus/src/vespa/messagebus/routing/routingnode.h @@ -6,7 +6,6 @@ #include <vespa/messagebus/ireplyhandler.h> #include <vespa/messagebus/message.h> #include <vespa/messagebus/messagebus.h> -#include <vespa/messagebus/network/inetwork.h> #include <vespa/messagebus/network/iserviceaddress.h> #include <vespa/messagebus/reply.h> #include <string> @@ -20,6 +19,9 @@ namespace mbus { +class HopBlueprint; +class INetwork; + /** * This class represents a node in the routing tree that is created when a route * is resolved. There will be one node per modification of the route. For every diff --git a/messagebus/src/vespa/messagebus/routing/routingnodeiterator.h b/messagebus/src/vespa/messagebus/routing/routingnodeiterator.h index 12ab0f63485..dad7251de64 100644 --- a/messagebus/src/vespa/messagebus/routing/routingnodeiterator.h +++ b/messagebus/src/vespa/messagebus/routing/routingnodeiterator.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 <vespa/messagebus/reply.h> #include "route.h" namespace mbus { class RoutingNode; +class Reply; /** * Implements an iterator for the child routing contexts of this. Use {@link @@ -66,7 +66,7 @@ public: * * @return The reply. */ - Reply::UP removeReply(); + std::unique_ptr<Reply> removeReply(); /** * Returns the reply of the current child. diff --git a/searchcore/src/apps/fdispatch/fdispatch.cpp b/searchcore/src/apps/fdispatch/fdispatch.cpp index 49bb978cf35..efca70b2b6a 100644 --- a/searchcore/src/apps/fdispatch/fdispatch.cpp +++ b/searchcore/src/apps/fdispatch/fdispatch.cpp @@ -9,6 +9,7 @@ #include <vespa/searchlib/aggregation/forcelink.hpp> #include <vespa/vespalib/util/signalhandler.h> #include <vespa/fastos/app.h> +#include <thread> #include <vespa/log/log.h> LOG_SETUP("fdispatch"); diff --git a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp index 33832dc98d0..bb26c0d88ec 100644 --- a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp +++ b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp @@ -18,6 +18,7 @@ #include <vespa/vespalib/util/slaveproc.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/objects/nbostream.h> +#include <vespa/config/helper/configgetter.hpp> #include <iostream> diff --git a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp index ae00e168c3d..e0102c8e059 100644 --- a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp +++ b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.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/config/helper/configgetter.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/fieldvalue/document.h> @@ -10,6 +10,9 @@ #include <vespa/vespalib/util/programoptions.h> #include <vespa/document/config/config-documenttypes.h> #include <iostream> +#include <vespa/config/helper/configgetter.hpp> +#include <vespa/fastos/app.h> + #include <vespa/log/log.h> LOG_SETUP("vespa-transactionlog-inspect"); diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index a5cac711d39..a0b947e11f8 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -25,6 +25,8 @@ #include <vespa/searchlib/tensor/tensor_attribute.h> #include <vespa/searchcore/proton/common/hw_info.h> #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/config/helper/configgetter.hpp> + #include <vespa/log/log.h> LOG_SETUP("docsummary_test"); diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 6d85baf0770..e948bb518d3 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -1,7 +1,5 @@ // 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("configurer_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> @@ -20,11 +18,11 @@ LOG_SETUP("configurer_test"); #include <vespa/searchcore/proton/server/executorthreadingservice.h> #include <vespa/searchcore/proton/server/fast_access_doc_subdb_configurer.h> #include <vespa/searchcore/proton/server/summaryadapter.h> +#include <vespa/searchcore/proton/server/reconfig_params.h> #include <vespa/searchcore/proton/test/documentdb_config_builder.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/nosyncproxy.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/searchcore/proton/common/hw_info.h> using namespace config; using namespace document; diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 88561b529bc..b483b4ea8f5 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_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/document/base/globalid.h> @@ -308,7 +308,7 @@ struct MyWorld { owned_objects.search_handler.reset(new MySearchHandler(matcher)); owned_objects.context.reset(new MatchContext( IAttributeContext::UP(new MyAttributeContext), - ISearchContext::UP(new FakeSearchContext))); + matching::ISearchContext::UP(new FakeSearchContext))); vespalib::SimpleThreadBundle threadBundle(threads); SearchReply::UP reply = matcher->match(*req, threadBundle, searchContext, attributeContext, diff --git a/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.cpp b/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.cpp index 05bf79cf1a2..3be1834a360 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.cpp +++ b/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.cpp @@ -7,8 +7,10 @@ #include <vespa/searchcore/fdispatch/search/querycacheutil.h> #include <vespa/searchcore/fdispatch/search/nodemanager.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/config/helper/configgetter.hpp> #include "engineadapter.h" #include "rpc.h" +#include <thread> #include <vespa/log/log.h> LOG_SETUP(".fdispatch"); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.cpp b/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.cpp index 702a77bbebe..00732fcedde 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.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/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.attribute.document_field_populator"); #include "document_field_populator.h" #include "document_field_retriever.h" #include <vespa/searchcore/proton/common/eventlogger.h> +#include <vespa/searchlib/attribute/attributevector.h> +#include <vespa/log/log.h> +LOG_SETUP(".proton.attribute.document_field_populator"); using document::Document; using search::index::Schema; @@ -25,7 +25,7 @@ getFieldName(const vespalib::string &subDbName, } DocumentFieldPopulator::DocumentFieldPopulator(const Schema::AttributeField &field, - search::AttributeVector::SP attr, + AttributeVectorSP attr, const vespalib::string &subDbName) : _field(field), _attr(attr), diff --git a/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.h b/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.h index a16401b775e..dcb543f84eb 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/document_field_populator.h @@ -14,14 +14,15 @@ namespace proton { class DocumentFieldPopulator : public IReprocessingRewriter { private: + using AttributeVectorSP = std::shared_ptr<search::AttributeVector>; search::index::Schema::AttributeField _field; - search::AttributeVector::SP _attr; + AttributeVectorSP _attr; vespalib::string _subDbName; int64_t _documentsPopulated; public: DocumentFieldPopulator(const search::index::Schema::AttributeField &field, - search::AttributeVector::SP attr, + AttributeVectorSP attr, const vespalib::string &subDbName); ~DocumentFieldPopulator(); diff --git a/searchcore/src/vespa/searchcore/proton/common/selectcontext.cpp b/searchcore/src/vespa/searchcore/proton/common/selectcontext.cpp index 5e15f6f65ea..36fa242daec 100644 --- a/searchcore/src/vespa/searchcore/proton/common/selectcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/selectcontext.cpp @@ -32,7 +32,7 @@ void SelectContext::getAttributeGuards(void) { _guards->resize(_cachedSelect._attributes.size()); - std::vector<AttributeVector::SP>::const_iterator j(_cachedSelect._attributes.begin()); + auto j(_cachedSelect._attributes.begin()); for (std::vector<AttributeGuard>::iterator i(_guards->begin()), ie(_guards->end()); i != ie; ++i, ++j) { *i = AttributeGuard(*j); } diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h index fc7b38a25ff..2d011adfbc0 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/persistenceengine.h @@ -7,7 +7,7 @@ #include <vespa/searchcore/proton/common/handlermap.hpp> #include <vespa/searchcore/proton/persistenceengine/ipersistencehandler.h> #include <vespa/vespalib/util/sync.h> -#include <vespa/vespalib/util/sync.h> +#include <vespa/vespalib/util/rwlock.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp index 8e402c7e3b9..14e29a2650c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.cpp @@ -1,9 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.server.docstorevalidator"); #include "docstorevalidator.h" +#include <vespa/searchlib/common/bitvector.h> namespace proton { @@ -69,6 +67,17 @@ DocStoreValidator::visitDone(void) (void) _orphans->countTrueBits(); } +uint32_t +DocStoreValidator::getInvalidCount(void) const +{ + return _invalid->countTrueBits(); +} + +uint32_t +DocStoreValidator::getOrphanCount(void) const +{ + return _orphans->countTrueBits(); +} void DocStoreValidator::killOrphans(search::IDocumentStore &store, diff --git a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h index 6fbaefb9088..fcca1fd9178 100644 --- a/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h +++ b/searchcore/src/vespa/searchcore/proton/server/docstorevalidator.h @@ -6,60 +6,31 @@ #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store.h> #include <vespa/searchcore/proton/feedoperation/lidvectorcontext.h> -namespace proton -{ +namespace search { class BitVector; } +namespace proton { class DocStoreValidator : public search::IDocumentStoreReadVisitor { - IDocumentMetaStore &_dms; - uint32_t _docIdLimit; - search::BitVector::UP _invalid; - search::BitVector::UP _orphans; - uint32_t _visitCount; - uint32_t _visitEmptyCount; + IDocumentMetaStore &_dms; + uint32_t _docIdLimit; + std::unique_ptr<search::BitVector> _invalid; + std::unique_ptr<search::BitVector> _orphans; + uint32_t _visitCount; + uint32_t _visitEmptyCount; public: DocStoreValidator(IDocumentMetaStore &dms); - virtual void - visit(uint32_t lid, const document::Document &doc); - - virtual void - visit(uint32_t lid); - - void - visitDone(void); - - void - killOrphans(search::IDocumentStore &store, - search::SerialNum serialNum); - - uint32_t - getInvalidCount(void) const - { - return _invalid->countTrueBits(); - } - - uint32_t - getOrphanCount(void) const - { - return _orphans->countTrueBits(); - } - - uint32_t - getVisitCount(void) const - { - return _visitCount; - } - - uint32_t - getVisitEmptyCount(void) const - { - return _visitEmptyCount; - } + virtual void visit(uint32_t lid, const document::Document &doc); + virtual void visit(uint32_t lid); - LidVectorContext::LP - getInvalidLids(void) const; + void visitDone(void); + void killOrphans(search::IDocumentStore &store, search::SerialNum serialNum); + uint32_t getInvalidCount() const; + uint32_t getOrphanCount() const; + uint32_t getVisitCount() const { return _visitCount; } + uint32_t getVisitEmptyCount() const { return _visitEmptyCount; } + LidVectorContext::LP getInvalidLids() const; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 97c438dbd09..e3523b4c449 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -2,48 +2,32 @@ #include "documentdb.h" #include "combiningfeedview.h" -#include "configvalidator.h" #include "document_meta_store_read_guards.h" #include "document_subdb_collection_explorer.h" #include "idocumentdbowner.h" #include "lid_space_compaction_handler.h" #include "maintenance_jobs_injector.h" -#include "searchcontext.h" -#include "summaryadapter.h" -#include "tlcproxy.h" #include "commit_and_wait_document_retriever.h" #include "documentdbconfigscout.h" -#include <vespa/searchcore/proton/metrics/metricswireservice.h> +#include "reconfig_params.h" #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/common/eventlogger.h> #include <vespa/searchcore/proton/common/schemautil.h> -#include <vespa/searchcore/proton/feedoperation/newconfigoperation.h> -#include <vespa/searchcore/proton/feedoperation/noopoperation.h> -#include <vespa/searchcore/proton/feedoperation/wipehistoryoperation.h> #include <vespa/searchcore/proton/index/index_writer.h> #include <vespa/searchcore/proton/initializer/task_runner.h> -#include <vespa/searchcore/proton/matching/matching_stats.h> -#include <vespa/searchcore/proton/metrics/attribute_metrics_collection.h> -#include <vespa/searchcore/proton/persistenceengine/bucket_guard.h> #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/searchlib/attribute/configconverter.h> #include <vespa/searchcommon/common/schemaconfigurer.h> #include <vespa/searchlib/engine/searchreply.h> #include <vespa/searchlib/engine/docsumreply.h> -#include <vespa/searchlib/common/serialnum.h> -#include <vespa/searchlib/common/lambdatask.h> -#include <vespa/vespalib/data/fileheader.h> + #include <vespa/vespalib/io/fileutil.h> -#include <vespa/vespalib/objects/objectvisitor.h> #include <vespa/vespalib/util/closuretask.h> -#include <vespa/vespalib/util/jsonwriter.h> -#include <sstream> #include <vespa/vespalib/util/exceptions.h> #include <vespa/log/log.h> LOG_SETUP(".proton.server.documentdb"); - using vespa::config::search::AttributesConfig; using vespa::config::search::core::ProtonConfig; using search::index::SchemaBuilder; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp b/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp index f511750a32e..cf16498b3be 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp @@ -1,21 +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(".proton.server.documentretriever"); - #include "documentretriever.h" -#include <vespa/document/base/field.h> #include <vespa/document/datatype/positiondatatype.h> -#include <vespa/document/fieldvalue/structfieldvalue.h> #include <vespa/document/repo/documenttyperepo.h> -#include <vespa/searchcommon/common/schema.h> #include <vespa/searchcore/proton/attribute/document_field_retriever.h> -#include <vespa/searchlib/attribute/attributeguard.h> -#include <vespa/searchlib/attribute/iattributemanager.h> -#include <vespa/searchlib/docstore/idocumentstore.h> -#include <vespa/searchlib/query/base.h> #include <vespa/vespalib/geo/zcurve.h> +#include <vespa/searchlib/attribute/attributevector.h> + +#include <vespa/log/log.h> +LOG_SETUP(".proton.server.documentretriever"); using document::Document; using document::DocumentType; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp index 06d6162baee..846adb1889e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.cpp @@ -1,9 +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/log/log.h> -LOG_SETUP(".proton.server.documentsubdbcollection"); - #include "combiningfeedview.h" #include "commit_and_wait_document_retriever.h" #include "document_subdb_collection_initializer.h" @@ -266,7 +262,7 @@ void DocumentSubDBCollection::applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params) + const ReconfigParams & params) { _reprocessingRunner.reset(); for (auto subDb : _subDBs) { diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h index d0c004ceba4..05554e6ec27 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h @@ -117,7 +117,7 @@ public: applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params); + const ReconfigParams & params); IFeedView::SP getFeedView(); IFlushTarget::List getFlushTargets(); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp index 24c000e5d4a..5b68ed0c3f2 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp @@ -5,6 +5,7 @@ #include "fast_access_doc_subdb.h" #include "fast_access_document_retriever.h" #include "document_subdb_initializer.h" +#include "reconfig_params.h" #include <vespa/searchcore/proton/attribute/attribute_collection_spec_factory.h> #include <vespa/searchcore/proton/attribute/attribute_factory.h> #include <vespa/searchcore/proton/attribute/attribute_manager_initializer.h> @@ -247,7 +248,7 @@ IReprocessingTask::List FastAccessDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params) + const ReconfigParams & params) { IReprocessingTask::List tasks; updateLidReuseDelayer(&newConfigSnapshot); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h index 7274bda8282..e876b18af4e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h @@ -116,7 +116,7 @@ public: IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params) override; + const ReconfigParams & params) override; proton::IAttributeManager::SP getAttributeManager() const override; IDocumentRetriever::UP getDocumentRetriever() override; diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index 3d56edd880d..95a1e99d5ab 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -13,6 +13,8 @@ #include <vespa/searchsummary/config/config-juniperrc.h> #include <fstream> #include <vespa/fastos/file.h> +#include <vespa/config/helper/configgetter.hpp> + #include <vespa/log/log.h> LOG_SETUP(".proton.server.fileconfigmanager"); diff --git a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h index 5838a66040e..3a2a2e43df9 100644 --- a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h @@ -85,7 +85,7 @@ public: virtual IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, - SerialNum serialNum, const ReconfigParams params) = 0; + SerialNum serialNum, const ReconfigParams & params) = 0; virtual std::shared_ptr<ISearchHandler> getSearchView() const = 0; virtual std::shared_ptr<IFeedView> getFeedView() const = 0; diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp index dcb91d6ab71..26ee44c083d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.cpp @@ -1,12 +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(".proton.server.searchable_doc_subdb_configurer"); #include "searchable_doc_subdb_configurer.h" +#include "reconfig_params.h" #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/common/document_type_inspector.h> -#include <vespa/searchcore/proton/matching/matcher.h> #include <vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.h> using namespace vespa::config::search; @@ -112,8 +109,9 @@ SearchableDocSubDBConfigurer(const ISummaryManager::SP &summaryMgr, _clock(clock), _subDbName(subDbName), _distributionKey(distributionKey) -{ -} +{ } + +SearchableDocSubDBConfigurer::~SearchableDocSubDBConfigurer() { } Matchers::UP SearchableDocSubDBConfigurer::createMatchers(const Schema::SP &schema, @@ -127,7 +125,6 @@ SearchableDocSubDBConfigurer::createMatchers(const Schema::SP &schema, properties.add(property.name, property.value); } - LOG(debug, "Adding matcher for rankprofile '%s'", name.c_str()); // schema instance only used during call. Matcher::SP profptr(new Matcher(*schema, properties, _clock, _queryLimiter, _constantValueRepo, _distributionKey)); newMatchers->add(name, profptr); @@ -153,8 +150,7 @@ reconfigure(const DocumentDBConfig &newConfig, const ReconfigParams ¶ms) { assert(!params.shouldAttributeManagerChange()); - AttributeCollectionSpec attrSpec(AttributeCollectionSpec::AttributeList(), - 0, 0); + AttributeCollectionSpec attrSpec(AttributeCollectionSpec::AttributeList(), 0, 0); reconfigure(newConfig, oldConfig, attrSpec, params); } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h index 2e1110dd07d..447a39085c8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchable_doc_subdb_configurer.h @@ -6,7 +6,6 @@ #include "isummaryadapter.h" #include "matchers.h" #include "matchview.h" -#include "reconfig_params.h" #include "searchable_feed_view.h" #include "searchview.h" #include <vespa/searchcore/proton/attribute/i_attribute_writer.h> @@ -26,6 +25,7 @@ namespace proton { +class ReconfigParams; /** * Class used to reconfig the feed view and search view used in a searchable sub database. */ @@ -80,6 +80,7 @@ public: const vespalib::Clock &clock, const vespalib::string &subDbName, uint32_t distributionKey); + ~SearchableDocSubDBConfigurer(); Matchers::UP createMatchers(const search::index::Schema::SP &schema, diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 2575d2edf84..62c01124248 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -3,6 +3,7 @@ #include "searchabledocsubdb.h" #include "fast_access_document_retriever.h" #include "document_subdb_initializer.h" +#include "reconfig_params.h" #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/flushengine/threadedflushtarget.h> #include <vespa/searchcore/proton/index/index_manager_initializer.h> @@ -167,7 +168,7 @@ IReprocessingTask::List SearchableDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params) + const ReconfigParams & params) { IReprocessingTask::List tasks; updateLidReuseDelayer(&newConfigSnapshot); diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index f3b5854395b..b1d80b57bc3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -1,7 +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 "documentdbconfig.h" #include "searchable_doc_subdb_configurer.h" #include "executorthreadingservice.h" #include "fast_access_doc_subdb.h" @@ -26,11 +25,11 @@ #include <vespa/vespalib/util/varholder.h> -namespace proton -{ +namespace proton { class MetricsWireService; class DocumentDBMetrics; +class DocumentDBConfig; /** * The searchable sub database supports searching and keeps all attribute fields in memory and @@ -110,83 +109,56 @@ protected: void updateLidReuseDelayer(const LidReuseDelayerConfig &config) override; public: SearchableDocSubDB(const Config &cfg, const Context &ctx); - ~SearchableDocSubDB(); std::unique_ptr<DocumentSubDbInitializer> createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, - const search::index::Schema::SP &unionSchema, + const Schema::SP &unionSchema, const vespa::config::search::core:: ProtonConfig::Summary &protonSummaryCfg, const vespa::config::search::core:: ProtonConfig::Index &indexCfg) const override; - virtual void setup(const DocumentSubDbInitializerResult &initResult) - override; + void setup(const DocumentSubDbInitializerResult &initResult) override; - virtual void + void initViews(const DocumentDBConfig &configSnapshot, - const matching::SessionManager::SP &sessionManager); + const matching::SessionManager::SP &sessionManager) override; - virtual IReprocessingTask::List + IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params); + const ReconfigParams & params) override; - virtual void - clearViews() + void clearViews() override { _rFeedView.clear(); _rSearchView.clear(); Parent::clearViews(); } - virtual proton::IAttributeManager::SP - getAttributeManager() const - { + proton::IAttributeManager::SP getAttributeManager() const override { return _rSearchView.get()->getAttributeManager(); } - virtual const IIndexManager::SP & - getIndexManager() const - { + const IIndexManager::SP &getIndexManager() const override { return _indexMgr; } - virtual const IIndexWriter::SP & - getIndexWriter() const - { + const IIndexWriter::SP &getIndexWriter() const override { return _indexWriter; } - virtual SerialNum - getOldestFlushedSerial(); - - virtual SerialNum - getNewestFlushedSerial(); - - virtual void - wipeHistory(SerialNum wipeSerial, - const search::index::Schema &newHistorySchema, - const search::index::Schema &wipeSchema); - - virtual void - setIndexSchema(const search::index::Schema::SP &schema, - const search::index::Schema::SP &fusionSchema); - - virtual size_t - getNumActiveDocs() const override; - - virtual search::SearchableStats - getSearchableStats() const; - - virtual IDocumentRetriever::UP - getDocumentRetriever(); - - virtual matching::MatchingStats - getMatcherStats(const vespalib::string &rankProfile) const; + SerialNum getOldestFlushedSerial() override; + SerialNum getNewestFlushedSerial() override; + void wipeHistory(SerialNum wipeSerial, const Schema &newHistorySchema, const Schema &wipeSchema) override; + void setIndexSchema(const Schema::SP &schema, const Schema::SP &fusionSchema) override; + size_t getNumActiveDocs() const override; + search::SearchableStats getSearchableStats() const override ; + IDocumentRetriever::UP getDocumentRetriever() override; + matching::MatchingStats getMatcherStats(const vespalib::string &rankProfile) const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index cc35d7649ce..e41c4ab6ed1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -385,7 +385,7 @@ IReprocessingTask::List StoreOnlyDocSubDB::applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params) + const ReconfigParams & params) { (void) oldConfigSnapshot; assert(_writeService.master().isCurrentThread()); diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index 00dcb10941c..a565da524a4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -247,7 +247,7 @@ public: applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, SerialNum serialNum, - const ReconfigParams params) override; + const ReconfigParams & params) override; ISearchHandler::SP getSearchView() const override { return _iSearchView.get(); } IFeedView::SP getFeedView() const override { return _iFeedView.get(); } diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h index d1f84031417..9c3bc57bbdf 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h @@ -48,7 +48,7 @@ struct DummyDocumentSubDb : public IDocumentSubDB virtual DocumentSubDbInitializer::UP createInitializer(const DocumentDBConfig &, SerialNum, - const search::index::Schema::SP &, + const Schema::SP &, const vespa::config::search::core::ProtonConfig:: Summary &, const vespa::config::search::core:: @@ -63,7 +63,7 @@ struct DummyDocumentSubDb : public IDocumentSubDB virtual IReprocessingTask::List applyConfig(const DocumentDBConfig &, const DocumentDBConfig &, SerialNum, - const ReconfigParams) override { + const ReconfigParams &) override { return IReprocessingTask::List(); } virtual ISearchHandler::SP getSearchView() const override { return ISearchHandler::SP(); } @@ -85,12 +85,9 @@ struct DummyDocumentSubDb : public IDocumentSubDB virtual void onReprocessDone(SerialNum) override { } virtual SerialNum getOldestFlushedSerial() override { return 0; } virtual SerialNum getNewestFlushedSerial() override { return 0; } - virtual void wipeHistory(SerialNum, - const search::index::Schema &, - const search::index::Schema &) override {} - virtual void setIndexSchema(const search::index::Schema::SP &, - const search::index::Schema::SP &) override {} - virtual search::SearchableStats getSearchableStats(void) const override { + virtual void wipeHistory(SerialNum, const Schema &, const Schema &) override { } + virtual void setIndexSchema(const Schema::SP &, const Schema::SP &) override { } + virtual search::SearchableStats getSearchableStats() const override { return search::SearchableStats(); } virtual IDocumentRetriever::UP getDocumentRetriever() override { diff --git a/searchlib/src/tests/features/item_raw_score/item_raw_score_test.cpp b/searchlib/src/tests/features/item_raw_score/item_raw_score_test.cpp index 20f9449062d..199a9fa72e3 100644 --- a/searchlib/src/tests/features/item_raw_score/item_raw_score_test.cpp +++ b/searchlib/src/tests/features/item_raw_score/item_raw_score_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/searchlib/features/setup.h> #include <vespa/searchlib/fef/test/indexenvironment.h> @@ -8,6 +8,7 @@ #include <vespa/searchlib/features/item_raw_score_feature.h> #include <vespa/searchlib/fef/fef.h> #include <vespa/searchlib/fef/test/dummy_dependency_handler.h> +#include <vespa/vespalib/stllike/asciistream.h> using search::feature_t; using namespace search::fef; diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp index 6f6496d05e7..59a51de3460 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.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. - #include "attribute_weighted_set_blueprint.h" +#include "isearchcontext.h" #include <vespa/searchlib/queryeval/weighted_set_term_search.h> #include <vespa/searchlib/query/queryterm.h> @@ -9,6 +9,8 @@ namespace search { namespace { +using attribute::ISearchContext; +using attribute::IAttributeVector; //----------------------------------------------------------------------------- class UseAttr @@ -29,10 +31,9 @@ public: class UseStringEnum : public UseAttr { public: - UseStringEnum(const AttributeVector & attr) + UseStringEnum(const IAttributeVector & attr) : UseAttr(attr) {} - bool mapToken(const AttributeVector::SearchContext &context, - int64_t &token) const + bool mapToken(const ISearchContext &context, int64_t &token) const { attribute::IAttributeVector::EnumHandle handle; if (attribute().findEnum(context.queryTerm().getTerm(), handle)) { @@ -51,9 +52,8 @@ public: class UseInteger : public UseAttr { public: - UseInteger(const AttributeVector & attr) : UseAttr(attr) {} - bool mapToken(const AttributeVector::SearchContext &context, - int64_t &token) const + UseInteger(const IAttributeVector & attr) : UseAttr(attr) {} + bool mapToken(const ISearchContext &context, int64_t &token) const { Int64Range range(context.getAsIntegerTerm()); if (range.isPoint()) { @@ -83,9 +83,9 @@ private: public: AttributeFilter(fef::TermFieldMatchData &tfmd, - const AttributeVector & attr, + const IAttributeVector & attr, const std::vector<int32_t> weights, - const std::vector<AttributeVector::SearchContext*> contexts) + const std::vector<ISearchContext*> contexts) : _tfmd(tfmd), _attr(attr), _map(), _weight(0) { for (size_t i = 0; i < contexts.size(); ++i) { @@ -115,7 +115,7 @@ public: } // namespace search::<unnamed> -AttributeWeightedSetBlueprint::AttributeWeightedSetBlueprint(const queryeval::FieldSpec &field, const AttributeVector & attr) +AttributeWeightedSetBlueprint::AttributeWeightedSetBlueprint(const queryeval::FieldSpec &field, const IAttributeVector & attr) : queryeval::ComplexLeafBlueprint(field), _numDocs(attr.getNumDocs()), _estHits(0), @@ -134,7 +134,7 @@ AttributeWeightedSetBlueprint::~AttributeWeightedSetBlueprint() } void -AttributeWeightedSetBlueprint::addToken(AttributeVector::SearchContext::UP context, int32_t weight) +AttributeWeightedSetBlueprint::addToken(std::unique_ptr<ISearchContext> context, int32_t weight) { _estHits = std::min(_estHits + context->approximateHits(), _numDocs); setEstimate(HitEstimate(_estHits, (_estHits == 0))); diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h index dadb0d1a0ec..ef3ddef9001 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h +++ b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.h @@ -10,26 +10,29 @@ namespace search { +namespace attribute { class ISearchContext; } + class AttributeWeightedSetBlueprint : public queryeval::ComplexLeafBlueprint { private: + using ISearchContext = attribute::ISearchContext; + using IAttributeVector = attribute::IAttributeVector; size_t _numDocs; size_t _estHits; std::vector<int32_t> _weights; - const AttributeVector & _attr; - std::vector<AttributeVector::SearchContext*> _contexts; + const IAttributeVector & _attr; + std::vector<ISearchContext*> _contexts; AttributeWeightedSetBlueprint(const AttributeWeightedSetBlueprint &); // disabled AttributeWeightedSetBlueprint &operator=(const AttributeWeightedSetBlueprint &); // disabled public: - AttributeWeightedSetBlueprint(const queryeval::FieldSpec &field, const AttributeVector & attr); + AttributeWeightedSetBlueprint(const queryeval::FieldSpec &field, const IAttributeVector & attr); virtual ~AttributeWeightedSetBlueprint(); - void addToken(AttributeVector::SearchContext::UP context, int32_t weight); + void addToken(std::unique_ptr<ISearchContext> context, int32_t weight); virtual queryeval::SearchIterator::UP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const; - virtual void - fetchPostings(bool strict); + virtual void fetchPostings(bool strict); }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/attribute/attributecontext.cpp b/searchlib/src/vespa/searchlib/attribute/attributecontext.cpp index 018505958e5..956f74634de 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributecontext.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributecontext.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 "attributecontext.h" +#include "attributevector.h" #include <vespa/vespalib/stllike/hash_map.hpp> using namespace search; diff --git a/searchlib/src/vespa/searchlib/attribute/attributeguard.cpp b/searchlib/src/vespa/searchlib/attribute/attributeguard.cpp index 11c473ed53f..ab971a39c20 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributeguard.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributeguard.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 "attributeguard.h" +#include "componentguard.hpp" +#include "attributevector.h" namespace search { @@ -38,4 +39,6 @@ void AttributeEnumGuard::takeLock() { } } +template class ComponentGuard<AttributeVector>; + } diff --git a/searchlib/src/vespa/searchlib/attribute/attributeguard.h b/searchlib/src/vespa/searchlib/attribute/attributeguard.h index 726dd436454..74f8be78628 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributeguard.h +++ b/searchlib/src/vespa/searchlib/attribute/attributeguard.h @@ -1,51 +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 <vespa/searchlib/attribute/attributevector.h> +#include "componentguard.h" +#include <vespa/searchcommon/attribute/iattributevector.h> +#include <shared_mutex> namespace search { -/** - * General class for guarding a component that is using an underlying generation handler. - **/ -template <typename T> -class ComponentGuard -{ -private: - typename T::SP _component; - typedef vespalib::GenerationHandler::Guard Guard; - Guard _generationGuard; -public: - ComponentGuard(); - virtual ~ComponentGuard() { } - /** - * Creates a guard for the shared pointer of the given component. - **/ - ComponentGuard(const typename T::SP & component); - const T & get() const { return *_component; } - - const typename T::SP & getSP(void) const { return _component; } - const T * operator -> () const { return _component.get(); } - const T & operator * () const { return *_component.get(); } - T & get() { return *_component; } - T * operator -> () { return _component.get(); } - T & operator * () { return *_component.get(); } - bool valid() const { return _component.get() != NULL; } -}; - -template <typename T> -ComponentGuard<T>::ComponentGuard() : - _component(), - _generationGuard() -{ -} - -template <typename T> -ComponentGuard<T>::ComponentGuard(const typename T::SP & component) : - _component(component), - _generationGuard(valid() ? _component->takeGenerationGuard() : Guard()) -{ -} +class AttributeVector; /** * This class makes sure that you will have a consistent view per document in the attribute vector @@ -54,10 +16,11 @@ ComponentGuard<T>::ComponentGuard(const typename T::SP & component) : class AttributeGuard : public ComponentGuard<AttributeVector> { public: - typedef std::unique_ptr<AttributeGuard> UP; - typedef std::shared_ptr<AttributeGuard> SP; + using UP = std::unique_ptr<AttributeGuard>; + using SP = std::shared_ptr<AttributeGuard>; + using AttributeVectorSP = std::shared_ptr<AttributeVector>; AttributeGuard(); - AttributeGuard(const AttributeVector::SP & attribute); + AttributeGuard(const AttributeVectorSP & attribute); }; /** @@ -68,7 +31,7 @@ class AttributeEnumGuard : public AttributeGuard public: AttributeEnumGuard(const AttributeEnumGuard &) = delete; AttributeEnumGuard & operator = (const AttributeEnumGuard &) = delete; - explicit AttributeEnumGuard(const AttributeVector::SP & attribute); + explicit AttributeEnumGuard(const AttributeVectorSP & attribute); explicit AttributeEnumGuard(const AttributeGuard & attribute); private: mutable std::shared_lock<std::shared_timed_mutex> _lock; diff --git a/searchlib/src/vespa/searchlib/attribute/attributemanager.h b/searchlib/src/vespa/searchlib/attribute/attributemanager.h index 6e166fe0835..4bb68e2c7ba 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributemanager.h +++ b/searchlib/src/vespa/searchlib/attribute/attributemanager.h @@ -3,8 +3,11 @@ #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/attribute/iattributemanager.h> +#include <vespa/searchlib/attribute/interlock.h> #include <vespa/searchlib/common/indexmetainfo.h> +#include <vespa/searchcommon/attribute/config.h> #include <vespa/vespalib/stllike/hash_map.h> +#include <vespa/vespalib/util/sync.h> namespace search { @@ -20,10 +23,10 @@ public: typedef std::vector<string> StringVector; typedef search::IndexMetaInfo::Snapshot Snapshot; typedef std::vector<AttributeGuard> AttributeList; - typedef AttributeVector::SP VectorHolder; + using VectorHolder = std::shared_ptr<AttributeVector>; AttributeManager(); AttributeManager(const string & base); - ~AttributeManager(void); + ~AttributeManager(); /** * This will give you a handle to an attributevector. It diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 1e244c111ad..7328d733818 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -4,12 +4,13 @@ #include "address_space_usage.h" #include "iattributesavetarget.h" +#include "changevector.h" +#include "isearchcontext.h" #include <vespa/fastlib/text/normwordfolder.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/searchcommon/attribute/iattributevector.h> #include <vespa/searchcommon/attribute/status.h> #include <vespa/searchcommon/common/undefinedvalues.h> -#include <vespa/searchlib/attribute/changevector.h> #include <vespa/searchlib/common/address_space.h> #include <vespa/searchlib/common/bitvector.h> #include <vespa/searchlib/common/range.h> @@ -500,7 +501,7 @@ public: - Range search */ - class SearchContext + class SearchContext : public attribute::ISearchContext { template <class SC> friend class AttributeIteratorT; template <class SC> friend class FilterAttributeIteratorT; @@ -543,8 +544,8 @@ public: bool _diversityCutoffStrict; }; typedef std::unique_ptr<SearchContext> UP; - virtual ~SearchContext(); - virtual unsigned int approximateHits() const; + ~SearchContext(); + unsigned int approximateHits() const override; static QueryTermSimpleUP decodeQuery(QueryPacketT searchSpec); /** @@ -560,8 +561,8 @@ public: * * @param useBitVector whether bitvectors should be used when available **/ - virtual queryeval::SearchIterator::UP - createIterator(fef::TermFieldMatchData *matchData, bool strict); + queryeval::SearchIterator::UP + createIterator(fef::TermFieldMatchData *matchData, bool strict) override; /** * Creates an attribute search iterator associated with this @@ -574,8 +575,8 @@ public: * * @param strict whether the iterator should be strict or not **/ - virtual queryeval::SearchIterator::UP - createFilterIterator(fef::TermFieldMatchData *matchData, bool strict); + queryeval::SearchIterator::UP + createFilterIterator(fef::TermFieldMatchData *matchData, bool strict) override; /* * Create temporary posting lists. Should be called before diff --git a/searchlib/src/vespa/searchlib/attribute/componentguard.h b/searchlib/src/vespa/searchlib/attribute/componentguard.h new file mode 100644 index 00000000000..448d77f211c --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/componentguard.h @@ -0,0 +1,42 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include <vespa/vespalib/util/generationhandler.h> +#include <memory> + +namespace search { + +/** + * General class for guarding a component that is using an underlying generation handler. + **/ +template <typename T> +class ComponentGuard +{ +private: + using Guard = vespalib::GenerationHandler::Guard; + using Component = std::shared_ptr<T>; + Component _component; + Guard _generationGuard; +public: + ComponentGuard(); + ComponentGuard(ComponentGuard &&) = default; + ComponentGuard & operator = (ComponentGuard &&) = default; + ComponentGuard(const ComponentGuard &); + ComponentGuard & operator = (const ComponentGuard &); + virtual ~ComponentGuard(); + /** + * Creates a guard for the shared pointer of the given component. + **/ + ComponentGuard(const Component & component); + const T & get() const { return *_component; } + + const Component & getSP(void) const { return _component; } + const T * operator -> () const { return _component.get(); } + const T & operator * () const { return *_component.get(); } + T & get() { return *_component; } + T * operator -> () { return _component.get(); } + T & operator * () { return *_component.get(); } + bool valid() const { return _component.get() != NULL; } +}; + +} diff --git a/searchlib/src/vespa/searchlib/attribute/componentguard.hpp b/searchlib/src/vespa/searchlib/attribute/componentguard.hpp new file mode 100644 index 00000000000..e02a7f14042 --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/componentguard.hpp @@ -0,0 +1,37 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include "componentguard.h" + +namespace search { + +template <typename T> +ComponentGuard<T>::ComponentGuard() : + _component(), + _generationGuard() +{ } + +template <typename T> +ComponentGuard<T>::ComponentGuard(const Component & component) : + _component(component), + _generationGuard(valid() ? _component->takeGenerationGuard() : Guard()) +{ } + +template <typename T> +ComponentGuard<T>::ComponentGuard(const ComponentGuard & rhs) : + _component(rhs._component), + _generationGuard(rhs._generationGuard) +{ } + +template <typename T> +ComponentGuard<T> & +ComponentGuard<T>::operator = (const ComponentGuard & rhs) { + ComponentGuard<T> tmp(rhs); + *this = std::move(tmp); + return *this; +} + +template <typename T> +ComponentGuard<T>::~ComponentGuard() { } + +} diff --git a/searchlib/src/vespa/searchlib/attribute/isearchcontext.h b/searchlib/src/vespa/searchlib/attribute/isearchcontext.h new file mode 100644 index 00000000000..b59b09050c1 --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/isearchcontext.h @@ -0,0 +1,70 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/searchlib/common/range.h> + +namespace search { + +namespace fef { + class TermFieldMatchData; +} +namespace queryeval { + class SearchIterator; +} + +class QueryTermBase; + +namespace attribute { + + + class ISearchContext { + public: + virtual ~ISearchContext() {} + + virtual unsigned int approximateHits() const = 0; + + /** + * Creates an attribute search iterator associated with this + * search context. + * + * @return attribute search iterator + * + * @param matchData the attribute match data used when + * unpacking data for a hit + * + * @param strict whether the iterator should be strict or not + * + * @param useBitVector whether bitvectors should be used when available + **/ + virtual std::unique_ptr<queryeval::SearchIterator> + createIterator(fef::TermFieldMatchData *matchData, bool strict) = 0; + + /** + * Creates an attribute search iterator associated with this + * search context. Postings lists are not used. + * + * @return attribute search iterator + * + * @param matchData the attribute match data used when + * unpacking data for a hit + * + * @param strict whether the iterator should be strict or not + **/ + virtual std::unique_ptr<queryeval::SearchIterator> + createFilterIterator(fef::TermFieldMatchData *matchData, bool strict) = 0; + + /* + * Create temporary posting lists. Should be called before + * createIterator is called. + */ + virtual void fetchPostings(bool strict) = 0; + virtual bool valid() const = 0; + virtual Int64Range getAsIntegerTerm() const = 0; + + virtual const QueryTermBase & queryTerm() const = 0; + + }; + +} +} diff --git a/searchlib/src/vespa/searchlib/common/documentlocations.cpp b/searchlib/src/vespa/searchlib/common/documentlocations.cpp index 7ac0a68342b..4d66dbd366f 100644 --- a/searchlib/src/vespa/searchlib/common/documentlocations.cpp +++ b/searchlib/src/vespa/searchlib/common/documentlocations.cpp @@ -2,6 +2,7 @@ #include "documentlocations.h" #include <vespa/searchlib/attribute/attributeguard.h> +#include <vespa/searchlib/attribute/attributevector.h> namespace search { namespace common { diff --git a/searchlib/src/vespa/searchlib/common/range.h b/searchlib/src/vespa/searchlib/common/range.h index 3fd53b43a97..f33630daaf4 100644 --- a/searchlib/src/vespa/searchlib/common/range.h +++ b/searchlib/src/vespa/searchlib/common/range.h @@ -24,7 +24,7 @@ private: T _upper; }; -typedef Range<int64_t> Int64Range; +using Int64Range = Range<int64_t>; } // namespace search diff --git a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp index efc6af32396..b1c68c4ffff 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.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 "geoposdfw.h" -#include <vespa/searchlib/attribute/iattributemanager.h> #include <vespa/searchlib/common/documentlocations.h> #include <vespa/searchlib/common/location.h> #include <vespa/vespalib/util/jsonwriter.h> #include <vespa/vespalib/data/slime/cursor.h> +#include <vespa/vespalib/stllike/asciistream.h> #include <vespa/log/log.h> LOG_SETUP(".searchlib.docsummary.geoposdfw"); @@ -47,10 +47,8 @@ void fmtZcurve(int64_t zval, vespalib::JSONWriter json) json.endObject(); } -} // namespace <unnamed> - vespalib::asciistream -GeoPositionDFW::formatField(const IAttributeVector & attribute, uint32_t docid) +formatField(const IAttributeVector & attribute, uint32_t docid) { vespalib::asciistream target; vespalib::JSONWriter json(target); @@ -93,12 +91,11 @@ GeoPositionDFW::formatField(const IAttributeVector & attribute, uint32_t docid) return target; } +} + void -GeoPositionDFW::insertField(uint32_t docid, - GeneralResult *, - GetDocsumsState * dsState, - ResType, - vespalib::slime::Inserter &target) +GeoPositionDFW::insertField(uint32_t docid, GeneralResult *, GetDocsumsState * dsState, + ResType, vespalib::slime::Inserter &target) { using vespalib::slime::Cursor; using vespalib::slime::ObjectInserter; diff --git a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.h b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.h index 91d834d45a7..a36045f0268 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.h @@ -12,23 +12,14 @@ namespace docsummary { **/ class GeoPositionDFW : public AttrDFW { -private: - vespalib::asciistream formatField(const attribute::IAttributeVector & v, uint32_t docid); public: typedef std::unique_ptr<GeoPositionDFW> UP; GeoPositionDFW(const vespalib::string & attrName); - virtual uint32_t WriteField(uint32_t docid, - GeneralResult * gres, - GetDocsumsState * state, - ResType type, - search::RawBuf * target); - virtual void insertField(uint32_t docid, - GeneralResult *gres, - GetDocsumsState *state, - ResType type, - vespalib::slime::Inserter &target); - static UP create(const char *attribute_name, - IAttributeManager *attribute_manager); + uint32_t WriteField(uint32_t docid, GeneralResult * gres, GetDocsumsState * state, + ResType type, search::RawBuf * target) override; + void insertField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, + ResType type, vespalib::slime::Inserter &target) override; + static UP create(const char *attribute_name, IAttributeManager *attribute_manager); }; } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp index 3ffa437dcfb..4835b41d21c 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.cpp @@ -1,11 +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 "positionsdfw.h" -#include <cmath> #include "docsumstate.h" #include "idocsumenvironment.h" #include <vespa/searchlib/common/location.h> +#include <vespa/vespalib/stllike/asciistream.h> #include <vespa/log/log.h> LOG_SETUP(".searchlib.docsummary.positionsdfw"); @@ -20,12 +19,10 @@ using search::common::Location; AbsDistanceDFW::AbsDistanceDFW(const vespalib::string & attrName) : AttrDFW(attrName) -{ -} +{ } uint64_t -AbsDistanceDFW::findMinDistance(uint32_t docid, - GetDocsumsState *state) +AbsDistanceDFW::findMinDistance(uint32_t docid, GetDocsumsState *state) { search::common::Location &location = *state->_parsedLocation; const IAttributeVector & attribute(vec(*state)); @@ -68,11 +65,8 @@ AbsDistanceDFW::findMinDistance(uint32_t docid, } void -AbsDistanceDFW::insertField(uint32_t docid, - GeneralResult *, - GetDocsumsState *state, - ResType type, - vespalib::slime::Inserter &target) +AbsDistanceDFW::insertField(uint32_t docid, GeneralResult *, GetDocsumsState *state, + ResType type, vespalib::slime::Inserter &target) { bool forceEmpty = true; @@ -112,11 +106,8 @@ AbsDistanceDFW::insertField(uint32_t docid, uint32_t -AbsDistanceDFW::WriteField(uint32_t docid, - GeneralResult *gres, - GetDocsumsState *state, - ResType type, - search::RawBuf *target) +AbsDistanceDFW::WriteField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, + ResType type, search::RawBuf *target) { (void) gres; @@ -198,9 +189,9 @@ PositionsDFW::PositionsDFW(const vespalib::string & attrName) : { } +namespace { vespalib::asciistream -PositionsDFW::formatField(const attribute::IAttributeVector & attribute, uint32_t docid, ResType type) -{ +formatField(const attribute::IAttributeVector &attribute, uint32_t docid, ResType type) { vespalib::asciistream target; int32_t docx = 0; int32_t docy = 0; @@ -214,7 +205,7 @@ PositionsDFW::formatField(const attribute::IAttributeVector & attribute, uint32_ } LOG(debug, "docid=%d, numValues=%d", docid, numValues); - bool isShort = ! IsBinaryCompatible(type, RES_LONG_STRING); + bool isShort = !IDocsumFieldWriter::IsBinaryCompatible(type, RES_LONG_STRING); for (uint32_t i = 0; i < numValues; i++) { int64_t docxy(pos[i]); vespalib::geo::ZCurve::decode(docxy, &docx, &docy); @@ -222,9 +213,11 @@ PositionsDFW::formatField(const attribute::IAttributeVector & attribute, uint32_ LOG(spam, "skipping empty zcurve value"); continue; } - double degrees_ns = docy; degrees_ns /= 1000000.0; - double degrees_ew = docx; degrees_ew /= 1000000.0; - + double degrees_ns = docy; + degrees_ns /= 1000000.0; + double degrees_ew = docx; + degrees_ew /= 1000000.0; + target << "<position x=\"" << docx << "\" y=\"" << docy << "\""; target << " latlong=\""; target << vespalib::FloatSpec::fixed; @@ -247,14 +240,11 @@ PositionsDFW::formatField(const attribute::IAttributeVector & attribute, uint32_ } return target; } - +} uint32_t -PositionsDFW::WriteField(uint32_t docid, - GeneralResult *, - GetDocsumsState * dsState, - ResType type, - search::RawBuf *target) +PositionsDFW::WriteField(uint32_t docid, GeneralResult *, GetDocsumsState * dsState, + ResType type, search::RawBuf *target) { int str_len_ofs = target->GetUsedLen(); @@ -277,11 +267,8 @@ PositionsDFW::WriteField(uint32_t docid, void -PositionsDFW::insertField(uint32_t docid, - GeneralResult *, - GetDocsumsState * dsState, - ResType type, - vespalib::slime::Inserter &target) +PositionsDFW::insertField(uint32_t docid, GeneralResult *, GetDocsumsState * dsState, + ResType type, vespalib::slime::Inserter &target) { vespalib::asciistream val(formatField(vec(*dsState), docid, type)); target.insertString(vespalib::slime::Memory(val.c_str(), val.size())); diff --git a/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.h b/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.h index 301bf2ceecc..2140ea52a63 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/positionsdfw.h @@ -14,49 +14,31 @@ private: public: AbsDistanceDFW(const vespalib::string & attrName); - virtual bool IsGenerated() const { return true; } - virtual uint32_t WriteField(uint32_t docid, - GeneralResult *gres, - GetDocsumsState *state, - ResType type, - search::RawBuf *target); - virtual void insertField(uint32_t docid, - GeneralResult *gres, - GetDocsumsState *state, - ResType type, - vespalib::slime::Inserter &target); + bool IsGenerated() const override { return true; } + uint32_t WriteField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, + ResType type, search::RawBuf *target) override; + void insertField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, + ResType type, vespalib::slime::Inserter &target) override; }; //-------------------------------------------------------------------------- class PositionsDFW : public AttrDFW { -private: - vespalib::asciistream formatField(const attribute::IAttributeVector & v, uint32_t docid, ResType type); - public: typedef std::unique_ptr<PositionsDFW> UP; PositionsDFW(const vespalib::string & attrName); - virtual bool IsGenerated() const { return true; } - virtual uint32_t WriteField(uint32_t docid, - GeneralResult *gres, - GetDocsumsState *state, - ResType type, - search::RawBuf *target); - virtual void insertField(uint32_t docid, - GeneralResult *gres, - GetDocsumsState *state, - ResType type, - vespalib::slime::Inserter &target); + bool IsGenerated() const override { return true; } + uint32_t WriteField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, + ResType type, search::RawBuf *target) override; + void insertField(uint32_t docid, GeneralResult *gres, GetDocsumsState *state, + ResType type, vespalib::slime::Inserter &target) override ; }; -PositionsDFW::UP createPositionsDFW(const char *attribute_name, - IAttributeManager *index_man); - -AbsDistanceDFW::UP createAbsDistanceDFW(const char *attribute_name, - IAttributeManager *index_man); +PositionsDFW::UP createPositionsDFW(const char *attribute_name, IAttributeManager *index_man); +AbsDistanceDFW::UP createAbsDistanceDFW(const char *attribute_name, IAttributeManager *index_man); } // namespace docsummary } // namespace search diff --git a/storage/src/tests/common/teststorageapp.cpp b/storage/src/tests/common/teststorageapp.cpp index dcd19468ac7..de4d52d8f45 100644 --- a/storage/src/tests/common/teststorageapp.cpp +++ b/storage/src/tests/common/teststorageapp.cpp @@ -13,6 +13,8 @@ #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/config/config.h> +#include <vespa/config/helper/configgetter.hpp> + #include <vespa/log/log.h> LOG_SETUP(".test.servicelayerapp"); diff --git a/storage/src/tests/distributor/bucketdbupdatertest.cpp b/storage/src/tests/distributor/bucketdbupdatertest.cpp index cb89ade9167..d76132e24ab 100644 --- a/storage/src/tests/distributor/bucketdbupdatertest.cpp +++ b/storage/src/tests/distributor/bucketdbupdatertest.cpp @@ -1,26 +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/vdstestlib/cppunit/macros.h> #include <iomanip> -#include <iostream> -#include <memory> #include <vespa/storageapi/message/persistence.h> #include <vespa/storage/distributor/bucketdbupdater.h> -#include <vespa/storageapi/message/bucket.h> -#include <vespa/storageapi/message/state.h> -#include <vespa/document/fieldvalue/document.h> -#include <vespa/vdslib/state/random.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/storageapi/message/bucket.h> -#include <vespa/storage/distributor/pendingclusterstate.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> -#include <vespa/storageframework/storageframework.h> -#include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/storage/storageutil/distributorstatecache.h> #include <tests/distributor/distributortestutil.h> -#include <tests/distributor/messagesenderstub.h> #include <vespa/storage/distributor/simpleclusterinformation.h> +#include <vespa/storage/distributor/distributor.h> #include <iostream> #include <fstream> diff --git a/storage/src/tests/distributor/bucketstateoperationtest.cpp b/storage/src/tests/distributor/bucketstateoperationtest.cpp index 1477f1d6ed0..67346626ad0 100644 --- a/storage/src/tests/distributor/bucketstateoperationtest.cpp +++ b/storage/src/tests/distributor/bucketstateoperationtest.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 <cppunit/extensions/HelperMacros.h> #include <tests/distributor/distributortestutil.h> #include <vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h> -#include <vespa/storageapi/messageapi/storagemessage.h> +#include <vespa/storage/distributor/distributor.h> namespace storage { diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp index 4bea7b3646a..40359ef460f 100644 --- a/storage/src/tests/distributor/distributortest.cpp +++ b/storage/src/tests/distributor/distributortest.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 <iomanip> #include <iostream> #include <memory> @@ -14,6 +14,7 @@ #include <tests/distributor/distributortestutil.h> #include <vespa/storage/config/config-stor-distributormanager.h> #include <tests/common/dummystoragelink.h> +#include <vespa/storage/distributor/distributor.h> namespace storage { diff --git a/storage/src/tests/distributor/distributortestutil.cpp b/storage/src/tests/distributor/distributortestutil.cpp index 4ed95011e97..1570aa98acc 100644 --- a/storage/src/tests/distributor/distributortestutil.cpp +++ b/storage/src/tests/distributor/distributortestutil.cpp @@ -2,13 +2,20 @@ #include <vespa/document/base/testdocman.h> #include <vespa/storageframework/defaultimplementation/memory/nomemorymanager.h> #include <tests/distributor/distributortestutil.h> -#include <vespa/vespalib/text/stringtokenizer.h> +#include <vespa/storage/distributor/distributor.h> #include <vespa/config-stor-distribution.h> namespace storage { namespace distributor { +DistributorTestUtil::DistributorTestUtil() + : _messageSender(_sender, _senderDown) +{ + _config = getStandardConfig(false); +} +DistributorTestUtil::~DistributorTestUtil() { } + void DistributorTestUtil::createLinks() { @@ -305,6 +312,51 @@ DistributorTestUtil::disableBucketActivationInConfig(bool disable) getConfig().configure(config); } +BucketDBUpdater& +DistributorTestUtil::getBucketDBUpdater() { + return _distributor->_bucketDBUpdater; +} +IdealStateManager& +DistributorTestUtil::getIdealStateManager() { + return _distributor->_idealStateManager; +} +ExternalOperationHandler& +DistributorTestUtil::getExternalOperationHandler() { + return _distributor->_externalOperationHandler; +} + +bool +DistributorTestUtil::tick() { + framework::ThreadWaitInfo res( + framework::ThreadWaitInfo::NO_MORE_CRITICAL_WORK_KNOWN); + { + framework::TickingLockGuard lock( + _distributor->_threadPool.freezeCriticalTicks()); + res.merge(_distributor->doCriticalTick(0)); + } + res.merge(_distributor->doNonCriticalTick(0)); + return !res.waitWanted(); +} + +DistributorConfiguration& +DistributorTestUtil::getConfig() { + return const_cast<DistributorConfiguration&>(_distributor->getConfig()); +} + +BucketDatabase& +DistributorTestUtil::getBucketDatabase() { + return _distributor->getDefaultBucketSpace().getBucketDatabase(); +} +const BucketDatabase& +DistributorTestUtil::getBucketDatabase() const { + return _distributor->getDefaultBucketSpace().getBucketDatabase(); +} + +const lib::Distribution& +DistributorTestUtil::getDistribution() const { + return _distributor->getDefaultBucketSpace().getDistribution(); +} + } } diff --git a/storage/src/tests/distributor/distributortestutil.h b/storage/src/tests/distributor/distributortestutil.h index b7375be8e98..d984e486cee 100644 --- a/storage/src/tests/distributor/distributortestutil.h +++ b/storage/src/tests/distributor/distributortestutil.h @@ -4,7 +4,6 @@ #include <tests/common/dummystoragelink.h> #include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> #include <vespa/storage/common/hostreporter/hostinfo.h> -#include <vespa/storage/distributor/distributor.h> #include <vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h> #include <vespa/storage/storageutil/utils.h> #include <tests/common/teststorageapp.h> @@ -13,18 +12,21 @@ #include <tests/common/testhelper.h> namespace storage { + namespace framework { class TickingThreadPool; } namespace distributor { +class BucketDBUpdater; +class Distributor; +class IdealStateManager; +class ExternalOperationHandler; +class Operation; + class DistributorTestUtil : private DoneInitializeHandler { public: - DistributorTestUtil() - : _messageSender(_sender, _senderDown) - { - _config = getStandardConfig(false); - } - virtual ~DistributorTestUtil() {}; + DistributorTestUtil(); + ~DistributorTestUtil(); /** * Sets up the storage link chain. @@ -101,51 +103,27 @@ public: int idx = -1, api::ReturnCode::Result result = api::ReturnCode::OK); - BucketDBUpdater& getBucketDBUpdater() { - return _distributor->_bucketDBUpdater; - } - IdealStateManager& getIdealStateManager() { - return _distributor->_idealStateManager; - } - ExternalOperationHandler& getExternalOperationHandler() { - return _distributor->_externalOperationHandler; - } + BucketDBUpdater& getBucketDBUpdater(); + IdealStateManager& getIdealStateManager(); + ExternalOperationHandler& getExternalOperationHandler(); Distributor& getDistributor() { return *_distributor; } - bool tick() { - framework::ThreadWaitInfo res( - framework::ThreadWaitInfo::NO_MORE_CRITICAL_WORK_KNOWN); - { - framework::TickingLockGuard lock( - _distributor->_threadPool.freezeCriticalTicks()); - res.merge(_distributor->doCriticalTick(0)); - } - res.merge(_distributor->doNonCriticalTick(0)); - return !res.waitWanted(); - } + bool tick(); - DistributorConfiguration& getConfig() { - return const_cast<DistributorConfiguration&>(_distributor->getConfig()); - } + DistributorConfiguration& getConfig(); vdstestlib::DirConfig& getDirConfig() { return _config; } // TODO explicit notion of bucket spaces for tests - BucketDatabase& getBucketDatabase() { - return _distributor->getDefaultBucketSpace().getBucketDatabase(); - } - const BucketDatabase& getBucketDatabase() const { - return _distributor->getDefaultBucketSpace().getBucketDatabase(); - } + BucketDatabase& getBucketDatabase(); + const BucketDatabase& getBucketDatabase() const; - const lib::Distribution& getDistribution() const { - return _distributor->getDefaultBucketSpace().getDistribution(); - } + const lib::Distribution& getDistribution() const; // "End to end" distribution change trigger, which will invoke the bucket // DB updater as expected based on the previous and new cluster state // and config. @@ -185,7 +163,7 @@ public: protected: vdstestlib::DirConfig _config; std::unique_ptr<TestDistributorApp> _node; - framework::TickingThreadPool::UP _threadPool; + std::unique_ptr<framework::TickingThreadPool> _threadPool; std::unique_ptr<Distributor> _distributor; std::unique_ptr<storage::DistributorComponent> _component; MessageSenderStub _sender; diff --git a/storage/src/tests/distributor/externaloperationhandlertest.cpp b/storage/src/tests/distributor/externaloperationhandlertest.cpp index 83be15c3576..c63db0c01e6 100644 --- a/storage/src/tests/distributor/externaloperationhandlertest.cpp +++ b/storage/src/tests/distributor/externaloperationhandlertest.cpp @@ -1,12 +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/distributortestutil.h> #include <vespa/storage/distributor/externaloperationhandler.h> #include <vespa/storageapi/message/persistence.h> -#include <vespa/storageapi/message/state.h> -#include <vespa/vdstestlib/cppunit/macros.h> -#include <vespa/document/base/testdocman.h> +#include <vespa/storage/distributor/distributor.h> namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/garbagecollectiontest.cpp b/storage/src/tests/distributor/garbagecollectiontest.cpp index 399222f0e34..73d872d3331 100644 --- a/storage/src/tests/distributor/garbagecollectiontest.cpp +++ b/storage/src/tests/distributor/garbagecollectiontest.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 <cppunit/extensions/HelperMacros.h> #include <vespa/storageapi/message/removelocation.h> #include <vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h> #include <vespa/storage/distributor/idealstatemanager.h> #include <tests/distributor/distributortestutil.h> +#include <vespa/storage/distributor/distributor.h> namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp index d9013ca2c22..43cfb27b799 100644 --- a/storage/src/tests/distributor/getoperationtest.cpp +++ b/storage/src/tests/distributor/getoperationtest.cpp @@ -1,13 +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/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/storage/distributor/externaloperationhandler.h> -#include <vespa/storage/distributor/distributormetricsset.h> -#include <vespa/storageapi/message/persistence.h> +#include <vespa/storage/distributor/distributor.h> #include <tests/distributor/distributortestutil.h> +#include <vespa/storageapi/message/persistence.h> #include <tests/common/dummystoragelink.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/testkit/testapp.h> diff --git a/storage/src/tests/distributor/idealstatemanagertest.cpp b/storage/src/tests/distributor/idealstatemanagertest.cpp index 9c97a2ba967..0522f0d4bc2 100644 --- a/storage/src/tests/distributor/idealstatemanagertest.cpp +++ b/storage/src/tests/distributor/idealstatemanagertest.cpp @@ -1,23 +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/vdstestlib/cppunit/macros.h> #include <tests/common/dummystoragelink.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storage/distributor/bucketdbupdater.h> -#include <vespa/document/fieldvalue/document.h> -#include <vespa/storage/common/bucketmessages.h> -#include <vespa/storage/distributor/idealstatemanager.h> +#include <vespa/storage/distributor/distributor.h> #include <vespa/storage/distributor/operations/idealstate/mergeoperation.h> -#include <vespa/storage/distributor/operations/idealstate/removebucketoperation.h> -#include <vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h> -#include <vespa/storage/distributor/operations/idealstate/splitoperation.h> #include <vespa/storageapi/message/stat.h> #include <vespa/storageapi/message/visitor.h> #include <vespa/storageapi/message/bucketsplitting.h> -#include <vespa/storage/storageutil/utils.h> #include <tests/distributor/distributortestutil.h> -#include <vespa/storage/distributor/statecheckers.h> -#include <vespa/storageapi/message/state.h> + + namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/joinbuckettest.cpp b/storage/src/tests/distributor/joinbuckettest.cpp index ec7e3aaac32..2e80605cc47 100644 --- a/storage/src/tests/distributor/joinbuckettest.cpp +++ b/storage/src/tests/distributor/joinbuckettest.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 <cppunit/extensions/HelperMacros.h> #include <vespa/storageapi/message/bucketsplitting.h> #include <vespa/storage/distributor/operations/idealstate/joinoperation.h> -#include <vespa/storage/distributor/idealstatemanager.h> +#include <vespa/storage/distributor/distributor.h> #include <tests/distributor/distributortestutil.h> namespace storage { diff --git a/storage/src/tests/distributor/mergeoperationtest.cpp b/storage/src/tests/distributor/mergeoperationtest.cpp index a2373731bc3..bd71b69673a 100644 --- a/storage/src/tests/distributor/mergeoperationtest.cpp +++ b/storage/src/tests/distributor/mergeoperationtest.cpp @@ -3,17 +3,13 @@ #include <boost/lexical_cast.hpp> #include <cppunit/extensions/HelperMacros.h> #include <iomanip> -#include <iostream> -#include <memory> #include <tests/common/dummystoragelink.h> #include <vespa/storage/distributor/idealstatemanager.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storage/distributor/operations/idealstate/mergeoperation.h> -#include <vespa/storage/distributor/pendingmessagetracker.h> -#include <vespa/storageapi/message/bucket.h> #include <vespa/storage/distributor/bucketdbupdater.h> #include <tests/distributor/distributortestutil.h> -#include <vespa/vespalib/text/stringtokenizer.h> +#include <vespa/storage/distributor/distributor.h> using std::shared_ptr; diff --git a/storage/src/tests/distributor/messagesenderstub.h b/storage/src/tests/distributor/messagesenderstub.h index d70c5355868..7b552ec6883 100644 --- a/storage/src/tests/distributor/messagesenderstub.h +++ b/storage/src/tests/distributor/messagesenderstub.h @@ -1,7 +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 <vespa/storage/distributor/distributor.h> #include <vespa/storage/distributor/distributormessagesender.h> namespace storage { diff --git a/storage/src/tests/distributor/operationtargetresolvertest.cpp b/storage/src/tests/distributor/operationtargetresolvertest.cpp index 3b62bd20299..d55c5658d2c 100644 --- a/storage/src/tests/distributor/operationtargetresolvertest.cpp +++ b/storage/src/tests/distributor/operationtargetresolvertest.cpp @@ -1,21 +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/fastos.h> #include <iomanip> #include <iostream> -#include <memory> #include <vespa/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storageapi/message/persistence.h> -#include <vespa/storageapi/message/state.h> #include <tests/distributor/distributortestutil.h> -#include <tests/common/dummystoragelink.h> #include <vespa/vdslib/distribution/idealnodecalculatorimpl.h> -#include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/storage/distributor/operationtargetresolverimpl.h> +#include <vespa/storage/distributor/externaloperationhandler.h> using document::BucketId; diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp index da99ca9e019..a8a76bbbf75 100644 --- a/storage/src/tests/distributor/putoperationtest.cpp +++ b/storage/src/tests/distributor/putoperationtest.cpp @@ -1,10 +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/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/storage/distributor/operations/external/putoperation.h> +#include <vespa/storage/distributor/distributor.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storageapi/message/state.h> @@ -14,8 +14,6 @@ #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/vespalib/testkit/test_kit.h> #include <iomanip> -#include <iostream> -#include <memory> using std::shared_ptr; using config::ConfigGetter; diff --git a/storage/src/tests/distributor/removebucketoperationtest.cpp b/storage/src/tests/distributor/removebucketoperationtest.cpp index aeceefa15a0..7cf63a3146f 100644 --- a/storage/src/tests/distributor/removebucketoperationtest.cpp +++ b/storage/src/tests/distributor/removebucketoperationtest.cpp @@ -1,13 +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 <cppunit/extensions/HelperMacros.h> #include <tests/common/dummystoragelink.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/storage/distributor/operations/idealstate/removebucketoperation.h> #include <vespa/storage/distributor/idealstatemanager.h> -#include <vespa/storage/distributor/pendingmessagetracker.h> -#include <vespa/storage/storageutil/utils.h> +#include <vespa/storage/distributor/distributor.h> #include <tests/distributor/distributortestutil.h> namespace storage { diff --git a/storage/src/tests/distributor/removelocationtest.cpp b/storage/src/tests/distributor/removelocationtest.cpp index 7a1bba86303..954bfb6210b 100644 --- a/storage/src/tests/distributor/removelocationtest.cpp +++ b/storage/src/tests/distributor/removelocationtest.cpp @@ -1,13 +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 <cppunit/extensions/HelperMacros.h> #include <iomanip> -#include <iostream> -#include <memory> #include <tests/common/dummystoragelink.h> #include <vespa/storageapi/message/removelocation.h> #include <vespa/storage/distributor/operations/external/removelocationoperation.h> #include <tests/distributor/distributortestutil.h> +#include <vespa/storage/distributor/distributor.h> namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/removeoperationtest.cpp b/storage/src/tests/distributor/removeoperationtest.cpp index 7907541a7c7..9d0849962e4 100644 --- a/storage/src/tests/distributor/removeoperationtest.cpp +++ b/storage/src/tests/distributor/removeoperationtest.cpp @@ -1,12 +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 <cppunit/extensions/HelperMacros.h> #include <iomanip> -#include <iostream> -#include <memory> #include <tests/common/dummystoragelink.h> -#include <vespa/storage/distributor/externaloperationhandler.h> +#include <vespa/storage/distributor/distributor.h> #include <vespa/storageapi/message/persistence.h> #include <tests/distributor/distributortestutil.h> #include <vespa/storage/distributor/operations/external/removeoperation.h> diff --git a/storage/src/tests/distributor/splitbuckettest.cpp b/storage/src/tests/distributor/splitbuckettest.cpp index d0fa69d600e..c69af0e038c 100644 --- a/storage/src/tests/distributor/splitbuckettest.cpp +++ b/storage/src/tests/distributor/splitbuckettest.cpp @@ -1,18 +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 <cppunit/extensions/HelperMacros.h> #include <iomanip> -#include <iostream> -#include <memory> #include <tests/common/dummystoragelink.h> #include <vespa/storageapi/message/bucketsplitting.h> #include <vespa/storage/distributor/operations/idealstate/splitoperation.h> -#include <vespa/storage/common/bucketmessages.h> #include <vespa/document/base/documentid.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storage/distributor/idealstatemanager.h> #include <vespa/storageapi/message/multioperation.h> #include <tests/distributor/distributortestutil.h> +#include <vespa/storage/distributor/distributor.h> using std::shared_ptr; using namespace document; diff --git a/storage/src/tests/distributor/statecheckerstest.cpp b/storage/src/tests/distributor/statecheckerstest.cpp index a3603eae6b3..ef04453b27f 100644 --- a/storage/src/tests/distributor/statecheckerstest.cpp +++ b/storage/src/tests/distributor/statecheckerstest.cpp @@ -19,6 +19,7 @@ #include <vespa/storage/distributor/statecheckers.h> #include <vespa/storageapi/message/state.h> #include <vespa/config-stor-distribution.h> +#include <vespa/storage/distributor/distributor.h> using namespace std::literals::string_literals; diff --git a/storage/src/tests/distributor/statoperationtest.cpp b/storage/src/tests/distributor/statoperationtest.cpp index 22fee6e44d7..f35869cf680 100644 --- a/storage/src/tests/distributor/statoperationtest.cpp +++ b/storage/src/tests/distributor/statoperationtest.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 <tests/common/dummystoragelink.h> #include <vespa/storageapi/message/stat.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <tests/distributor/distributortestutil.h> #include <vespa/storage/distributor/operations/external/statbucketoperation.h> #include <vespa/storage/distributor/operations/external/statbucketlistoperation.h> +#include <vespa/storage/distributor/distributor.h> namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp index 60f836e3ea7..8556f5b5229 100644 --- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp +++ b/storage/src/tests/distributor/twophaseupdateoperationtest.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/config/helper/configgetter.h> #include <cppunit/extensions/HelperMacros.h> #include <vespa/document/config/config-documenttypes.h> @@ -7,17 +7,13 @@ #include <vespa/document/base/testdocrepo.h> #include <vespa/document/update/arithmeticvalueupdate.h> #include <iomanip> -#include <iostream> -#include <memory> #include <tests/common/dummystoragelink.h> #include <vespa/storage/distributor/externaloperationhandler.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storage/distributor/operations/external/twophaseupdateoperation.h> -#include <vespa/storageapi/message/state.h> #include <vespa/storageapi/message/batch.h> -#include <vespa/storageapi/message/bucket.h> #include <tests/distributor/distributortestutil.h> -#include <tests/distributor/messagesenderstub.h> +#include <vespa/storage/distributor/distributor.h> namespace storage { namespace distributor { diff --git a/storage/src/tests/distributor/updateoperationtest.cpp b/storage/src/tests/distributor/updateoperationtest.cpp index d0b4bf39db6..07813faa03b 100644 --- a/storage/src/tests/distributor/updateoperationtest.cpp +++ b/storage/src/tests/distributor/updateoperationtest.cpp @@ -1,19 +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 <cppunit/extensions/HelperMacros.h> #include <iomanip> -#include <iostream> -#include <memory> #include <tests/common/dummystoragelink.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storageapi/message/state.h> #include <vespa/storageapi/message/bucket.h> #include <tests/distributor/distributortestutil.h> -#include <vespa/config/helper/configgetter.h> -#include <vespa/document/config/config-documenttypes.h> -#include <tests/distributor/messagesenderstub.h> #include <vespa/storage/distributor/operations/external/updateoperation.h> #include <vespa/vespalib/testkit/test_kit.h> +#include <vespa/storage/distributor/distributor.h> using std::shared_ptr; using namespace document; diff --git a/storage/src/tests/distributor/visitoroperationtest.cpp b/storage/src/tests/distributor/visitoroperationtest.cpp index 7bd9eea29b0..caf326a8720 100644 --- a/storage/src/tests/distributor/visitoroperationtest.cpp +++ b/storage/src/tests/distributor/visitoroperationtest.cpp @@ -1,5 +1,4 @@ // 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 <iomanip> #include <iostream> #include <memory> @@ -11,6 +10,7 @@ #include <vespa/storage/distributor/operations/external/visitoroperation.h> #include <vespa/storage/distributor/operations/external/visitororder.h> #include <tests/distributor/distributortestutil.h> +#include <vespa/storage/distributor/distributor.h> #include <tests/common/dummystoragelink.h> #include <vespa/vdstestlib/cppunit/macros.h> diff --git a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp index e5db345505c..2e4179d5c4b 100644 --- a/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp +++ b/storage/src/vespa/storage/bucketdb/storagebucketdbinitializer.cpp @@ -11,6 +11,7 @@ #include <vespa/vespalib/io/fileutil.h> #include <vespa/config/config.h> #include <vespa/vespalib/stllike/hash_map.hpp> +#include <vespa/config/helper/configgetter.hpp> #include <iomanip> #include <vespa/log/log.h> diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.h b/storage/src/vespa/storage/distributor/bucketdbupdater.h index 84903b9fe57..c87907fe0b2 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.h +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.h @@ -1,27 +1,27 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <set> +#include "bucketlistmerger.h" +#include "messageguard.h" +#include "distributorcomponent.h" +#include "distributormessagesender.h" +#include "pendingclusterstate.h" +#include "managed_bucket_space_component.h" #include <vespa/document/bucket/bucketid.h> #include <vespa/storageapi/messageapi/returncode.h> #include <vespa/storageapi/message/bucket.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/storage/common/storagelink.h> #include <vespa/storageframework/storageframework.h> -#include <vespa/storage/distributor/bucketlistmerger.h> -#include <vespa/storage/distributor/messageguard.h> -#include <vespa/storage/distributor/distributorcomponent.h> -#include <vespa/storage/distributor/distributormessagesender.h> -#include <vespa/storage/distributor/pendingclusterstate.h> -#include <vespa/storage/distributor/managed_bucket_space_component.h> + #include <vespa/storageframework/generic/memory/memorymanagerinterface.h> #include <vespa/storageapi/messageapi/messagehandler.h> +#include <set> +#include <deque> -namespace storage -{ +namespace storage { -namespace distributor -{ +namespace distributor { class Distributor; diff --git a/storage/src/vespa/storage/distributor/distributor.h b/storage/src/vespa/storage/distributor/distributor.h index f7f186699bf..c56f4f9456a 100644 --- a/storage/src/vespa/storage/distributor/distributor.h +++ b/storage/src/vespa/storage/distributor/distributor.h @@ -2,24 +2,25 @@ #pragma once -#include <vespa/config/config.h> + +#include "idealstatemanager.h" +#include "bucketdbupdater.h" +#include "pendingmessagetracker.h" +#include "externaloperationhandler.h" +#include "maintenancebucket.h" +#include "min_replica_provider.h" +#include "distributorinterface.h" + +#include "statusreporterdelegate.h" +#include "distributor_host_info_reporter.h" +#include <vespa/storage/distributor/maintenance/maintenancescheduler.h> +#include <vespa/storage/distributor/bucketdb/bucketdbmetricupdater.h> #include <vespa/storage/common/distributorcomponent.h> #include <vespa/storage/common/doneinitializehandler.h> #include <vespa/storage/common/messagesender.h> -#include <vespa/storage/distributor/idealstatemanager.h> -#include <vespa/storage/distributor/bucketdbupdater.h> -#include <vespa/storage/distributor/pendingmessagetracker.h> -#include <vespa/storage/distributor/externaloperationhandler.h> -#include <vespa/storage/distributor/bucketdb/bucketdbmetricupdater.h> -#include <vespa/storage/distributor/bucketdbupdater.h> -#include <vespa/storage/distributor/maintenancebucket.h> -#include <vespa/storage/distributor/min_replica_provider.h> -#include <vespa/storage/distributor/distributorinterface.h> -#include <vespa/storage/distributor/maintenance/maintenancescheduler.h> -#include <vespa/storage/distributor/statusreporterdelegate.h> -#include <vespa/storage/distributor/distributor_host_info_reporter.h> #include <vespa/storageapi/message/state.h> #include <vespa/storageframework/generic/thread/tickingthread.h> +#include <vespa/config/config.h> #include <vespa/vespalib/util/sync.h> #include <unordered_map> diff --git a/storage/src/vespa/storage/distributor/externaloperationhandler.cpp b/storage/src/vespa/storage/distributor/externaloperationhandler.cpp index bc0429f806c..c5354c54f25 100644 --- a/storage/src/vespa/storage/distributor/externaloperationhandler.cpp +++ b/storage/src/vespa/storage/distributor/externaloperationhandler.cpp @@ -32,16 +32,12 @@ ExternalOperationHandler::ExternalOperationHandler( ManagedBucketSpace& bucketSpace, const MaintenanceOperationGenerator& gen, DistributorComponentRegister& compReg) - : ManagedBucketSpaceComponent(owner, bucketSpace, compReg, - "External operation handler"), + : ManagedBucketSpaceComponent(owner, bucketSpace, compReg, "External operation handler"), _operationGenerator(gen), _rejectFeedBeforeTimeReached() // At epoch -{ -} +{ } -ExternalOperationHandler::~ExternalOperationHandler() -{ -} +ExternalOperationHandler::~ExternalOperationHandler() { } bool ExternalOperationHandler::handleMessage( diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.h b/storage/src/vespa/storage/distributor/pendingclusterstate.h index c4d83f439a0..939eb5fcd13 100644 --- a/storage/src/vespa/storage/distributor/pendingclusterstate.h +++ b/storage/src/vespa/storage/distributor/pendingclusterstate.h @@ -9,6 +9,7 @@ #include <vespa/storage/bucketdb/bucketdatabase.h> #include <vespa/storage/distributor/clusterinformation.h> #include <unordered_set> +#include <deque> namespace storage { diff --git a/storage/src/vespa/storage/persistence/persistenceutil.cpp b/storage/src/vespa/storage/persistence/persistenceutil.cpp index 0df12bdfb01..2d8a8561ba6 100644 --- a/storage/src/vespa/storage/persistence/persistenceutil.cpp +++ b/storage/src/vespa/storage/persistence/persistenceutil.cpp @@ -2,12 +2,12 @@ #include "persistenceutil.h" #include <vespa/config/config.h> -#include <vespa/log/log.h> - -namespace storage { +#include <vespa/config/helper/configgetter.hpp> +#include <vespa/log/log.h> LOG_SETUP(".persistence.util"); +namespace storage { namespace { std::string generateName(void* p) { std::ostringstream ost; diff --git a/storage/src/vespa/storage/storageserver/statemanager.h b/storage/src/vespa/storage/storageserver/statemanager.h index d1838e851d1..537ecec2e72 100644 --- a/storage/src/vespa/storage/storageserver/statemanager.h +++ b/storage/src/vespa/storage/storageserver/statemanager.h @@ -13,8 +13,6 @@ */ #pragma once -#include <map> -#include <atomic> #include <vespa/storage/common/hostreporter/hostinfo.h> #include <vespa/storage/common/nodestateupdater.h> #include <vespa/storage/common/storagelink.h> @@ -23,6 +21,9 @@ #include <vespa/storageframework/storageframework.h> #include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/objects/floatingpointtype.h> +#include <deque> +#include <map> +#include <atomic> namespace metrics { class MetricManager; diff --git a/storage/src/vespa/storage/tools/getidealstate.cpp b/storage/src/vespa/storage/tools/getidealstate.cpp index da32aba9897..c3c7a4ba480 100644 --- a/storage/src/vespa/storage/tools/getidealstate.cpp +++ b/storage/src/vespa/storage/tools/getidealstate.cpp @@ -7,6 +7,7 @@ #include <vespa/config/config.h> #include <vespa/config/print/ostreamconfigwriter.h> #include <vespa/config-stor-distribution.h> +#include <vespa/config/helper/configgetter.hpp> #include <iostream> #include <sstream> diff --git a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h index 997a55d00fc..0d3b9938089 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h +++ b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.h @@ -2,12 +2,13 @@ #pragma once +#include "rankmanager.h" #include <vespa/searchsummary/docsummary/juniperproperties.h> #include <vespa/storage/visiting/visitor.h> #include <vespa/config/retriever/simpleconfigurer.h> #include <vespa/config/subscription/configuri.h> #include <vespa/vsm/vsm/vsm-adapter.h> -#include "rankmanager.h" +#include <vespa/fastlib/text/normwordfolder.h> namespace storage { diff --git a/vdslib/src/tests/distribution/distributiontest.cpp b/vdslib/src/tests/distribution/distributiontest.cpp index fbd9e86f9ac..868e57cab2b 100644 --- a/vdslib/src/tests/distribution/distributiontest.cpp +++ b/vdslib/src/tests/distribution/distributiontest.cpp @@ -3,20 +3,19 @@ #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/distribution/idealnodecalculator.h> #include <vespa/config/helper/configfetcher.h> -#include <cmath> #include <chrono> #include <thread> #include <fstream> -#include <stdlib.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/vespalib/util/regexp.h> #include <vespa/vespalib/stllike/lexical_cast.h> -#include <vespa/vdslib/state/clusterstate.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/config-stor-distribution.h> +#include <vespa/config/helper/configgetter.hpp> + namespace storage { namespace lib { diff --git a/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp b/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp index 3816fc765d2..b6367281be9 100644 --- a/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp +++ b/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.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/vespaclient/clusterlist/clusterlist.h> #include <vespa/config/config.h> +#include <vespa/config/helper/configgetter.hpp> #include <sstream> using namespace vespaclient; diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp index d338769d4fd..37a2b981063 100644 --- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp +++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp @@ -1,19 +1,21 @@ // 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/fnet/frt/frt.h> #include <vespa/slobrok/sbmirror.h> #include <iostream> -#include <vespa/log/log.h> #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/vespalib/util/programoptions.h> #include <vespa/vespaclient/clusterlist/clusterlist.h> #include <vespa/vespalib/text/lowercase.h> #include <vespa/config-stor-distribution.h> +#include <vespa/config/helper/configgetter.hpp> +#include <vespa/fastos/app.h> +#include <vespa/log/log.h> LOG_SETUP("vdsstatetool"); namespace storage { diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.cpp b/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.cpp index 6bca0db2991..ae2c362aae2 100644 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.cpp +++ b/vespaclient/src/vespa/vespaclient/vespadoclocator/locator.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 <boost/tokenizer.hpp> #include <vespa/documentapi/messagebus/documentprotocol.h> #include <vespa/messagebus/configagent.h> @@ -8,6 +8,8 @@ #include <vespa/vdslib/bucketdistribution.h> #include <vespa/messagebus/config-messagebus.h> #include <vespa/config/helper/configgetter.h> +#include <vespa/config/helper/configgetter.hpp> + #include "locator.h" diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp index 7d4db8732c0..c5d29b23d99 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.cpp @@ -1,25 +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("vesparoute"); #include "application.h" -#include "params.h" -#include <vespa/config/helper/configgetter.h> #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/util/stringutil.h> #include <vespa/documentapi/messagebus/documentprotocol.h> #include <vespa/messagebus/configagent.h> -#include <vespa/messagebus/network/rpcsendv1.h> -#include <vespa/messagebus/routing/policydirective.h> +#include <vespa/messagebus/routing/routingtable.h> #include <vespa/messagebus/routing/routedirective.h> #include <vespa/messagebus/rpcmessagebus.h> -#include <vespa/messagebus/config-messagebus.h> #include <vespa/slobrok/sbmirror.h> -#include <algorithm> -#include <vector> +#include <vespa/config/helper/configgetter.hpp> + using config::ConfigGetter; using document::DocumenttypesConfig; diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.h b/vespaclient/src/vespa/vespaclient/vesparoute/application.h index bdfbd8d3c92..215ffaecfcf 100644 --- a/vespaclient/src/vespa/vespaclient/vesparoute/application.h +++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.h @@ -3,6 +3,7 @@ #include <vespa/fastos/app.h> #include <vespa/messagebus/messagebus.h> +#include <vespa/messagebus/routing/hopblueprint.h> #include "mynetwork.h" #include "params.h" #include <vespa/documentapi/loadtypes/loadtypeset.h> |