summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-07 17:27:01 +0100
committerGitHub <noreply@github.com>2022-02-07 17:27:01 +0100
commitbd0c959b2b87546b3ae3cd3016aefa2676a6d56f (patch)
treef01b60da271f5730e647d6dcd2dee77619f5902f /config
parenta0ddc94cb6a4f97d4677ad53c8263e27d3ecc09d (diff)
parentd11a831d24165bc0263aa9a6b015940003c3d660 (diff)
Merge pull request #21082 from vespa-engine/balder/reduce-code-visibility
Reduce code visibility and include only what you need from config lib…
Diffstat (limited to 'config')
-rw-r--r--config/src/apps/vespa-get-config/getconfig.cpp10
-rw-r--r--config/src/tests/api/api.cpp2
-rw-r--r--config/src/tests/configagent/configagent.cpp33
-rw-r--r--config/src/tests/configfetcher/configfetcher.cpp4
-rw-r--r--config/src/tests/configformat/configformat.cpp1
-rw-r--r--config/src/tests/configgen/configgen.cpp1
-rw-r--r--config/src/tests/configholder/configholder.cpp4
-rw-r--r--config/src/tests/configmanager/configmanager.cpp17
-rw-r--r--config/src/tests/configparser/configparser.cpp8
-rw-r--r--config/src/tests/configretriever/configretriever.cpp16
-rw-r--r--config/src/tests/configuri/configuri_test.cpp5
-rw-r--r--config/src/tests/failover/failover.cpp7
-rw-r--r--config/src/tests/file_subscription/file_subscription.cpp7
-rw-r--r--config/src/tests/frt/frt.cpp10
-rw-r--r--config/src/tests/functiontest/functiontest.cpp11
-rw-r--r--config/src/tests/getconfig/getconfig.cpp2
-rw-r--r--config/src/tests/legacysubscriber/legacysubscriber.cpp2
-rw-r--r--config/src/tests/misc/misc.cpp17
-rw-r--r--config/src/tests/payload_converter/payload_converter.cpp8
-rw-r--r--config/src/tests/print/print.cpp6
-rw-r--r--config/src/tests/raw_subscription/raw_subscription.cpp9
-rw-r--r--config/src/tests/subscriber/subscriber.cpp41
-rw-r--r--config/src/tests/subscription/subscription.cpp8
-rw-r--r--config/src/tests/unittest/unittest.cpp2
-rw-r--r--config/src/vespa/config/common/cancelhandler.h4
-rw-r--r--config/src/vespa/config/common/configdefinition.cpp8
-rw-r--r--config/src/vespa/config/common/configdefinition.h7
-rw-r--r--config/src/vespa/config/common/configholder.cpp4
-rw-r--r--config/src/vespa/config/common/configholder.h10
-rw-r--r--config/src/vespa/config/common/configkey.cpp4
-rw-r--r--config/src/vespa/config/common/configkey.h9
-rw-r--r--config/src/vespa/config/common/configmanager.cpp2
-rw-r--r--config/src/vespa/config/common/configparser.cpp2
-rw-r--r--config/src/vespa/config/common/configparser.h6
-rw-r--r--config/src/vespa/config/common/configupdate.cpp6
-rw-r--r--config/src/vespa/config/common/configupdate.h12
-rw-r--r--config/src/vespa/config/common/configvalue.cpp18
-rw-r--r--config/src/vespa/config/common/configvalue.h24
-rw-r--r--config/src/vespa/config/common/configvalue.hpp8
-rw-r--r--config/src/vespa/config/common/iconfigcontext.h4
-rw-r--r--config/src/vespa/config/common/iconfigholder.h3
-rw-r--r--config/src/vespa/config/common/iconfigmanager.h2
-rw-r--r--config/src/vespa/config/common/misc.cpp2
-rw-r--r--config/src/vespa/config/common/misc.h6
-rw-r--r--config/src/vespa/config/common/payload_converter.cpp4
-rw-r--r--config/src/vespa/config/common/payload_converter.h12
-rw-r--r--config/src/vespa/config/common/source.h4
-rw-r--r--config/src/vespa/config/common/sourcefactory.h8
-rw-r--r--config/src/vespa/config/common/subscribehandler.h7
-rw-r--r--config/src/vespa/config/common/types.h21
-rw-r--r--config/src/vespa/config/config.h27
-rw-r--r--config/src/vespa/config/configgen/configinstance.h2
-rw-r--r--config/src/vespa/config/file/filesource.cpp18
-rw-r--r--config/src/vespa/config/file/filesource.h17
-rw-r--r--config/src/vespa/config/file/filesourcefactory.cpp13
-rw-r--r--config/src/vespa/config/file/filesourcefactory.h8
-rw-r--r--config/src/vespa/config/frt/frtconfigagent.cpp5
-rw-r--r--config/src/vespa/config/frt/frtconfigagent.h24
-rw-r--r--config/src/vespa/config/frt/frtsourcefactory.cpp7
-rw-r--r--config/src/vespa/config/frt/frtsourcefactory.h2
-rw-r--r--config/src/vespa/config/helper/configfetcher.cpp24
-rw-r--r--config/src/vespa/config/helper/configfetcher.h16
-rw-r--r--config/src/vespa/config/helper/configfetcher.hpp7
-rw-r--r--config/src/vespa/config/helper/configgetter.h4
-rw-r--r--config/src/vespa/config/helper/configgetter.hpp10
-rw-r--r--config/src/vespa/config/helper/configpoller.cpp15
-rw-r--r--config/src/vespa/config/helper/configpoller.h16
-rw-r--r--config/src/vespa/config/helper/configpoller.hpp24
-rw-r--r--config/src/vespa/config/helper/ihandle.h23
-rw-r--r--config/src/vespa/config/helper/legacysubscriber.h4
-rw-r--r--config/src/vespa/config/helper/legacysubscriber.hpp4
-rw-r--r--config/src/vespa/config/print/asciiconfigreader.h7
-rw-r--r--config/src/vespa/config/print/asciiconfigreader.hpp12
-rw-r--r--config/src/vespa/config/print/fileconfigreader.h3
-rw-r--r--config/src/vespa/config/print/fileconfigreader.hpp6
-rw-r--r--config/src/vespa/config/print/istreamconfigreader.h3
-rw-r--r--config/src/vespa/config/print/istreamconfigreader.hpp9
-rw-r--r--config/src/vespa/config/raw/rawsource.cpp13
-rw-r--r--config/src/vespa/config/raw/rawsource.h16
-rw-r--r--config/src/vespa/config/raw/rawsourcefactory.cpp6
-rw-r--r--config/src/vespa/config/raw/rawsourcefactory.h2
-rw-r--r--config/src/vespa/config/retriever/configretriever.cpp2
-rw-r--r--config/src/vespa/config/retriever/configretriever.h16
-rw-r--r--config/src/vespa/config/retriever/configsnapshot.cpp24
-rw-r--r--config/src/vespa/config/retriever/configsnapshot.h11
-rw-r--r--config/src/vespa/config/retriever/configsnapshot.hpp5
-rw-r--r--config/src/vespa/config/retriever/fixedconfigsubscriber.cpp4
-rw-r--r--config/src/vespa/config/retriever/fixedconfigsubscriber.h4
-rw-r--r--config/src/vespa/config/retriever/genericconfigsubscriber.cpp6
-rw-r--r--config/src/vespa/config/retriever/genericconfigsubscriber.h4
-rw-r--r--config/src/vespa/config/retriever/simpleconfigretriever.cpp2
-rw-r--r--config/src/vespa/config/retriever/simpleconfigretriever.h4
-rw-r--r--config/src/vespa/config/set/configinstancesourcefactory.cpp23
-rw-r--r--config/src/vespa/config/set/configinstancesourcefactory.h4
-rw-r--r--config/src/vespa/config/set/configsetsource.cpp17
-rw-r--r--config/src/vespa/config/set/configsetsource.h14
-rw-r--r--config/src/vespa/config/set/configsetsourcefactory.cpp12
-rw-r--r--config/src/vespa/config/set/configsetsourcefactory.h12
-rw-r--r--config/src/vespa/config/subscription/confighandle.h10
-rw-r--r--config/src/vespa/config/subscription/confighandle.hpp9
-rw-r--r--config/src/vespa/config/subscription/configinstancespec.h3
-rw-r--r--config/src/vespa/config/subscription/configsubscriber.cpp6
-rw-r--r--config/src/vespa/config/subscription/configsubscriber.h8
-rw-r--r--config/src/vespa/config/subscription/configsubscriber.hpp5
-rw-r--r--config/src/vespa/config/subscription/configsubscription.cpp9
-rw-r--r--config/src/vespa/config/subscription/configsubscription.h26
-rw-r--r--config/src/vespa/config/subscription/configsubscriptionset.cpp13
-rw-r--r--config/src/vespa/config/subscription/configsubscriptionset.h31
-rw-r--r--config/src/vespa/config/subscription/configuri.cpp4
-rw-r--r--config/src/vespa/config/subscription/configuri.h10
-rw-r--r--config/src/vespa/config/subscription/sourcespec.cpp4
-rw-r--r--config/src/vespa/config/subscription/sourcespec.h4
112 files changed, 563 insertions, 518 deletions
diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp
index af8c7120d19..29c68d49da7 100644
--- a/config/src/apps/vespa-get-config/getconfig.cpp
+++ b/config/src/apps/vespa-get-config/getconfig.cpp
@@ -2,10 +2,10 @@
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/fnet/frt/target.h>
-#include <vespa/config/config.h>
#include <vespa/config/frt/frtconfigrequestfactory.h>
#include <vespa/config/frt/frtconnection.h>
#include <vespa/config/common/payload_converter.h>
+#include <vespa/config/common/configvalue.h>
#include <vespa/fastos/app.h>
#include <string>
@@ -92,7 +92,7 @@ GetConfig::Main()
bool debugging = false;
int c = -1;
- std::vector<vespalib::string> defSchema;
+ StringVector defSchema;
const char *schemaString = nullptr;
const char *defName = nullptr;
const char *defMD5 = "";
@@ -246,8 +246,8 @@ GetConfig::Main()
} else {
response->fill();
ConfigKey rKey(response->getKey());
- ConfigState rState(response->getConfigState());
- ConfigValue rValue(response->getValue());
+ const ConfigState & rState = response->getConfigState();
+ const ConfigValue & rValue = response->getValue();
if (debugging) {
printf("defName %s\n", rKey.getDefName().c_str());
printf("defMD5 %s\n", rKey.getDefMd5().c_str());
@@ -265,7 +265,7 @@ GetConfig::Main()
if (printAsJson) {
printf("%s\n", rValue.asJson().c_str());
} else {
- std::vector<vespalib::string> lines = rValue.getLegacyFormat();
+ StringVector lines = rValue.getLegacyFormat();
for (uint32_t j = 0; j < lines.size(); j++) {
printf("%s\n", lines[j].c_str());
}
diff --git a/config/src/tests/api/api.cpp b/config/src/tests/api/api.cpp
index 9cf6ea610bf..3377d256b97 100644
--- a/config/src/tests/api/api.cpp
+++ b/config/src/tests/api/api.cpp
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
#include <config-my.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
using namespace config;
diff --git a/config/src/tests/configagent/configagent.cpp b/config/src/tests/configagent/configagent.cpp
index 3fbbee8c601..4843b2f0647 100644
--- a/config/src/tests/configagent/configagent.cpp
+++ b/config/src/tests/configagent/configagent.cpp
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
-#include <vespa/config/raw/rawsource.h>
#include <vespa/config/common/misc.h>
#include <vespa/config/common/configrequest.h>
#include <vespa/config/common/timingvalues.h>
#include <vespa/config/common/trace.h>
+#include <vespa/config/common/configkey.h>
+#include <vespa/config/common/configholder.h>
#include <vespa/config/frt/frtconfigagent.h>
#include <config-my.h>
@@ -30,10 +30,10 @@ public:
class MyConfigResponse : public ConfigResponse
{
public:
- MyConfigResponse(const ConfigKey & key, const ConfigValue & value, bool valid, int64_t timestamp,
+ MyConfigResponse(const ConfigKey & key, ConfigValue value, bool valid, int64_t timestamp,
const vespalib::string & xxhash64, const std::string & errorMsg, int errorC0de, bool iserror)
: _key(key),
- _value(value),
+ _value(std::move(value)),
_fillCalled(false),
_valid(valid),
_state(xxhash64, timestamp, false),
@@ -83,10 +83,8 @@ public:
class MyHolder : public IConfigHolder
{
public:
- MyHolder()
- : _update()
- {
- }
+ MyHolder() noexcept = default;
+ ~MyHolder() = default;
std::unique_ptr<ConfigUpdate> provide() override
{
@@ -135,7 +133,7 @@ static TimingValues testTimingValues(
2000); // maxDelayMultiplier
TEST("require that agent returns correct values") {
- FRTConfigAgent handler(IConfigHolder::SP(new MyHolder()), testTimingValues);
+ FRTConfigAgent handler(std::make_shared<MyHolder>(), testTimingValues);
ASSERT_EQUAL(500u, handler.getTimeout());
ASSERT_EQUAL(0u, handler.getWaitTime());
ConfigState cs;
@@ -147,12 +145,12 @@ TEST("require that agent returns correct values") {
TEST("require that successful request is delivered to holder") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue(createValue("l33t", "a"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createOKResponse(testKey, testValue));
ASSERT_TRUE(latch->poll());
- ConfigUpdate::UP update(latch->provide());
+ std::unique_ptr<ConfigUpdate> update(latch->provide());
ASSERT_TRUE(update);
ASSERT_TRUE(update->hasChanged());
MyConfig cfg(update->getValue());
@@ -163,13 +161,13 @@ TEST("require that important(the change) request is delivered to holder even if
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue1(createValue("l33t", "a"));
const ConfigValue testValue2(createValue("l34t", "b"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey),
MyConfigResponse::createOKResponse(testKey, testValue1, 1, testValue1.getXxhash64()));
ASSERT_TRUE(latch->poll());
- ConfigUpdate::UP update(latch->provide());
+ std::unique_ptr<ConfigUpdate> update(latch->provide());
ASSERT_TRUE(update);
ASSERT_TRUE(update->hasChanged());
MyConfig cfg(update->getValue());
@@ -190,7 +188,7 @@ TEST("require that important(the change) request is delivered to holder even if
TEST("require that successful request sets correct wait time") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue(createValue("l33t", "a"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createOKResponse(testKey, testValue));
@@ -203,7 +201,7 @@ TEST("require that successful request sets correct wait time") {
TEST("require that bad config response returns false") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
const ConfigValue testValue(createValue("myval", "a"));
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createConfigErrorResponse(testKey, testValue));
@@ -241,10 +239,9 @@ TEST("require that bad config response returns false") {
TEST("require that bad response returns false") {
const ConfigKey testKey(ConfigKey::create<MyConfig>("mykey"));
- std::vector<vespalib::string> lines;
- const ConfigValue testValue(lines, "a");
+ const ConfigValue testValue(StringVector(), "a");
- IConfigHolder::SP latch(new MyHolder());
+ auto latch = std::make_shared<MyHolder>();
FRTConfigAgent handler(latch, testTimingValues);
handler.handleResponse(MyConfigRequest(testKey), MyConfigResponse::createServerErrorResponse(testKey, testValue));
diff --git a/config/src/tests/configfetcher/configfetcher.cpp b/config/src/tests/configfetcher/configfetcher.cpp
index 4782557338d..6142f9469fc 100644
--- a/config/src/tests/configfetcher/configfetcher.cpp
+++ b/config/src/tests/configfetcher/configfetcher.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <vespa/config/common/configcontext.h>
#include <vespa/vespalib/util/exception.h>
#include "config-my.h"
@@ -125,7 +125,7 @@ namespace {
struct ConfigFixture {
MyConfigBuilder builder;
ConfigSet set;
- ConfigContext::SP context;
+ std::shared_ptr<ConfigContext> context;
ConfigFixture() : builder(), set(), context() {
set.addBuilder("cfgid", &builder);
context = std::make_shared<ConfigContext>(set);
diff --git a/config/src/tests/configformat/configformat.cpp b/config/src/tests/configformat/configformat.cpp
index 6623e2ee254..65c40eaea8d 100644
--- a/config/src/tests/configformat/configformat.cpp
+++ b/config/src/tests/configformat/configformat.cpp
@@ -1,6 +1,5 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/print/fileconfigformatter.h>
#include <vespa/vespalib/data/slime/slime.h>
diff --git a/config/src/tests/configgen/configgen.cpp b/config/src/tests/configgen/configgen.cpp
index b7113dec972..2d08b526e8d 100644
--- a/config/src/tests/configgen/configgen.cpp
+++ b/config/src/tests/configgen/configgen.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/helper/configgetter.hpp>
#include "config-motd.h"
diff --git a/config/src/tests/configholder/configholder.cpp b/config/src/tests/configholder/configholder.cpp
index db32cc2e309..b2f6cd83693 100644
--- a/config/src/tests/configholder/configholder.cpp
+++ b/config/src/tests/configholder/configholder.cpp
@@ -14,8 +14,8 @@ constexpr vespalib::duration ONE_MINUTE = 60s;
TEST("Require that element order is correct")
{
- ConfigValue value(std::vector<vespalib::string>(), "foo");
- ConfigValue value2(std::vector<vespalib::string>(), "bar");
+ ConfigValue value(StringVector(), "foo");
+ ConfigValue value2(StringVector(), "bar");
ConfigHolder holder;
holder.handle(std::make_unique<ConfigUpdate>(value, true, 0));
diff --git a/config/src/tests/configmanager/configmanager.cpp b/config/src/tests/configmanager/configmanager.cpp
index 2cc5d4fad4f..9bed974f628 100644
--- a/config/src/tests/configmanager/configmanager.cpp
+++ b/config/src/tests/configmanager/configmanager.cpp
@@ -1,11 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/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/common/iconfigholder.h>
+
#include <vespa/config/raw/rawsource.h>
#include "config-my.h"
@@ -36,12 +37,12 @@ namespace {
class MySource : public Source
{
public:
- MySource(TestContext * data, const IConfigHolder::SP & holder) : _holder(holder), _data(data) { }
+ MySource(TestContext * data, std::shared_ptr<IConfigHolder> holder) : _holder(std::move(holder)), _data(data) { }
void getConfig() override
{
_data->numGetConfig++;
if (_data->respond) {
- _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(), true, _data->generation)));
+ _holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(), true, _data->generation));
}
}
void reload(int64_t generation) override
@@ -53,7 +54,7 @@ namespace {
{
_data->numClose++;
}
- IConfigHolder::SP _holder;
+ std::shared_ptr<IConfigHolder> _holder;
TestContext * _data;
};
@@ -61,10 +62,10 @@ namespace {
{
public:
MySourceFactory(TestContext * d) : data(d) { }
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override
{
(void) key;
- return Source::UP(new MySource(data, holder));
+ return std::make_unique<MySource>(data, std::move(holder));
}
TestContext * data;
};
@@ -78,9 +79,9 @@ namespace {
{
}
SourceSpecKey createKey() const { return SourceSpecKey(_key); }
- SourceFactory::UP createSourceFactory(const TimingValues & timingValues) const override {
+ std::unique_ptr<SourceFactory> createSourceFactory(const TimingValues & timingValues) const override {
(void) timingValues;
- return SourceFactory::UP(new MySourceFactory(_data));
+ return std::make_unique<MySourceFactory>(_data);
}
SourceSpec * clone() const { return new MySpec(*this); }
private:
diff --git a/config/src/tests/configparser/configparser.cpp b/config/src/tests/configparser/configparser.cpp
index 965c2a5a312..3e569a2d3fb 100644
--- a/config/src/tests/configparser/configparser.cpp
+++ b/config/src/tests/configparser/configparser.cpp
@@ -1,8 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configparser.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/common/configvalue.h>
#include "config-foo.h"
#include <fstream>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -102,14 +102,14 @@ TEST("require that array lengths may be specified")
}
TEST("require that escaped values are properly unescaped") {
- std::vector<vespalib::string> payload;
+ StringVector payload;
payload.push_back("foo \"a\\nb\\rc\\\\d\\\"e\x42g\"");
vespalib::string value(ConfigParser::parse<vespalib::string>("foo", payload));
ASSERT_EQUAL("a\nb\rc\\d\"eBg", value);
}
TEST("verify that locale does not affect double parsing") {
- std::vector<vespalib::string> payload;
+ StringVector payload;
setlocale(LC_NUMERIC, "nb_NO.UTF-8");
payload.push_back("foo 3,14");
ASSERT_EXCEPTION(ConfigParser::parse<double>("foo", payload), InvalidConfigException, "Value 3,14 is not a legal double");
@@ -127,7 +127,7 @@ TEST("require that maps can be parsed")
}
TEST("handles quotes for bool values") {
- std::vector<vespalib::string> payload;
+ StringVector payload;
payload.push_back("foo \"true\"");
payload.push_back("bar \"123\"");
payload.push_back("baz \"1234\"");
diff --git a/config/src/tests/configretriever/configretriever.cpp b/config/src/tests/configretriever/configretriever.cpp
index dbbcd0dec24..fdd106e44f2 100644
--- a/config/src/tests/configretriever/configretriever.cpp
+++ b/config/src/tests/configretriever/configretriever.cpp
@@ -14,6 +14,8 @@
#include <vespa/config/subscription/configsubscription.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/frt/protocol.h>
+#include <vespa/config/retriever/configsnapshot.hpp>
#include <thread>
#include <atomic>
@@ -34,7 +36,7 @@ struct ConfigTestFixture {
BootstrapConfigBuilder bootstrapBuilder;
map<std::string, ComponentFixture::SP> componentConfig;
ConfigSet set;
- IConfigContext::SP context;
+ std::shared_ptr<IConfigContext> context;
int idcounter;
ConfigTestFixture(const std::string & id)
@@ -115,11 +117,11 @@ struct MySource : public Source
struct SubscriptionFixture
{
- IConfigHolder::SP holder;
- ConfigSubscription::SP sub;
+ std::shared_ptr<IConfigHolder> holder;
+ std::shared_ptr<ConfigSubscription> sub;
SubscriptionFixture(const ConfigKey & key, const ConfigValue value)
- : holder(new ConfigHolder()),
- sub(new ConfigSubscription(0, key, holder, Source::UP(new MySource())))
+ : holder(std::make_shared<ConfigHolder>()),
+ sub(std::make_shared<ConfigSubscription>(0, key, holder, std::make_unique<MySource>()))
{
holder->handle(std::make_unique<ConfigUpdate>(value, 3, 3));
ASSERT_TRUE(sub->nextUpdate(0, 0ms));
@@ -215,7 +217,7 @@ TEST("require that SimpleConfigRetriever usage works") {
barBuilder.barValue = "fooz";
set.addBuilder("id", &fooBuilder);
set.addBuilder("id", &barBuilder);
- IConfigContext::SP ctx(new ConfigContext(set));
+ auto ctx = std::make_shared<ConfigContext>(set);
ConfigKeySet sub;
sub.add<FooConfig>("id");
sub.add<BarConfig>("id");
@@ -281,7 +283,7 @@ TEST_F("require that SimpleConfigurer usage works", ConfigurableFixture()) {
barBuilder.barValue = "fooz";
set.addBuilder("id", &fooBuilder);
set.addBuilder("id", &barBuilder);
- IConfigContext::SP ctx(new ConfigContext(set));
+ auto ctx = std::make_shared<ConfigContext>(set);
ConfigKeySet sub;
sub.add<FooConfig>("id");
sub.add<BarConfig>("id");
diff --git a/config/src/tests/configuri/configuri_test.cpp b/config/src/tests/configuri/configuri_test.cpp
index 1089886cb1d..e4b3ea06195 100644
--- a/config/src/tests/configuri/configuri_test.cpp
+++ b/config/src/tests/configuri/configuri_test.cpp
@@ -1,7 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
+#include <vespa/config/subscription/configuri.h>
#include "config-my.h"
using namespace config;
@@ -47,7 +48,7 @@ TEST("Require that URI can be created from instance") {
}
-TEST_F("Require that URI can be \"forked\"", IConfigContext::SP(new ConfigContext())) {
+TEST_F("Require that URI can be \"forked\"", std::shared_ptr<IConfigContext>(std::make_shared<ConfigContext>())) {
assertConfigId("baz", ConfigUri("foo/bar").createWithNewId("baz"));
ConfigUri parent("foo", f1);
ConfigUri child = parent.createWithNewId("baz");
diff --git a/config/src/tests/failover/failover.cpp b/config/src/tests/failover/failover.cpp
index 4bac1fb9062..e342a477b13 100644
--- a/config/src/tests/failover/failover.cpp
+++ b/config/src/tests/failover/failover.cpp
@@ -1,10 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/common/misc.h>
#include <vespa/config/frt/protocol.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/fnet/frt/rpcrequest.h>
@@ -189,7 +188,7 @@ TimingValues testTimingValues(
1200); // fatalDelay
struct ConfigCheckFixture {
- IConfigContext::SP ctx;
+ std::shared_ptr<IConfigContext> ctx;
NetworkFixture & nf;
ConfigCheckFixture(NetworkFixture & f2)
@@ -221,7 +220,7 @@ struct ConfigCheckFixture {
};
struct ConfigReloadFixture {
- IConfigContext::SP ctx;
+ std::shared_ptr<IConfigContext> ctx;
NetworkFixture & nf;
ConfigSubscriber s;
ConfigHandle<MyConfig>::UP handle;
diff --git a/config/src/tests/file_subscription/file_subscription.cpp b/config/src/tests/file_subscription/file_subscription.cpp
index 1201f72f90e..2d1a8498ba5 100644
--- a/config/src/tests/file_subscription/file_subscription.cpp
+++ b/config/src/tests/file_subscription/file_subscription.cpp
@@ -1,8 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/config/common/configholder.h>
-#include <vespa/config/file/filesource.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/sourcefactory.h>
#include <vespa/config/common/configcontext.h>
@@ -63,12 +62,12 @@ TEST("requireThatFileSpecGivesCorrectSource") {
SourceFactory::UP factory(spec.createSourceFactory(TimingValues()));
ASSERT_TRUE(factory);
auto holder = std::make_shared<ConfigHolder>();
- Source::UP src = factory->createSource(holder, ConfigKey("my", "my", "bar", "foo"));
+ std::unique_ptr<Source> src = factory->createSource(holder, ConfigKey("my", "my", "bar", "foo"));
ASSERT_TRUE(src);
src->getConfig();
ASSERT_TRUE(holder->poll());
- ConfigUpdate::UP update(holder->provide());
+ std::unique_ptr<ConfigUpdate> update(holder->provide());
ASSERT_TRUE(update);
const ConfigValue & value(update->getValue());
ASSERT_EQUAL(1u, value.numLines());
diff --git a/config/src/tests/frt/frt.cpp b/config/src/tests/frt/frt.cpp
index 54adbf4d787..0a0c3262b84 100644
--- a/config/src/tests/frt/frt.cpp
+++ b/config/src/tests/frt/frt.cpp
@@ -16,6 +16,8 @@
#include <vespa/fnet/frt/error.h>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/config/frt/protocol.h>
+#include <vespa/config/common/configvalue.hpp>
+
#include <lz4.h>
#include <thread>
@@ -29,15 +31,15 @@ using namespace config::protocol::v3;
namespace {
struct UpdateFixture : public IConfigHolder {
- ConfigUpdate::UP update;
+ std::unique_ptr<ConfigUpdate> update;
bool notified;
UpdateFixture()
: update(),
notified(false)
{ }
- ConfigUpdate::UP provide() override { return ConfigUpdate::UP(); }
- void handle(ConfigUpdate::UP u) override { update = std::move(u); }
+ std::unique_ptr<ConfigUpdate> provide() override { return std::unique_ptr<ConfigUpdate>(); }
+ void handle(std::unique_ptr<ConfigUpdate> u) override { update = std::move(u); }
bool wait(milliseconds timeoutInMillis) override { (void) timeoutInMillis; return notified; }
bool poll() override { return notified; }
void interrupt() override { }
@@ -75,7 +77,7 @@ namespace {
const vespalib::string & configXxhash64="",
int changed=0,
long generation=0,
- const std::vector<vespalib::string> & payload = std::vector<vespalib::string>(),
+ const StringVector & payload = StringVector(),
const vespalib::string & ns = "")
{
FRT_RPCRequest * req = new FRT_RPCRequest();
diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp
index 80433b0382c..333645176a0 100644
--- a/config/src/tests/functiontest/functiontest.cpp
+++ b/config/src/tests/functiontest/functiontest.cpp
@@ -1,13 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/config/config.h>
-#include <vespa/config/common/exceptions.h>
#include "config-function-test.h"
-
-#include <fstream>
-#include <vespa/log/log.h>
+#include <vespa/config/common/exceptions.h>
+#include <vespa/config/configgen/configpayload.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <fstream>
+
+#include <vespa/log/log.h>
LOG_SETUP("functiontest_test");
diff --git a/config/src/tests/getconfig/getconfig.cpp b/config/src/tests/getconfig/getconfig.cpp
index 4081ce2f1d6..a9598df9be9 100644
--- a/config/src/tests/getconfig/getconfig.cpp
+++ b/config/src/tests/getconfig/getconfig.cpp
@@ -12,7 +12,7 @@ namespace {
struct ConfigFixture {
MyConfigBuilder builder;
ConfigSet set;
- ConfigContext::SP context;
+ std::shared_ptr<IConfigContext> context;
ConfigFixture() : builder(), set(), context() {
set.addBuilder("cfgid", &builder);
context = std::make_shared<ConfigContext>(set);
diff --git a/config/src/tests/legacysubscriber/legacysubscriber.cpp b/config/src/tests/legacysubscriber/legacysubscriber.cpp
index 51a32731b0e..7b5f2e2fc0e 100644
--- a/config/src/tests/legacysubscriber/legacysubscriber.cpp
+++ b/config/src/tests/legacysubscriber/legacysubscriber.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/helper/legacysubscriber.h>
+#include <vespa/config/helper/legacysubscriber.hpp>
#include <fstream>
#include <config-my.h>
#include <config-foo.h>
diff --git a/config/src/tests/misc/misc.cpp b/config/src/tests/misc/misc.cpp
index 25b6cf36326..25c6762326d 100644
--- a/config/src/tests/misc/misc.cpp
+++ b/config/src/tests/misc/misc.cpp
@@ -3,6 +3,7 @@
#include <vespa/config/common/configupdate.h>
#include <vespa/config/common/misc.h>
#include <vespa/config/common/configvalue.h>
+#include <vespa/config/common/configkey.h>
#include <vespa/config/common/errorcode.h>
#include <vespa/config/common/vespa_version.h>
#include <vespa/config/subscription/sourcespec.h>
@@ -12,7 +13,7 @@
using namespace config;
TEST("requireThatConfigUpdateWorks") {
- std::vector<vespalib::string> lines;
+ StringVector lines;
lines.push_back("foo");
ConfigUpdate up(ConfigValue(lines, "myxxhash"), true, 1337);
@@ -25,13 +26,13 @@ TEST("requireThatConfigUpdateWorks") {
}
TEST("requireThatConfigValueWorks") {
- std::vector<vespalib::string> lines;
+ StringVector lines;
lines.push_back("myFooField \"bar\"");
- ConfigValue v1(lines, calculateContentXxhash64(lines));
- ConfigValue v2(lines, calculateContentXxhash64(lines));
- ConfigValue v3(lines, calculateContentXxhash64(lines));
+ ConfigValue v1(lines);
+ ConfigValue v2(lines);
+ ConfigValue v3(lines);
lines.push_back("myFooField \"bar2\"");
- ConfigValue v4(lines, calculateContentXxhash64(lines));
+ ConfigValue v4(lines);
ASSERT_TRUE(v1 == v2);
ASSERT_TRUE(v1 == v3);
}
@@ -108,11 +109,11 @@ TEST("requireThatConfigKeyWorks") {
TEST("require that config key initializes schema")
{
- std::vector<vespalib::string> schema;
+ StringVector schema;
schema.push_back("foo");
schema.push_back("bar");
ConfigKey key("id1", "def1", "namespace1", "xxhash1", schema);
- const std::vector<vespalib::string> &vref(key.getDefSchema());
+ const StringVector &vref(key.getDefSchema());
for (size_t i = 0; i < schema.size(); i++) {
ASSERT_EQUAL(schema[i], vref[i]);
}
diff --git a/config/src/tests/payload_converter/payload_converter.cpp b/config/src/tests/payload_converter/payload_converter.cpp
index 2ecb2062944..d5212048b2e 100644
--- a/config/src/tests/payload_converter/payload_converter.cpp
+++ b/config/src/tests/payload_converter/payload_converter.cpp
@@ -19,7 +19,7 @@ TEST("require that v2 payload leaf values can be converted to cfg format") {
root.setDouble("baz", 3.1);
root.setBool("quux", true);
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
std::sort(lines.begin(), lines.end());
ASSERT_EQUAL(4u, lines.size());
@@ -36,7 +36,7 @@ TEST("require that v2 payload struct values can be converted to cfg format") {
inner.setString("foo", "bar");
inner.setLong("bar", 8);
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
std::sort(lines.begin(), lines.end());
ASSERT_EQUAL(2u, lines.size());
@@ -51,7 +51,7 @@ TEST("require that v2 payload array values can be converted to cfg format") {
inner.addString("foo");
inner.addLong(8);
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
ASSERT_EQUAL(2u, lines.size());
EXPECT_EQUAL("arr[0] \"foo\"", lines[0]);
EXPECT_EQUAL("arr[1] 8", lines[1]);
@@ -72,7 +72,7 @@ TEST("require that v2 payload nested structures can be converted to cfg format")
Cursor & innerArr2(innerobj.setArray("arr2"));
innerArr2.addString("muhaha");
PayloadConverter converter(root);
- std::vector<vespalib::string> lines(converter.convert());
+ StringVector lines(converter.convert());
std::sort(lines.begin(), lines.end());
ASSERT_EQUAL(3u, lines.size());
EXPECT_EQUAL("arr[0].foo \"bar\"", lines[0]);
diff --git a/config/src/tests/print/print.cpp b/config/src/tests/print/print.cpp
index 325b8dc28fa..fa20482cf0a 100644
--- a/config/src/tests/print/print.cpp
+++ b/config/src/tests/print/print.cpp
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/print.h>
-#include <vespa/config/print/fileconfigreader.h>
-#include <vespa/config/print/istreamconfigreader.h>
+#include <vespa/config/print/fileconfigreader.hpp>
+#include <vespa/config/print/istreamconfigreader.hpp>
#include <vespa/config/helper/configgetter.hpp>
+#include <vespa/vespalib/util/exceptions.h>
#include "config-my.h"
#include "config-motd.h"
#include <sys/stat.h>
diff --git a/config/src/tests/raw_subscription/raw_subscription.cpp b/config/src/tests/raw_subscription/raw_subscription.cpp
index 7141a21d35d..da35d10da52 100644
--- a/config/src/tests/raw_subscription/raw_subscription.cpp
+++ b/config/src/tests/raw_subscription/raw_subscription.cpp
@@ -1,9 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configholder.h>
#include <vespa/config/common/sourcefactory.h>
-#include <vespa/config/raw/rawsource.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include "config-my.h"
using namespace config;
@@ -13,13 +12,13 @@ TEST("require that raw spec can create source factory")
RawSpec spec("myField \"foo\"\n");
auto raw = spec.createSourceFactory(TimingValues());
ASSERT_TRUE(raw);
- IConfigHolder::SP holder(new ConfigHolder());
- Source::UP src = raw->createSource(holder, ConfigKey("myid", "my", "bar", "foo"));
+ std::shared_ptr<IConfigHolder> holder(new ConfigHolder());
+ std::unique_ptr<Source> src = raw->createSource(holder, ConfigKey("myid", "my", "bar", "foo"));
ASSERT_TRUE(src);
src->getConfig();
ASSERT_TRUE(holder->poll());
- ConfigUpdate::UP update(holder->provide());
+ std::unique_ptr<ConfigUpdate> update(holder->provide());
ASSERT_TRUE(update);
const ConfigValue & value(update->getValue());
ASSERT_EQUAL(1u, value.numLines());
diff --git a/config/src/tests/subscriber/subscriber.cpp b/config/src/tests/subscriber/subscriber.cpp
index 5871add2618..68e211ec3f8 100644
--- a/config/src/tests/subscriber/subscriber.cpp
+++ b/config/src/tests/subscriber/subscriber.cpp
@@ -3,11 +3,12 @@
#include "config-bar.h"
#include "config-baz.h"
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/misc.h>
#include <vespa/config/common/configholder.h>
-#include <vespa/config/subscription/configsubscription.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/common/iconfigmanager.h>
+#include <vespa/config/common/iconfigcontext.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <thread>
using namespace config;
@@ -18,9 +19,9 @@ namespace {
ConfigValue createValue(const std::string & value)
{
- std::vector< vespalib::string > lines;
+ StringVector lines;
lines.push_back(value);
- return ConfigValue(lines, calculateContentXxhash64(lines));
+ return ConfigValue(std::move(lines));
}
ConfigValue createFooValue(const std::string & value)
@@ -40,13 +41,13 @@ namespace {
void verifyConfig(const std::string & expected, std::unique_ptr<FooConfig> cfg)
{
- ASSERT_TRUE(cfg.get() != NULL);
+ ASSERT_TRUE(cfg);
ASSERT_EQUAL(expected, cfg->fooValue);
}
void verifyConfig(const std::string & expected, std::unique_ptr<BarConfig> cfg)
{
- ASSERT_TRUE(cfg.get() != NULL);
+ ASSERT_TRUE(cfg);
ASSERT_EQUAL(expected, cfg->barValue);
}
@@ -72,7 +73,7 @@ namespace {
SubscriptionId idCounter;
- std::vector<IConfigHolder::SP> _holders;
+ std::vector<std::shared_ptr<IConfigHolder>> _holders;
int numCancel;
@@ -80,7 +81,7 @@ namespace {
ConfigSubscription::SP subscribe(const ConfigKey & key, milliseconds timeoutInMillis) override {
(void) timeoutInMillis;
- IConfigHolder::SP holder(new ConfigHolder());
+ auto holder = std::make_shared<ConfigHolder>();
_holders.push_back(holder);
return std::make_shared<ConfigSubscription>(0, key, holder, std::make_unique<MySource>());
@@ -116,16 +117,18 @@ namespace {
{
public:
MyManager & _m;
- APIFixture(MyManager & m)
+ APIFixture(MyManager & m) noexcept
: _m(m)
{
}
- APIFixture(const APIFixture & rhs)
+ APIFixture(const APIFixture & rhs) noexcept
: IConfigContext(rhs),
_m(rhs._m)
{ }
+ ~APIFixture() override = default;
+
IConfigManager & getManagerInstance() override {
return _m;
}
@@ -144,7 +147,7 @@ namespace {
ConfigHandle<FooConfig>::UP h1;
ConfigHandle<BarConfig>::UP h2;
- StandardFixture(MyManager & F1, APIFixture & F2) : f1(F1), s(IConfigContext::SP(new APIFixture(F2)))
+ StandardFixture(MyManager & F1, APIFixture & F2) : f1(F1), s(std::make_shared<APIFixture>(F2))
{
h1 = s.subscribe<FooConfig>("myid");
h2 = s.subscribe<BarConfig>("myid");
@@ -206,7 +209,7 @@ TEST_F("requireThatSubscriptionsCannotBeAddedWhenFrozen", SimpleFixture()) {
}
TEST_FF("requireThatNextConfigReturnsFalseUntilSubscriptionHasSucceeded", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid");
ASSERT_FALSE(s.nextConfigNow());
@@ -335,7 +338,7 @@ TEST_MT_FFF("requireThatNextConfigIsInterruptedOnClose", 2, MyManager, APIFixtur
}
TEST_FF("requireThatHandlesAreMarkedAsChanged", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid2");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid2");
EXPECT_FALSE(s.nextConfigNow());
@@ -357,7 +360,7 @@ TEST_FF("requireThatHandlesAreMarkedAsChanged", MyManager, APIFixture(f1)) {
}
TEST_FF("requireThatNextGenerationMarksChanged", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid2");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid2");
f1.updateValue(0, createFooValue("foo"), 1);
@@ -380,7 +383,7 @@ TEST_FF("requireThatNextGenerationMarksChanged", MyManager, APIFixture(f1)) {
}
TEST_FF("requireThatgetGenerationIsSet", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid2");
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid2");
f1.updateValue(0, createFooValue("foo"), 1);
@@ -407,7 +410,7 @@ TEST_FFF("requireThatConfigHandleStillHasConfigOnTimestampUpdate", MyManager, AP
}
TEST_FF("requireThatTimeStamp0Works", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid");
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
ConfigHandle<BazConfig>::UP h3 = s.subscribe<BazConfig>("myid");
@@ -421,7 +424,7 @@ TEST_FF("requireThatTimeStamp0Works", MyManager, APIFixture(f1)) {
}
TEST_FF("requireThatNextGenerationWorksWithManyConfigs", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<BarConfig>::UP h2 = s.subscribe<BarConfig>("myid");
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
ConfigHandle<BazConfig>::UP h3 = s.subscribe<BazConfig>("myid");
@@ -483,7 +486,7 @@ TEST_FF("requireThatNextGenerationWorksWithManyConfigs", MyManager, APIFixture(f
}
TEST_FF("requireThatConfigSubscriberHandlesProxyCache", MyManager, APIFixture(f1)) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
f1.updateValue(0, createFooValue("foo"), 1);
f1.updateGeneration(0, 2);
@@ -501,7 +504,7 @@ TEST_FF("requireThatConfigSubscriberHandlesProxyCache", MyManager, APIFixture(f1
TEST_MT_FF("requireThatConfigSubscriberWaitsUntilNextConfigSucceeds", 2, MyManager, APIFixture(f1)) {
if (thread_id == 0) {
- ConfigSubscriber s(IConfigContext::SP(new APIFixture(f2)));
+ ConfigSubscriber s(std::make_shared<APIFixture>(f2));
ConfigHandle<FooConfig>::UP h1 = s.subscribe<FooConfig>("myid");
f1.updateValue(0, createFooValue("foo"), 1);
ASSERT_TRUE(s.nextConfigNow());
diff --git a/config/src/tests/subscription/subscription.cpp b/config/src/tests/subscription/subscription.cpp
index a65528d67ee..f35ea3c6cef 100644
--- a/config/src/tests/subscription/subscription.cpp
+++ b/config/src/tests/subscription/subscription.cpp
@@ -38,12 +38,12 @@ namespace {
struct SubscriptionFixture
{
- IConfigHolder::SP holder;
+ std::shared_ptr<IConfigHolder> holder;
ConfigSubscription sub;
SourceFixture src;
SubscriptionFixture(const ConfigKey & key)
: holder(new ConfigHolder()),
- sub(0, key, holder, Source::UP(new MySource(&src)))
+ sub(0, key, holder, std::make_unique<MySource>(&src))
{
}
};
@@ -100,11 +100,11 @@ TEST_MT_F("requireThatNextUpdateReturnsInterrupted", 2, SubscriptionFixture(Conf
TEST_F("Require that isChanged takes generation into account", SubscriptionFixture(ConfigKey::create<MyConfig>("myid")))
{
- f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(std::vector<vespalib::string>(), "a"), true, 1));
+ f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(StringVector(), "a"), true, 1));
ASSERT_TRUE(f1.sub.nextUpdate(0, 0ms));
f1.sub.flip();
ASSERT_EQUAL(1, f1.sub.getLastGenerationChanged());
- f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(std::vector<vespalib::string>(), "b"), true, 2));
+ f1.holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(StringVector(), "b"), true, 2));
ASSERT_TRUE(f1.sub.nextUpdate(1, 0ms));
f1.sub.flip();
ASSERT_EQUAL(2, f1.sub.getLastGenerationChanged());
diff --git a/config/src/tests/unittest/unittest.cpp b/config/src/tests/unittest/unittest.cpp
index 1ba11db89b9..207a139f31d 100644
--- a/config/src/tests/unittest/unittest.cpp
+++ b/config/src/tests/unittest/unittest.cpp
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
#include "config-my.h"
#include "config-foo.h"
#include "config-bar.h"
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/log/log.h>
LOG_SETUP("unittest");
diff --git a/config/src/vespa/config/common/cancelhandler.h b/config/src/vespa/config/common/cancelhandler.h
index 7641b774fbf..8dde83ba7d9 100644
--- a/config/src/vespa/config/common/cancelhandler.h
+++ b/config/src/vespa/config/common/cancelhandler.h
@@ -13,9 +13,9 @@ struct CancelHandler
*
* @param subscription ConfigSubscription to cancel
*/
- virtual void unsubscribe(const ConfigSubscription::SP & subscription) = 0;
+ virtual void unsubscribe(const std::shared_ptr<ConfigSubscription> & subscription) = 0;
- virtual ~CancelHandler() { }
+ virtual ~CancelHandler() = default;
};
}
diff --git a/config/src/vespa/config/common/configdefinition.cpp b/config/src/vespa/config/common/configdefinition.cpp
index 21bafcda8f6..a02460f8e64 100644
--- a/config/src/vespa/config/common/configdefinition.cpp
+++ b/config/src/vespa/config/common/configdefinition.cpp
@@ -12,8 +12,8 @@ ConfigDefinition::ConfigDefinition()
: _schema()
{}
-ConfigDefinition::ConfigDefinition(const std::vector<vespalib::string> & schema)
- : _schema(schema)
+ConfigDefinition::ConfigDefinition(StringVector schema)
+ : _schema(std::move(schema))
{}
void
@@ -36,8 +36,8 @@ vespalib::string
ConfigDefinition::asString() const
{
vespalib::asciistream as;
- for (auto it(_schema.begin()), mt(_schema.end()); it != mt; it++) {
- as << *it;
+ for (const auto & line : _schema) {
+ as << line;
}
return as.str();
}
diff --git a/config/src/vespa/config/common/configdefinition.h b/config/src/vespa/config/common/configdefinition.h
index 78ab7877394..5ef87cbe7f7 100644
--- a/config/src/vespa/config/common/configdefinition.h
+++ b/config/src/vespa/config/common/configdefinition.h
@@ -1,8 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/vespalib/stllike/string.h>
-#include <vector>
+#include "types.h"
namespace vespalib::slime {
struct Cursor;
@@ -16,12 +15,12 @@ namespace config {
class ConfigDefinition {
public:
ConfigDefinition();
- ConfigDefinition(const std::vector<vespalib::string> & schema);
+ ConfigDefinition(StringVector schema);
void deserialize(const vespalib::slime::Inspector & inspector);
void serialize(vespalib::slime::Cursor & cursor) const;
vespalib::string asString() const;
private:
- std::vector<vespalib::string> _schema;
+ StringVector _schema;
};
} //namespace config
diff --git a/config/src/vespa/config/common/configholder.cpp b/config/src/vespa/config/common/configholder.cpp
index f16d70f11b1..41c88e13b06 100644
--- a/config/src/vespa/config/common/configholder.cpp
+++ b/config/src/vespa/config/common/configholder.cpp
@@ -13,7 +13,7 @@ ConfigHolder::ConfigHolder()
ConfigHolder::~ConfigHolder() = default;
-ConfigUpdate::UP
+std::unique_ptr<ConfigUpdate>
ConfigHolder::provide()
{
std::lock_guard guard(_lock);
@@ -21,7 +21,7 @@ ConfigHolder::provide()
}
void
-ConfigHolder::handle(ConfigUpdate::UP update)
+ConfigHolder::handle(std::unique_ptr<ConfigUpdate> update)
{
std::lock_guard guard(_lock);
if (_current) {
diff --git a/config/src/vespa/config/common/configholder.h b/config/src/vespa/config/common/configholder.h
index 75324bd9d2e..c9b5a37765a 100644
--- a/config/src/vespa/config/common/configholder.h
+++ b/config/src/vespa/config/common/configholder.h
@@ -16,15 +16,15 @@ public:
ConfigHolder();
~ConfigHolder() override;
- ConfigUpdate::UP provide() override;
- void handle(ConfigUpdate::UP update) override;
+ std::unique_ptr<ConfigUpdate> provide() override;
+ void handle(std::unique_ptr<ConfigUpdate> update) override;
bool wait(milliseconds timeoutInMillis) override;
bool poll() override;
void interrupt() override;
public:
- std::mutex _lock;
- std::condition_variable _cond;
- ConfigUpdate::UP _current;
+ std::mutex _lock;
+ std::condition_variable _cond;
+ std::unique_ptr<ConfigUpdate> _current;
};
} // namespace config
diff --git a/config/src/vespa/config/common/configkey.cpp b/config/src/vespa/config/common/configkey.cpp
index f6f0b6cba00..79fa6fec81b 100644
--- a/config/src/vespa/config/common/configkey.cpp
+++ b/config/src/vespa/config/common/configkey.cpp
@@ -20,7 +20,7 @@ ConfigKey::ConfigKey(vespalib::stringref configId,
vespalib::stringref defName,
vespalib::stringref defNamespace,
vespalib::stringref defMd5,
- const std::vector<vespalib::string> & defSchema)
+ const StringVector & defSchema)
: _configId(configId),
_defName(defName),
_defNamespace(defNamespace),
@@ -66,7 +66,7 @@ const vespalib::string & ConfigKey::getDefName() const { return _defName; }
const vespalib::string & ConfigKey::getConfigId() const { return _configId; }
const vespalib::string & ConfigKey::getDefNamespace() const { return _defNamespace; }
const vespalib::string & ConfigKey::getDefMd5() const { return _defMd5; }
-const std::vector<vespalib::string> & ConfigKey::getDefSchema() const { return _defSchema; }
+const StringVector & ConfigKey::getDefSchema() const { return _defSchema; }
const vespalib::string
ConfigKey::toString() const
diff --git a/config/src/vespa/config/common/configkey.h b/config/src/vespa/config/common/configkey.h
index 96b7ada92e4..60db8d6e8cc 100644
--- a/config/src/vespa/config/common/configkey.h
+++ b/config/src/vespa/config/common/configkey.h
@@ -1,8 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/vespalib/stllike/string.h>
-#include <vector>
+#include "types.h"
namespace config {
@@ -17,7 +16,7 @@ public:
vespalib::stringref defName,
vespalib::stringref defNamespace,
vespalib::stringref defMd5,
- const std::vector<vespalib::string> & defSchema);
+ const StringVector & defSchema);
ConfigKey(const ConfigKey &);
ConfigKey & operator = (const ConfigKey &);
@@ -34,7 +33,7 @@ public:
const vespalib::string & getConfigId() const;
const vespalib::string & getDefNamespace() const;
const vespalib::string & getDefMd5() const;
- const std::vector<vespalib::string> & getDefSchema() const;
+ const StringVector & getDefSchema() const;
template <typename ConfigType>
static const ConfigKey create(vespalib::stringref configId)
@@ -51,7 +50,7 @@ private:
vespalib::string _defName;
vespalib::string _defNamespace;
vespalib::string _defMd5;
- std::vector<vespalib::string> _defSchema;
+ StringVector _defSchema;
vespalib::string _key;
};
diff --git a/config/src/vespa/config/common/configmanager.cpp b/config/src/vespa/config/common/configmanager.cpp
index fb082b8479a..d982a77bd1c 100644
--- a/config/src/vespa/config/common/configmanager.cpp
+++ b/config/src/vespa/config/common/configmanager.cpp
@@ -31,7 +31,7 @@ ConfigManager::subscribe(const ConfigKey & key, milliseconds timeoutInMillis)
SubscriptionId id(_idGenerator.fetch_add(1));
auto holder = std::make_shared<ConfigHolder>();
- Source::UP source = _sourceFactory->createSource(holder, key);
+ std::unique_ptr<Source> source = _sourceFactory->createSource(holder, key);
source->reload(_generation);
source->getConfig();
diff --git a/config/src/vespa/config/common/configparser.cpp b/config/src/vespa/config/common/configparser.cpp
index a8785642ca7..3e18d6ae4e7 100644
--- a/config/src/vespa/config/common/configparser.cpp
+++ b/config/src/vespa/config/common/configparser.cpp
@@ -123,7 +123,7 @@ getValueForKey(vespalib::stringref key, vespalib::stringref line,
}
-std::vector<vespalib::string>
+StringVector
ConfigParser::getLinesForKey(vespalib::stringref key,
const vsvector & lines)
{
diff --git a/config/src/vespa/config/common/configparser.h b/config/src/vespa/config/common/configparser.h
index b96bf77fd77..dc89930c23e 100644
--- a/config/src/vespa/config/common/configparser.h
+++ b/config/src/vespa/config/common/configparser.h
@@ -1,12 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include "types.h"
#include <vespa/vespalib/util/stringfmt.h>
-#include <map>
#include <set>
-#include <vector>
#include <cerrno>
-#include <cstdint>
namespace config {
@@ -16,7 +14,7 @@ namespace config {
*/
class ConfigParser {
public:
- typedef std::vector<vespalib::string> vsvector;
+ using vsvector = StringVector;
private:
static vsvector getLinesForKey(vespalib::stringref key, const vsvector & config);
diff --git a/config/src/vespa/config/common/configupdate.cpp b/config/src/vespa/config/common/configupdate.cpp
index e46dd781b2d..55f12775a46 100644
--- a/config/src/vespa/config/common/configupdate.cpp
+++ b/config/src/vespa/config/common/configupdate.cpp
@@ -3,13 +3,13 @@
namespace config {
-ConfigUpdate::ConfigUpdate(const ConfigValue & value, bool changed, int64_t generation)
- : _value(value),
+ConfigUpdate::ConfigUpdate(ConfigValue value, bool changed, int64_t generation)
+ : _value(std::move(value)),
_hasChanged(changed),
_generation(generation)
{
}
-
+ConfigUpdate::~ConfigUpdate() = default;
const ConfigValue & ConfigUpdate::getValue() const { return _value; }
bool ConfigUpdate::hasChanged() const { return _hasChanged; }
int64_t ConfigUpdate::getGeneration() const { return _generation; }
diff --git a/config/src/vespa/config/common/configupdate.h b/config/src/vespa/config/common/configupdate.h
index 571b32a97dc..35d641615a0 100644
--- a/config/src/vespa/config/common/configupdate.h
+++ b/config/src/vespa/config/common/configupdate.h
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <memory>
#include "configvalue.h"
namespace config {
@@ -13,17 +12,18 @@ namespace config {
class ConfigUpdate
{
public:
- typedef std::unique_ptr<ConfigUpdate> UP;
- ConfigUpdate(const ConfigValue & value, bool changed, int64_t generation);
-
+ ConfigUpdate(ConfigValue value, bool changed, int64_t generation);
+ ConfigUpdate(const ConfigUpdate &) = delete;
+ ConfigUpdate & operator = (const ConfigUpdate &) = delete;
+ ~ConfigUpdate();
const ConfigValue & getValue() const;
bool hasChanged() const;
int64_t getGeneration() const;
void merge(const ConfigUpdate & b) { _hasChanged = _hasChanged || b.hasChanged(); }
private:
ConfigValue _value;
- bool _hasChanged;
- int64_t _generation;
+ bool _hasChanged;
+ int64_t _generation;
};
} // namespace config
diff --git a/config/src/vespa/config/common/configvalue.cpp b/config/src/vespa/config/common/configvalue.cpp
index da1cbfc792c..586ada889bc 100644
--- a/config/src/vespa/config/common/configvalue.cpp
+++ b/config/src/vespa/config/common/configvalue.cpp
@@ -2,16 +2,23 @@
#include "configvalue.h"
#include "payload_converter.h"
#include "misc.h"
+#include <vespa/config/frt/protocol.h>
#include <vespa/vespalib/data/slime/slime.h>
namespace config {
-ConfigValue::ConfigValue(const std::vector<vespalib::string> & lines, const vespalib::string & xxhash)
+ConfigValue::ConfigValue(StringVector lines, const vespalib::string & xxhash)
: _payload(),
- _lines(lines),
+ _lines(std::move(lines)),
_xxhash64(xxhash)
{ }
+ConfigValue::ConfigValue(StringVector lines)
+ : _payload(),
+ _lines(std::move(lines)),
+ _xxhash64(calculateContentXxhash64(_lines))
+{ }
+
ConfigValue::ConfigValue()
: _payload(),
_lines(),
@@ -26,7 +33,6 @@ ConfigValue::ConfigValue(PayloadPtr payload, const vespalib::string & xxhash)
ConfigValue::ConfigValue(const ConfigValue &) = default;
ConfigValue & ConfigValue::operator = (const ConfigValue &) = default;
-
ConfigValue::~ConfigValue() = default;
int
@@ -41,10 +47,10 @@ ConfigValue::operator!=(const ConfigValue & rhs) const
return (!(*this == rhs));
}
-std::vector<vespalib::string>
+StringVector
ConfigValue::getLegacyFormat() const
{
- std::vector<vespalib::string> lines;
+ StringVector lines;
if (_payload) {
const vespalib::slime::Inspector & payload(_payload->getSlimePayload());
PayloadConverter converter(payload);
@@ -69,7 +75,7 @@ void
ConfigValue::serializeV1(vespalib::slime::Cursor & cursor) const
{
// TODO: Remove v1 when we can bump disk format.
- std::vector<vespalib::string> lines(getLegacyFormat());
+ StringVector lines(getLegacyFormat());
for (size_t i = 0; i < lines.size(); i++) {
cursor.addString(vespalib::Memory(lines[i]));
}
diff --git a/config/src/vespa/config/common/configvalue.h b/config/src/vespa/config/common/configvalue.h
index bf4c320c061..c071b3cfd7c 100644
--- a/config/src/vespa/config/common/configvalue.h
+++ b/config/src/vespa/config/common/configvalue.h
@@ -1,15 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/config/frt/protocol.h>
-#include <vespa/config/configgen/configpayload.h>
-#include <vespa/vespalib/stllike/string.h>
-#include <vector>
+#include <vespa/config/common/types.h>
#include <memory>
#include <climits>
namespace vespalib::slime { struct Cursor; }
-
+namespace config::protocol { struct Payload; }
namespace config {
typedef std::shared_ptr<const protocol::Payload> PayloadPtr;
@@ -20,10 +17,12 @@ typedef std::shared_ptr<const protocol::Payload> PayloadPtr;
*/
class ConfigValue {
public:
- typedef std::unique_ptr<ConfigValue> UP;
- ConfigValue(const std::vector<vespalib::string> & lines, const vespalib::string & xxhash);
+ explicit ConfigValue(StringVector lines);
+ ConfigValue(StringVector lines, const vespalib::string & xxhash);
ConfigValue(PayloadPtr data, const vespalib::string & xxhash);
ConfigValue();
+ ConfigValue(ConfigValue &&) noexcept = default;
+ ConfigValue & operator = (ConfigValue &&) noexcept = default;
ConfigValue(const ConfigValue &);
ConfigValue & operator = (const ConfigValue &);
~ConfigValue();
@@ -33,8 +32,8 @@ public:
size_t numLines() const { return _lines.size(); }
const vespalib::string & getLine(int i) const { return _lines.at(i); }
- const std::vector<vespalib::string> & getLines() const { return _lines; }
- std::vector<vespalib::string> getLegacyFormat() const;
+ const StringVector & getLines() const { return _lines; }
+ StringVector getLegacyFormat() const;
vespalib::string asJson() const;
const vespalib::string& getXxhash64() const { return _xxhash64; }
@@ -45,12 +44,9 @@ public:
std::unique_ptr<ConfigType> newInstance() const;
private:
- PayloadPtr _payload;
- std::vector<vespalib::string> _lines;
+ PayloadPtr _payload;
+ StringVector _lines;
vespalib::string _xxhash64;
};
} //namespace config
-
-#include "configvalue.hpp"
-
diff --git a/config/src/vespa/config/common/configvalue.hpp b/config/src/vespa/config/common/configvalue.hpp
index 665ce69c7a5..89177454dc3 100644
--- a/config/src/vespa/config/common/configvalue.hpp
+++ b/config/src/vespa/config/common/configvalue.hpp
@@ -1,5 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "configvalue.h"
+#include <vespa/config/configgen/configpayload.h>
+#include <vespa/config/frt/protocol.h>
+
namespace config {
template <typename ConfigType>
@@ -8,9 +12,9 @@ ConfigValue::newInstance() const
{
if (_payload) {
const vespalib::slime::Inspector & payload(_payload->getSlimePayload());
- return std::unique_ptr<ConfigType>(new ConfigType(::config::ConfigPayload(payload)));
+ return std::make_unique<ConfigType>(::config::ConfigPayload(payload));
} else {
- return std::unique_ptr<ConfigType>(new ConfigType(*this));
+ return std::make_unique<ConfigType>(*this);
}
}
diff --git a/config/src/vespa/config/common/iconfigcontext.h b/config/src/vespa/config/common/iconfigcontext.h
index acc97a7cb8c..71be1dec715 100644
--- a/config/src/vespa/config/common/iconfigcontext.h
+++ b/config/src/vespa/config/common/iconfigcontext.h
@@ -15,8 +15,6 @@ class IConfigManager;
class IConfigContext
{
public:
- typedef std::shared_ptr<IConfigContext> SP;
-
/**
* Get an instance of the config manager.
*
@@ -29,7 +27,7 @@ public:
*/
virtual void reload() = 0;
- virtual ~IConfigContext() { }
+ virtual ~IConfigContext() = default;
};
} // namespace
diff --git a/config/src/vespa/config/common/iconfigholder.h b/config/src/vespa/config/common/iconfigholder.h
index ff8e117cb37..9b474ccf70b 100644
--- a/config/src/vespa/config/common/iconfigholder.h
+++ b/config/src/vespa/config/common/iconfigholder.h
@@ -17,8 +17,7 @@ class IConfigHolder : public ConfigHandler,
public Interruptable
{
public:
- typedef std::shared_ptr<IConfigHolder> SP;
- virtual ~IConfigHolder() { }
+ virtual ~IConfigHolder() = default;
};
} // namespace config
diff --git a/config/src/vespa/config/common/iconfigmanager.h b/config/src/vespa/config/common/iconfigmanager.h
index ab0576428f1..3f5304b075f 100644
--- a/config/src/vespa/config/common/iconfigmanager.h
+++ b/config/src/vespa/config/common/iconfigmanager.h
@@ -12,7 +12,7 @@ class IConfigManager : public SubscribeHandler,
public ReloadHandler
{
public:
- virtual ~IConfigManager() { }
+ virtual ~IConfigManager() = default;
};
} // namespace config
diff --git a/config/src/vespa/config/common/misc.cpp b/config/src/vespa/config/common/misc.cpp
index 34985d19c68..7eba045a2c7 100644
--- a/config/src/vespa/config/common/misc.cpp
+++ b/config/src/vespa/config/common/misc.cpp
@@ -14,7 +14,7 @@ using vespalib::Memory;
namespace config {
vespalib::string
-calculateContentXxhash64(const std::vector<vespalib::string> & fileContents)
+calculateContentXxhash64(const StringVector & fileContents)
{
vespalib::string normalizedLines;
XXH64_hash_t xxhash64;
diff --git a/config/src/vespa/config/common/misc.h b/config/src/vespa/config/common/misc.h
index 06546a85292..f26ee3df850 100644
--- a/config/src/vespa/config/common/misc.h
+++ b/config/src/vespa/config/common/misc.h
@@ -1,9 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include "configkey.h"
-#include <vespa/vespalib/stllike/string.h>
-#include <vector>
+#include "types.h"
#include <memory>
namespace vespalib {
@@ -19,7 +17,7 @@ namespace config {
/**
* Miscellaneous utility functions specific to config.
*/
-vespalib::string calculateContentXxhash64(const std::vector<vespalib::string> & fileContents);
+vespalib::string calculateContentXxhash64(const StringVector & fileContents);
bool isGenerationNewer(int64_t newGen, int64_t oldGen);
diff --git a/config/src/vespa/config/common/payload_converter.cpp b/config/src/vespa/config/common/payload_converter.cpp
index 3cdc745c77a..2ab6f6607ea 100644
--- a/config/src/vespa/config/common/payload_converter.cpp
+++ b/config/src/vespa/config/common/payload_converter.cpp
@@ -12,9 +12,9 @@ PayloadConverter::PayloadConverter(const Inspector & inspector)
_lines()
{}
-PayloadConverter::~PayloadConverter() { }
+PayloadConverter::~PayloadConverter() = default;
-const std::vector<vespalib::string> &
+const StringVector &
PayloadConverter::convert()
{
_lines.clear();
diff --git a/config/src/vespa/config/common/payload_converter.h b/config/src/vespa/config/common/payload_converter.h
index 504fb06cf0a..1bf239b4a97 100644
--- a/config/src/vespa/config/common/payload_converter.h
+++ b/config/src/vespa/config/common/payload_converter.h
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include "types.h"
#include <vespa/vespalib/data/slime/object_traverser.h>
#include <vespa/vespalib/data/slime/array_traverser.h>
-#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/asciistream.h>
namespace config {
@@ -16,7 +16,7 @@ class PayloadConverter : public vespalib::slime::ObjectTraverser, public vespali
public:
PayloadConverter(const vespalib::slime::Inspector & inspector);
~PayloadConverter();
- const std::vector<vespalib::string> & convert();
+ const StringVector & convert();
void field(const vespalib::Memory & symbol, const vespalib::slime::Inspector & inspector) override;
void entry(size_t idx, const vespalib::slime::Inspector & inspector) override;
private:
@@ -38,11 +38,11 @@ private:
Node(int idx) : name(""), arrayIndex(idx) {}
Node(const vespalib::string & nm) : name(nm), arrayIndex(-1) {}
};
+ using NodeStack = std::vector<Node>;
const vespalib::slime::Inspector & _inspector;
- std::vector<vespalib::string> _lines;
- typedef std::vector<Node> NodeStack;
- NodeStack _nodeStack;
- vespalib::asciistream _buf;
+ StringVector _lines;
+ NodeStack _nodeStack;
+ vespalib::asciistream _buf;
};
} // namespace config
diff --git a/config/src/vespa/config/common/source.h b/config/src/vespa/config/common/source.h
index f3014d0854c..1e1f39fd07e 100644
--- a/config/src/vespa/config/common/source.h
+++ b/config/src/vespa/config/common/source.h
@@ -11,13 +11,11 @@ namespace config {
*/
class Source {
public:
- typedef std::unique_ptr<Source> UP;
-
virtual void getConfig() = 0;
virtual void reload(int64_t generation) = 0;
virtual void close() = 0;
- virtual ~Source() { }
+ virtual ~Source() = default;
};
} // namespace common
diff --git a/config/src/vespa/config/common/sourcefactory.h b/config/src/vespa/config/common/sourcefactory.h
index de97977c924..0236bea2802 100644
--- a/config/src/vespa/config/common/sourcefactory.h
+++ b/config/src/vespa/config/common/sourcefactory.h
@@ -1,21 +1,21 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <memory>
#include "source.h"
#include "configkey.h"
-#include "iconfigholder.h"
namespace config {
+class IConfigHolder;
+
/*
* Source factory, creating possible config sources.
*/
class SourceFactory {
public:
typedef std::unique_ptr<SourceFactory> UP;
- virtual Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const = 0;
- virtual ~SourceFactory() { }
+ virtual std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const = 0;
+ virtual ~SourceFactory() = default;
};
} // namespace common
diff --git a/config/src/vespa/config/common/subscribehandler.h b/config/src/vespa/config/common/subscribehandler.h
index 5ab70677996..da8bdfadcf2 100644
--- a/config/src/vespa/config/common/subscribehandler.h
+++ b/config/src/vespa/config/common/subscribehandler.h
@@ -2,10 +2,11 @@
#pragma once
#include "configkey.h"
-#include <vespa/config/subscription/configsubscription.h>
namespace config {
+class ConfigSubscription;
+
struct SubscribeHandler
{
using milliseconds = std::chrono::milliseconds;
@@ -18,8 +19,8 @@ struct SubscribeHandler
* @param timeoutInMillis the timeout of the subscribe call.
* @return subscription object containing data relevant to client
*/
- virtual ConfigSubscription::SP subscribe(const ConfigKey & key, milliseconds timeoutInMillis) = 0;
- virtual ~SubscribeHandler() { }
+ virtual std::shared_ptr<ConfigSubscription> subscribe(const ConfigKey & key, milliseconds timeoutInMillis) = 0;
+ virtual ~SubscribeHandler() = default;
};
}
diff --git a/config/src/vespa/config/common/types.h b/config/src/vespa/config/common/types.h
new file mode 100644
index 00000000000..b59685ffaa0
--- /dev/null
+++ b/config/src/vespa/config/common/types.h
@@ -0,0 +1,21 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include <vespa/vespalib/stllike/string.h>
+#include <vector>
+#include <map>
+
+namespace config {
+
+using StringVector = std::vector<vespalib::string>;
+using BoolVector = std::vector<bool>;
+using DoubleVector = std::vector<double>;
+using LongVector = std::vector<int64_t>;
+using IntVector = std::vector<int32_t>;
+using StringMap = std::map<vespalib::string, vespalib::string>;
+using BoolMap = std::map<vespalib::string, bool>;
+using DoubleMap = std::map<vespalib::string, double>;
+using LongMap = std::map<vespalib::string, int64_t>;
+using IntMap = std::map<vespalib::string, int32_t>;
+
+}
diff --git a/config/src/vespa/config/config.h b/config/src/vespa/config/config.h
deleted file mode 100644
index 6c383f4fef3..00000000000
--- a/config/src/vespa/config/config.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#pragma once
-
-#include <vespa/config/subscription/configsubscriber.h>
-#include <vespa/config/subscription/confighandle.h>
-#include <vespa/config/subscription/sourcespec.h>
-#include <vespa/config/subscription/configuri.h>
-#include <vespa/config/helper/configgetter.h>
-#include <vespa/config/helper/configfetcher.h>
-#include <vespa/config/common/misc.h>
-#include <vespa/config/retriever/configretriever.h>
-
-/*! \mainpage Cloud Config API for C++
- *
- * /section Introduction
- *
- * This document is provided as an API reference to use when developing with the
- * C++ config API.
- */
-
-/**
- * @section DESCRIPTION
- *
- * This file contains all necessary includes as well as functions used to
- * subscribe to and retrieve config.
- */
-
diff --git a/config/src/vespa/config/configgen/configinstance.h b/config/src/vespa/config/configgen/configinstance.h
index f25c0536ac6..21acf15859b 100644
--- a/config/src/vespa/config/configgen/configinstance.h
+++ b/config/src/vespa/config/configgen/configinstance.h
@@ -22,7 +22,7 @@ public:
virtual void serialize(ConfigDataBuffer & buffer) const = 0;
- virtual ~ConfigInstance() { }
+ virtual ~ConfigInstance() = default;
};
} // namespace config
diff --git a/config/src/vespa/config/file/filesource.cpp b/config/src/vespa/config/file/filesource.cpp
index 83a7e10716f..1585bd1bd53 100644
--- a/config/src/vespa/config/file/filesource.cpp
+++ b/config/src/vespa/config/file/filesource.cpp
@@ -3,34 +3,34 @@
#include "filesource.h"
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/config/common/misc.h>
-#include <vespa/vespalib/io/fileutil.h>
+#include <vespa/config/common/iconfigholder.h>
#include <vespa/vespalib/stllike/asciistream.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
using vespalib::asciistream;
namespace config {
-FileSource::FileSource(const IConfigHolder::SP & holder, const vespalib::string & fileName)
- : _holder(holder),
+FileSource::FileSource(std::shared_ptr<IConfigHolder> holder, const vespalib::string & fileName)
+ : _holder(std::move(holder)),
_fileName(fileName),
_lastLoaded(-1),
_generation(1)
{ }
+FileSource::~FileSource() = default;
+
void
FileSource::getConfig()
{
- std::vector<vespalib::string> lines(readConfigFile(_fileName));
+ StringVector lines(readConfigFile(_fileName));
int64_t last = getLast(_fileName);
if (last > _lastLoaded) {
- _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(lines, calculateContentXxhash64(lines)), true, _generation)));
+ _holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(lines), true, _generation));
_lastLoaded = last;
} else {
- _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(lines, calculateContentXxhash64(lines)), false, _generation)));
+ _holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(lines), false, _generation));
}
}
@@ -49,7 +49,7 @@ FileSource::getLast(const vespalib::string & fileName)
return filestat.st_mtime;
}
-std::vector<vespalib::string>
+StringVector
FileSource::readConfigFile(const vespalib::string & fileName)
{
asciistream is(asciistream::createFromFile(fileName));
diff --git a/config/src/vespa/config/file/filesource.h b/config/src/vespa/config/file/filesource.h
index 5ed673a445c..f355cd2159b 100644
--- a/config/src/vespa/config/file/filesource.h
+++ b/config/src/vespa/config/file/filesource.h
@@ -2,29 +2,30 @@
#pragma once
#include <vespa/config/common/source.h>
-#include <vespa/config/common/iconfigholder.h>
-#include <vespa/vespalib/stllike/string.h>
-#include <vespa/vespalib/util/noncopyable.hpp>
+#include <vespa/config/common/types.h>
namespace config {
class FileSpec;
class DirSpec;
+class IConfigHolder;
-class FileSource : public Source,
- public vespalib::noncopyable
+class FileSource : public Source
{
private:
- IConfigHolder::SP _holder;
+ std::shared_ptr<IConfigHolder> _holder;
const vespalib::string _fileName;
int64_t _lastLoaded;
int64_t _generation;
- std::vector<vespalib::string> readConfigFile(const vespalib::string & fileName);
+ StringVector readConfigFile(const vespalib::string & fileName);
int64_t getLast(const vespalib::string & fileName);
public:
- FileSource(const IConfigHolder::SP & holder, const vespalib::string & fileName);
+ FileSource(std::shared_ptr<IConfigHolder> holder, const vespalib::string & fileName);
+ FileSource(const FileSource &) = delete;
+ FileSource & operator = (const FileSource &) = delete;
+ ~FileSource() override;
void getConfig() override;
void close() override;
void reload(int64_t generation) override;
diff --git a/config/src/vespa/config/file/filesourcefactory.cpp b/config/src/vespa/config/file/filesourcefactory.cpp
index 8d8979dd553..09f1d23ed17 100644
--- a/config/src/vespa/config/file/filesourcefactory.cpp
+++ b/config/src/vespa/config/file/filesourcefactory.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "filesourcefactory.h"
#include "filesource.h"
-#include <vespa/config/common/exceptions.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -23,8 +22,8 @@ DirSourceFactory::DirSourceFactory(const DirSpec & dirSpec)
}
}
-Source::UP
-DirSourceFactory::createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const
+std::unique_ptr<Source>
+DirSourceFactory::createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const
{
vespalib::string fileId(key.getDefName());
if (!key.getConfigId().empty()) {
@@ -45,7 +44,7 @@ DirSourceFactory::createSource(const IConfigHolder::SP & holder, const ConfigKey
vespalib::string fName = _dirName;
if (!fName.empty()) fName += "/";
fName += fileId;
- return Source::UP(new FileSource(holder, fName));
+ return std::make_unique<FileSource>(std::move(holder), fName);
}
FileSourceFactory::FileSourceFactory(const FileSpec & fileSpec)
@@ -53,11 +52,11 @@ FileSourceFactory::FileSourceFactory(const FileSpec & fileSpec)
{
}
-Source::UP
-FileSourceFactory::createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const
+std::unique_ptr<Source>
+FileSourceFactory::createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const
{
(void) key;
- return Source::UP(new FileSource(holder, _fileName));
+ return std::make_unique<FileSource>(std::move(holder), _fileName);
}
} // namespace config
diff --git a/config/src/vespa/config/file/filesourcefactory.h b/config/src/vespa/config/file/filesourcefactory.h
index c5ba5769a53..d751d499d95 100644
--- a/config/src/vespa/config/file/filesourcefactory.h
+++ b/config/src/vespa/config/file/filesourcefactory.h
@@ -2,7 +2,7 @@
#pragma once
#include <vespa/config/common/sourcefactory.h>
-#include <vespa/vespalib/stllike/string.h>
+#include <vespa/config/common/types.h>
namespace config {
@@ -20,7 +20,7 @@ public:
/**
* Create source handling config described by key.
*/
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override;
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override;
private:
vespalib::string _fileName;
};
@@ -36,10 +36,10 @@ public:
/**
* Create source handling config described by key.
*/
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override;
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override;
private:
vespalib::string _dirName;
- std::vector<vespalib::string> _fileNames;
+ StringVector _fileNames;
};
diff --git a/config/src/vespa/config/frt/frtconfigagent.cpp b/config/src/vespa/config/frt/frtconfigagent.cpp
index 827ef75251b..b6014a1d668 100644
--- a/config/src/vespa/config/frt/frtconfigagent.cpp
+++ b/config/src/vespa/config/frt/frtconfigagent.cpp
@@ -2,14 +2,15 @@
#include "frtconfigagent.h"
#include "frtconfigrequestv3.h"
#include <vespa/config/common/trace.h>
+#include <vespa/config/common/iconfigholder.h>
#include <vespa/log/log.h>
LOG_SETUP(".config.frt.frtconfigagent");
namespace config {
-FRTConfigAgent::FRTConfigAgent(const IConfigHolder::SP & holder, const TimingValues & timingValues)
- : _holder(holder),
+FRTConfigAgent::FRTConfigAgent(std::shared_ptr<IConfigHolder> holder, const TimingValues & timingValues)
+ : _holder(std::move(holder)),
_timingValues(timingValues),
_configState(),
_latest(),
diff --git a/config/src/vespa/config/frt/frtconfigagent.h b/config/src/vespa/config/frt/frtconfigagent.h
index b4303537d38..c69f4204168 100644
--- a/config/src/vespa/config/frt/frtconfigagent.h
+++ b/config/src/vespa/config/frt/frtconfigagent.h
@@ -3,12 +3,14 @@
#include <vespa/config/common/configstate.h>
#include <vespa/config/common/timingvalues.h>
-#include <vespa/config/common/iconfigholder.h>
#include <vespa/config/common/configresponse.h>
#include <vespa/config/common/configrequest.h>
+#include <vespa/config/common/configvalue.h>
namespace config {
+class IConfigHolder;
+
class ConfigAgent
{
public:
@@ -19,14 +21,14 @@ public:
virtual uint64_t getWaitTime() const = 0;
virtual const ConfigState & getConfigState() const = 0;
- virtual ~ConfigAgent() { }
+ virtual ~ConfigAgent() = default;
};
class FRTConfigAgent : public ConfigAgent
{
public:
- FRTConfigAgent(const IConfigHolder::SP & holder, const TimingValues & timingValues);
- ~FRTConfigAgent();
+ FRTConfigAgent(std::shared_ptr<IConfigHolder> holder, const TimingValues & timingValues);
+ ~FRTConfigAgent() override;
void handleResponse(const ConfigRequest & request, ConfigResponse::UP response) override;
uint64_t getTimeout() const override;
uint64_t getWaitTime() const override;
@@ -37,14 +39,14 @@ private:
void handleErrorResponse(const ConfigRequest & request, ConfigResponse::UP response);
void setWaitTime(uint64_t delay, int multiplier);
- IConfigHolder::SP _holder;
+ std::shared_ptr<IConfigHolder> _holder;
const TimingValues _timingValues;
- ConfigState _configState;
- ConfigValue _latest;
- uint64_t _waitTime;
- uint64_t _numConfigured;
- unsigned int _failedRequests;
- uint64_t _nextTimeout;
+ ConfigState _configState;
+ ConfigValue _latest;
+ uint64_t _waitTime;
+ uint64_t _numConfigured;
+ unsigned int _failedRequests;
+ uint64_t _nextTimeout;
};
}
diff --git a/config/src/vespa/config/frt/frtsourcefactory.cpp b/config/src/vespa/config/frt/frtsourcefactory.cpp
index c8331cfa815..259098edb90 100644
--- a/config/src/vespa/config/frt/frtsourcefactory.cpp
+++ b/config/src/vespa/config/frt/frtsourcefactory.cpp
@@ -11,10 +11,11 @@ FRTSourceFactory::FRTSourceFactory(ConnectionFactory::UP connectionFactory, cons
{
}
-Source::UP
-FRTSourceFactory::createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const
+std::unique_ptr<Source>
+FRTSourceFactory::createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const
{
- return std::make_unique<FRTSource>(_connectionFactory, _requestFactory, std::make_unique<FRTConfigAgent>(holder, _timingValues), key);
+ return std::make_unique<FRTSource>(_connectionFactory, _requestFactory,
+ std::make_unique<FRTConfigAgent>(std::move(holder), _timingValues), key);
}
} // namespace config
diff --git a/config/src/vespa/config/frt/frtsourcefactory.h b/config/src/vespa/config/frt/frtsourcefactory.h
index 23595c0d70f..4331c6411dc 100644
--- a/config/src/vespa/config/frt/frtsourcefactory.h
+++ b/config/src/vespa/config/frt/frtsourcefactory.h
@@ -19,7 +19,7 @@ public:
/**
* Create source handling config described by key.
*/
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override;
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override;
private:
ConnectionFactory::SP _connectionFactory;
diff --git a/config/src/vespa/config/helper/configfetcher.cpp b/config/src/vespa/config/helper/configfetcher.cpp
index d85308bbcbb..b2cf6e1955d 100644
--- a/config/src/vespa/config/helper/configfetcher.cpp
+++ b/config/src/vespa/config/helper/configfetcher.cpp
@@ -1,9 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "configfetcher.h"
+#include "configpoller.h"
#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/configcontext.h>
#include <vespa/vespalib/util/thread.h>
+
#include <vespa/log/log.h>
LOG_SETUP(".config.helper.configfetcher");
@@ -11,19 +13,16 @@ namespace config {
VESPA_THREAD_STACK_TAG(config_fetcher_thread);
-ConfigFetcher::ConfigFetcher(const IConfigContext::SP & context)
- : _poller(context),
- _thread(std::make_unique<vespalib::Thread>(_poller, config_fetcher_thread)),
+ConfigFetcher::ConfigFetcher(std::shared_ptr<IConfigContext> context)
+ : _poller(std::make_unique<ConfigPoller>(std::move(context))),
+ _thread(std::make_unique<vespalib::Thread>(*_poller, config_fetcher_thread)),
_closed(false),
_started(false)
{
}
ConfigFetcher::ConfigFetcher(const SourceSpec & spec)
- : _poller(std::make_shared<ConfigContext>(spec)),
- _thread(std::make_unique<vespalib::Thread>(_poller, config_fetcher_thread)),
- _closed(false),
- _started(false)
+ : ConfigFetcher(std::make_shared<ConfigContext>(spec))
{
}
@@ -32,8 +31,8 @@ ConfigFetcher::start()
{
if (!_closed) {
LOG(debug, "Polling for config");
- _poller.poll();
- if (_poller.getGeneration() == -1) {
+ _poller->poll();
+ if (_poller->getGeneration() == -1) {
throw ConfigTimeoutException("ConfigFetcher::start timed out getting initial config");
}
LOG(debug, "Starting fetcher thread...");
@@ -48,11 +47,16 @@ ConfigFetcher::~ConfigFetcher()
close();
}
+int64_t
+ConfigFetcher::getGeneration() const {
+ return _poller->getGeneration();
+}
+
void
ConfigFetcher::close()
{
if (!_closed) {
- _poller.close();
+ _poller->close();
if (_started)
_thread->join();
}
diff --git a/config/src/vespa/config/helper/configfetcher.h b/config/src/vespa/config/helper/configfetcher.h
index e8cd6a66ebc..8891f0989e5 100644
--- a/config/src/vespa/config/helper/configfetcher.h
+++ b/config/src/vespa/config/helper/configfetcher.h
@@ -1,14 +1,18 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include "configpoller.h"
#include <vespa/config/common/timingvalues.h>
+#include <vespa/config/helper/ifetchercallback.h>
+#include <vespa/config/subscription/sourcespec.h>
#include <atomic>
namespace vespalib { class Thread; }
namespace config {
+class ConfigPoller;
+class IConfigContext;
+
/**
* A config fetcher subscribes to a config and notifies a callback when done
*/
@@ -16,7 +20,7 @@ class ConfigFetcher
{
public:
using milliseconds = std::chrono::milliseconds;
- ConfigFetcher(const IConfigContext::SP & context);
+ ConfigFetcher(std::shared_ptr<IConfigContext> context);
ConfigFetcher(const SourceSpec & spec = ServerSpec());
~ConfigFetcher();
@@ -25,16 +29,12 @@ public:
void start();
void close();
- int64_t getGeneration() const { return _poller.getGeneration(); }
+ int64_t getGeneration() const;
private:
- ConfigPoller _poller;
+ std::unique_ptr<ConfigPoller> _poller;
std::unique_ptr<vespalib::Thread> _thread;
std::atomic<bool> _closed;
std::atomic<bool> _started;
};
} // namespace config
-
-
-#include "configfetcher.hpp"
-
diff --git a/config/src/vespa/config/helper/configfetcher.hpp b/config/src/vespa/config/helper/configfetcher.hpp
index 9123c54797e..585a798b2ba 100644
--- a/config/src/vespa/config/helper/configfetcher.hpp
+++ b/config/src/vespa/config/helper/configfetcher.hpp
@@ -1,12 +1,17 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include "configfetcher.h"
+#include "configpoller.hpp"
+
namespace config {
template <typename ConfigType>
void
ConfigFetcher::subscribe(const std::string & configId, IFetcherCallback<ConfigType> * callback, milliseconds subscribeTimeout)
{
- _poller.subscribe<ConfigType>(configId, callback, subscribeTimeout);
+ _poller->subscribe<ConfigType>(configId, callback, subscribeTimeout);
}
} // namespace config
diff --git a/config/src/vespa/config/helper/configgetter.h b/config/src/vespa/config/helper/configgetter.h
index fab8ee98da4..dfb61da3c6f 100644
--- a/config/src/vespa/config/helper/configgetter.h
+++ b/config/src/vespa/config/helper/configgetter.h
@@ -19,9 +19,9 @@ class ConfigGetter
public:
using milliseconds = std::chrono::milliseconds;
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 std::shared_ptr<IConfigContext> & context, milliseconds subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT);
+ static std::unique_ptr<ConfigType> getConfig(int64_t &generation, const std::string & configId, std::shared_ptr<IConfigContext> context, milliseconds 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 std::shared_ptr<IConfigContext> & context, milliseconds subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT);
+ static std::unique_ptr<ConfigType> getConfig(const std::string & configId, std::shared_ptr<IConfigContext> context, milliseconds subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT);
};
} // namespace config
diff --git a/config/src/vespa/config/helper/configgetter.hpp b/config/src/vespa/config/helper/configgetter.hpp
index 0a757ada83e..b01781ee313 100644
--- a/config/src/vespa/config/helper/configgetter.hpp
+++ b/config/src/vespa/config/helper/configgetter.hpp
@@ -1,7 +1,7 @@
// Copyright Yahoo. 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>
+#include <vespa/config/subscription/configsubscriber.hpp>
namespace config {
@@ -18,9 +18,9 @@ ConfigGetter<ConfigType>::getConfig(int64_t &generation, const std::string & con
template <typename ConfigType>
std::unique_ptr<ConfigType>
-ConfigGetter<ConfigType>::getConfig(int64_t &generation, const std::string & configId, const IConfigContext::SP & context, milliseconds subscribeTimeout)
+ConfigGetter<ConfigType>::getConfig(int64_t &generation, const std::string & configId, std::shared_ptr<IConfigContext> context, milliseconds subscribeTimeout)
{
- ConfigSubscriber s(context);
+ ConfigSubscriber s(std::move(context));
std::unique_ptr< ConfigHandle<ConfigType> > h = s.subscribe<ConfigType>(configId, subscribeTimeout);
s.nextConfigNow();
generation = s.getGeneration();
@@ -37,10 +37,10 @@ ConfigGetter<ConfigType>::getConfig(const std::string & configId, const SourceSp
template <typename ConfigType>
std::unique_ptr<ConfigType>
-ConfigGetter<ConfigType>::getConfig(const std::string & configId, const IConfigContext::SP & context, milliseconds subscribeTimeout)
+ConfigGetter<ConfigType>::getConfig(const std::string & configId, std::shared_ptr<IConfigContext> context, milliseconds subscribeTimeout)
{
int64_t ignoreGeneration;
- return getConfig(ignoreGeneration, configId, context, subscribeTimeout);
+ return getConfig(ignoreGeneration, configId, std::move(context), subscribeTimeout);
}
} // namespace config
diff --git a/config/src/vespa/config/helper/configpoller.cpp b/config/src/vespa/config/helper/configpoller.cpp
index 879c21bea8c..e9ed0af6b5e 100644
--- a/config/src/vespa/config/helper/configpoller.cpp
+++ b/config/src/vespa/config/helper/configpoller.cpp
@@ -2,15 +2,16 @@
#include "configpoller.h"
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/subscription/configsubscriber.h>
#include <vespa/log/log.h>
LOG_SETUP(".config.helper.configpoller");
namespace config {
-ConfigPoller::ConfigPoller(const IConfigContext::SP & context)
+ConfigPoller::ConfigPoller(std::shared_ptr<IConfigContext> context)
: _generation(-1),
- _subscriber(context),
+ _subscriber(std::make_unique<ConfigSubscriber>(std::move(context))),
_handleList(),
_callbackList()
{
@@ -22,7 +23,7 @@ void
ConfigPoller::run()
{
try {
- while (!_subscriber.isClosed()) {
+ while (!_subscriber->isClosed()) {
poll();
}
} catch (config::InvalidConfigException & e) {
@@ -35,11 +36,11 @@ void
ConfigPoller::poll()
{
LOG(debug, "Checking for new config");
- if (_subscriber.nextGeneration()) {
- if (_subscriber.isClosed())
+ if (_subscriber->nextGeneration()) {
+ if (_subscriber->isClosed())
return;
LOG(debug, "Got new config, reconfiguring");
- _generation = _subscriber.getGeneration();
+ _generation = _subscriber->getGeneration();
for (size_t i = 0; i < _handleList.size(); i++) {
ICallback * callback(_callbackList[i]);
if (_handleList[i]->isChanged())
@@ -53,7 +54,7 @@ ConfigPoller::poll()
void
ConfigPoller::close()
{
- _subscriber.close();
+ _subscriber->close();
}
}
diff --git a/config/src/vespa/config/helper/configpoller.h b/config/src/vespa/config/helper/configpoller.h
index 40fa1784f59..addfd731b69 100644
--- a/config/src/vespa/config/helper/configpoller.h
+++ b/config/src/vespa/config/helper/configpoller.h
@@ -3,12 +3,14 @@
#include "ifetchercallback.h"
#include "ihandle.h"
-#include <vespa/config/subscription/configsubscriber.h>
#include <vespa/config/common/timingvalues.h>
#include <vespa/vespalib/util/runnable.h>
namespace config {
+class IConfigContext;
+class ConfigSubscriber;
+
/**
* A config poller runs a polling sequence on a set of configs that it has
* subscribed to.
@@ -16,8 +18,8 @@ namespace config {
class ConfigPoller : public vespalib::Runnable {
public:
using milliseconds = std::chrono::milliseconds;
- ConfigPoller(const IConfigContext::SP & context);
- ~ConfigPoller();
+ ConfigPoller(std::shared_ptr<IConfigContext> context);
+ ~ConfigPoller() override;
void run() override;
template <typename ConfigType>
void subscribe(const std::string & configId, IFetcherCallback<ConfigType> * callback, milliseconds subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT);
@@ -26,11 +28,9 @@ public:
int64_t getGeneration() const { return _generation; }
private:
int64_t _generation;
- ConfigSubscriber _subscriber;
- std::vector<IHandle::UP> _handleList;
- std::vector<ICallback *> _callbackList;
+ std::unique_ptr<ConfigSubscriber> _subscriber;
+ std::vector<IHandle::UP> _handleList;
+ std::vector<ICallback *> _callbackList;
};
} // namespace config
-
-#include "configpoller.hpp"
diff --git a/config/src/vespa/config/helper/configpoller.hpp b/config/src/vespa/config/helper/configpoller.hpp
index 4088a311609..540ea160e7e 100644
--- a/config/src/vespa/config/helper/configpoller.hpp
+++ b/config/src/vespa/config/helper/configpoller.hpp
@@ -1,12 +1,34 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include "configpoller.h"
+#include <vespa/config/subscription/configsubscriber.hpp>
+
namespace config {
template <typename ConfigType>
+class GenericHandle : public IHandle
+{
+public:
+ GenericHandle(std::unique_ptr<ConfigHandle<ConfigType> > handle)
+ : _handle(std::move(handle))
+ {
+ }
+
+ std::unique_ptr<const ConfigInstance> getConfig() override {
+ return std::unique_ptr<const ConfigInstance>(_handle->getConfig().release());
+ }
+ bool isChanged() override { return _handle->isChanged(); }
+private:
+ std::unique_ptr<ConfigHandle <ConfigType> > _handle;
+};
+
+template <typename ConfigType>
void
ConfigPoller::subscribe(const std::string & configId, IFetcherCallback<ConfigType> * callback, milliseconds subscribeTimeout)
{
- std::unique_ptr<ConfigHandle<ConfigType> > handle(_subscriber.subscribe<ConfigType>(configId, subscribeTimeout));
+ std::unique_ptr<ConfigHandle<ConfigType> > handle(_subscriber->subscribe<ConfigType>(configId, subscribeTimeout));
_handleList.emplace_back(std::make_unique<GenericHandle<ConfigType>>(std::move(handle)));
_callbackList.push_back(callback);
}
diff --git a/config/src/vespa/config/helper/ihandle.h b/config/src/vespa/config/helper/ihandle.h
index 4d8de8243d0..271b9f9051d 100644
--- a/config/src/vespa/config/helper/ihandle.h
+++ b/config/src/vespa/config/helper/ihandle.h
@@ -1,34 +1,19 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/config/subscription/confighandle.h>
+#include <memory>
namespace config {
+class ConfigInstance;
+
class IHandle
{
public:
typedef std::unique_ptr<IHandle> UP;
virtual std::unique_ptr<const ConfigInstance> getConfig() = 0;
virtual bool isChanged() = 0;
- virtual ~IHandle() { }
-};
-
-template <typename ConfigType>
-class GenericHandle : public IHandle
-{
-public:
- GenericHandle(std::unique_ptr<ConfigHandle<ConfigType> > handle)
- : _handle(std::move(handle))
- {
- }
-
- std::unique_ptr<const ConfigInstance> getConfig() override {
- return std::unique_ptr<const ConfigInstance>(_handle->getConfig().release());
- }
- bool isChanged() override { return _handle->isChanged(); }
-private:
- std::unique_ptr<ConfigHandle <ConfigType> > _handle;
+ virtual ~IHandle() = default;
};
}
diff --git a/config/src/vespa/config/helper/legacysubscriber.h b/config/src/vespa/config/helper/legacysubscriber.h
index 5e370a3a6c2..0389c346096 100644
--- a/config/src/vespa/config/helper/legacysubscriber.h
+++ b/config/src/vespa/config/helper/legacysubscriber.h
@@ -3,7 +3,6 @@
#include "legacy.h"
#include "configfetcher.h"
-#include <vespa/config/subscription/sourcespec.h>
namespace config {
@@ -27,6 +26,3 @@ private:
};
} // namespace config
-
-#include "legacysubscriber.hpp"
-
diff --git a/config/src/vespa/config/helper/legacysubscriber.hpp b/config/src/vespa/config/helper/legacysubscriber.hpp
index 9610f8f78db..c11f97e81b7 100644
--- a/config/src/vespa/config/helper/legacysubscriber.hpp
+++ b/config/src/vespa/config/helper/legacysubscriber.hpp
@@ -1,5 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include "legacysubscriber.h"
+#include "configfetcher.hpp"
#include <vespa/config/common/configcontext.h>
namespace config {
diff --git a/config/src/vespa/config/print/asciiconfigreader.h b/config/src/vespa/config/print/asciiconfigreader.h
index 11a9da2da4e..5be777386b4 100644
--- a/config/src/vespa/config/print/asciiconfigreader.h
+++ b/config/src/vespa/config/print/asciiconfigreader.h
@@ -2,11 +2,11 @@
#pragma once
#include "configreader.h"
-#include "configformatter.h"
-#include <vespa/vespalib/stllike/asciistream.h>
namespace config {
+class ConfigFormatter;
+
/**
* Read a config from istream
*/
@@ -22,6 +22,3 @@ private:
};
} // namespace config
-
-#include "asciiconfigreader.hpp"
-
diff --git a/config/src/vespa/config/print/asciiconfigreader.hpp b/config/src/vespa/config/print/asciiconfigreader.hpp
index 3a76f7536b9..6f9919e6f71 100644
--- a/config/src/vespa/config/print/asciiconfigreader.hpp
+++ b/config/src/vespa/config/print/asciiconfigreader.hpp
@@ -1,5 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include "asciiconfigreader.h"
+#include <vespa/config/common/types.h>
+#include <vespa/config/common/configvalue.h>
+
namespace config {
template <typename ConfigType>
@@ -15,19 +21,19 @@ AsciiConfigReader<ConfigType>::read(const ConfigFormatter & formatter)
ConfigDataBuffer buffer;
buffer.setEncodedString(_is.str());
formatter.decode(buffer);
- return std::unique_ptr<ConfigType>(new ConfigType(buffer));
+ return std::make_unique<ConfigType>(buffer);
}
template <typename ConfigType>
std::unique_ptr<ConfigType>
AsciiConfigReader<ConfigType>::read()
{
- std::vector<vespalib::string> lines;
+ StringVector lines;
vespalib::string line;
while (getline(_is, line)) {
lines.push_back(line);
}
- return std::unique_ptr<ConfigType>(new ConfigType(ConfigValue(lines, calculateContentXxhash64(lines))));
+ return std::make_unique<ConfigType>(ConfigValue(std::move(lines)));
}
} // namespace config
diff --git a/config/src/vespa/config/print/fileconfigreader.h b/config/src/vespa/config/print/fileconfigreader.h
index 1d47d9c04a7..ca794f6c8a6 100644
--- a/config/src/vespa/config/print/fileconfigreader.h
+++ b/config/src/vespa/config/print/fileconfigreader.h
@@ -24,6 +24,3 @@ private:
};
} // namespace config
-
-#include "fileconfigreader.hpp"
-
diff --git a/config/src/vespa/config/print/fileconfigreader.hpp b/config/src/vespa/config/print/fileconfigreader.hpp
index dec390ef358..b4d0dac86f5 100644
--- a/config/src/vespa/config/print/fileconfigreader.hpp
+++ b/config/src/vespa/config/print/fileconfigreader.hpp
@@ -29,14 +29,14 @@ FileConfigReader<ConfigType>::read(const ConfigFormatter & formatter)
buf << file.rdbuf();
buffer.setEncodedString(buf.str());
formatter.decode(buffer);
- return std::unique_ptr<ConfigType>(new ConfigType(buffer));
+ return std::make_unique<ConfigType>(buffer);
}
template <typename ConfigType>
std::unique_ptr<ConfigType>
FileConfigReader<ConfigType>::read()
{
- std::vector<vespalib::string> lines;
+ StringVector lines;
std::ifstream f(_fileName.c_str());
if (f.fail())
throw vespalib::IllegalArgumentException(std::string("Unable to open file ") + _fileName);
@@ -44,7 +44,7 @@ FileConfigReader<ConfigType>::read()
for (std::getline(f, line); f; std::getline(f, line)) {
lines.push_back(line);
}
- return std::unique_ptr<ConfigType>(new ConfigType(ConfigValue(lines, calculateContentXxhash64(lines))));
+ return std::make_unique<ConfigType>(ConfigValue(std::move(lines)));
}
} // namespace config
diff --git a/config/src/vespa/config/print/istreamconfigreader.h b/config/src/vespa/config/print/istreamconfigreader.h
index 511fbe2f538..d941d1582ac 100644
--- a/config/src/vespa/config/print/istreamconfigreader.h
+++ b/config/src/vespa/config/print/istreamconfigreader.h
@@ -21,6 +21,3 @@ private:
};
} // namespace config
-
-#include "istreamconfigreader.hpp"
-
diff --git a/config/src/vespa/config/print/istreamconfigreader.hpp b/config/src/vespa/config/print/istreamconfigreader.hpp
index 11b41ddbe2f..1cc0d975919 100644
--- a/config/src/vespa/config/print/istreamconfigreader.hpp
+++ b/config/src/vespa/config/print/istreamconfigreader.hpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <istream>
+#include "istreamconfigreader.h"
+#include <sstream>
namespace config {
@@ -19,19 +20,19 @@ IstreamConfigReader<ConfigType>::read(const ConfigFormatter & formatter)
buf << _is.rdbuf();
buffer.setEncodedString(buf.str());
formatter.decode(buffer);
- return std::unique_ptr<ConfigType>(new ConfigType(buffer));
+ return std::make_unique<ConfigType>(buffer);
}
template <typename ConfigType>
std::unique_ptr<ConfigType>
IstreamConfigReader<ConfigType>::read()
{
- std::vector<vespalib::string> lines;
+ StringVector lines;
std::string line;
while (getline(_is, line)) {
lines.push_back(line);
}
- return std::unique_ptr<ConfigType>(new ConfigType(ConfigValue(lines, calculateContentXxhash64(lines))));
+ return std::make_unique<ConfigType>(ConfigValue(std::move(lines)));
}
} // namespace config
diff --git a/config/src/vespa/config/raw/rawsource.cpp b/config/src/vespa/config/raw/rawsource.cpp
index af3d7f6f7f5..f37f30bb2f7 100644
--- a/config/src/vespa/config/raw/rawsource.cpp
+++ b/config/src/vespa/config/raw/rawsource.cpp
@@ -1,13 +1,16 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "rawsource.h"
#include <vespa/config/common/misc.h>
+#include <vespa/config/common/iconfigholder.h>
+#include <vespa/config/common/configvalue.h>
#include <vespa/vespalib/stllike/asciistream.h>
namespace config {
+RawSource::~RawSource() = default;
-RawSource::RawSource(const IConfigHolder::SP & holder, const vespalib::string & payload)
- : _holder(holder),
+RawSource::RawSource(std::shared_ptr<IConfigHolder> holder, const vespalib::string & payload)
+ : _holder(std::move(holder)),
_payload(payload)
{
}
@@ -15,9 +18,7 @@ RawSource::RawSource(const IConfigHolder::SP & holder, const vespalib::string &
void
RawSource::getConfig()
{
- auto lines(readConfig());
- ConfigValue value(lines, calculateContentXxhash64(lines));
- _holder->handle(ConfigUpdate::UP(new ConfigUpdate(value, true, 1)));
+ _holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(readConfig()), true, 1));
}
void
@@ -31,7 +32,7 @@ RawSource::close()
{
}
-std::vector<vespalib::string>
+StringVector
RawSource::readConfig()
{
vespalib::asciistream is(_payload);
diff --git a/config/src/vespa/config/raw/rawsource.h b/config/src/vespa/config/raw/rawsource.h
index 2b15e459de4..a6e1e806cbf 100644
--- a/config/src/vespa/config/raw/rawsource.h
+++ b/config/src/vespa/config/raw/rawsource.h
@@ -2,24 +2,26 @@
#pragma once
#include <vespa/config/common/source.h>
-#include <vespa/config/common/iconfigholder.h>
-#include <vespa/vespalib/stllike/string.h>
-
+#include <vespa/config/common/types.h>
namespace config {
+class IConfigHolder;
+
/**
* Class for sending and receiving config request from a raw string.
*/
class RawSource : public Source {
public:
- RawSource(const IConfigHolder::SP & holder, const vespalib::string & payload);
-
+ RawSource(std::shared_ptr<IConfigHolder> holder, const vespalib::string & payload);
+ RawSource(const RawSource &) = delete;
+ RawSource & operator = (const RawSource &) = delete;
+ ~RawSource() override;
void getConfig() override;
void reload(int64_t generation) override;
void close() override;
private:
- IConfigHolder::SP _holder;
- std::vector<vespalib::string> readConfig();
+ std::shared_ptr<IConfigHolder> _holder;
+ StringVector readConfig();
const vespalib::string _payload;
};
diff --git a/config/src/vespa/config/raw/rawsourcefactory.cpp b/config/src/vespa/config/raw/rawsourcefactory.cpp
index d6f3dfd6be9..396ee8b7c27 100644
--- a/config/src/vespa/config/raw/rawsourcefactory.cpp
+++ b/config/src/vespa/config/raw/rawsourcefactory.cpp
@@ -6,11 +6,11 @@
namespace config {
-Source::UP
-RawSourceFactory::createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const
+std::unique_ptr<Source>
+RawSourceFactory::createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const
{
(void) key;
- return Source::UP(new RawSource(holder, _payload));
+ return std::make_unique<RawSource>(std::move(holder), _payload);
}
}
diff --git a/config/src/vespa/config/raw/rawsourcefactory.h b/config/src/vespa/config/raw/rawsourcefactory.h
index 191547b5d8c..3b8d8986625 100644
--- a/config/src/vespa/config/raw/rawsourcefactory.h
+++ b/config/src/vespa/config/raw/rawsourcefactory.h
@@ -14,7 +14,7 @@ public:
: _payload(payload)
{ }
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override;
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override;
private:
const vespalib::string _payload;
};
diff --git a/config/src/vespa/config/retriever/configretriever.cpp b/config/src/vespa/config/retriever/configretriever.cpp
index 20c81742821..125d8ef3012 100644
--- a/config/src/vespa/config/retriever/configretriever.cpp
+++ b/config/src/vespa/config/retriever/configretriever.cpp
@@ -13,7 +13,7 @@ namespace config {
const milliseconds ConfigRetriever::DEFAULT_NEXTGENERATION_TIMEOUT(60000);
ConfigRetriever::ConfigRetriever(const ConfigKeySet & bootstrapSet,
- const IConfigContext::SP & context,
+ std::shared_ptr<IConfigContext> context,
milliseconds subscribeTimeout)
: _bootstrapSubscriber(bootstrapSet, context, subscribeTimeout),
_configSubscriber(),
diff --git a/config/src/vespa/config/retriever/configretriever.h b/config/src/vespa/config/retriever/configretriever.h
index ad57f4887fc..8a47ad825cb 100644
--- a/config/src/vespa/config/retriever/configretriever.h
+++ b/config/src/vespa/config/retriever/configretriever.h
@@ -27,7 +27,7 @@ class ConfigRetriever
public:
using milliseconds = std::chrono::milliseconds;
ConfigRetriever(const ConfigKeySet & bootstrapSet,
- const IConfigContext::SP & context,
+ std::shared_ptr<IConfigContext> context,
milliseconds subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT);
~ConfigRetriever();
@@ -93,13 +93,13 @@ public:
static const milliseconds DEFAULT_SUBSCRIBE_TIMEOUT;
static const milliseconds DEFAULT_NEXTGENERATION_TIMEOUT;
private:
- FixedConfigSubscriber _bootstrapSubscriber;
- std::unique_ptr<GenericConfigSubscriber> _configSubscriber;
- std::mutex _lock;
- std::vector<ConfigSubscription::SP> _subscriptionList;
- ConfigKeySet _lastKeySet;
- IConfigContext::SP _context;
- std::unique_ptr<SourceSpec> _spec;
+ FixedConfigSubscriber _bootstrapSubscriber;
+ std::unique_ptr<GenericConfigSubscriber> _configSubscriber;
+ std::mutex _lock;
+ std::vector<std::shared_ptr<ConfigSubscription>> _subscriptionList;
+ ConfigKeySet _lastKeySet;
+ std::shared_ptr<IConfigContext> _context;
+ std::unique_ptr<SourceSpec> _spec;
bool _closed;
int64_t _generation;
milliseconds _subscribeTimeout;
diff --git a/config/src/vespa/config/retriever/configsnapshot.cpp b/config/src/vespa/config/retriever/configsnapshot.cpp
index e999538e713..293a90ebbba 100644
--- a/config/src/vespa/config/retriever/configsnapshot.cpp
+++ b/config/src/vespa/config/retriever/configsnapshot.cpp
@@ -5,6 +5,7 @@
#include <vespa/config/print/configdatabuffer.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/misc.h>
+#include <vespa/config/frt/protocol.h>
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/stllike/asciistream.h>
@@ -41,8 +42,9 @@ ConfigSnapshot::swap(ConfigSnapshot &rhs) {
}
ConfigSnapshot::ConfigSnapshot(const SubscriptionList &subscriptionList, int64_t generation)
- : _valueMap(),
- _generation(generation) {
+ : _valueMap(),
+ _generation(generation)
+{
for (SubscriptionList::const_iterator it(subscriptionList.begin()), mt(subscriptionList.end()); it != mt; it++) {
_valueMap[(*it)->getKey()] = Value((*it)->getLastGenerationChanged(), (*it)->getConfig());
}
@@ -66,10 +68,10 @@ ConfigSnapshot
ConfigSnapshot::subset(const ConfigKeySet & keySet) const
{
ValueMap subSet;
- for (ConfigKeySet::const_iterator it(keySet.begin()), mt(keySet.end()); it != mt; it++) {
- ValueMap::const_iterator found(_valueMap.find(*it));
+ for (const ConfigKey & key : keySet) {
+ ValueMap::const_iterator found(_valueMap.find(key));
if (found != _valueMap.end()) {
- subSet[*it] = found->second;
+ subSet[key] = found->second;
}
}
return ConfigSnapshot(subSet, _generation);
@@ -127,15 +129,13 @@ ConfigSnapshot::serializeV2(Cursor & root) const
void
ConfigSnapshot::serializeKeyV1(Cursor & cursor, const ConfigKey & key) const
{
- typedef std::vector<vespalib::string> SchemaVector;
cursor.setString("configId", Memory(key.getConfigId()));
cursor.setString("defName", Memory(key.getDefName()));
cursor.setString("defNamespace", Memory(key.getDefNamespace()));
cursor.setString("defMd5", Memory(key.getDefMd5()));
Cursor & defSchema(cursor.setArray("defSchema"));
- const SchemaVector & vec(key.getDefSchema());
- for (SchemaVector::const_iterator it(vec.begin()), mt(vec.end()); it != mt; it++) {
- defSchema.addString(vespalib::Memory(*it));
+ for (const vespalib::string & line : key.getDefSchema()) {
+ defSchema.addString(vespalib::Memory(line));
}
}
@@ -203,7 +203,7 @@ ConfigSnapshot::deserializeV2(Inspector & root)
ConfigKey
ConfigSnapshot::deserializeKeyV1(Inspector & inspector) const
{
- std::vector<vespalib::string> schema;
+ StringVector schema;
Inspector & s(inspector["defSchema"]);
for (size_t i = 0; i < s.children(); i++) {
schema.push_back(s[i].asString().make_string());
@@ -219,13 +219,13 @@ ConfigSnapshot::deserializeKeyV1(Inspector & inspector) const
std::pair<int64_t, ConfigValue>
ConfigSnapshot::deserializeValueV1(Inspector & inspector) const
{
- std::vector<vespalib::string> payload;
+ StringVector payload;
int64_t lastChanged = static_cast<int64_t>(inspector["lastChanged"].asDouble());
Inspector & s(inspector["lines"]);
for (size_t i = 0; i < s.children(); i++) {
payload.push_back(s[i].asString().make_string());
}
- return Value(lastChanged, ConfigValue(payload, calculateContentXxhash64(payload)));
+ return Value(lastChanged, ConfigValue(payload));
}
namespace {
diff --git a/config/src/vespa/config/retriever/configsnapshot.h b/config/src/vespa/config/retriever/configsnapshot.h
index b7d49ca2584..8393fd38ed3 100644
--- a/config/src/vespa/config/retriever/configsnapshot.h
+++ b/config/src/vespa/config/retriever/configsnapshot.h
@@ -3,8 +3,7 @@
#include "configkeyset.h"
#include <vespa/config/common/configvalue.h>
-#include <vespa/vespalib/stllike/string.h>
-#include <map>
+#include <vespa/config/common/misc.h>
namespace config {
@@ -18,7 +17,7 @@ class ConfigDataBuffer;
class ConfigSnapshot
{
public:
- typedef std::vector<std::shared_ptr<ConfigSubscription>> SubscriptionList;
+ using SubscriptionList = std::vector<std::shared_ptr<ConfigSubscription>>;
/**
* Construct an empty config snapshot.
@@ -95,8 +94,8 @@ public:
void serialize(ConfigDataBuffer & buffer) const;
void deserialize(const ConfigDataBuffer & buffer);
private:
- typedef std::pair<int64_t, ConfigValue> Value;
- typedef std::map<ConfigKey, Value> ValueMap;
+ using Value = std::pair<int64_t, ConfigValue>;
+ using ValueMap = std::map<ConfigKey, Value>;
const static int64_t SNAPSHOT_FORMAT_VERSION;
ConfigSnapshot(const ValueMap & valueMap, int64_t generation);
@@ -121,5 +120,3 @@ private:
};
} // namespace config
-
-#include "configsnapshot.hpp"
diff --git a/config/src/vespa/config/retriever/configsnapshot.hpp b/config/src/vespa/config/retriever/configsnapshot.hpp
index 387fc9712e0..5513eaa9d65 100644
--- a/config/src/vespa/config/retriever/configsnapshot.hpp
+++ b/config/src/vespa/config/retriever/configsnapshot.hpp
@@ -1,5 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
+#include "configsnapshot.h"
+#include <vespa/config/common/configvalue.hpp>
+
namespace config {
template <typename ConfigType>
diff --git a/config/src/vespa/config/retriever/fixedconfigsubscriber.cpp b/config/src/vespa/config/retriever/fixedconfigsubscriber.cpp
index 07049a8ac2b..da199c2e298 100644
--- a/config/src/vespa/config/retriever/fixedconfigsubscriber.cpp
+++ b/config/src/vespa/config/retriever/fixedconfigsubscriber.cpp
@@ -3,9 +3,9 @@
namespace config {
FixedConfigSubscriber::FixedConfigSubscriber(const ConfigKeySet & keySet,
- const IConfigContext::SP & context,
+ std::shared_ptr<IConfigContext> context,
milliseconds subscribeTimeout)
- : _set(context),
+ : _set(std::move(context)),
_subscriptionList()
{
for (const ConfigKey & key : keySet) {
diff --git a/config/src/vespa/config/retriever/fixedconfigsubscriber.h b/config/src/vespa/config/retriever/fixedconfigsubscriber.h
index 5ae684db782..1ca4d8cf0b3 100644
--- a/config/src/vespa/config/retriever/fixedconfigsubscriber.h
+++ b/config/src/vespa/config/retriever/fixedconfigsubscriber.h
@@ -15,14 +15,14 @@ class FixedConfigSubscriber
{
public:
using milliseconds = std::chrono::milliseconds;
- FixedConfigSubscriber(const ConfigKeySet & keySet, const IConfigContext::SP & context, milliseconds subscribeTimeout);
+ FixedConfigSubscriber(const ConfigKeySet & keySet, std::shared_ptr<IConfigContext> context, milliseconds subscribeTimeout);
bool nextGeneration(milliseconds timeoutInMillis);
void close();
int64_t getGeneration() const;
ConfigSnapshot getConfigSnapshot() const;
private:
ConfigSubscriptionSet _set;
- std::vector<ConfigSubscription::SP> _subscriptionList;
+ std::vector<std::shared_ptr<ConfigSubscription>> _subscriptionList;
};
} // namespace config
diff --git a/config/src/vespa/config/retriever/genericconfigsubscriber.cpp b/config/src/vespa/config/retriever/genericconfigsubscriber.cpp
index 96146bb8927..4190c404d04 100644
--- a/config/src/vespa/config/retriever/genericconfigsubscriber.cpp
+++ b/config/src/vespa/config/retriever/genericconfigsubscriber.cpp
@@ -3,8 +3,8 @@
namespace config {
-GenericConfigSubscriber::GenericConfigSubscriber(const IConfigContext::SP & context)
- : _set(context)
+GenericConfigSubscriber::GenericConfigSubscriber(std::shared_ptr<IConfigContext> context)
+ : _set(std::move(context))
{ }
bool
@@ -13,7 +13,7 @@ GenericConfigSubscriber::nextGeneration(milliseconds timeoutInMillis)
return _set.acquireSnapshot(timeoutInMillis, true);
}
-ConfigSubscription::SP
+std::shared_ptr<ConfigSubscription>
GenericConfigSubscriber::subscribe(const ConfigKey & key, milliseconds timeoutInMillis)
{
return _set.subscribe(key, timeoutInMillis);
diff --git a/config/src/vespa/config/retriever/genericconfigsubscriber.h b/config/src/vespa/config/retriever/genericconfigsubscriber.h
index 17d37ffb7ff..b2b7be5b9e4 100644
--- a/config/src/vespa/config/retriever/genericconfigsubscriber.h
+++ b/config/src/vespa/config/retriever/genericconfigsubscriber.h
@@ -14,9 +14,9 @@ class GenericConfigSubscriber
{
public:
using milliseconds = std::chrono::milliseconds;
- GenericConfigSubscriber(const IConfigContext::SP & context);
+ GenericConfigSubscriber(std::shared_ptr<IConfigContext> context);
bool nextGeneration(milliseconds timeoutInMillis);
- ConfigSubscription::SP subscribe(const ConfigKey & key, milliseconds timeoutInMillis);
+ std::shared_ptr<ConfigSubscription> subscribe(const ConfigKey & key, milliseconds timeoutInMillis);
void close();
int64_t getGeneration() const;
private:
diff --git a/config/src/vespa/config/retriever/simpleconfigretriever.cpp b/config/src/vespa/config/retriever/simpleconfigretriever.cpp
index fc4f21718af..43dad7d9429 100644
--- a/config/src/vespa/config/retriever/simpleconfigretriever.cpp
+++ b/config/src/vespa/config/retriever/simpleconfigretriever.cpp
@@ -3,7 +3,7 @@
namespace config {
SimpleConfigRetriever::SimpleConfigRetriever(const ConfigKeySet & keySet,
- const IConfigContext::SP & context,
+ std::shared_ptr<IConfigContext> context,
milliseconds subscribeTimeout)
: _set(context),
_subscriptionList()
diff --git a/config/src/vespa/config/retriever/simpleconfigretriever.h b/config/src/vespa/config/retriever/simpleconfigretriever.h
index 1e19789db9f..2650532cda2 100644
--- a/config/src/vespa/config/retriever/simpleconfigretriever.h
+++ b/config/src/vespa/config/retriever/simpleconfigretriever.h
@@ -20,7 +20,7 @@ public:
using milliseconds = std::chrono::milliseconds;
SimpleConfigRetriever(const ConfigKeySet & keySet,
- const IConfigContext::SP & context,
+ std::shared_ptr<IConfigContext> context,
milliseconds subscribeTimeout = DEFAULT_SUBSCRIBE_TIMEOUT);
/**
@@ -35,7 +35,7 @@ public:
private:
ConfigSubscriptionSet _set;
- std::vector<ConfigSubscription::SP> _subscriptionList;
+ std::vector<std::shared_ptr<ConfigSubscription>> _subscriptionList;
};
} // namespace config
diff --git a/config/src/vespa/config/set/configinstancesourcefactory.cpp b/config/src/vespa/config/set/configinstancesourcefactory.cpp
index 3ed0fdc932e..64abaada0a4 100644
--- a/config/src/vespa/config/set/configinstancesourcefactory.cpp
+++ b/config/src/vespa/config/set/configinstancesourcefactory.cpp
@@ -1,26 +1,25 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "configinstancesourcefactory.h"
+#include <vespa/config/common/iconfigholder.h>
namespace {
class ConfigInstanceSource : public config::Source {
public:
- ConfigInstanceSource(const config::IConfigHolder::SP & holder, const vespalib::asciistream & buffer)
- : _holder(holder),
- _buffer(buffer),
+ ConfigInstanceSource(std::shared_ptr<config::IConfigHolder> holder, vespalib::asciistream buffer)
+ : _holder(std::move(holder)),
+ _buffer(std::move(buffer)),
_generation(-1)
{ }
void close() override { }
void getConfig() override {
- std::vector<vespalib::string> lines(_buffer.getlines());
- std::string currentXxhash64(config::calculateContentXxhash64(lines));
- _holder->handle(config::ConfigUpdate::UP(new config::ConfigUpdate(config::ConfigValue(lines, currentXxhash64), true, _generation)));
+ _holder->handle(std::make_unique<config::ConfigUpdate>(config::ConfigValue(_buffer.getlines()), true, _generation));
}
void reload(int64_t generation) override { _generation = generation; }
private:
- config::IConfigHolder::SP _holder;
+ std::shared_ptr<config::IConfigHolder> _holder;
vespalib::asciistream _buffer;
int64_t _generation;
};
@@ -29,18 +28,18 @@ private:
namespace config {
-ConfigInstanceSourceFactory::ConfigInstanceSourceFactory(const ConfigKey & key, const vespalib::asciistream & buffer)
+ConfigInstanceSourceFactory::ConfigInstanceSourceFactory(const ConfigKey & key, vespalib::asciistream buffer)
: _key(key),
- _buffer(buffer)
+ _buffer(std::move(buffer))
{
}
-Source::UP
-ConfigInstanceSourceFactory::createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const
+std::unique_ptr<Source>
+ConfigInstanceSourceFactory::createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const
{
(void) key;
// TODO: Check key against _key
- return Source::UP(new ConfigInstanceSource(holder, _buffer));
+ return std::make_unique<ConfigInstanceSource>(std::move(holder), _buffer);
}
} // namespace config
diff --git a/config/src/vespa/config/set/configinstancesourcefactory.h b/config/src/vespa/config/set/configinstancesourcefactory.h
index 279da055d91..bff81a457c4 100644
--- a/config/src/vespa/config/set/configinstancesourcefactory.h
+++ b/config/src/vespa/config/set/configinstancesourcefactory.h
@@ -17,12 +17,12 @@ class ConfigKey;
class ConfigInstanceSourceFactory : public SourceFactory
{
public:
- ConfigInstanceSourceFactory(const ConfigKey & key, const vespalib::asciistream & buffer);
+ ConfigInstanceSourceFactory(const ConfigKey & key, vespalib::asciistream buffer);
/**
* Create source handling config described by key.
*/
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override;
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override;
private:
const ConfigKey _key;
vespalib::asciistream _buffer;
diff --git a/config/src/vespa/config/set/configsetsource.cpp b/config/src/vespa/config/set/configsetsource.cpp
index c60126b17e7..94547fbe63d 100644
--- a/config/src/vespa/config/set/configsetsource.cpp
+++ b/config/src/vespa/config/set/configsetsource.cpp
@@ -2,6 +2,7 @@
#include "configsetsource.h"
#include <vespa/config/print/asciiconfigwriter.h>
+#include <vespa/config/common/iconfigholder.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/log/log.h>
@@ -9,17 +10,17 @@ LOG_SETUP(".config.set.configsetsource");
namespace config {
-ConfigSetSource::ConfigSetSource(const IConfigHolder::SP & holder, const ConfigKey & key, const BuilderMapSP & builderMap)
- : _holder(holder),
+ConfigSetSource::ConfigSetSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key, BuilderMapSP builderMap)
+ : _holder(std::move(holder)),
_key(key),
_generation(1),
- _builderMap(builderMap)
+ _builderMap(std::move(builderMap))
{
if (!validRequest(key))
throw ConfigRuntimeException("Invalid subscribe for key " + key.toString() + ", not builder found");
}
-ConfigSetSource::~ConfigSetSource() { }
+ConfigSetSource::~ConfigSetSource() = default;
void
ConfigSetSource::getConfig()
@@ -29,17 +30,17 @@ ConfigSetSource::getConfig()
vespalib::asciistream ss;
AsciiConfigWriter writer(ss);
writer.write(*instance);
- std::vector<vespalib::string> lines(ss.getlines());
- std::string currentXxhash64(calculateContentXxhash64(lines));
+ StringVector lines(ss.getlines());
+ vespalib::string currentXxhash64(calculateContentXxhash64(lines));
if (isGenerationNewer(_generation, _lastState.generation) && currentXxhash64.compare(_lastState.xxhash64) != 0) {
LOG(debug, "New generation, updating");
- _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(lines, currentXxhash64), true, _generation)));
+ _holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(std::move(lines), currentXxhash64), true, _generation));
_lastState.xxhash64 = currentXxhash64;
_lastState.generation = _generation;
} else {
LOG(debug, "Sending timestamp update");
- _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(lines, currentXxhash64), false, _generation)));
+ _holder->handle(std::make_unique<ConfigUpdate>(ConfigValue(std::move(lines), currentXxhash64), false, _generation));
_lastState.generation = _generation;
}
}
diff --git a/config/src/vespa/config/set/configsetsource.h b/config/src/vespa/config/set/configsetsource.h
index aa9e8425f96..95cc0049a7a 100644
--- a/config/src/vespa/config/set/configsetsource.h
+++ b/config/src/vespa/config/set/configsetsource.h
@@ -3,13 +3,13 @@
#include <vespa/config/common/source.h>
#include <vespa/config/common/configkey.h>
-#include <vespa/config/common/iconfigholder.h>
#include <vespa/config/common/configstate.h>
#include <map>
namespace config {
class ConfigInstance;
+class IConfigHolder;
/**
* Class for sending and receiving config request from a raw string.
@@ -18,18 +18,20 @@ class ConfigSetSource : public Source {
public:
typedef std::map<ConfigKey, ConfigInstance *> BuilderMap;
typedef std::shared_ptr<BuilderMap> BuilderMapSP;
- ConfigSetSource(const IConfigHolder::SP & holder, const ConfigKey & key, const BuilderMapSP & builderMap);
+ ConfigSetSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key, BuilderMapSP builderMap);
+ ConfigSetSource(const ConfigSetSource &) = delete;
+ ConfigSetSource & operator =(const ConfigSetSource &) = delete;
~ConfigSetSource();
void getConfig() override;
void reload(int64_t generation) override;
void close() override;
private:
- IConfigHolder::SP _holder;
+ std::shared_ptr<IConfigHolder> _holder;
const ConfigKey _key;
- int64_t _generation;
- BuilderMapSP _builderMap;
- ConfigState _lastState;
+ int64_t _generation;
+ BuilderMapSP _builderMap;
+ ConfigState _lastState;
bool validRequest(const ConfigKey & key);
};
diff --git a/config/src/vespa/config/set/configsetsourcefactory.cpp b/config/src/vespa/config/set/configsetsourcefactory.cpp
index b2ca99879cb..9d443cdaabc 100644
--- a/config/src/vespa/config/set/configsetsourcefactory.cpp
+++ b/config/src/vespa/config/set/configsetsourcefactory.cpp
@@ -3,15 +3,17 @@
namespace config {
-ConfigSetSourceFactory::ConfigSetSourceFactory(const BuilderMapSP & builderMap)
- : _builderMap(builderMap)
+ConfigSetSourceFactory::ConfigSetSourceFactory(BuilderMapSP builderMap)
+ : _builderMap(std::move(builderMap))
{
}
-Source::UP
-ConfigSetSourceFactory::createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const
+ConfigSetSourceFactory::~ConfigSetSourceFactory() = default;
+
+std::unique_ptr<Source>
+ConfigSetSourceFactory::createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const
{
- return Source::UP(new ConfigSetSource(holder, key, _builderMap));
+ return std::make_unique<ConfigSetSource>(std::move(holder), key, _builderMap);
}
} // namespace config
diff --git a/config/src/vespa/config/set/configsetsourcefactory.h b/config/src/vespa/config/set/configsetsourcefactory.h
index 88e2eedb255..c42e14a7c84 100644
--- a/config/src/vespa/config/set/configsetsourcefactory.h
+++ b/config/src/vespa/config/set/configsetsourcefactory.h
@@ -16,14 +16,10 @@ class ConfigKey;
class ConfigSetSourceFactory : public SourceFactory
{
public:
- typedef ConfigSetSource::BuilderMap BuilderMap;
- typedef ConfigSetSource::BuilderMapSP BuilderMapSP;
- ConfigSetSourceFactory(const BuilderMapSP & builderMap);
-
- /**
- * Create source handling config described by key.
- */
- Source::UP createSource(const IConfigHolder::SP & holder, const ConfigKey & key) const override;
+ using BuilderMapSP = ConfigSetSource::BuilderMapSP;
+ explicit ConfigSetSourceFactory(BuilderMapSP builderMap);
+ ~ConfigSetSourceFactory() override;
+ std::unique_ptr<Source> createSource(std::shared_ptr<IConfigHolder> holder, const ConfigKey & key) const override;
private:
BuilderMapSP _builderMap;
};
diff --git a/config/src/vespa/config/subscription/confighandle.h b/config/src/vespa/config/subscription/confighandle.h
index 69532e5ba48..98a3e844acd 100644
--- a/config/src/vespa/config/subscription/confighandle.h
+++ b/config/src/vespa/config/subscription/confighandle.h
@@ -2,10 +2,11 @@
#pragma once
#include <memory>
-#include <vespa/config/subscription/configsubscription.h>
namespace config {
+class ConfigSubscription;
+
/**
* A ConfigHandle is a subscription handle that is capable of looking up config
* objects of a generic type.
@@ -16,7 +17,8 @@ class ConfigHandle
public:
typedef std::unique_ptr<ConfigHandle <ConfigType> > UP;
- ConfigHandle(const ConfigSubscription::SP & subscription);
+ explicit ConfigHandle(std::shared_ptr<ConfigSubscription> subscription);
+ ~ConfigHandle();
/**
* Return the currently available config known to the ConfigHandle. Throws
@@ -38,10 +40,8 @@ public:
*/
bool isChanged() const;
private:
- ConfigSubscription::SP _subscription;
+ std::shared_ptr<ConfigSubscription> _subscription;
};
} // namespace config
-#include "confighandle.hpp"
-
diff --git a/config/src/vespa/config/subscription/confighandle.hpp b/config/src/vespa/config/subscription/confighandle.hpp
index 9ce94808601..9ad27a5cb3f 100644
--- a/config/src/vespa/config/subscription/confighandle.hpp
+++ b/config/src/vespa/config/subscription/confighandle.hpp
@@ -1,15 +1,20 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "confighandle.h"
+#include <vespa/config/common/configvalue.hpp>
namespace config {
template <typename ConfigType>
-ConfigHandle<ConfigType>::ConfigHandle(const ConfigSubscription::SP & subscription)
- : _subscription(subscription)
+ConfigHandle<ConfigType>::ConfigHandle(std::shared_ptr<ConfigSubscription> subscription)
+ : _subscription(std::move(subscription))
{
}
template <typename ConfigType>
+ConfigHandle<ConfigType>::~ConfigHandle() = default;
+
+template <typename ConfigType>
std::unique_ptr<ConfigType>
ConfigHandle<ConfigType>::getConfig() const
{
diff --git a/config/src/vespa/config/subscription/configinstancespec.h b/config/src/vespa/config/subscription/configinstancespec.h
index 2294b37e1d1..32ee78b1d71 100644
--- a/config/src/vespa/config/subscription/configinstancespec.h
+++ b/config/src/vespa/config/subscription/configinstancespec.h
@@ -15,6 +15,9 @@ class ConfigInstanceSpec : public SourceSpec
{
public:
ConfigInstanceSpec(const ConfigInstance & instance);
+ ConfigInstanceSpec(const ConfigInstanceSpec &) = delete;
+ ConfigInstanceSpec & operator =(const ConfigInstanceSpec &) = delete;
+ ~ConfigInstanceSpec() override;
std::unique_ptr<SourceFactory> createSourceFactory(const TimingValues & timingValues) const override;
private:
const ConfigKey _key;
diff --git a/config/src/vespa/config/subscription/configsubscriber.cpp b/config/src/vespa/config/subscription/configsubscriber.cpp
index 2627b479df9..0645481a1f5 100644
--- a/config/src/vespa/config/subscription/configsubscriber.cpp
+++ b/config/src/vespa/config/subscription/configsubscriber.cpp
@@ -6,8 +6,8 @@
namespace config {
-ConfigSubscriber::ConfigSubscriber(const IConfigContext::SP & context)
- : _set(context)
+ConfigSubscriber::ConfigSubscriber(std::shared_ptr<IConfigContext> context)
+ : _set(std::move(context))
{ }
@@ -15,6 +15,8 @@ ConfigSubscriber::ConfigSubscriber(const SourceSpec & spec)
: _set(std::make_shared<ConfigContext>(spec))
{ }
+ConfigSubscriber::~ConfigSubscriber() = default;
+
bool
ConfigSubscriber::nextConfig(milliseconds timeoutInMillis)
{
diff --git a/config/src/vespa/config/subscription/configsubscriber.h b/config/src/vespa/config/subscription/configsubscriber.h
index 1cc82b6db8c..fd6497155fc 100644
--- a/config/src/vespa/config/subscription/configsubscriber.h
+++ b/config/src/vespa/config/subscription/configsubscriber.h
@@ -45,7 +45,10 @@ public:
*
* @param context A ConfigContext shared between all subscribers.
*/
- ConfigSubscriber(const IConfigContext::SP & context);
+ explicit ConfigSubscriber(std::shared_ptr<IConfigContext> context);
+ ConfigSubscriber(const ConfigSubscriber &) = delete;
+ ConfigSubscriber & operator= (const ConfigSubscriber &) = delete;
+ ~ConfigSubscriber();
/**
* Checks if one or more of the configs in the set is updated or not.
@@ -106,6 +109,3 @@ private:
};
} // namespace config
-
-#include "configsubscriber.hpp"
-
diff --git a/config/src/vespa/config/subscription/configsubscriber.hpp b/config/src/vespa/config/subscription/configsubscriber.hpp
index 28c54240748..ca890f8e35d 100644
--- a/config/src/vespa/config/subscription/configsubscriber.hpp
+++ b/config/src/vespa/config/subscription/configsubscriber.hpp
@@ -1,5 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "configsubscriber.h"
+#include "confighandle.hpp"
+
namespace config {
template <typename ConfigType>
@@ -7,7 +10,7 @@ std::unique_ptr<ConfigHandle<ConfigType> >
ConfigSubscriber::subscribe(const std::string & configId, milliseconds timeoutInMillis)
{
const ConfigKey key(ConfigKey::create<ConfigType>(configId));
- return std::unique_ptr<ConfigHandle<ConfigType> >(new ConfigHandle<ConfigType>(_set.subscribe(key, timeoutInMillis)));
+ return std::make_unique<ConfigHandle<ConfigType> >(_set.subscribe(key, timeoutInMillis));
}
}
diff --git a/config/src/vespa/config/subscription/configsubscription.cpp b/config/src/vespa/config/subscription/configsubscription.cpp
index 9790541906b..d49c5c32478 100644
--- a/config/src/vespa/config/subscription/configsubscription.cpp
+++ b/config/src/vespa/config/subscription/configsubscription.cpp
@@ -1,16 +1,19 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "configsubscription.h"
+#include <vespa/config/common/configupdate.h>
+#include <vespa/config/common/iconfigholder.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/misc.h>
-#include "configsubscription.h"
namespace config {
-ConfigSubscription::ConfigSubscription(const SubscriptionId & id, const ConfigKey & key, const IConfigHolder::SP & holder, Source::UP source)
+ConfigSubscription::ConfigSubscription(const SubscriptionId & id, const ConfigKey & key,
+ std::shared_ptr<IConfigHolder> holder, std::unique_ptr<Source> source)
: _id(id),
_key(key),
_source(std::move(source)),
- _holder(holder),
+ _holder(std::move(holder)),
_next(),
_current(),
_isChanged(false),
diff --git a/config/src/vespa/config/subscription/configsubscription.h b/config/src/vespa/config/subscription/configsubscription.h
index 08dcac6a580..05c03736fa3 100644
--- a/config/src/vespa/config/subscription/configsubscription.h
+++ b/config/src/vespa/config/subscription/configsubscription.h
@@ -1,15 +1,17 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "subscriptionid.h"
-#include <vespa/config/common/iconfigholder.h>
#include <vespa/config/common/configkey.h>
#include <vespa/config/common/source.h>
-
#include <atomic>
#include <chrono>
namespace config {
+class IConfigHolder;
+class ConfigUpdate;
+class ConfigValue;
+
/**
* A subscription can be polled for config updates, and handles interruption of
* the nextUpdate call.
@@ -20,7 +22,7 @@ public:
typedef std::unique_ptr<ConfigSubscription> UP;
typedef std::shared_ptr<ConfigSubscription> SP;
- ConfigSubscription(const SubscriptionId & id, const ConfigKey & key, const IConfigHolder::SP & holder, Source::UP source);
+ ConfigSubscription(const SubscriptionId & id, const ConfigKey & key, std::shared_ptr<IConfigHolder> holder, std::unique_ptr<Source> source);
~ConfigSubscription();
/**
@@ -57,15 +59,15 @@ public:
void reload(int64_t generation);
private:
- const SubscriptionId _id;
- const ConfigKey _key;
- Source::UP _source;
- IConfigHolder::SP _holder;
- ConfigUpdate::UP _next;
- ConfigUpdate::UP _current;
- bool _isChanged;
- int64_t _lastGenerationChanged;
- std::atomic<bool> _closed;
+ const SubscriptionId _id;
+ const ConfigKey _key;
+ std::unique_ptr<Source> _source;
+ std::shared_ptr<IConfigHolder> _holder;
+ std::unique_ptr<ConfigUpdate> _next;
+ std::unique_ptr<ConfigUpdate> _current;
+ bool _isChanged;
+ int64_t _lastGenerationChanged;
+ std::atomic<bool> _closed;
};
typedef std::vector<ConfigSubscription::SP> SubscriptionList;
diff --git a/config/src/vespa/config/subscription/configsubscriptionset.cpp b/config/src/vespa/config/subscription/configsubscriptionset.cpp
index 63c9f287350..9ad4dfe3f9d 100644
--- a/config/src/vespa/config/subscription/configsubscriptionset.cpp
+++ b/config/src/vespa/config/subscription/configsubscriptionset.cpp
@@ -1,8 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "configsubscriptionset.h"
+#include "configsubscription.h"
#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/misc.h>
+#include <vespa/config/common/iconfigmanager.h>
+#include <vespa/config/common/iconfigcontext.h>
#include <thread>
#include <vespa/log/log.h>
@@ -13,9 +16,9 @@ using namespace std::chrono;
namespace config {
-ConfigSubscriptionSet::ConfigSubscriptionSet(const IConfigContext::SP & context)
- : _context(context),
- _mgr(context->getManagerInstance()),
+ConfigSubscriptionSet::ConfigSubscriptionSet(std::shared_ptr<IConfigContext> context)
+ : _context(std::move(context)),
+ _mgr(_context->getManagerInstance()),
_currentGeneration(-1),
_subscriptionList(),
_state(OPEN)
@@ -119,7 +122,7 @@ ConfigSubscriptionSet::isClosed() const
return (_state.load(std::memory_order_relaxed) == CLOSED);
}
-ConfigSubscription::SP
+std::shared_ptr<ConfigSubscription>
ConfigSubscriptionSet::subscribe(const ConfigKey & key, milliseconds timeoutInMillis)
{
if (_state != OPEN) {
@@ -127,7 +130,7 @@ ConfigSubscriptionSet::subscribe(const ConfigKey & key, milliseconds timeoutInMi
}
LOG(debug, "Subscribing with config Id(%s), defName(%s)", key.getConfigId().c_str(), key.getDefName().c_str());
- ConfigSubscription::SP s = _mgr.subscribe(key, timeoutInMillis);
+ std::shared_ptr<ConfigSubscription> s = _mgr.subscribe(key, timeoutInMillis);
_subscriptionList.push_back(s);
return s;
}
diff --git a/config/src/vespa/config/subscription/configsubscriptionset.h b/config/src/vespa/config/subscription/configsubscriptionset.h
index ea37a133ef8..89c74a97be2 100644
--- a/config/src/vespa/config/subscription/configsubscriptionset.h
+++ b/config/src/vespa/config/subscription/configsubscriptionset.h
@@ -2,16 +2,19 @@
//
#pragma once
-#include "confighandle.h"
#include "subscriptionid.h"
-#include "configsubscription.h"
-#include "configprovider.h"
-#include <vespa/config/common/iconfigcontext.h>
-#include <vespa/config/common/iconfigmanager.h>
#include <atomic>
+#include <chrono>
+#include <memory>
+#include <vector>
namespace config {
+class IConfigContext;
+class IConfigManager;
+class ConfigSubscription;
+class ConfigKey;
+
/**
* A ConfigSubscriptionSet is a set of configs that can be subscribed to.
*/
@@ -25,8 +28,10 @@ public:
*
* @param context A ConfigContext shared between all subscriptions.
*/
- ConfigSubscriptionSet(const IConfigContext::SP & context);
+ explicit ConfigSubscriptionSet(std::shared_ptr<IConfigContext> context);
+ ConfigSubscriptionSet(const ConfigSubscriptionSet &) = delete;
+ ConfigSubscriptionSet & operator= (const ConfigSubscriptionSet &) = delete;
~ConfigSubscriptionSet();
/**
@@ -48,7 +53,7 @@ public:
bool isClosed() const;
// Helpers for doing the subscription
- ConfigSubscription::SP subscribe(const ConfigKey & key, milliseconds timeoutInMillis);
+ std::shared_ptr<ConfigSubscription> subscribe(const ConfigKey & key, milliseconds timeoutInMillis);
// Tries to acquire a new snapshot of config within the timeout
bool acquireSnapshot(milliseconds timeoutInMillis, bool requireDifference);
@@ -56,13 +61,13 @@ public:
private:
// Describes the state of the subscriber.
enum SubscriberState { OPEN, FROZEN, CONFIGURED, CLOSED };
+ using SubscriptionList = std::vector<std::shared_ptr<ConfigSubscription>>;
- IConfigContext::SP _context; // Context to keep alive managers.
- IConfigManager & _mgr; // The config manager that we use.
- int64_t _currentGeneration; // Holds the current config generation.
- SubscriptionList _subscriptionList; // List of current subscriptions.
-
- std::atomic<SubscriberState> _state; // Current state of this subscriber.
+ std::shared_ptr<IConfigContext> _context; // Context to keep alive managers.
+ IConfigManager & _mgr; // The config manager that we use.
+ int64_t _currentGeneration; // Holds the current config generation.
+ SubscriptionList _subscriptionList; // List of current subscriptions.
+ std::atomic<SubscriberState> _state; // Current state of this subscriber.
};
} // namespace config
diff --git a/config/src/vespa/config/subscription/configuri.cpp b/config/src/vespa/config/subscription/configuri.cpp
index 001e7adbb8b..edb06f8b237 100644
--- a/config/src/vespa/config/subscription/configuri.cpp
+++ b/config/src/vespa/config/subscription/configuri.cpp
@@ -18,7 +18,7 @@ ConfigUri::ConfigUri(const vespalib::string &configId)
{
}
-ConfigUri::ConfigUri(const vespalib::string &configId, IConfigContext::SP context)
+ConfigUri::ConfigUri(const vespalib::string &configId, std::shared_ptr<IConfigContext> context)
: _configId(configId),
_context(std::move(context)),
_empty(false)
@@ -34,7 +34,7 @@ ConfigUri::createWithNewId(const vespalib::string & configId) const
}
const vespalib::string & ConfigUri::getConfigId() const { return _configId; }
-const IConfigContext::SP & ConfigUri::getContext() const { return _context; }
+const std::shared_ptr<IConfigContext> & ConfigUri::getContext() const { return _context; }
ConfigUri
ConfigUri::createFromInstance(const ConfigInstance & instance)
diff --git a/config/src/vespa/config/subscription/configuri.h b/config/src/vespa/config/subscription/configuri.h
index 7fe32312d30..d8472d9a637 100644
--- a/config/src/vespa/config/subscription/configuri.h
+++ b/config/src/vespa/config/subscription/configuri.h
@@ -46,7 +46,7 @@ public:
* @param configId The config id.
* @param context A context object that can be shared with multiple URIs.
*/
- ConfigUri(const vespalib::string &configId, IConfigContext::SP context);
+ ConfigUri(const vespalib::string &configId, std::shared_ptr<IConfigContext> context);
~ConfigUri();
@@ -90,7 +90,7 @@ public:
* Get the context for this uri. Used by subscriber.
* @return The context.
*/
- const IConfigContext::SP & getContext() const;
+ const std::shared_ptr<IConfigContext> & getContext() const;
/**
* Empty if the original id was empty or created with createEmpty
@@ -99,9 +99,9 @@ public:
bool empty() const { return _empty; }
private:
- vespalib::string _configId;
- IConfigContext::SP _context;
- bool _empty;
+ vespalib::string _configId;
+ std::shared_ptr<IConfigContext> _context;
+ bool _empty;
};
} // namespace config
diff --git a/config/src/vespa/config/subscription/sourcespec.cpp b/config/src/vespa/config/subscription/sourcespec.cpp
index c8fd577935d..8009cdfd217 100644
--- a/config/src/vespa/config/subscription/sourcespec.cpp
+++ b/config/src/vespa/config/subscription/sourcespec.cpp
@@ -153,7 +153,9 @@ ConfigInstanceSpec::ConfigInstanceSpec(const ConfigInstance& instance)
writer.write(instance);
}
-SourceFactory::UP
+ConfigInstanceSpec::~ConfigInstanceSpec() = default;
+
+std::unique_ptr<SourceFactory>
ConfigInstanceSpec::createSourceFactory(const TimingValues& ) const
{
return std::make_unique<ConfigInstanceSourceFactory>(_key, _buffer);
diff --git a/config/src/vespa/config/subscription/sourcespec.h b/config/src/vespa/config/subscription/sourcespec.h
index 040c16204e3..a57b22ca322 100644
--- a/config/src/vespa/config/subscription/sourcespec.h
+++ b/config/src/vespa/config/subscription/sourcespec.h
@@ -37,7 +37,7 @@ public:
* @return An std::unique_ptr<Source> that can be used to ask for config.
*/
virtual SourceFactorySP createSourceFactory(const TimingValues & timingValues) const = 0;
- virtual ~SourceSpec() { }
+ virtual ~SourceSpec() = default;
};
@@ -131,7 +131,7 @@ class ServerSpec : public SourceSpec
{
public:
/// A list of host specifications
- typedef std::vector<vespalib::string> HostSpecList;
+ using HostSpecList = std::vector<vespalib::string>;
/**
* Construct a ServerSpec that fetches the host specs from the