summaryrefslogtreecommitdiffstats
path: root/documentapi
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-12-04 19:26:34 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2016-12-12 02:55:45 +0100
commitf94a9a21d6d546868ef2cf63ea3532469450ffd7 (patch)
tree7174466dc53a7009eb425d4c2fc7b5202e112542 /documentapi
parentd1fc3e5707851697bfe9a07b40f1b8e3672be8aa (diff)
Split out so documentprotocol.h does not pull in everything.
Diffstat (limited to 'documentapi')
-rw-r--r--documentapi/src/tests/policies/policies_test.cpp7
-rw-r--r--documentapi/src/tests/policies/testframe.h1
-rw-r--r--documentapi/src/tests/policyfactory/policyfactory.cpp3
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/documentprotocol.cpp25
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/documentprotocol.h34
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routablefactories50.h1
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.cpp2
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/systemstate/nodestate.h5
8 files changed, 49 insertions, 29 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 &param) 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.