aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-12-04 00:05:29 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2016-12-12 02:55:45 +0100
commit2464562bb2202d6b9e45d08f00c27de961c4e9d3 (patch)
treeecf5f3c2b2ec14b75528fc18a343bd7a796ccbbd /documentapi
parent925ec7eb8ee709c0d6722227104df6dc89f307f0 (diff)
Avoid pulling in the config library all the time.
Diffstat (limited to 'documentapi')
-rw-r--r--documentapi/src/tests/loadtypes/loadtypetest.cpp7
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp5
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp22
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h8
4 files changed, 25 insertions, 17 deletions
diff --git a/documentapi/src/tests/loadtypes/loadtypetest.cpp b/documentapi/src/tests/loadtypes/loadtypetest.cpp
index 42b58b1a9c9..03c1da178b0 100644
--- a/documentapi/src/tests/loadtypes/loadtypetest.cpp
+++ b/documentapi/src/tests/loadtypes/loadtypetest.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/vdstestlib/cppunit/macros.h>
+
#include <vespa/documentapi/loadtypes/loadtypeset.h>
+#include <vespa/vdstestlib/cppunit/macros.h>
+#include <vespa/config/config.h>
namespace documentapi {
@@ -18,7 +19,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(LoadTypeTest);
#define ASSERT_CONFIG_FAILURE(configId, error) \
try { \
- LoadTypeSet createdFromConfigId(configId); \
+ LoadTypeSet createdFromConfigId(vespalib::stringref(configId)); \
CPPUNIT_FAIL("Config was expected to fail with error: " \
+ string(error)); \
} catch (config::InvalidConfigException& e) { \
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
index 33d14aae044..5a577ac450b 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.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/documentapi/messagebus/policies/contentpolicy.h>
namespace documentapi {
ContentPolicy::ContentPolicy(const string& param)
: StoragePolicy(param)
-{
-}
+{ }
string
ContentPolicy::createConfigId(const string & clusterName) const
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp
index 3caa19f240a..39cdad6f46b 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.cpp
@@ -1,17 +1,12 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "storagepolicy.h"
-#include <algorithm>
#include <vespa/document/base/documentid.h>
#include <vespa/messagebus/emptyreply.h>
-#include <vespa/messagebus/errorcode.h>
-#include <vespa/messagebus/routing/ihopdirective.h>
-#include <vespa/messagebus/routing/routingcontext.h>
#include <vespa/messagebus/routing/verbatimdirective.h>
-#include <vespa/vespalib/util/random.h>
#include <vespa/documentapi/documentapi.h>
-#include <vespa/documentapi/messagebus/documentprotocol.h>
#include <vespa/vespalib/stllike/asciistream.h>
+#include <vespa/config-stor-distribution.h>
#include <vespa/log/log.h>
LOG_SETUP(".storagepolicy");
@@ -35,6 +30,18 @@ StoragePolicy::StoragePolicy(const string& param)
}
}
+namespace {
+ class CallBack : public config::IFetcherCallback<storage::lib::Distribution::DistributionConfig>
+ {
+ public:
+ CallBack(StoragePolicy & policy) : _policy(policy) { }
+ void configure(std::unique_ptr<storage::lib::Distribution::DistributionConfig> config) override {
+ _policy.configure(std::move(config));
+ }
+ private:
+ StoragePolicy & _policy;
+ };
+}
string StoragePolicy::init()
{
string error = ExternSlobrokPolicy::init();
@@ -53,7 +60,8 @@ string StoragePolicy::init()
} else {
_configFetcher.reset(new config::ConfigFetcher(uri.getContext()));
}
- _configFetcher->subscribe<vespa::config::content::StorDistributionConfig>(uri.getConfigId(), this);
+ _callBack = std::make_unique<CallBack>(*this);
+ _configFetcher->subscribe<vespa::config::content::StorDistributionConfig>(uri.getConfigId(), static_cast<CallBack *>(_callBack.get()));
_configFetcher->start();
return "";
}
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h
index 1f80b36c109..f65ae964579 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/storagepolicy.h
@@ -10,15 +10,15 @@
namespace documentapi {
-class StoragePolicy : public ExternSlobrokPolicy,
- public config::IFetcherCallback<vespa::config::content::StorDistributionConfig>
+class StoragePolicy : public ExternSlobrokPolicy
{
private:
document::BucketIdFactory _bucketIdFactory;
std::unique_ptr<storage::lib::ClusterState> _state;
string _clusterName;
string _clusterConfigId;
- std::unique_ptr<config::ConfigFetcher> _configFetcher;
+ std::unique_ptr<config::ICallback> _callBack;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
std::unique_ptr<storage::lib::Distribution> _distribution;
std::unique_ptr<storage::lib::Distribution> _nextDistribution;
@@ -42,7 +42,7 @@ public:
*/
const storage::lib::ClusterState* getSystemState() const { return _state.get(); }
- void configure(std::unique_ptr<vespa::config::content::StorDistributionConfig> config);
+ virtual void configure(std::unique_ptr<storage::lib::Distribution::DistributionConfig> config);
string init();