diff options
34 files changed, 145 insertions, 114 deletions
diff --git a/documentapi/src/tests/policies/policies_test.cpp b/documentapi/src/tests/policies/policies_test.cpp index ac48f66d1e6..4362a7a096e 100644 --- a/documentapi/src/tests/policies/policies_test.cpp +++ b/documentapi/src/tests/policies/policies_test.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("policies_test"); #include <vespa/document/config/config-documenttypes.h> #include <vespa/document/datatype/datatype.h> @@ -29,6 +26,8 @@ LOG_SETUP("policies_test"); #include <vespa/vdslib/container/mutabledocumentlist.h> #include <vespa/vespalib/testkit/testapp.h> #include "testframe.h" +#include <vespa/log/log.h> +LOG_SETUP("policies_test"); using document::DataType; using document::Document; @@ -920,7 +919,7 @@ namespace { ost << "group[0].nodes[" << i << "].index " << i << "\n"; } ost << "disk_distribution " - << vespa::config::content::StorDistributionConfig::getDiskDistributionName(distr) + << storage::lib::Distribution::getDiskDistributionName(distr) << "\n"; return ost.str(); } diff --git a/documentapi/src/tests/policies/testframe.h b/documentapi/src/tests/policies/testframe.h index 6c3080974d1..26039cf951e 100644 --- a/documentapi/src/tests/policies/testframe.h +++ b/documentapi/src/tests/policies/testframe.h @@ -9,6 +9,7 @@ #include <vespa/messagebus/testlib/receptor.h> #include <vespa/messagebus/testlib/slobrok.h> #include <vespa/documentapi/loadtypes/loadtypeset.h> +#include <vespa/document/repo/documenttyperepo.h> using documentapi::string; diff --git a/documentapi/src/tests/policyfactory/policyfactory.cpp b/documentapi/src/tests/policyfactory/policyfactory.cpp index 25ce9f3d1c9..d8db57c9ecb 100644 --- a/documentapi/src/tests/policyfactory/policyfactory.cpp +++ b/documentapi/src/tests/policyfactory/policyfactory.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> - +#include <vespa/documentapi/messagebus/iroutingpolicyfactory.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/documentapi/messagebus/documentprotocol.h> #include <vespa/documentapi/loadtypes/loadtypeset.h> diff --git a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp index 59dc90343b8..0849a93acbc 100644 --- a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.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(".documentprotocol"); #include "routablefactories50.h" #include "routablefactories51.h" @@ -15,6 +12,10 @@ LOG_SETUP(".documentprotocol"); #include <vespa/messagebus/routing/routingcontext.h> #include <vespa/vespalib/component/versionspecification.h> #include <vespa/vespalib/util/exceptions.h> +#include "routablerepository.h" +#include "routingpolicyrepository.h" +#include <vespa/log/log.h> +LOG_SETUP(".documentprotocol"); using document::DocumentTypeRepo; @@ -25,8 +26,8 @@ const mbus::string DocumentProtocol::NAME = "document"; DocumentProtocol::DocumentProtocol(const LoadTypeSet& loadTypes, DocumentTypeRepo::SP repo, const string &configId) : - _routingPolicyRepository(), - _routableRepository(loadTypes), + _routingPolicyRepository(new RoutingPolicyRepository()), + _routableRepository(new RoutableRepository(loadTypes)), _systemState(SystemState::newInstance("")), _repo(repo) { @@ -108,23 +109,25 @@ DocumentProtocol::DocumentProtocol(const LoadTypeSet& loadTypes, putRoutableFactory(MESSAGE_REMOVEDOCUMENT, IRoutableFactory::SP(new RoutableFactories52::RemoveDocumentMessageFactory()), from52); } +DocumentProtocol::~DocumentProtocol() { } + mbus::IRoutingPolicy::UP DocumentProtocol::createPolicy(const mbus::string &name, const mbus::string ¶m) const { - return _routingPolicyRepository.createPolicy(name, param); + return _routingPolicyRepository->createPolicy(name, param); } DocumentProtocol & DocumentProtocol::putRoutingPolicyFactory(const string &name, IRoutingPolicyFactory::SP factory) { - _routingPolicyRepository.putFactory(name, factory); + _routingPolicyRepository->putFactory(name, factory); return *this; } mbus::Blob DocumentProtocol::encode(const vespalib::Version &version, const mbus::Routable &routable) const { - mbus::Blob blob(_routableRepository.encode(version, routable)); + mbus::Blob blob(_routableRepository->encode(version, routable)); // When valgrind reports errors of uninitialized data being written to // the network, it is useful to be able to see the serialized data to // try to identify what bits are uninitialized. @@ -144,7 +147,7 @@ mbus::Routable::UP DocumentProtocol::decode(const vespalib::Version &version, mbus::BlobRef data) const { try { - return _routableRepository.decode(version, data); + return _routableRepository->decode(version, data); } catch (vespalib::Exception &e) { LOG(warning, "%s", e.getMessage().c_str()); return mbus::Routable::UP(); @@ -154,14 +157,14 @@ DocumentProtocol::decode(const vespalib::Version &version, mbus::BlobRef data) c uint32_t DocumentProtocol::getRoutableTypes(const vespalib::Version &version, std::vector<uint32_t> &out) const { - return _routableRepository.getRoutableTypes(version, out); + return _routableRepository->getRoutableTypes(version, out); } DocumentProtocol & DocumentProtocol::putRoutableFactory(uint32_t type, IRoutableFactory::SP factory, const vespalib::VersionSpecification &version) { - _routableRepository.putFactory(version, type, factory); + _routableRepository->putFactory(version, type, factory); return *this; } diff --git a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h index 16225d96122..59aeb51589e 100644 --- a/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h +++ b/documentapi/src/vespa/documentapi/messagebus/documentprotocol.h @@ -1,26 +1,35 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "iroutablefactory.h" -#include "routablerepository.h" -#include "routingpolicyrepository.h" -#include <vespa/document/repo/documenttyperepo.h> #include <vespa/documentapi/messagebus/systemstate/systemstate.h> #include <vespa/messagebus/errorcode.h> #include <vespa/messagebus/iprotocol.h> #include <vespa/messagebus/reply.h> #include <vespa/messagebus/routing/routingcontext.h> +namespace vespalib { + class VersionSpecification; +} +namespace document { + class DocumentTypeRepo; + class ByteBuffer; +} + namespace documentapi { class LoadTypeSet; +class RoutingPolicyRepository; +class RoutableRepository; +class SystemState; +class IRoutingPolicyFactory; +class IRoutableFactory; class DocumentProtocol : public mbus::IProtocol { private: - RoutingPolicyRepository _routingPolicyRepository; - RoutableRepository _routableRepository; - SystemState::UP _systemState; - document::DocumentTypeRepo::SP _repo; + std::unique_ptr<RoutingPolicyRepository> _routingPolicyRepository; + std::unique_ptr<RoutableRepository> _routableRepository; + std::unique_ptr<SystemState> _systemState; + std::shared_ptr<document::DocumentTypeRepo> _repo; public: /** @@ -190,8 +199,9 @@ public: * @param configId The id to use when subscribing to config. */ DocumentProtocol(const LoadTypeSet& loadTypes, - document::DocumentTypeRepo::SP repo, + std::shared_ptr<document::DocumentTypeRepo> repo, const string &configId = ""); + ~DocumentProtocol(); /** * Adds a new routable factory to this protocol. This method is thread-safe, and may be invoked on a @@ -202,7 +212,7 @@ public: * @param factory The factory to add. * @return This, to allow chaining. */ - DocumentProtocol &putRoutingPolicyFactory(const string &name, IRoutingPolicyFactory::SP factory); + DocumentProtocol &putRoutingPolicyFactory(const string &name, std::shared_ptr<IRoutingPolicyFactory> factory); /** * Adds a new routable factory to this protocol. This method is thread-safe, and may be invoked on a @@ -215,7 +225,7 @@ public: * @param version The version for which this factory can be used. * @return This, to allow chaining. */ - DocumentProtocol &putRoutableFactory(uint32_t type, IRoutableFactory::SP factory, + DocumentProtocol &putRoutableFactory(uint32_t type, std::shared_ptr<IRoutableFactory> factory, const vespalib::VersionSpecification &version); /** @@ -227,7 +237,7 @@ public: * @param versions The versions for which this factory can be used. * @return This, to allow chaining. */ - DocumentProtocol &putRoutableFactory(uint32_t type, IRoutableFactory::SP factory, + DocumentProtocol &putRoutableFactory(uint32_t type, std::shared_ptr<IRoutableFactory> factory, const std::vector<vespalib::VersionSpecification> &versions); /** diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h index 76cc5a6b2dd..6e164ec6286 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h +++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories50.h @@ -11,6 +11,7 @@ #include <vespa/messagebus/blobref.h> #include <vespa/vespalib/util/growablebytebuffer.h> #include <vespa/documentapi/documentapi.h> +#include "iroutablefactory.h" namespace document { class DocumentTypeRepo; } diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp b/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp index 5d671fa90ec..a0ae6a9c364 100644 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp @@ -36,6 +36,8 @@ NodeState::NodeState(StateMap args) : // empty } +NodeState::~NodeState() { } + NodeState & NodeState::addChild(const string &key, const NodeState &child) { diff --git a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h b/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h index c9663fc302b..b80b1482efc 100644 --- a/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h +++ b/documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h @@ -44,6 +44,9 @@ private: const string toString(const string &prefix) const; public: + NodeState(NodeState && rhs) = default; + NodeState & operator = (NodeState && rhs) = default; + NodeState & operator = (const NodeState & rhs) = default; /** * Creates a node state that no internal content. */ @@ -64,6 +67,8 @@ public: */ NodeState(StateMap args); + ~NodeState(); + /** * Adds a child to this node at the given location. The key can be a location string, in which case the * necessary intermediate node states are created. diff --git a/messagebus/src/vespa/messagebus/callstack.cpp b/messagebus/src/vespa/messagebus/callstack.cpp index c9312e60e33..d9c37c6e9ee 100644 --- a/messagebus/src/vespa/messagebus/callstack.cpp +++ b/messagebus/src/vespa/messagebus/callstack.cpp @@ -20,6 +20,8 @@ CallStack::discard() } } +CallStack::CallStack() : _stack() { } +CallStack::~CallStack() { } void CallStack::swap(CallStack &dst) { diff --git a/messagebus/src/vespa/messagebus/callstack.h b/messagebus/src/vespa/messagebus/callstack.h index d82c27966b9..f4e0ffe0df4 100644 --- a/messagebus/src/vespa/messagebus/callstack.h +++ b/messagebus/src/vespa/messagebus/callstack.h @@ -39,7 +39,8 @@ public: /** * Create a new empty CallStack. **/ - CallStack() : _stack() { } + CallStack(); + ~CallStack(); /** * Swap the content of this and the argument stack. diff --git a/messagebus/src/vespa/messagebus/iprotocol.h b/messagebus/src/vespa/messagebus/iprotocol.h index 18d45d9560d..481d99e03ee 100644 --- a/messagebus/src/vespa/messagebus/iprotocol.h +++ b/messagebus/src/vespa/messagebus/iprotocol.h @@ -3,7 +3,6 @@ #pragma once #include <vespa/messagebus/routing/iroutingpolicy.h> -#include <string> #include <vespa/vespalib/component/version.h> #include "blobref.h" #include "routable.h" diff --git a/messagebus/src/vespa/messagebus/routable.cpp b/messagebus/src/vespa/messagebus/routable.cpp index 94096516ca4..061b0ecefde 100644 --- a/messagebus/src/vespa/messagebus/routable.cpp +++ b/messagebus/src/vespa/messagebus/routable.cpp @@ -14,6 +14,8 @@ Routable::Routable() : // empty } +Routable::~Routable() { } + void Routable::discard() { diff --git a/messagebus/src/vespa/messagebus/routable.h b/messagebus/src/vespa/messagebus/routable.h index 8bb5db297a2..b02c72efaca 100644 --- a/messagebus/src/vespa/messagebus/routable.h +++ b/messagebus/src/vespa/messagebus/routable.h @@ -46,7 +46,7 @@ public: /** * Required for inheritance. */ - virtual ~Routable() { /* empty */ } + virtual ~Routable(); /** * Discards this routable. Invoking this prevents the auto-generation of diff --git a/persistence/src/tests/spi/clusterstatetest.cpp b/persistence/src/tests/spi/clusterstatetest.cpp index aac2e0a0e17..7770b9045e0 100644 --- a/persistence/src/tests/spi/clusterstatetest.cpp +++ b/persistence/src/tests/spi/clusterstatetest.cpp @@ -153,11 +153,9 @@ ClusterStateTest::testNodeInitializing() namespace { -lib::Distribution::DistributionConfig getCfg(uint16_t redundancy, - uint16_t readyCopies) +lib::Distribution::DistributionConfig getCfg(uint16_t redundancy, uint16_t readyCopies) { - lib::Distribution::DistributionConfigBuilder config( - lib::Distribution::getDefaultDistributionConfig(redundancy, 100)); + lib::Distribution::DistributionConfigBuilder config(lib::Distribution::getDefaultDistributionConfig(redundancy, 100).get()); config.readyCopies = readyCopies; return config; } diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index d3313e2149b..f73cfaf0e9d 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -9,6 +9,7 @@ #include <vespa/document/fieldset/fieldsets.h> #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/state/clusterstate.h> +#include <vespa/config-stor-distribution.h> #include <set> using document::BucketId; diff --git a/storage/src/tests/common/teststorageapp.cpp b/storage/src/tests/common/teststorageapp.cpp index eb4c1c41c78..c6fb4de4fb0 100644 --- a/storage/src/tests/common/teststorageapp.cpp +++ b/storage/src/tests/common/teststorageapp.cpp @@ -1,18 +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 <tests/common/teststorageapp.h> - -#include <vespa/log/log.h> #include <vespa/persistence/dummyimpl/dummypersistence.h> #include <vespa/storage/bucketdb/storagebucketdbinitializer.h> #include <vespa/storage/config/config-stor-server.h> +#include <vespa/config-stor-distribution.h> +#include <vespa/config-load-type.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storageframework/defaultimplementation/memory/nomemorymanager.h> #include <vespa/config-fleetcontroller.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/io/fileutil.h> - +#include <vespa/log/log.h> LOG_SETUP(".test.servicelayerapp"); using storage::framework::defaultimplementation::ComponentRegisterImpl; diff --git a/storage/src/tests/distributor/distributortestutil.cpp b/storage/src/tests/distributor/distributortestutil.cpp index 24af9f46f97..4ed95011e97 100644 --- a/storage/src/tests/distributor/distributortestutil.cpp +++ b/storage/src/tests/distributor/distributortestutil.cpp @@ -1,10 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <ctype.h> #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/config-stor-distribution.h> namespace storage { @@ -32,9 +31,8 @@ DistributorTestUtil::setupDistributor(int redundancy, uint32_t earlyReturn, bool requirePrimaryToBeWritten) { - lib::Distribution::DistributionConfig config( - lib::Distribution::getDefaultDistributionConfig( - redundancy, nodeCount)); + lib::Distribution::DistributionConfigBuilder config( + lib::Distribution::getDefaultDistributionConfig(redundancy, nodeCount).get()); config.redundancy = redundancy; config.initialRedundancy = earlyReturn; config.ensurePrimaryPersisted = requirePrimaryToBeWritten; diff --git a/storage/src/tests/distributor/statecheckerstest.cpp b/storage/src/tests/distributor/statecheckerstest.cpp index 5bf66dbb128..a3603eae6b3 100644 --- a/storage/src/tests/distributor/statecheckerstest.cpp +++ b/storage/src/tests/distributor/statecheckerstest.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <tests/common/dummystoragelink.h> #include <vespa/storageapi/message/persistence.h> @@ -19,6 +18,7 @@ #include <tests/distributor/distributortestutil.h> #include <vespa/storage/distributor/statecheckers.h> #include <vespa/storageapi/message/state.h> +#include <vespa/config-stor-distribution.h> using namespace std::literals::string_literals; diff --git a/storage/src/vespa/storage/bucketmover/bucketmover.cpp b/storage/src/vespa/storage/bucketmover/bucketmover.cpp index f6319b7ef55..ab6346be167 100644 --- a/storage/src/vespa/storage/bucketmover/bucketmover.cpp +++ b/storage/src/vespa/storage/bucketmover/bucketmover.cpp @@ -341,8 +341,7 @@ BucketMover::storageDistributionChanged() lib::Distribution::SP distribution = _component.getDistribution(); // Verify that the actual disk distribution changed, if not ignore - vespa::config::content::StorDistributionConfig::DiskDistribution newDistr( - distribution->getDiskDistribution()); + lib::Distribution::DiskDistribution newDistr(distribution->getDiskDistribution()); if (_diskDistribution == newDistr) return; @@ -350,18 +349,14 @@ BucketMover::storageDistributionChanged() if (_currentRun.get() != 0) { LOG(info, "Aborting bucket mover run as disk distribution changed " "from %s to %s.", - vespa::config::content::StorDistributionConfig::getDiskDistributionName( - _diskDistribution).c_str(), - vespa::config::content::StorDistributionConfig::getDiskDistributionName( - newDistr).c_str()); + lib::Distribution::getDiskDistributionName(_diskDistribution).c_str(), + lib::Distribution::getDiskDistributionName(newDistr).c_str()); _currentRun->abort(); } else { LOG(info, "Regathering state as disk distribution changed " "from %s to %s.", - vespa::config::content::StorDistributionConfig::getDiskDistributionName( - _diskDistribution).c_str(), - vespa::config::content::StorDistributionConfig::getDiskDistributionName( - newDistr).c_str()); + lib::Distribution::getDiskDistributionName(_diskDistribution).c_str(), + lib::Distribution::getDiskDistributionName(newDistr).c_str()); } _diskDistribution = newDistr; _nextRun = framework::SecondTime(0); @@ -473,8 +468,7 @@ BucketMover::printCurrentStatus(std::ostream& out, << (currentTime - rs._endTime).toString(framework::DIFFERENCE) << " ago)</h2>\n" << "<p>Disk distribution: " - << vespa::config::content::StorDistributionConfig::getDiskDistributionName( - _diskDistribution) + << lib::Distribution::getDiskDistributionName(_diskDistribution) << "</p>\n"; out << "<p>This is the status from the last completed bucket database scan " << "done by the bucket mover. After starting storage, or after " diff --git a/storage/src/vespa/storage/bucketmover/bucketmover.h b/storage/src/vespa/storage/bucketmover/bucketmover.h index d54b1c60de8..da0d6e889b7 100644 --- a/storage/src/vespa/storage/bucketmover/bucketmover.h +++ b/storage/src/vespa/storage/bucketmover/bucketmover.h @@ -22,7 +22,7 @@ #include <vespa/storage/bucketmover/run.h> #include <vespa/storageframework/storageframework.h> #include <vespa/storageframework/storageframework.h> -#include <vespa/config-stor-distribution.h> +#include <vespa/vdslib/distribution/distribution.h> #include <vespa/storage/common/servicelayercomponent.h> namespace storage { @@ -47,7 +47,7 @@ class BucketMover : public StorageLink, std::list<RunStatistics> _history; vespalib::Monitor _wait; config::ConfigFetcher _configFetcher; - vespa::config::content::StorDistributionConfig::DiskDistribution _diskDistribution; + lib::Distribution::DiskDistribution _diskDistribution; uint32_t _maxSleepTime; framework::Thread::UP _thread; diff --git a/storage/src/vespa/storage/bucketmover/runstatistics.cpp b/storage/src/vespa/storage/bucketmover/runstatistics.cpp index a0cd0617f9a..7383e0ca5ef 100644 --- a/storage/src/vespa/storage/bucketmover/runstatistics.cpp +++ b/storage/src/vespa/storage/bucketmover/runstatistics.cpp @@ -74,8 +74,7 @@ RunStatistics::print(std::ostream& out, bool verbose, << " ago"; } out << " with distribution " - << vespa::config::content::StorDistributionConfig::getDiskDistributionName( - _distribution) + << lib::Distribution::getDiskDistributionName(_distribution) << "</h3>\n<blockquote>"; if (!completed) { std::ostringstream progress; diff --git a/storage/src/vespa/storage/bucketmover/runstatistics.h b/storage/src/vespa/storage/bucketmover/runstatistics.h index 161dcacfbe3..1483c241eb9 100644 --- a/storage/src/vespa/storage/bucketmover/runstatistics.h +++ b/storage/src/vespa/storage/bucketmover/runstatistics.h @@ -41,7 +41,7 @@ #include <vespa/storageframework/storageframework.h> #include <vector> #include <vespa/vdslib/state/nodestate.h> -#include <vespa/config-stor-distribution.h> +#include <vespa/vdslib/distribution/distribution.h> namespace storage { @@ -50,8 +50,7 @@ class Clock; namespace bucketmover { struct RunStatistics : public document::Printable { - typedef vespa::config::content::StorDistributionConfig::DiskDistribution - DiskDistribution; + using DiskDistribution = lib::Distribution::DiskDistribution; /** Data kept as targets for moves for each disk. */ struct DiskMatrix { diff --git a/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp b/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp index a017fd9e11f..fdd309fabd3 100644 --- a/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/external/visitoroperation.cpp @@ -658,7 +658,7 @@ void VisitorOperation::attemptToParseOrderingSelector() { std::unique_ptr<document::select::Node> docSelection; - document::DocumentTypeRepo::SP repo(_owner.getTypeRepo()); + std::shared_ptr<document::DocumentTypeRepo> repo(_owner.getTypeRepo()); document::select::Parser parser( *repo, _owner.getBucketIdFactory()); docSelection = parser.parse(_msg->getDocumentSelection()); diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp index a3cec6a8b77..daf311ace67 100644 --- a/storage/src/vespa/storage/persistence/mergehandler.cpp +++ b/storage/src/vespa/storage/persistence/mergehandler.cpp @@ -614,7 +614,7 @@ MergeHandler::applyDiffLocally( FlushGuard flushGuard(_spi, bucket, context); - document::DocumentTypeRepo::SP repo(_env._component.getTypeRepo()); + std::shared_ptr<document::DocumentTypeRepo> repo(_env._component.getTypeRepo()); assert(repo.get() != nullptr); uint32_t existingCount = entries.size(); diff --git a/storage/src/vespa/storage/persistence/persistenceutil.h b/storage/src/vespa/storage/persistence/persistenceutil.h index 0007ebd9666..ed4812b3505 100644 --- a/storage/src/vespa/storage/persistence/persistenceutil.h +++ b/storage/src/vespa/storage/persistence/persistenceutil.h @@ -71,7 +71,7 @@ struct PersistenceUtil { uint16_t _nodeIndex; FileStorThreadMetrics& _metrics; const document::BucketIdFactory& _bucketFactory; - const document::DocumentTypeRepo::SP _repo; + const std::shared_ptr<document::DocumentTypeRepo> _repo; uint8_t _lowestPriority; PauseHandler _pauseHandler; spi::PersistenceProvider& _spi; diff --git a/storage/src/vespa/storage/persistence/testandsethelper.cpp b/storage/src/vespa/storage/persistence/testandsethelper.cpp index 56ce67a17b8..7ea40720f27 100644 --- a/storage/src/vespa/storage/persistence/testandsethelper.cpp +++ b/storage/src/vespa/storage/persistence/testandsethelper.cpp @@ -4,6 +4,7 @@ #include <vespa/storage/persistence/fieldvisitor.h> #include <vespa/storage/persistence/testandsethelper.h> #include <vespa/document/select/parser.h> +#include <vespa/document/repo/documenttyperepo.h> using namespace std::string_literals; diff --git a/storage/src/vespa/storage/tools/analyzedistribution.cpp b/storage/src/vespa/storage/tools/analyzedistribution.cpp index 07aef4eea14..b2b95c15d30 100644 --- a/storage/src/vespa/storage/tools/analyzedistribution.cpp +++ b/storage/src/vespa/storage/tools/analyzedistribution.cpp @@ -144,15 +144,15 @@ struct Distribution { lib::ClusterState state; std::unique_ptr<lib::Distribution> distribution; - static vespa::config::content::StorDistributionConfig::DiskDistribution getDistr(Type t) { + static lib::Distribution::DiskDistribution getDistr(Type t) { switch (t) { - case INDEX: return vespa::config::content::StorDistributionConfig::MODULO_INDEX; - case BID: return vespa::config::content::StorDistributionConfig::MODULO_BID; - case TEST: return vespa::config::content::StorDistributionConfig::MODULO_BID; + case INDEX: return lib::Distribution::MODULO_INDEX; + case BID: return lib::Distribution::MODULO_BID; + case TEST: return lib::Distribution::MODULO_BID; } // Compiler refuse to detect that the above is all possibilities assert(false); - return vespa::config::content::StorDistributionConfig::MODULO_BID; + return lib::Distribution::MODULO_BID; } static uint8_t getDistributionBits(const lib::ClusterState& state, Type t) @@ -176,7 +176,7 @@ struct Distribution { } // Compiler refuse to detect that the above is all possibilities assert(false); - return vespa::config::content::StorDistributionConfig::MODULO_BID; + return lib::Distribution::MODULO_BID; } Distribution(const lib::ClusterState& state_, uint32_t diskCount_, Type t) @@ -186,7 +186,7 @@ struct Distribution { nodeState(), diskCount(diskCount_), state(state_), - distribution(new lib::Distribution(*config::ConfigGetter<vespa::config::content::StorDistributionConfig>::getConfig("storage/cluster.storage"))) + distribution(new lib::Distribution("storage/cluster.storage")) { for (uint32_t i=0, n=state.getNodeCount(lib::NodeType::STORAGE); i < n; ++i) diff --git a/storage/src/vespa/storage/tools/getidealstate.cpp b/storage/src/vespa/storage/tools/getidealstate.cpp index 2ee8e479da8..da32aba9897 100644 --- a/storage/src/vespa/storage/tools/getidealstate.cpp +++ b/storage/src/vespa/storage/tools/getidealstate.cpp @@ -1,12 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/document/bucket/bucketidfactory.h> #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vdslib/state/clusterstate.h> #include <vespa/vespalib/util/programoptions.h> #include <vespa/config/config.h> #include <vespa/config/print/ostreamconfigwriter.h> +#include <vespa/config-stor-distribution.h> #include <iostream> #include <sstream> @@ -108,9 +108,7 @@ int run(int argc, char** argv) { } uint16_t redundancy(o.redundancy); - vespa::config::content::StorDistributionConfig::DiskDistribution diskDistribution( - vespa::config::content::StorDistributionConfig::getDiskDistribution( - o.diskDistribution)); + lib::Distribution::DiskDistribution diskDistribution(lib::Distribution::getDiskDistribution(o.diskDistribution)); std::unique_ptr<lib::Distribution> distribution; lib::ClusterState clusterState(o.clusterState); @@ -123,8 +121,8 @@ int run(int argc, char** argv) { config::ConfigUri uri(o.getConfigId()); std::unique_ptr<vespa::config::content::StorDistributionConfig> config = config::ConfigGetter<vespa::config::content::StorDistributionConfig>::getConfig(uri.getConfigId(), uri.getContext()); redundancy = config->redundancy; - diskDistribution = config->diskDistribution; distribution.reset(new lib::Distribution(*config)); + diskDistribution = distribution->getDiskDistribution(); if (o.verbose) { std::cerr << "Using distribution config: '"; config::OstreamConfigWriter ocw(std::cerr); @@ -145,16 +143,13 @@ int run(int argc, char** argv) { << redundancy << " with cluster state " << clusterState << "\n"; } - vespa::config::content::StorDistributionConfig config( - lib::Distribution::getDefaultDistributionConfig( - redundancy, - clusterState.getNodeCount(lib::NodeType::DISTRIBUTOR), - diskDistribution)); + lib::Distribution::ConfigWrapper config(lib::Distribution::getDefaultDistributionConfig( + redundancy, clusterState.getNodeCount(lib::NodeType::DISTRIBUTOR), diskDistribution)); distribution.reset(new lib::Distribution(config)); if (o.verbose) { std::cerr << "Using distribution config: '"; config::OstreamConfigWriter ocw(std::cerr); - ocw.write(config); + ocw.write(config.get()); std::cerr << "'.\n"; } } diff --git a/vdslib/src/tests/distribution/distributiontest.cpp b/vdslib/src/tests/distribution/distributiontest.cpp index d037c3f14b1..fbd9e86f9ac 100644 --- a/vdslib/src/tests/distribution/distributiontest.cpp +++ b/vdslib/src/tests/distribution/distributiontest.cpp @@ -313,7 +313,6 @@ namespace { struct Test { const NodeType* _nodeType; std::string _state; - Distribution::DistributionConfig _distributionConfig; std::unique_ptr<Distribution> _distribution; uint32_t _bucketsToTest; const char* _upStates; @@ -322,9 +321,7 @@ namespace { Test() : _nodeType(&NodeType::STORAGE), _state("distributor:10 storage:10"), - _distributionConfig( - Distribution::getDefaultDistributionConfig(3, 10)), - _distribution(new Distribution(_distributionConfig)), + _distribution(new Distribution(Distribution::getDefaultDistributionConfig(3, 10))), _bucketsToTest(100), _upStates("uir"), _redundancy(2) diff --git a/vdslib/src/vespa/vdslib/distribution/distribution.cpp b/vdslib/src/vespa/vdslib/distribution/distribution.cpp index 211fe239710..597fae6c0c4 100644 --- a/vdslib/src/vespa/vdslib/distribution/distribution.cpp +++ b/vdslib/src/vespa/vdslib/distribution/distribution.cpp @@ -43,13 +43,12 @@ Distribution::Distribution() _ensurePrimaryPersisted(true), _diskDistribution() { - vespa::config::content::StorDistributionConfig& config( - getDefaultDistributionConfig(0, 0)); + auto config(getDefaultDistributionConfig(0, 0)); vespalib::asciistream ost; config::AsciiConfigWriter writer(ost); - writer.write(config); + writer.write(config.get()); _serialized = ost.str(); - configure(config); + configure(config.get()); } Distribution::Distribution(const Distribution& d) @@ -66,7 +65,16 @@ Distribution::Distribution(const Distribution& d) configure(*reader.read()); } -Distribution::Distribution(const vespa::config::content::StorDistributionConfig& config) +Distribution::ConfigWrapper::ConfigWrapper(std::unique_ptr<DistributionConfig> cfg) : + _cfg(std::move(cfg)) +{ } +Distribution::ConfigWrapper::~ConfigWrapper() { } + +Distribution::Distribution(const ConfigWrapper & config) : + Distribution(config.get()) +{ } + +Distribution::Distribution(const vespa::config::content::StorDistributionConfig & config) : _distributionBitMasks(getDistributionBitMasks()), _nodeGraph(), _redundancy(), @@ -280,6 +288,11 @@ vespalib::string Distribution::getDiskDistributionName(DiskDistribution dist) { return DistributionConfig::getDiskDistributionName(toConfig(dist)); } +Distribution::DiskDistribution +Distribution::getDiskDistribution(vespalib::stringref name) { + return fromConfig(DistributionConfig::getDiskDistribution(name)); +} + void Distribution::print(std::ostream& out, bool, const std::string&) const { out << serialize(); @@ -630,21 +643,21 @@ Distribution::getIdealNodes(const NodeType& nodeType, } } -Distribution::DistributionConfig +Distribution::ConfigWrapper Distribution::getDefaultDistributionConfig(uint16_t redundancy, uint16_t nodeCount, DiskDistribution distr) { - vespa::config::content::StorDistributionConfigBuilder config; - config.redundancy = redundancy; - config.group.resize(1); - config.group[0].index = "invalid"; - config.group[0].name = "invalid"; - config.group[0].partitions = "*"; - config.group[0].nodes.resize(nodeCount); + std::unique_ptr<vespa::config::content::StorDistributionConfigBuilder> config(new vespa::config::content::StorDistributionConfigBuilder()); + config->redundancy = redundancy; + config->group.resize(1); + config->group[0].index = "invalid"; + config->group[0].name = "invalid"; + config->group[0].partitions = "*"; + config->group[0].nodes.resize(nodeCount); for (uint16_t i=0; i<nodeCount; ++i) { - config.group[0].nodes[i].index = i; + config->group[0].nodes[i].index = i; } - config.diskDistribution = toConfig(distr); - return config; + config->diskDistribution = toConfig(distr); + return ConfigWrapper(std::move(config)); } std::vector<uint16_t> diff --git a/vdslib/src/vespa/vdslib/distribution/distribution.h b/vdslib/src/vespa/vdslib/distribution/distribution.h index 3ec75b18d65..6d784a05658 100644 --- a/vdslib/src/vespa/vdslib/distribution/distribution.h +++ b/vdslib/src/vespa/vdslib/distribution/distribution.h @@ -113,9 +113,20 @@ private: void configure(const DistributionConfig & config); public: + class ConfigWrapper { + public: + ConfigWrapper(ConfigWrapper && rhs) = default; + ConfigWrapper & operator = (ConfigWrapper && rhs) = default; + ConfigWrapper(std::unique_ptr<DistributionConfig> cfg); + ~ConfigWrapper(); + const DistributionConfig & get() const { return *_cfg; } + private: + std::unique_ptr<DistributionConfig> _cfg; + }; Distribution(); Distribution(const Distribution&); - Distribution(const DistributionConfig&); + Distribution(const ConfigWrapper & cfg); + Distribution(const DistributionConfig & cfg); Distribution(const vespalib::string& serialized); ~Distribution(); @@ -178,10 +189,11 @@ public: * with a really simple setup with no hierarchical grouping. This function * should not be used by any production code. */ - static DistributionConfig getDefaultDistributionConfig( + static ConfigWrapper getDefaultDistributionConfig( uint16_t redundancy = 2, uint16_t nodeCount = 10, DiskDistribution distr = MODULO_BID); static vespalib::string getDiskDistributionName(DiskDistribution dist); + static DiskDistribution getDiskDistribution(vespalib::stringref name); /** * Utility function used by distributor to split copies into groups to diff --git a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp index ac863e30478..d338769d4fd 100644 --- a/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp +++ b/vespaclient/src/vespa/vespaclient/vdsstates/statesapp.cpp @@ -12,6 +12,7 @@ #include <vespa/vespalib/util/programoptions.h> #include <vespa/vespaclient/clusterlist/clusterlist.h> #include <vespa/vespalib/text/lowercase.h> +#include <vespa/config-stor-distribution.h> LOG_SETUP("vdsstatetool"); diff --git a/vespalib/src/vespa/vespalib/trace/trace.cpp b/vespalib/src/vespa/vespalib/trace/trace.cpp index 018fd11ddbc..2dbf3b32e7e 100644 --- a/vespalib/src/vespa/vespalib/trace/trace.cpp +++ b/vespalib/src/vespa/vespalib/trace/trace.cpp @@ -1,10 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/trace/trace.h> - -#include <algorithm> -#include <vespa/fastos/fastos.h> -#include <vespa/vespalib/util/vstringfmt.h> +#include <vespa/vespalib/util/stringfmt.h> +#include <sys/time.h> namespace vespalib { @@ -22,6 +20,8 @@ Trace::Trace(uint32_t level) : // empty } +Trace::~Trace() { } + Trace & Trace::clear() { @@ -54,8 +54,7 @@ Trace::trace(uint32_t level, const string ¬e, bool addTime) if (addTime) { struct timeval tv; gettimeofday(&tv, NULL); - _root.addChild(vespalib::make_vespa_string( - "[%ld.%06ld] %s", tv.tv_sec, tv.tv_usec, note.c_str())); + _root.addChild(make_string("[%ld.%06ld] %s", tv.tv_sec, tv.tv_usec, note.c_str())); } else { _root.addChild(note); } diff --git a/vespalib/src/vespa/vespalib/trace/trace.h b/vespalib/src/vespa/vespalib/trace/trace.h index 493f2b931b7..a2dd07306fd 100644 --- a/vespalib/src/vespa/vespalib/trace/trace.h +++ b/vespalib/src/vespa/vespalib/trace/trace.h @@ -28,6 +28,7 @@ public: * Create an empty Trace with level set to 0 (no tracing) */ Trace(); + ~Trace(); /** * Create an empty trace with given level. |