summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-05 23:32:00 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-06 00:26:08 +0000
commit4c5a7cac411b30b9b4bd3ca067efcc9f3719b0ea (patch)
tree2e09c62b854357bbb1c8d433898d004e3f3995a5
parentb84ef936b1cedce0b99f79e03b2fe25a8db5f7c3 (diff)
Reduce code visibility and include only what you need from config library.
-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.h22
-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.cpp10
-rw-r--r--config/src/vespa/config/set/configsetsourcefactory.h10
-rw-r--r--config/src/vespa/config/subscription/confighandle.h9
-rw-r--r--config/src/vespa/config/subscription/confighandle.hpp6
-rw-r--r--config/src/vespa/config/subscription/configinstancespec.h3
-rw-r--r--config/src/vespa/config/subscription/configsubscriber.cpp4
-rw-r--r--config/src/vespa/config/subscription/configsubscriber.h5
-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.h26
-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
-rw-r--r--configd/src/apps/sentinel/config-owner.cpp4
-rw-r--r--configd/src/apps/sentinel/config-owner.h2
-rw-r--r--configd/src/apps/sentinel/manager.h1
-rw-r--r--configd/src/apps/sentinel/model-owner.cpp6
-rw-r--r--configd/src/apps/sentinel/model-owner.h2
-rw-r--r--configutil/src/apps/configstatus/main.cpp4
-rw-r--r--configutil/src/apps/modelinspect/main.cpp4
-rw-r--r--configutil/src/lib/configstatus.cpp4
-rw-r--r--configutil/src/lib/configstatus.h2
-rw-r--r--configutil/src/lib/modelinspect.cpp7
-rw-r--r--configutil/src/lib/modelinspect.h2
-rw-r--r--configutil/src/tests/config_status/config_status_test.cpp1
-rw-r--r--document/src/vespa/document/base/testdocrepo.cpp4
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp1
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h2
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp13
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h19
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp9
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h11
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.cpp22
-rw-r--r--logd/src/logd/config_subscriber.cpp1
-rw-r--r--logd/src/logd/config_subscriber.h3
-rw-r--r--logd/src/tests/watcher/watcher_test.cpp2
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp10
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/cf-handler.h4
-rw-r--r--messagebus/src/tests/configagent/configagent.cpp2
-rw-r--r--messagebus/src/tests/routingspec/routingspec.cpp1
-rw-r--r--messagebus/src/vespa/messagebus/configagent.h1
-rw-r--r--messagebus/src/vespa/messagebus/rpcmessagebus.cpp2
-rw-r--r--messagebus/src/vespa/messagebus/rpcmessagebus.h1
-rw-r--r--metrics/src/vespa/metrics/metricmanager.cpp8
-rw-r--r--metrics/src/vespa/metrics/metricmanager.h7
-rw-r--r--searchcommon/src/vespa/searchcommon/config/subscriptionproxyng.h20
-rw-r--r--searchcore/src/apps/tests/persistenceconformance_test.cpp3
-rw-r--r--searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp2
-rw-r--r--searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp2
-rw-r--r--searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp1
-rw-r--r--searchcore/src/tests/proton/documentdb/documentdb_test.cpp2
-rw-r--r--searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp2
-rw-r--r--searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h5
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h9
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h9
-rw-r--r--slobrok/src/tests/configure/configure.cpp1
-rw-r--r--slobrok/src/vespa/slobrok/cfg.cpp16
-rw-r--r--slobrok/src/vespa/slobrok/cfg.h13
-rw-r--r--slobrok/src/vespa/slobrok/server/configshim.cpp4
-rw-r--r--slobrok/src/vespa/slobrok/server/configshim.h2
-rw-r--r--slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp3
-rw-r--r--slobrok/src/vespa/slobrok/server/sbenv.h6
-rw-r--r--staging_vespalib/src/tests/json/json.cpp6
-rw-r--r--storage/src/tests/common/global_bucket_space_distribution_converter_test.cpp1
-rw-r--r--storage/src/tests/common/teststorageapp.cpp3
-rw-r--r--storage/src/tests/distributor/putoperationtest.cpp2
-rw-r--r--storage/src/tests/frameworkimpl/status/statustest.cpp2
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketmanager.cpp1
-rw-r--r--storage/src/vespa/storage/common/global_bucket_space_distribution_converter.cpp3
-rw-r--r--storage/src/vespa/storage/distributor/distributor_stripe.h1
-rw-r--r--storage/src/vespa/storage/distributor/statecheckers.cpp4
-rw-r--r--storage/src/vespa/storage/distributor/top_level_distributor.h1
-rw-r--r--storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp10
-rw-r--r--storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h10
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp11
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormanager.h8
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp10
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h30
-rw-r--r--storage/src/vespa/storage/storageserver/bouncer.cpp9
-rw-r--r--storage/src/vespa/storage/storageserver/bouncer.h36
-rw-r--r--storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp9
-rw-r--r--storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h8
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.cpp1
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.h7
-rw-r--r--storage/src/vespa/storage/storageserver/mergethrottler.cpp11
-rw-r--r--storage/src/vespa/storage/storageserver/mergethrottler.h12
-rw-r--r--storage/src/vespa/storage/storageserver/opslogger.cpp12
-rw-r--r--storage/src/vespa/storage/storageserver/opslogger.h9
-rw-r--r--storage/src/vespa/storage/storageserver/priorityconverter.cpp9
-rw-r--r--storage/src/vespa/storage/storageserver/priorityconverter.h9
-rw-r--r--storage/src/vespa/storage/storageserver/servicelayernode.h1
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.cpp1
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.h3
-rw-r--r--storage/src/vespa/storage/tools/getidealstate.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/visitormanager.cpp12
-rw-r--r--storage/src/vespa/storage/visiting/visitormanager.h11
-rw-r--r--storageserver/src/vespa/storageserver/app/process.cpp3
-rw-r--r--storageserver/src/vespa/storageserver/app/process.h2
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/rankmanager.cpp1
-rw-r--r--vdslib/src/vespa/vdslib/distribution/distribution.cpp5
-rw-r--r--vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp3
-rw-r--r--vespaclient/src/vespa/vespaclient/vesparoute/application.h8
-rw-r--r--vespalib/src/vespa/vespalib/stllike/asciistream.cpp167
-rw-r--r--vsm/src/vespa/vsm/vsm/vsm-adapter.cpp20
-rw-r--r--vsm/src/vespa/vsm/vsm/vsm-adapter.h15
-rw-r--r--vsm/src/vespa/vsm/vsm/vsm-adapter.hpp18
210 files changed, 1001 insertions, 859 deletions
diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp
index 347d92e0ef4..bc38eddc0dd 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 = "";
@@ -241,8 +241,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());
@@ -260,7 +260,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..a1f92738d0c 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);
+ 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..c6663c7f3f8
--- /dev/null
+++ b/config/src/vespa/config/common/types.h
@@ -0,0 +1,22 @@
+// 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 {
+
+typedef std::vector<vespalib::string> StringVector;
+typedef std::vector<bool> BoolVector;
+typedef std::vector<double> DoubleVector;
+typedef std::vector<int64_t> LongVector;
+typedef std::vector<int32_t> IntVector;
+typedef std::map<vespalib::string, vespalib::string> StringMap;
+typedef std::map<vespalib::string, bool> BoolMap;
+typedef std::map<vespalib::string, double> DoubleMap;
+typedef std::map<vespalib::string, int64_t> LongMap;
+typedef std::map<vespalib::string, int32_t> IntMap;
+
+} // namespace common
+
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..136d1fd6353 100644
--- a/config/src/vespa/config/set/configsetsourcefactory.cpp
+++ b/config/src/vespa/config/set/configsetsourcefactory.cpp
@@ -3,15 +3,15 @@
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
+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..ca18142312f 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);
+ using BuilderMapSP = ConfigSetSource::BuilderMapSP;
+ ConfigSetSourceFactory(BuilderMapSP builderMap);
- /**
- * 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:
BuilderMapSP _builderMap;
};
diff --git a/config/src/vespa/config/subscription/confighandle.h b/config/src/vespa/config/subscription/confighandle.h
index 69532e5ba48..fd8218aec17 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,7 @@ class ConfigHandle
public:
typedef std::unique_ptr<ConfigHandle <ConfigType> > UP;
- ConfigHandle(const ConfigSubscription::SP & subscription);
+ ConfigHandle(std::shared_ptr<ConfigSubscription> subscription);
/**
* Return the currently available config known to the ConfigHandle. Throws
@@ -38,10 +39,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..123ed55e4b8 100644
--- a/config/src/vespa/config/subscription/confighandle.hpp
+++ b/config/src/vespa/config/subscription/confighandle.hpp
@@ -1,11 +1,13 @@
// 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))
{
}
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..1cdb06fe306 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))
{ }
diff --git a/config/src/vespa/config/subscription/configsubscriber.h b/config/src/vespa/config/subscription/configsubscriber.h
index 1cc82b6db8c..719cb5d1bc9 100644
--- a/config/src/vespa/config/subscription/configsubscriber.h
+++ b/config/src/vespa/config/subscription/configsubscriber.h
@@ -45,7 +45,7 @@ public:
*
* @param context A ConfigContext shared between all subscribers.
*/
- ConfigSubscriber(const IConfigContext::SP & context);
+ ConfigSubscriber(std::shared_ptr<IConfigContext> context);
/**
* Checks if one or more of the configs in the set is updated or not.
@@ -106,6 +106,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..35f29499786 100644
--- a/config/src/vespa/config/subscription/configsubscriptionset.h
+++ b/config/src/vespa/config/subscription/configsubscriptionset.h
@@ -2,16 +2,18 @@
//
#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>
namespace config {
+class IConfigContext;
+class IConfigManager;
+class ConfigSubscription;
+class ConfigKey;
+
/**
* A ConfigSubscriptionSet is a set of configs that can be subscribed to.
*/
@@ -25,7 +27,7 @@ public:
*
* @param context A ConfigContext shared between all subscriptions.
*/
- ConfigSubscriptionSet(const IConfigContext::SP & context);
+ ConfigSubscriptionSet(std::shared_ptr<IConfigContext> context);
~ConfigSubscriptionSet();
@@ -48,7 +50,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 +58,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
diff --git a/configd/src/apps/sentinel/config-owner.cpp b/configd/src/apps/sentinel/config-owner.cpp
index 40fe5267dae..90ceb705dc7 100644
--- a/configd/src/apps/sentinel/config-owner.cpp
+++ b/configd/src/apps/sentinel/config-owner.cpp
@@ -1,9 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "config-owner.h"
-#include <vespa/vespalib/util/exceptions.h>
-#include <vespa/config/common/exceptions.h>
-#include <string>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/log/log.h>
LOG_SETUP(".sentinel.config-owner");
diff --git a/configd/src/apps/sentinel/config-owner.h b/configd/src/apps/sentinel/config-owner.h
index a9083b553fa..2e44f8cd338 100644
--- a/configd/src/apps/sentinel/config-owner.h
+++ b/configd/src/apps/sentinel/config-owner.h
@@ -4,7 +4,7 @@
#include <vespa/config-sentinel.h>
#include <vespa/config-model.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configsubscriber.h>
using cloud::config::SentinelConfig;
diff --git a/configd/src/apps/sentinel/manager.h b/configd/src/apps/sentinel/manager.h
index 8aaa406d578..48c95fe7a3d 100644
--- a/configd/src/apps/sentinel/manager.h
+++ b/configd/src/apps/sentinel/manager.h
@@ -8,7 +8,6 @@
#include "service.h"
#include "state-api.h"
#include <vespa/config-sentinel.h>
-#include <vespa/config/config.h>
#include <vespa/vespalib/net/state_server.h>
#include <sys/types.h>
#include <sys/select.h>
diff --git a/configd/src/apps/sentinel/model-owner.cpp b/configd/src/apps/sentinel/model-owner.cpp
index 8b1db60c73d..5dd7a033933 100644
--- a/configd/src/apps/sentinel/model-owner.cpp
+++ b/configd/src/apps/sentinel/model-owner.cpp
@@ -1,12 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "model-owner.h"
-#include <vespa/vespalib/util/exceptions.h>
#include <vespa/config/common/exceptions.h>
-#include <string>
-#include <chrono>
-#include <vespa/log/log.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
+#include <vespa/log/log.h>
LOG_SETUP(".sentinel.model-owner");
using namespace std::chrono_literals;
diff --git a/configd/src/apps/sentinel/model-owner.h b/configd/src/apps/sentinel/model-owner.h
index 6c3038b4b55..762846e1ccd 100644
--- a/configd/src/apps/sentinel/model-owner.h
+++ b/configd/src/apps/sentinel/model-owner.h
@@ -3,7 +3,7 @@
#pragma once
#include <vespa/config-model.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configsubscriber.h>
#include <optional>
#include <mutex>
diff --git a/configutil/src/apps/configstatus/main.cpp b/configutil/src/apps/configstatus/main.cpp
index 717c120f8e2..cd0424633d9 100644
--- a/configutil/src/apps/configstatus/main.cpp
+++ b/configutil/src/apps/configstatus/main.cpp
@@ -2,10 +2,10 @@
#include <vespa/defaults.h>
#include <vespa/vespalib/text/stringtokenizer.h>
-#include <iostream>
-#include <cstdlib>
#include "lib/configstatus.h"
+#include <vespa/config/subscription/sourcespec.h>
#include <vespa/fastos/app.h>
+#include <iostream>
#include <vespa/log/log.h>
LOG_SETUP("vespa-config-status");
diff --git a/configutil/src/apps/modelinspect/main.cpp b/configutil/src/apps/modelinspect/main.cpp
index c9fc51febb5..7053adf17fa 100644
--- a/configutil/src/apps/modelinspect/main.cpp
+++ b/configutil/src/apps/modelinspect/main.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/defaults.h>
-#include <iostream>
-#include <cstdlib>
#include "lib/modelinspect.h"
#include <vespa/vespalib/text/stringtokenizer.h>
+#include <vespa/config/subscription/sourcespec.h>
#include <vespa/fastos/app.h>
+#include <iostream>
#include <vespa/log/log.h>
LOG_SETUP("vespa-model-inspect");
diff --git a/configutil/src/lib/configstatus.cpp b/configutil/src/lib/configstatus.cpp
index 529765dccd5..841d1604866 100644
--- a/configutil/src/lib/configstatus.cpp
+++ b/configutil/src/lib/configstatus.cpp
@@ -7,8 +7,8 @@
#include <vbench/http/server_spec.h>
#include <vbench/http/http_client.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <iostream>
-#include <cstdlib>
using configdefinitions::tagsContain;
@@ -69,7 +69,7 @@ struct ComponentTraverser : public vespalib::slime::ObjectTraverser
}
};
-ComponentTraverser::~ComponentTraverser() {}
+ComponentTraverser::~ComponentTraverser() = default;
class MyHttpHandler : public vbench::HttpResultHandler {
private:
diff --git a/configutil/src/lib/configstatus.h b/configutil/src/lib/configstatus.h
index 9e1627af4a9..4d792748419 100644
--- a/configutil/src/lib/configstatus.h
+++ b/configutil/src/lib/configstatus.h
@@ -4,7 +4,7 @@
#include "hostfilter.h"
#include <vespa/config-model.h>
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configuri.h>
class ConfigStatus
{
diff --git a/configutil/src/lib/modelinspect.cpp b/configutil/src/lib/modelinspect.cpp
index 611a41d1a84..d840a7d45ca 100644
--- a/configutil/src/lib/modelinspect.cpp
+++ b/configutil/src/lib/modelinspect.cpp
@@ -7,6 +7,7 @@
#include <iostream>
#include <algorithm>
#include <cstdlib>
+#include <set>
using configdefinitions::tagsContain;
using configdefinitions::upcase;
@@ -32,7 +33,7 @@ ModelInspect::ModelInspect(Flags flags, const config::ConfigUri uri, std::ostrea
} catch (config::ConfigRuntimeException &e) {
std::cerr << e.getMessage() << "\n";
}
- if (_cfg.get() != NULL) {
+ if (_cfg) {
if (_flags.verbose) std::cerr << "success!\n";
} else {
std::cerr << "FATAL ERROR: failed to get model configuration.\n";
@@ -40,9 +41,7 @@ ModelInspect::ModelInspect(Flags flags, const config::ConfigUri uri, std::ostrea
}
}
-ModelInspect::~ModelInspect()
-{
-}
+ModelInspect::~ModelInspect() = default;
void
ModelInspect::printPort(const vespalib::string &host, int port,
diff --git a/configutil/src/lib/modelinspect.h b/configutil/src/lib/modelinspect.h
index dae5f3f4e92..33ef94b259b 100644
--- a/configutil/src/lib/modelinspect.h
+++ b/configutil/src/lib/modelinspect.h
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/config-model.h>
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configuri.h>
class ModelInspect
diff --git a/configutil/src/tests/config_status/config_status_test.cpp b/configutil/src/tests/config_status/config_status_test.cpp
index 9b8b96acdb8..b6f1fd44d3f 100644
--- a/configutil/src/tests/config_status/config_status_test.cpp
+++ b/configutil/src/tests/config_status/config_status_test.cpp
@@ -3,7 +3,6 @@
#include <lib/configstatus.h>
#include <vespa/vespalib/portal/portal.h>
#include <vespa/config-model.h>
-#include <vespa/config/config.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/config/common/configcontext.h>
diff --git a/document/src/vespa/document/base/testdocrepo.cpp b/document/src/vespa/document/base/testdocrepo.cpp
index d48bac0ff74..fed14eef792 100644
--- a/document/src/vespa/document/base/testdocrepo.cpp
+++ b/document/src/vespa/document/base/testdocrepo.cpp
@@ -4,7 +4,7 @@
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/repo/configbuilder.h>
-#include <vespa/config/print/fileconfigreader.h>
+#include <vespa/config/print/fileconfigreader.hpp>
using document::config_builder::Struct;
using document::config_builder::Wset;
@@ -18,7 +18,7 @@ TestDocRepo::TestDocRepo()
_repo(new DocumentTypeRepo(_cfg)) {
}
- TestDocRepo::~TestDocRepo() {}
+TestDocRepo::~TestDocRepo() = default;
DocumenttypesConfig TestDocRepo::getDefaultConfig() {
const int type1_id = 238423572;
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
index 9872663ca7b..39e67408e76 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
@@ -10,6 +10,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/config-stor-distribution.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <vespa/config/subscription/configuri.h>
#include <cassert>
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h
index ac9c58bf276..9580f242c25 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.h
@@ -6,8 +6,6 @@
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/document/bucket/bucketidfactory.h>
#include <vespa/messagebus/routing/hop.h>
-#include <vespa/config/helper/ifetchercallback.h>
-#include <vespa/config/helper/configfetcher.h>
namespace config {
class ICallback;
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp
index dc55bd7a8b6..9d3dd874bb0 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.cpp
@@ -12,10 +12,11 @@
#include <vespa/messagebus/routing/routingtable.h>
#include <vespa/messagebus/messagebus.h>
#include <vespa/vespalib/util/stringfmt.h>
-
-#include <vespa/log/log.h>
+#include <vespa/config/helper/configfetcher.hpp>
+#include <vespa/config/subscription/configuri.h>
#include <vespa/documentapi/messagebus/messages/removedocumentmessage.h>
+#include <vespa/log/log.h>
LOG_SETUP(".documentrouteselectorpolicy");
using document::select::Result;
@@ -30,12 +31,14 @@ DocumentRouteSelectorPolicy::DocumentRouteSelectorPolicy(
_lock(),
_config(),
_error("Not configured."),
- _fetcher(configUri.getContext())
+ _fetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext()))
{
- _fetcher.subscribe<messagebus::protocol::DocumentrouteselectorpolicyConfig>(configUri.getConfigId(), this);
- _fetcher.start();
+ _fetcher->subscribe<messagebus::protocol::DocumentrouteselectorpolicyConfig>(configUri.getConfigId(), this);
+ _fetcher->start();
}
+DocumentRouteSelectorPolicy::~DocumentRouteSelectorPolicy() = default;
+
void
DocumentRouteSelectorPolicy::configure(std::unique_ptr<messagebus::protocol::DocumentrouteselectorpolicyConfig> cfg)
{
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h
index 43b28e7d35f..bf191ddde20 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/documentrouteselectorpolicy.h
@@ -6,8 +6,7 @@
#include <map>
#include <vespa/messagebus/routing/iroutingpolicy.h>
#include <vespa/documentapi/common.h>
-#include <vespa/config/config.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/ifetchercallback.h>
namespace document { class DocumentTypeRepo; }
@@ -16,6 +15,11 @@ namespace mbus {
class RoutingContext;
}
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
+
namespace documentapi {
/**
@@ -31,11 +35,11 @@ private:
typedef std::shared_ptr<document::select::Node> SelectorPtr;
typedef std::map<string, SelectorPtr> ConfigMap;
- const document::DocumentTypeRepo &_repo;
- mutable std::mutex _lock;
- ConfigMap _config;
- string _error;
- config::ConfigFetcher _fetcher;
+ const document::DocumentTypeRepo &_repo;
+ mutable std::mutex _lock;
+ ConfigMap _config;
+ string _error;
+ std::unique_ptr<config::ConfigFetcher> _fetcher;
/**
* This method runs the selector associated with the given location on the content of the message. If the selector
@@ -56,6 +60,7 @@ public:
*/
DocumentRouteSelectorPolicy(const document::DocumentTypeRepo &repo,
const config::ConfigUri &configUri);
+ ~DocumentRouteSelectorPolicy() override;
/**
* This is a safety mechanism to allow the constructor to fail and signal that it can not be used.
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp
index 9c5d978546b..0d7df9a9482 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.cpp
@@ -4,6 +4,9 @@
#include <vespa/documentapi/messagebus/documentprotocol.h>
#include <vespa/messagebus/message.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
+#include <vespa/config/helper/configfetcher.hpp>
+#include <vespa/config/subscription/configuri.h>
+
using vespa::config::content::MessagetyperouteselectorpolicyConfig;
@@ -25,10 +28,10 @@ MessageTypePolicy::MessageTypePolicy(const config::ConfigUri & configUri) :
config::IFetcherCallback<MessagetyperouteselectorpolicyConfig>(),
_map(),
_defaultRoute(),
- _fetcher(configUri.getContext())
+ _fetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext()))
{
- _fetcher.subscribe<MessagetyperouteselectorpolicyConfig>(configUri.getConfigId(), this);
- _fetcher.start();
+ _fetcher->subscribe<MessagetyperouteselectorpolicyConfig>(configUri.getConfigId(), this);
+ _fetcher->start();
}
MessageTypePolicy::~MessageTypePolicy() {}
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h
index 6b6ff78b810..ffeda17d778 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/messagetypepolicy.h
@@ -4,17 +4,20 @@
#include <vespa/messagebus/routing/iroutingpolicy.h>
#include <vespa/vespalib/util/ptrholder.h>
#include <vespa/config-messagetyperouteselectorpolicy.h>
-#include <vespa/config/config.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/documentapi/common.h>
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace mbus {
class RoutingContext;
class Route;
}
namespace documentapi {
-namespace policy {class MessageTypeMap; }
+namespace policy { class MessageTypeMap; }
/**
* This policy is responsible for selecting among the given recipient routes
* according to the configured document selection properties. To factilitate
@@ -31,7 +34,7 @@ private:
MessageTypeHolder _map;
RouteHolder _defaultRoute;
- config::ConfigFetcher _fetcher;
+ std::unique_ptr<config::ConfigFetcher> _fetcher;
public:
/**
diff --git a/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.cpp b/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.cpp
index ab43da5816c..a067610fb25 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/routingpolicyfactories.cpp
@@ -10,28 +10,29 @@
#include <vespa/documentapi/messagebus/policies/messagetypepolicy.h>
#include <vespa/documentapi/messagebus/policies/roundrobinpolicy.h>
#include <vespa/documentapi/messagebus/policies/subsetservicepolicy.h>
+#include <vespa/config/subscription/configuri.h>
using namespace documentapi;
mbus::IRoutingPolicy::UP
RoutingPolicyFactories::AndPolicyFactory::createPolicy(const string &param) const
{
- return mbus::IRoutingPolicy::UP(new ANDPolicy(param));
+ return std::make_unique<ANDPolicy>(param);
}
mbus::IRoutingPolicy::UP
RoutingPolicyFactories::MessageTypePolicyFactory::createPolicy(const string &param) const
{
- return mbus::IRoutingPolicy::UP(new MessageTypePolicy(param));
+ return std::make_unique<MessageTypePolicy>(param);
}
mbus::IRoutingPolicy::UP
RoutingPolicyFactories::ContentPolicyFactory::createPolicy(const string &param) const
{
- mbus::IRoutingPolicy::UP ret(new ContentPolicy(param));
+ auto ret = std::make_unique<ContentPolicy>(param);
string error = static_cast<ContentPolicy&>(*ret).getError();
if (!error.empty()) {
- ret.reset(new ErrorPolicy(error));
+ return std::make_unique<ErrorPolicy>(error);
}
return ret;
}
@@ -43,7 +44,7 @@ RoutingPolicyFactories::LoadBalancerPolicyFactory::createPolicy(const string &pa
string error = static_cast<LoadBalancerPolicy&>(*ret).getError();
if (!error.empty()) {
fprintf(stderr, "Got error %s\n", error.c_str());
- ret.reset(new ErrorPolicy(error));
+ return std::make_unique<ErrorPolicy>(error);
}
return ret;
}
@@ -60,11 +61,10 @@ DocumentRouteSelectorPolicyFactory(const document::DocumentTypeRepo &repo,
mbus::IRoutingPolicy::UP
RoutingPolicyFactories::DocumentRouteSelectorPolicyFactory::createPolicy(const string &param) const
{
- mbus::IRoutingPolicy::UP ret(new DocumentRouteSelectorPolicy(
- _repo, param.empty() ? _configId : param));
+ auto ret = std::make_unique<DocumentRouteSelectorPolicy>(_repo, param.empty() ? _configId : param);
string error = static_cast<DocumentRouteSelectorPolicy&>(*ret).getError();
if (!error.empty()) {
- ret.reset(new ErrorPolicy(error));
+ return std::make_unique<ErrorPolicy>(error);
}
return ret;
}
@@ -83,17 +83,17 @@ RoutingPolicyFactories::ExternPolicyFactory::createPolicy(const string &param) c
mbus::IRoutingPolicy::UP
RoutingPolicyFactories::LocalServicePolicyFactory::createPolicy(const string &param) const
{
- return mbus::IRoutingPolicy::UP(new LocalServicePolicy(param));
+ return std::make_unique<LocalServicePolicy>(param);
}
mbus::IRoutingPolicy::UP
RoutingPolicyFactories::RoundRobinPolicyFactory::createPolicy(const string &param) const
{
- return mbus::IRoutingPolicy::UP(new RoundRobinPolicy(param));
+ return std::make_unique<RoundRobinPolicy>(param);
}
mbus::IRoutingPolicy::UP
RoutingPolicyFactories::SubsetServicePolicyFactory::createPolicy(const string &param) const
{
- return mbus::IRoutingPolicy::UP(new SubsetServicePolicy(param));
+ return std::make_unique<SubsetServicePolicy>(param);
}
diff --git a/logd/src/logd/config_subscriber.cpp b/logd/src/logd/config_subscriber.cpp
index be3d42fb6f0..0b47d22096a 100644
--- a/logd/src/logd/config_subscriber.cpp
+++ b/logd/src/logd/config_subscriber.cpp
@@ -3,6 +3,7 @@
#include "config_subscriber.h"
#include "empty_forwarder.h"
#include "rpc_forwarder.h"
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/log/log.h>
LOG_SETUP("");
diff --git a/logd/src/logd/config_subscriber.h b/logd/src/logd/config_subscriber.h
index 9f7dea12d33..3c5ac202832 100644
--- a/logd/src/logd/config_subscriber.h
+++ b/logd/src/logd/config_subscriber.h
@@ -3,7 +3,8 @@
#include "forwarder.h"
#include <logd/config-logd.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configsubscriber.h>
+#include <vespa/config/subscription/configuri.h>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/vespalib/util/time.h>
diff --git a/logd/src/tests/watcher/watcher_test.cpp b/logd/src/tests/watcher/watcher_test.cpp
index f897ab32b5c..50c8f47a203 100644
--- a/logd/src/tests/watcher/watcher_test.cpp
+++ b/logd/src/tests/watcher/watcher_test.cpp
@@ -34,7 +34,7 @@ struct ConfigFixture {
const std::string configId;
LogdConfigBuilder logdBuilder;
ConfigSet set;
- IConfigContext::SP context;
+ std::shared_ptr<IConfigContext> context;
int idcounter;
ConfigFixture(const std::string & id);
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
index c76012d146a..b8e2a95783e 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
+++ b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
@@ -1,15 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "cf-handler.h"
-#include <cstdlib>
-#include <dirent.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <vespa/defaults.h>
#include <vespa/config/common/configsystem.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
+#include <dirent.h>
+#include <sys/stat.h>
#include <vespa/log/log.h>
LOG_SETUP(".cf-handler");
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.h b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.h
index 8e7196fb034..651b8d22fa8 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.h
+++ b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.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 <vespa/config/config.h>
-#include <vespa/config-logforwarder.h>
#include "child-handler.h"
+#include <vespa/config-logforwarder.h>
+#include <vespa/config/subscription/configsubscriber.h>
using cloud::config::LogforwarderConfig;
diff --git a/messagebus/src/tests/configagent/configagent.cpp b/messagebus/src/tests/configagent/configagent.cpp
index 32c28fd8c3d..06940c682f0 100644
--- a/messagebus/src/tests/configagent/configagent.cpp
+++ b/messagebus/src/tests/configagent/configagent.cpp
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
-#include <vespa/config/print/fileconfigreader.h>
#include <vespa/messagebus/configagent.h>
#include <vespa/messagebus/iconfighandler.h>
#include <vespa/messagebus/routing/routingspec.h>
#include <vespa/messagebus/config-messagebus.h>
+#include <vespa/config/print/fileconfigreader.hpp>
using namespace mbus;
using namespace messagebus;
diff --git a/messagebus/src/tests/routingspec/routingspec.cpp b/messagebus/src/tests/routingspec/routingspec.cpp
index 0079c7c8673..c3e6754ee7d 100644
--- a/messagebus/src/tests/routingspec/routingspec.cpp
+++ b/messagebus/src/tests/routingspec/routingspec.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/config/config.h>
#include <vespa/messagebus/configagent.h>
#include <vespa/messagebus/iconfighandler.h>
#include <vespa/messagebus/routing/routingspec.h>
diff --git a/messagebus/src/vespa/messagebus/configagent.h b/messagebus/src/vespa/messagebus/configagent.h
index c7327b60527..84bf18aab99 100644
--- a/messagebus/src/vespa/messagebus/configagent.h
+++ b/messagebus/src/vespa/messagebus/configagent.h
@@ -2,7 +2,6 @@
#pragma once
-#include <memory>
#include <vespa/messagebus/common.h>
#include <vespa/config/helper/configfetcher.h>
#include <vespa/messagebus/config-messagebus.h>
diff --git a/messagebus/src/vespa/messagebus/rpcmessagebus.cpp b/messagebus/src/vespa/messagebus/rpcmessagebus.cpp
index 0700415e691..a79171f5af2 100644
--- a/messagebus/src/vespa/messagebus/rpcmessagebus.cpp
+++ b/messagebus/src/vespa/messagebus/rpcmessagebus.cpp
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "rpcmessagebus.h"
#include <vespa/messagebus/network/rpcnetworkparams.h>
-#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
namespace mbus {
diff --git a/messagebus/src/vespa/messagebus/rpcmessagebus.h b/messagebus/src/vespa/messagebus/rpcmessagebus.h
index 822677e48e6..ed4258bef2d 100644
--- a/messagebus/src/vespa/messagebus/rpcmessagebus.h
+++ b/messagebus/src/vespa/messagebus/rpcmessagebus.h
@@ -5,7 +5,6 @@
#include "configagent.h"
#include "protocolset.h"
#include <vespa/messagebus/network/rpcnetwork.h>
-#include <vespa/config/helper/legacysubscriber.h>
namespace config {class ConfigUri; }
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp
index 6336672ac08..2fd09094f4c 100644
--- a/metrics/src/vespa/metrics/metricmanager.cpp
+++ b/metrics/src/vespa/metrics/metricmanager.cpp
@@ -11,8 +11,9 @@
#include <vespa/vespalib/util/time.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/hashtable.hpp>
+#include <vespa/config/subscription/configsubscriber.hpp>
+#include <set>
#include <sstream>
-#include <algorithm>
#include <cassert>
#include <vespa/log/bufferedlogger.h>
@@ -160,8 +161,7 @@ MetricManager::isInitialized() const {
}
void
-MetricManager::init(const config::ConfigUri & uri, FastOS_ThreadPool& pool,
- bool startThread)
+MetricManager::init(const config::ConfigUri & uri, FastOS_ThreadPool& pool, bool startThread)
{
if (isInitialized()) {
throw vespalib::IllegalStateException(
@@ -452,7 +452,7 @@ MetricManager::createSnapshotPeriods(const Config& config)
void
MetricManager::configure(const MetricLockGuard & , std::unique_ptr<Config> config)
{
- assert(config.get() != 0);
+ assert(config);
if (LOG_WOULD_LOG(debug)) {
std::ostringstream ost;
config::OstreamConfigWriter w(ost);
diff --git a/metrics/src/vespa/metrics/metricmanager.h b/metrics/src/vespa/metrics/metricmanager.h
index 300604d1f9f..0efbe1b091a 100644
--- a/metrics/src/vespa/metrics/metricmanager.h
+++ b/metrics/src/vespa/metrics/metricmanager.h
@@ -43,7 +43,6 @@
*/
#pragma once
-#include <vespa/metrics/config-metricsmanager.h>
#include "metricset.h"
#include "metricsnapshot.h"
#include "memoryconsumption.h"
@@ -52,7 +51,9 @@
#include <vespa/vespalib/stllike/hash_set.h>
#include <vespa/vespalib/util/document_runnable.h>
#include <vespa/vespalib/util/jsonwriter.h>
-#include <vespa/config/config.h>
+#include <vespa/metrics/config-metricsmanager.h>
+#include <vespa/config/subscription/configsubscriber.h>
+#include <vespa/config/subscription/configuri.h>
#include <map>
#include <list>
@@ -96,7 +97,7 @@ public:
private:
MetricSnapshot _activeMetrics;
std::unique_ptr<config::ConfigSubscriber> _configSubscriber;
- config::ConfigHandle<MetricsmanagerConfig>::UP _configHandle;
+ std::unique_ptr<config::ConfigHandle<MetricsmanagerConfig>> _configHandle;
std::unique_ptr<MetricsmanagerConfig> _config;
std::map<Metric::String, ConsumerSpec::SP> _consumerConfig;
std::list<UpdateHook*> _periodicUpdateHooks;
diff --git a/searchcommon/src/vespa/searchcommon/config/subscriptionproxyng.h b/searchcommon/src/vespa/searchcommon/config/subscriptionproxyng.h
index 7683ca771b8..dd24480f689 100644
--- a/searchcommon/src/vespa/searchcommon/config/subscriptionproxyng.h
+++ b/searchcommon/src/vespa/searchcommon/config/subscriptionproxyng.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/config/helper/legacysubscriber.h>
-#include <vespa/vespalib/stllike/string.h>
+#include <vespa/config/helper/legacysubscriber.hpp>
namespace search {
@@ -14,7 +13,7 @@ class SubscriptionProxyNg : public config::IFetcherCallback<CFG>
private:
ME &_target;
Method _method;
- config::LegacySubscriber *_subscriber;
+ std::unique_ptr<config::LegacySubscriber> _subscriber;
vespalib::string _cfgId;
SubscriptionProxyNg(const SubscriptionProxyNg&);
@@ -24,7 +23,7 @@ public:
SubscriptionProxyNg(ME &target, Method method)
: _target(target),
_method(method),
- _subscriber(NULL),
+ _subscriber(),
_cfgId("")
{
}
@@ -35,26 +34,25 @@ public:
return _cfgId.c_str();
}
void subscribe(const char *configId) {
- if (_subscriber != NULL) {
- if (configId != NULL && strcmp(configId, _subscriber->id().c_str()) == 0)
+ if (_subscriber) {
+ if (configId != nullptr && strcmp(configId, _subscriber->id().c_str()) == 0)
{
return; // same id; ignore
} else {
unsubscribe();
}
}
- if (configId != NULL && configId[0] != '\0') {
+ if (configId != nullptr && configId[0] != '\0') {
_cfgId = configId;
- _subscriber = new config::LegacySubscriber();
+ _subscriber = std::make_unique<config::LegacySubscriber>();
_subscriber->subscribe<CFG>(configId, this);
}
}
void unsubscribe() {
- delete _subscriber;
- _subscriber = NULL;
+ _subscriber.reset();
_cfgId = "";
}
- virtual void configure(std::unique_ptr<CFG> cfg) override {
+ void configure(std::unique_ptr<CFG> cfg) override {
(_target.*_method)(*cfg);
}
};
diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp
index 385d0eb363e..483cc3f2792 100644
--- a/searchcore/src/apps/tests/persistenceconformance_test.cpp
+++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp
@@ -39,6 +39,7 @@
#include <vespa/searchsummary/config/config-juniperrc.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/size_literals.h>
+#include <vespa/config/subscription/sourcespec.h>
#include <vespa/log/log.h>
LOG_SETUP("persistenceconformance_test");
@@ -199,7 +200,7 @@ public:
fileCfg.saveConfig(*snapshot, 1);
}
config::DirSpec spec(inputCfg + "/config-1");
- TuneFileDocumentDB::SP tuneFileDocDB(new TuneFileDocumentDB());
+ auto tuneFileDocDB = std::make_shared<TuneFileDocumentDB>();
DocumentDBConfigHelper mgr(spec, docType.getName());
auto b = std::make_shared<BootstrapConfig>(1, factory.getTypeCfg(), factory.getTypeRepo(),
make_proton_config(),
diff --git a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp
index a52c9ec2fb6..5ec1794c1b0 100644
--- a/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp
+++ b/searchcore/src/apps/verify_ranksetup/verify_ranksetup.cpp
@@ -4,7 +4,6 @@
#include <vespa/config-attributes.h>
#include <vespa/config-indexschema.h>
#include <vespa/config-rank-profiles.h>
-#include <vespa/config/config.h>
#include <vespa/config/helper/legacy.h>
#include <vespa/config/common/configcontext.h>
#include <vespa/config/common/exceptions.h>
@@ -21,6 +20,7 @@
#include <vespa/searchlib/features/setup.h>
#include <vespa/searchlib/fef/fef.h>
#include <vespa/searchlib/fef/test/plugin/setup.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/fastos/app.h>
#include <optional>
diff --git a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp
index 9819a1d50af..9f6254f9baa 100644
--- a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp
+++ b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp
@@ -1,13 +1,11 @@
// 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/print/fileconfigwriter.h>
#include <vespa/document/config/config-documenttypes.h>
#include <vespa/document/document.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/documentapi/documentapi.h>
#include <vespa/messagebus/destinationsession.h>
-#include <vespa/messagebus/protocolset.h>
#include <vespa/messagebus/rpcmessagebus.h>
#include <vespa/messagebus/network/rpcnetworkparams.h>
#include <vespa/vespalib/io/fileutil.h>
diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
index 1851455e321..b9e3549053a 100644
--- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp
@@ -35,6 +35,7 @@
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
+#include <vespa/config/subscription/sourcespec.h>
using namespace cloud::config::filedistribution;
using namespace document;
diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp
index 77f7cf4d8ed..7ba3e0b8240 100644
--- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp
@@ -6,7 +6,6 @@
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_bucket_space.h>
-#include <vespa/fastos/file.h>
#include <vespa/persistence/dummyimpl/dummy_bucket_executor.h>
#include <vespa/searchcore/proton/attribute/flushableattribute.h>
#include <vespa/searchcore/proton/common/statusreport.h>
@@ -35,6 +34,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/size_literals.h>
+#include <vespa/config/subscription/sourcespec.h>
#include <iostream>
using namespace cloud::config::filedistribution;
diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
index 6d3eaa30263..3c9e9fc3a64 100644
--- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
+++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp
@@ -69,7 +69,7 @@ struct ConfigTestFixture {
BucketspacesConfigBuilder bucketspacesBuilder;
map<std::string, DoctypeFixture::UP> dbConfig;
ConfigSet set;
- IConfigContext::SP context;
+ std::shared_ptr<IConfigContext> context;
int idcounter;
ConfigTestFixture(const std::string & id)
diff --git a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp
index aa819d08b58..85f8e8171a8 100644
--- a/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp
+++ b/searchcore/src/tests/proton/proton_configurer/proton_configurer_test.cpp
@@ -7,12 +7,12 @@
#include <vespa/config-rank-profiles.h>
#include <vespa/config-summary.h>
#include <vespa/config-summarymap.h>
+#include <vespa/config-bucketspaces.h>
#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/fileacquirer/config-filedistributorrpc.h>
#include <vespa/searchcore/proton/common/alloc_config.h>
#include <vespa/searchcore/proton/server/bootstrapconfig.h>
-#include <vespa/searchcore/proton/server/bootstrapconfigmanager.h>
#include <vespa/searchcore/proton/server/documentdbconfigmanager.h>
#include <vespa/searchcore/proton/server/document_db_config_owner.h>
#include <vespa/searchcore/proton/server/proton_config_snapshot.h>
@@ -21,14 +21,12 @@
#include <vespa/searchcore/proton/server/i_proton_disk_layout.h>
#include <vespa/searchcore/proton/server/threading_service_config.h>
#include <vespa/searchsummary/config/config-juniperrc.h>
-#include <vespa/searchcore/config/config-ranking-constants.h>
-#include <vespa/searchcore/config/config-onnx-models.h>
-#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/searchcommon/common/schemaconfigurer.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/test/insertion_operators.h>
-#include <vespa/config-bucketspaces.h>
+#include <vespa/config/subscription/configuri.h>
+#include <vespa/vespalib/gtest/gtest.h>
using namespace config;
using namespace proton;
diff --git a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
index c21bb0866cf..6d69c884c90 100644
--- a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
@@ -1,15 +1,17 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "hw_info_sampler.h"
-#include <vespa/config/config.h>
#include <vespa/config/print/fileconfigwriter.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/fastos/file.h>
#include <vespa/searchcore/config/config-hwinfo.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/time.h>
#include <vespa/vespalib/util/size_literals.h>
+#include <vespa/vespalib/util/alloc.h>
#include <filesystem>
#include <thread>
+
#include <vespa/log/log.h>
LOG_SETUP(".proton.common.hw_info_sampler");
@@ -55,7 +57,8 @@ sampleCpuCores(const HwInfoSampler::Config &cfg)
return std::thread::hardware_concurrency();
}
-std::unique_ptr<HwinfoConfig> readConfig(const vespalib::string &path) {
+std::unique_ptr<HwinfoConfig>
+readConfig(const vespalib::string &path) {
FileSpec spec(path + "/" + "hwinfo.cfg");
ConfigSubscriber s(spec);
std::unique_ptr<ConfigHandle<HwinfoConfig>> handle = s.subscribe<HwinfoConfig>("hwinfo");
diff --git a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp
index 8f99eb5e8a7..f0cb123b49f 100644
--- a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp
@@ -8,6 +8,7 @@
#include <vespa/config-bucketspaces.h>
#include <vespa/searchlib/common/tunefileinfo.hpp>
#include <vespa/vespalib/io/fileutil.h>
+#include <vespa/config/retriever/configsnapshot.hpp>
#include <cassert>
#include <vespa/log/log.h>
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp
index 06132803414..b7c319d46f5 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.cpp
@@ -14,6 +14,7 @@
#include <vespa/config-summarymap.h>
#include <vespa/config/file_acquirer/file_acquirer.h>
#include <vespa/config/common/configcontext.h>
+#include <vespa/config/retriever/configretriever.h>
#include <vespa/config/helper/legacy.h>
#include <vespa/config-attributes.h>
#include <vespa/config-indexschema.h>
@@ -23,6 +24,7 @@
#include <vespa/searchsummary/config/config-juniperrc.h>
#include <vespa/vespalib/time/time_box.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/config/retriever/configsnapshot.hpp>
#include <thread>
#include <cassert>
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h
index a3c29212c66..ad5959d551b 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdbconfigmanager.h
@@ -3,9 +3,12 @@
#pragma once
#include "documentdbconfig.h"
-#include <vespa/config/config.h>
#include <mutex>
+namespace config {
+ class ConfigRetriever;
+ class DirSpec;
+}
namespace proton {
class BootstrapConfig;
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h
index 56a4d1b8c9f..e6d036df7d9 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h
+++ b/searchcore/src/vespa/searchcore/proton/server/proton_config_fetcher.h
@@ -2,14 +2,13 @@
#pragma once
-#include <vespa/fastos/thread.h>
-#include <vespa/searchcore/proton/common/doctypename.h>
-#include <vespa/vespalib/stllike/string.h>
-#include <vespa/config/config.h>
#include "bootstrapconfigmanager.h"
#include "documentdbconfigmanager.h"
#include "i_document_db_config_owner.h"
-#include <chrono>
+#include <vespa/fastos/thread.h>
+#include <vespa/searchcore/proton/common/doctypename.h>
+#include <vespa/config/retriever/configretriever.h>
+#include <vespa/config/subscription/configuri.h>
namespace document { class DocumentTypeRepo; }
diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp
index 9ca3b678054..a9b0f96c4db 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp
+++ b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp
@@ -2,6 +2,7 @@
#include "translogserverapp.h"
#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <vespa/vespalib/util/time.h>
#include <vespa/log/log.h>
@@ -16,11 +17,11 @@ TransLogServerApp::TransLogServerApp(const config::ConfigUri & tlsConfigUri,
: _lock(),
_tls(),
_tlsConfig(),
- _tlsConfigFetcher(tlsConfigUri.getContext()),
+ _tlsConfigFetcher(std::make_unique<config::ConfigFetcher>(tlsConfigUri.getContext())),
_fileHeaderContext(fileHeaderContext)
{
- _tlsConfigFetcher.subscribe<searchlib::TranslogserverConfig>(tlsConfigUri.getConfigId(), this);
- _tlsConfigFetcher.start();
+ _tlsConfigFetcher->subscribe<searchlib::TranslogserverConfig>(tlsConfigUri.getConfigId(), this);
+ _tlsConfigFetcher->start();
}
namespace {
@@ -93,7 +94,7 @@ TransLogServerApp::start()
TransLogServerApp::~TransLogServerApp()
{
- _tlsConfigFetcher.close();
+ _tlsConfigFetcher->close();
}
void
diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h
index 7c3ebdcf22c..c5854958b9e 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h
+++ b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h
@@ -3,10 +3,13 @@
#include "translogserver.h"
#include <vespa/searchlib/config/config-translogserver.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/vespalib/util/ptrholder.h>
-namespace config { class ConfigUri; }
+namespace config {
+ class ConfigFetcher;
+ class ConfigUri;
+}
namespace search::common { class FileHeaderContext; }
namespace search::transactionlog {
@@ -17,7 +20,7 @@ private:
mutable std::mutex _lock;
TransLogServer::SP _tls;
vespalib::PtrHolder<searchlib::TranslogserverConfig> _tlsConfig;
- config::ConfigFetcher _tlsConfigFetcher;
+ std::unique_ptr<config::ConfigFetcher> _tlsConfigFetcher;
const common::FileHeaderContext & _fileHeaderContext;
void configure(std::unique_ptr<searchlib::TranslogserverConfig> cfg) override ;
diff --git a/slobrok/src/tests/configure/configure.cpp b/slobrok/src/tests/configure/configure.cpp
index 77705864f80..295906fe8c1 100644
--- a/slobrok/src/tests/configure/configure.cpp
+++ b/slobrok/src/tests/configure/configure.cpp
@@ -4,7 +4,6 @@
#include <vespa/slobrok/sbmirror.h>
#include <vespa/slobrok/sbregister.h>
#include <vespa/slobrok/server/slobrokserver.h>
-#include <vespa/config/config.h>
#include <vespa/config/common/configcontext.h>
#include <vespa/config-slobroks.h>
#include <vespa/fnet/transport.h>
diff --git a/slobrok/src/vespa/slobrok/cfg.cpp b/slobrok/src/vespa/slobrok/cfg.cpp
index 557e94d56d8..12e41bac4fc 100644
--- a/slobrok/src/vespa/slobrok/cfg.cpp
+++ b/slobrok/src/vespa/slobrok/cfg.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "cfg.h"
+#include <vespa/config/subscription/configsubscriber.hpp>
namespace slobrok {
@@ -21,7 +22,7 @@ extract(const cloud::config::SlobroksConfig &cfg)
bool
Configurator::poll()
{
- bool retval = _subscriber.nextGenerationNow();
+ bool retval = _subscriber->nextGenerationNow();
if (retval) {
std::unique_ptr<cloud::config::SlobroksConfig> cfg = _handle->getConfig();
_target.setup(extract(*cfg));
@@ -31,12 +32,21 @@ Configurator::poll()
Configurator::Configurator(Configurable& target, const config::ConfigUri & uri)
- : _subscriber(uri.getContext()),
- _handle(_subscriber.subscribe<cloud::config::SlobroksConfig>(uri.getConfigId())),
+ : _subscriber(std::make_unique<config::ConfigSubscriber>(uri.getContext())),
+ _handle(_subscriber->subscribe<cloud::config::SlobroksConfig>(uri.getConfigId())),
_target(target)
{
}
+Configurator::~Configurator() = default;
+
+
+int64_t
+Configurator::getGeneration() const {
+ return _subscriber->getGeneration();
+}
+
+
ConfiguratorFactory::ConfiguratorFactory(const config::ConfigUri& uri)
: _uri(uri)
{
diff --git a/slobrok/src/vespa/slobrok/cfg.h b/slobrok/src/vespa/slobrok/cfg.h
index d3150a6f941..bd7bffe1d15 100644
--- a/slobrok/src/vespa/slobrok/cfg.h
+++ b/slobrok/src/vespa/slobrok/cfg.h
@@ -3,8 +3,12 @@
#include <vespa/vespalib/util/ptrholder.h>
#include <vespa/config-slobroks.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/subscription/confighandle.h>
+namespace config {
+ class ConfigSubscriber;
+}
namespace slobrok {
class Configurable {
@@ -16,15 +20,16 @@ public:
class Configurator {
private:
- config::ConfigSubscriber _subscriber;
- config::ConfigHandle<cloud::config::SlobroksConfig>::UP _handle;
+ std::unique_ptr<config::ConfigSubscriber> _subscriber;
+ std::unique_ptr<config::ConfigHandle<cloud::config::SlobroksConfig>> _handle;
Configurable &_target;
public:
Configurator(Configurable &target, const config::ConfigUri & uri);
+ ~Configurator();
bool poll();
typedef std::unique_ptr<Configurator> UP;
- int64_t getGeneration() const { return _subscriber.getGeneration(); }
+ int64_t getGeneration() const;
};
class ConfiguratorFactory {
diff --git a/slobrok/src/vespa/slobrok/server/configshim.cpp b/slobrok/src/vespa/slobrok/server/configshim.cpp
index d6922685009..cc4892e616c 100644
--- a/slobrok/src/vespa/slobrok/server/configshim.cpp
+++ b/slobrok/src/vespa/slobrok/server/configshim.cpp
@@ -18,11 +18,11 @@ ConfigShim::ConfigShim(uint32_t port, const std::string& cfgId)
_factory(config::ConfigUri(_configId))
{}
-ConfigShim::ConfigShim(uint32_t port, const std::string& cfgId, config::IConfigContext::SP cfgCtx)
+ConfigShim::ConfigShim(uint32_t port, const std::string& cfgId, std::shared_ptr<config::IConfigContext> cfgCtx)
: _port(port),
_enableStateServer(false),
_configId(cfgId),
- _factory(config::ConfigUri(cfgId, cfgCtx))
+ _factory(config::ConfigUri(cfgId, std::move(cfgCtx)))
{}
ConfigShim::~ConfigShim() = default;
diff --git a/slobrok/src/vespa/slobrok/server/configshim.h b/slobrok/src/vespa/slobrok/server/configshim.h
index aebbe2dece4..f31eeb5c463 100644
--- a/slobrok/src/vespa/slobrok/server/configshim.h
+++ b/slobrok/src/vespa/slobrok/server/configshim.h
@@ -17,7 +17,7 @@ private:
public:
ConfigShim(uint32_t port);
ConfigShim(uint32_t port, const std::string& cfgId);
- ConfigShim(uint32_t port, const std::string& cfgId, config::IConfigContext::SP cfgCtx);
+ ConfigShim(uint32_t port, const std::string& cfgId, std::shared_ptr<config::IConfigContext> cfgCtx);
~ConfigShim();
ConfigShim & enableStateServer(bool v) { _enableStateServer = v; return *this; }
diff --git a/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp b/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp
index f2ebc7ce78d..1bf6596744d 100644
--- a/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp
+++ b/slobrok/src/vespa/slobrok/server/reconfigurable_stateserver.cpp
@@ -3,11 +3,10 @@
#include "reconfigurable_stateserver.h"
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/net/state_server.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <thread>
#include <vespa/log/log.h>
-#include <vespa/config/common/exceptions.h>
-
LOG_SETUP(".slobrok.server.reconfigurable_stateserver");
using namespace std::chrono_literals;
diff --git a/slobrok/src/vespa/slobrok/server/sbenv.h b/slobrok/src/vespa/slobrok/server/sbenv.h
index a27680365a0..644344285ad 100644
--- a/slobrok/src/vespa/slobrok/server/sbenv.h
+++ b/slobrok/src/vespa/slobrok/server/sbenv.h
@@ -39,9 +39,9 @@ private:
std::unique_ptr<FNET_Transport> _transport;
std::unique_ptr<FRT_Supervisor> _supervisor;
- ConfigShim _configShim;
- Configurator::UP _configurator;
- bool _shuttingDown;
+ ConfigShim _configShim;
+ std::unique_ptr<Configurator> _configurator;
+ bool _shuttingDown;
SBEnv(const SBEnv &); // Not used
SBEnv &operator=(const SBEnv &); // Not used
diff --git a/staging_vespalib/src/tests/json/json.cpp b/staging_vespalib/src/tests/json/json.cpp
index 15bb841b8ca..1a707ae1776 100644
--- a/staging_vespalib/src/tests/json/json.cpp
+++ b/staging_vespalib/src/tests/json/json.cpp
@@ -358,7 +358,7 @@ JSONTest::testJsonStreamErrors()
try{
vespalib::asciistream as;
vespalib::JsonStream stream(as);
- stream << Object() << Array();
+ stream << Object() << jsonstream::Array();
} catch (vespalib::JsonStreamException& e) {
EXPECT_EQUAL("Invalid state on call: An array value cannot be an object key ({}(ObjectExpectingKey))", e.getReason());
}
@@ -423,7 +423,7 @@ JSONTest::testJsonStreamErrors()
try{
vespalib::asciistream as;
vespalib::JsonStream stream(as);
- stream << Object() << End() << Array();
+ stream << Object() << End() << jsonstream::Array();
} catch (vespalib::JsonStreamException& e) {
EXPECT_EQUAL("Invalid state on call: Stream already finalized. Can't start a new array. (Finalized)", e.getReason());
}
@@ -442,7 +442,7 @@ JSONTest::testJsonStreamStateReporting()
using namespace vespalib::jsonstream;
vespalib::asciistream as;
vespalib::JsonStream stream(as);
- stream << Array() << 13
+ stream << jsonstream::Array() << 13
<< "foo"
<< Object() << "key" << "value" << End()
<< false
diff --git a/storage/src/tests/common/global_bucket_space_distribution_converter_test.cpp b/storage/src/tests/common/global_bucket_space_distribution_converter_test.cpp
index 23a0df81bab..cd70aecd1bb 100644
--- a/storage/src/tests/common/global_bucket_space_distribution_converter_test.cpp
+++ b/storage/src/tests/common/global_bucket_space_distribution_converter_test.cpp
@@ -2,7 +2,6 @@
#include <vespa/storage/common/global_bucket_space_distribution_converter.h>
#include <vespa/vdslib/distribution/distribution.h>
-#include <vespa/config/config.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vespalib/gtest/gtest.h>
diff --git a/storage/src/tests/common/teststorageapp.cpp b/storage/src/tests/common/teststorageapp.cpp
index 7a19e84791d..91fdf5aa602 100644
--- a/storage/src/tests/common/teststorageapp.cpp
+++ b/storage/src/tests/common/teststorageapp.cpp
@@ -4,14 +4,13 @@
#include <vespa/storage/common/content_bucket_db_options.h>
#include <vespa/storage/config/config-stor-server.h>
#include <vespa/config-stor-distribution.h>
-#include <vespa/config-load-type.h>
#include <vespa/config-fleetcontroller.h>
#include <vespa/persistence/dummyimpl/dummypersistence.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/time.h>
-#include <vespa/config/config.h>
+#include <vespa/config/subscription/configuri.h>
#include <vespa/config/helper/configgetter.hpp>
#include <thread>
#include <sstream>
diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp
index b02395717e0..53773a55826 100644
--- a/storage/src/tests/distributor/putoperationtest.cpp
+++ b/storage/src/tests/distributor/putoperationtest.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <tests/distributor/distributor_stripe_test_util.h>
-#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/storage/distributor/top_level_distributor.h>
@@ -13,6 +12,7 @@
#include <vespa/storageapi/message/state.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/text/stringtokenizer.h>
+#include <vespa/config/helper/configgetter.h>
using std::shared_ptr;
using config::ConfigGetter;
diff --git a/storage/src/tests/frameworkimpl/status/statustest.cpp b/storage/src/tests/frameworkimpl/status/statustest.cpp
index 2e136977026..97bfa41aece 100644
--- a/storage/src/tests/frameworkimpl/status/statustest.cpp
+++ b/storage/src/tests/frameworkimpl/status/statustest.cpp
@@ -2,7 +2,6 @@
#include <vespa/storageframework/defaultimplementation/component/componentregisterimpl.h>
#include <vespa/storage/frameworkimpl/status/statuswebserver.h>
-#include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h>
#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
#include <vespa/storageframework/generic/status/xmlstatusreporter.h>
#include <tests/common/teststorageapp.h>
@@ -10,6 +9,7 @@
#include <vespa/vespalib/net/crypto_engine.h>
#include <vespa/vespalib/net/socket_spec.h>
#include <vespa/vespalib/net/sync_crypto_socket.h>
+#include <vespa/config/subscription/configuri.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <gmock/gmock.h>
diff --git a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
index 9edac8d79ff..73ddeeb888b 100644
--- a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
+++ b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
@@ -18,7 +18,6 @@
#include <vespa/storageapi/message/stat.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include <vespa/config/config.h>
#include <vespa/config/helper/configgetter.hpp>
#include <chrono>
#include <thread>
diff --git a/storage/src/vespa/storage/common/global_bucket_space_distribution_converter.cpp b/storage/src/vespa/storage/common/global_bucket_space_distribution_converter.cpp
index 9f9bbf4992e..a8c6bf6529c 100644
--- a/storage/src/vespa/storage/common/global_bucket_space_distribution_converter.cpp
+++ b/storage/src/vespa/storage/common/global_bucket_space_distribution_converter.cpp
@@ -2,9 +2,8 @@
#include "global_bucket_space_distribution_converter.h"
#include <vespa/vdslib/distribution/distribution.h>
-#include <vespa/config/config.h>
#include <vespa/config/print/asciiconfigwriter.h>
-#include <vespa/config/print/asciiconfigreader.h>
+#include <vespa/config/print/asciiconfigreader.hpp>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vdslib/distribution/distribution_config_util.h>
#include <vespa/vespalib/stllike/asciistream.h>
diff --git a/storage/src/vespa/storage/distributor/distributor_stripe.h b/storage/src/vespa/storage/distributor/distributor_stripe.h
index 809b4dd0e41..49b062d6cc1 100644
--- a/storage/src/vespa/storage/distributor/distributor_stripe.h
+++ b/storage/src/vespa/storage/distributor/distributor_stripe.h
@@ -13,7 +13,6 @@
#include "stripe_access_guard.h"
#include "stripe_bucket_db_updater.h"
#include "tickable_stripe.h"
-#include <vespa/config/config.h>
#include <vespa/storage/common/doneinitializehandler.h>
#include <vespa/storage/common/messagesender.h>
#include <vespa/storage/distributor/bucketdb/bucketdbmetricupdater.h>
diff --git a/storage/src/vespa/storage/distributor/statecheckers.cpp b/storage/src/vespa/storage/distributor/statecheckers.cpp
index a2069219d5d..d400151b349 100644
--- a/storage/src/vespa/storage/distributor/statecheckers.cpp
+++ b/storage/src/vespa/storage/distributor/statecheckers.cpp
@@ -656,6 +656,10 @@ public:
addNode(entry->getNodeRef(i).getNode());
}
}
+ MergeNodes(MergeNodes && rhs) noexcept = default;
+ MergeNodes & operator =(MergeNodes && rhs) noexcept = delete;
+ MergeNodes(const MergeNodes & rhs) = delete;
+ MergeNodes & operator =(const MergeNodes & rhs) = delete;
~MergeNodes();
diff --git a/storage/src/vespa/storage/distributor/top_level_distributor.h b/storage/src/vespa/storage/distributor/top_level_distributor.h
index 64e431c9d4e..20a61acfa37 100644
--- a/storage/src/vespa/storage/distributor/top_level_distributor.h
+++ b/storage/src/vespa/storage/distributor/top_level_distributor.h
@@ -17,7 +17,6 @@
#include "statusreporterdelegate.h"
#include "stripe_bucket_db_updater.h" // TODO this is temporary
#include "stripe_host_info_notifier.h"
-#include <vespa/config/config.h>
#include <vespa/storage/common/distributorcomponent.h>
#include <vespa/storage/common/doneinitializehandler.h>
#include <vespa/storage/common/messagesender.h>
diff --git a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
index 45dd44d0245..a9b7a727a5b 100644
--- a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
+++ b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
@@ -7,6 +7,8 @@
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/component/vtag.h>
#include <vespa/vespalib/net/crypto_engine.h>
+#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <functional>
#include <vespa/log/log.h>
@@ -21,17 +23,17 @@ StatusWebServer::StatusWebServer(
: _reporterMap(reporterMap),
_port(0),
_httpServer(),
- _configFetcher(configUri.getContext()),
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
_component(std::make_unique<framework::Component>(componentRegister, "Status"))
{
- _configFetcher.subscribe<vespa::config::content::core::StorStatusConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<vespa::config::content::core::StorStatusConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
}
StatusWebServer::~StatusWebServer()
{
// Avoid getting config during shutdown
- _configFetcher.close();
+ _configFetcher->close();
if (_httpServer) {
LOG(debug, "Shutting down status web server on port %u", _httpServer->getListenPort());
diff --git a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h
index f4bf2534036..429f5249441 100644
--- a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h
+++ b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.h
@@ -12,12 +12,15 @@
#include <vespa/storage/config/config-stor-status.h>
#include <vespa/storageframework/generic/thread/runnable.h>
-#include <vespa/config/config.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/vespalib/portal/portal.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <list>
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace storage {
namespace framework {
@@ -28,6 +31,7 @@ namespace framework {
class HttpUrlPath;
class Component;
}
+
class StatusWebServer : private config::IFetcherCallback<vespa::config::content::core::StorStatusConfig>
{
class WebServer : public vespalib::Portal::GetHandler {
@@ -64,7 +68,7 @@ class StatusWebServer : private config::IFetcherCallback<vespa::config::content:
framework::StatusReporterMap& _reporterMap;
uint16_t _port;
std::unique_ptr<WebServer> _httpServer;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
std::unique_ptr<framework::Component> _component;
public:
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
index 0e511241d18..d5097f4f8e4 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
@@ -24,7 +24,8 @@
#include <vespa/vespalib/util/idestructorcallback.h>
#include <vespa/vespalib/util/sequencedtaskexecutor.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include <algorithm>
+#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <thread>
#include <vespa/log/bufferedlogger.h>
@@ -73,7 +74,7 @@ FileStorManager(const config::ConfigUri & configUri, spi::PersistenceProvider& p
_persistenceHandlers(),
_threads(),
_bucketOwnershipNotifier(std::make_unique<BucketOwnershipNotifier>(_component, *this)),
- _configFetcher(configUri.getContext()),
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
_use_async_message_handling_on_schedule(false),
_metrics(std::make_unique<FileStorMetrics>()),
_filestorHandler(),
@@ -83,8 +84,8 @@ FileStorManager(const config::ConfigUri & configUri, spi::PersistenceProvider& p
_host_info_reporter(_component.getStateUpdater()),
_resource_usage_listener_registration(provider.register_resource_usage_listener(_host_info_reporter))
{
- _configFetcher.subscribe(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe(configUri.getConfigId(), this);
+ _configFetcher->start();
_component.registerMetric(*_metrics);
_component.registerStatusPage(*this);
_component.getStateUpdater().addStateListener(*this);
@@ -851,7 +852,7 @@ void FileStorManager::onClose()
_bucketExecutorRegistration.reset();
_resource_usage_listener_registration.reset();
// Avoid getting config during shutdown
- _configFetcher.close();
+ _configFetcher->close();
LOG(debug, "Closed _configFetcher.");
_filestorHandler->close();
LOG(debug, "Closed _filestorHandler.");
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h
index b7450de13d8..83f1826c498 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.h
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.h
@@ -25,10 +25,12 @@
#include <vespa/storage/common/nodestateupdater.h>
#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
-#include <vespa/config/subscription/configuri.h>
#include <vespa/config/helper/ifetchercallback.h>
-#include <vespa/config/config.h>
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace vespalib { class IDestructorCallback; }
namespace storage {
@@ -68,7 +70,7 @@ class FileStorManager : public StorageLinkQueued,
std::unique_ptr<BucketOwnershipNotifier> _bucketOwnershipNotifier;
std::unique_ptr<vespa::config::content::StorFilestorConfig> _config;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
bool _use_async_message_handling_on_schedule;
std::shared_ptr<FileStorMetrics> _metrics;
std::unique_ptr<FileStorHandler> _filestorHandler;
diff --git a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
index 90f7f292a6d..040ace55c52 100644
--- a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
@@ -4,6 +4,8 @@
#include "filestormanager.h"
#include <vespa/persistence/spi/persistenceprovider.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <algorithm>
#include <vespa/log/log.h>
@@ -47,7 +49,7 @@ ModifiedBucketChecker::ModifiedBucketChecker(
_provider(provider),
_component(),
_thread(),
- _configFetcher(configUri.getContext()),
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
_monitor(),
_stateLock(),
_bucketSpaces(),
@@ -56,8 +58,8 @@ ModifiedBucketChecker::ModifiedBucketChecker(
_maxPendingChunkSize(100),
_singleThreadMode(false)
{
- _configFetcher.subscribe<vespa::config::content::core::StorServerConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<vespa::config::content::core::StorServerConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
std::ostringstream threadName;
threadName << "Modified bucket checker " << static_cast<void*>(this);
@@ -195,7 +197,7 @@ ModifiedBucketChecker::tick()
// Do two phases of locking, as we want tick() to both fetch modified
// buckets and send the first chunk for these in a single call. However,
// we want getModifiedBuckets() to called outside the lock.
- bool shouldRequestFromProvider = false;
+ bool shouldRequestFromProvider;
{
std::lock_guard guard(_stateLock);
if (!currentChunkFinished()) {
diff --git a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h
index 6a8b9e5c008..8c0b4084428 100644
--- a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h
+++ b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h
@@ -9,8 +9,12 @@
#include <vespa/storage/persistence/messages.h>
#include <vespa/storage/persistence/types.h>
#include <vespa/document/bucket/bucketidlist.h>
-#include <vespa/config/config.h>
+#include <vespa/config/helper/ifetchercallback.h>
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace storage {
namespace spi { struct PersistenceProvider; }
@@ -80,18 +84,18 @@ private:
void pop_back() { _buckets.pop_back(); }
};
- spi::PersistenceProvider& _provider;
- ServiceLayerComponent::UP _component;
- framework::Thread::UP _thread;
- config::ConfigFetcher _configFetcher;
- std::mutex _monitor;
- std::condition_variable _cond;
- std::mutex _stateLock;
- CyclicBucketSpaceIterator::UP _bucketSpaces;
- BucketIdListResult _rechecksNotStarted;
- size_t _pendingRequests;
- size_t _maxPendingChunkSize;
- bool _singleThreadMode; // For unit testing only
+ spi::PersistenceProvider & _provider;
+ ServiceLayerComponent::UP _component;
+ framework::Thread::UP _thread;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
+ std::mutex _monitor;
+ std::condition_variable _cond;
+ std::mutex _stateLock;
+ CyclicBucketSpaceIterator::UP _bucketSpaces;
+ BucketIdListResult _rechecksNotStarted;
+ size_t _pendingRequests;
+ size_t _maxPendingChunkSize;
+ bool _singleThreadMode; // For unit testing only
};
} // ns storage
diff --git a/storage/src/vespa/storage/storageserver/bouncer.cpp b/storage/src/vespa/storage/storageserver/bouncer.cpp
index ea14a1b7492..5241a1a88dd 100644
--- a/storage/src/vespa/storage/storageserver/bouncer.cpp
+++ b/storage/src/vespa/storage/storageserver/bouncer.cpp
@@ -9,6 +9,7 @@
#include <vespa/storageapi/message/state.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <sstream>
@@ -27,7 +28,7 @@ Bouncer::Bouncer(StorageComponentRegister& compReg, const config::ConfigUri & co
_baselineNodeState("s:i"),
_derivedNodeStates(),
_clusterState(&lib::State::UP),
- _configFetcher(configUri.getContext()),
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
_metrics(std::make_unique<BouncerMetrics>())
{
_component.getStateUpdater().addStateListener(*this);
@@ -36,8 +37,8 @@ Bouncer::Bouncer(StorageComponentRegister& compReg, const config::ConfigUri & co
// exception allowing program to continue if missing/faulty config.
try{
if (!configUri.empty()) {
- _configFetcher.subscribe<vespa::config::content::core::StorBouncerConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<vespa::config::content::core::StorBouncerConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
} else {
LOG(info, "No config id specified. Using defaults rather than "
"config");
@@ -66,7 +67,7 @@ Bouncer::print(std::ostream& out, bool verbose,
void
Bouncer::onClose()
{
- _configFetcher.close();
+ _configFetcher->close();
_component.getStateUpdater().removeStateListener(*this);
}
diff --git a/storage/src/vespa/storage/storageserver/bouncer.h b/storage/src/vespa/storage/storageserver/bouncer.h
index e6ddfe7ad49..50a08387b39 100644
--- a/storage/src/vespa/storage/storageserver/bouncer.h
+++ b/storage/src/vespa/storage/storageserver/bouncer.h
@@ -11,7 +11,7 @@
#pragma once
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/vdslib/state/nodestate.h>
#include <vespa/storage/common/nodestateupdater.h>
#include <vespa/storage/common/storagecomponent.h>
@@ -19,7 +19,10 @@
#include <vespa/storage/config/config-stor-bouncer.h>
#include <unordered_map>
-namespace config { class ConfigUri; }
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace storage {
@@ -36,7 +39,7 @@ class Bouncer : public StorageLink,
using BucketSpaceNodeStateMapping = std::unordered_map<document::BucketSpace, lib::NodeState, document::BucketSpace::hash>;
BucketSpaceNodeStateMapping _derivedNodeStates;
const lib::State* _clusterState;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
std::unique_ptr<BouncerMetrics> _metrics;
public:
@@ -47,36 +50,20 @@ public:
const std::string& indent) const override;
void configure(std::unique_ptr<vespa::config::content::core::StorBouncerConfig> config) override;
-
const BouncerMetrics& metrics() const noexcept;
private:
- void validateConfig(
- const vespa::config::content::core::StorBouncerConfig&) const;
-
+ void validateConfig(const vespa::config::content::core::StorBouncerConfig&) const;
void onClose() override;
-
- void abortCommandForUnavailableNode(api::StorageMessage&,
- const lib::State&);
-
- void rejectCommandWithTooHighClockSkew(api::StorageMessage& msg,
- int maxClockSkewInSeconds);
-
+ void abortCommandForUnavailableNode(api::StorageMessage&, const lib::State&);
+ void rejectCommandWithTooHighClockSkew(api::StorageMessage& msg, int maxClockSkewInSeconds);
void abortCommandDueToClusterDown(api::StorageMessage&);
-
- void rejectDueToInsufficientPriority(api::StorageMessage&,
- api::StorageMessage::Priority);
-
+ void rejectDueToInsufficientPriority(api::StorageMessage&, api::StorageMessage::Priority);
void reject_due_to_too_few_bucket_bits(api::StorageMessage&);
-
bool clusterIsUp() const;
-
bool isDistributor() const;
-
bool isExternalLoad(const api::MessageType&) const noexcept;
-
bool isExternalWriteOperation(const api::MessageType&) const noexcept;
-
bool priorityRejectionIsEnabled(int configuredPriority) const noexcept {
return (configuredPriority != -1);
}
@@ -86,12 +73,9 @@ private:
* update commands), return that timestamp. Otherwise, return 0.
*/
uint64_t extractMutationTimestampIfAny(const api::StorageMessage& msg);
-
bool onDown(const std::shared_ptr<api::StorageMessage>&) override;
-
void handleNewState() override;
const lib::NodeState &getDerivedNodeState(document::BucketSpace bucketSpace) const;
-
void append_node_identity(std::ostream& target_stream) const;
};
diff --git a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp
index ee58710e585..9d7dd95d922 100644
--- a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp
+++ b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.cpp
@@ -11,6 +11,9 @@
#include <vespa/storage/common/content_bucket_space_repo.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/metrics/metrictimer.h>
+#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
+
#include <vespa/log/bufferedlogger.h>
@@ -24,7 +27,7 @@ ChangedBucketOwnershipHandler::ChangedBucketOwnershipHandler(
: StorageLink("Changed bucket ownership handler"),
_component(compReg, "changedbucketownershiphandler"),
_metrics(),
- _configFetcher(configUri.getContext()),
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
_stateLock(),
_currentState(), // Not set yet, so ownership will not be valid
_currentOwnership(std::make_shared<OwnershipState>(
@@ -33,8 +36,8 @@ ChangedBucketOwnershipHandler::ChangedBucketOwnershipHandler(
_abortMutatingIdealStateOps(false),
_abortMutatingExternalLoadOps(false)
{
- _configFetcher.subscribe<vespa::config::content::PersistenceConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<vespa::config::content::PersistenceConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
_component.registerMetric(_metrics);
}
diff --git a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h
index ddf8516ed6e..e753d96871e 100644
--- a/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h
+++ b/storage/src/vespa/storage/storageserver/changedbucketownershiphandler.h
@@ -3,8 +3,8 @@
#include <vespa/document/bucket/bucketid.h>
#include <vespa/storage/common/storagelink.h>
-#include <vespa/config/config.h>
#include <vespa/config-persistence.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/storage/common/servicelayercomponent.h>
#include <vespa/storage/persistence/messages.h>
#include <vespa/metrics/valuemetric.h>
@@ -14,6 +14,10 @@
#include <vector>
#include <unordered_map>
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace storage {
namespace lib {
@@ -112,7 +116,7 @@ public:
private:
ServiceLayerComponent _component;
Metrics _metrics;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
mutable std::mutex _stateLock;
std::shared_ptr<const lib::ClusterStateBundle> _currentState;
OwnershipState::CSP _currentOwnership;
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
index 9b67830b3dc..237dc76d783 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
@@ -19,6 +19,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <string_view>
#include <vespa/log/bufferedlogger.h>
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.h b/storage/src/vespa/storage/storageserver/communicationmanager.h
index c899cee3e14..80117b32030 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.h
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.h
@@ -21,15 +21,18 @@
#include <vespa/storageapi/mbusprot/storagereply.h>
#include <vespa/messagebus/imessagehandler.h>
#include <vespa/messagebus/ireplyhandler.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/vespalib/util/document_runnable.h>
#include <vespa/config/subscription/configuri.h>
+#include <vespa/config-bucketspaces.h>
#include <map>
#include <queue>
#include <atomic>
#include <mutex>
-#include <vespa/config-bucketspaces.h>
+namespace config {
+ class ConfigFetcher;
+}
namespace mbus {
class RPCMessageBus;
class SourceSession;
diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.cpp b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
index 4b4ff6c7e37..28a76413149 100644
--- a/storage/src/vespa/storage/storageserver/mergethrottler.cpp
+++ b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
@@ -8,9 +8,10 @@
#include <vespa/messagebus/dynamicthrottlepolicy.h>
#include <vespa/messagebus/error.h>
#include <vespa/config/common/exceptions.h>
+#include <vespa/config/helper/configfetcher.hpp>
+#include <vespa/config/subscription/configuri.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include <algorithm>
#include <cassert>
#include <vespa/log/log.h>
@@ -185,7 +186,7 @@ MergeThrottler::MergeThrottler(
_queueSequence(0),
_messageLock(),
_stateLock(),
- _configFetcher(configUri.getContext()),
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
_metrics(std::make_unique<Metrics>()),
_component(compReg, "mergethrottler"),
_thread(),
@@ -198,8 +199,8 @@ MergeThrottler::MergeThrottler(
{
_throttlePolicy->setMinWindowSize(20);
_throttlePolicy->setMaxWindowSize(20);
- _configFetcher.subscribe<StorServerConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<StorServerConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
_component.registerStatusPage(*this);
_component.registerMetric(*_metrics);
}
@@ -271,7 +272,7 @@ void
MergeThrottler::onClose()
{
// Avoid getting config on shutdown
- _configFetcher.close();
+ _configFetcher->close();
{
std::lock_guard guard(_messageLock);
// Note: used to prevent taking locks in different order if onFlush
diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.h b/storage/src/vespa/storage/storageserver/mergethrottler.h
index b953595c91e..e501e0edd39 100644
--- a/storage/src/vespa/storage/storageserver/mergethrottler.h
+++ b/storage/src/vespa/storage/storageserver/mergethrottler.h
@@ -20,13 +20,15 @@
#include <vespa/metrics/countmetric.h>
#include <vespa/metrics/valuemetric.h>
#include <vespa/metrics/metrictimer.h>
-#include <vespa/config/config.h>
+#include <vespa/config/helper/ifetchercallback.h>
+
#include <chrono>
-namespace mbus {
-class DynamicThrottlePolicy;
+namespace mbus { class DynamicThrottlePolicy; }
+namespace config {
+ class ConfigFetcher;
+ class ConfigUri;
}
-
namespace storage {
class AbortBucketOperationsCommand;
@@ -170,7 +172,7 @@ private:
mutable std::mutex _messageLock;
std::condition_variable _messageCond;
mutable std::mutex _stateLock;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
// Messages pending to be processed by the worker thread
std::vector<api::StorageMessage::SP> _messagesDown;
std::vector<api::StorageMessage::SP> _messagesUp;
diff --git a/storage/src/vespa/storage/storageserver/opslogger.cpp b/storage/src/vespa/storage/storageserver/opslogger.cpp
index 244813775a1..03322cb55fd 100644
--- a/storage/src/vespa/storage/storageserver/opslogger.cpp
+++ b/storage/src/vespa/storage/storageserver/opslogger.cpp
@@ -2,6 +2,8 @@
#include "opslogger.h"
#include <vespa/storageapi/message/persistence.h>
+#include <vespa/config/helper/configfetcher.hpp>
+#include <vespa/config/subscription/configuri.h>
#include <sstream>
#include <vespa/log/log.h>
@@ -16,10 +18,10 @@ OpsLogger::OpsLogger(StorageComponentRegister& compReg,
_fileName(),
_targetFile(nullptr),
_component(compReg, "opslogger"),
- _configFetcher(configUri.getContext())
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext()))
{
- _configFetcher.subscribe<vespa::config::content::core::StorOpsloggerConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<vespa::config::content::core::StorOpsloggerConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
}
OpsLogger::~OpsLogger()
@@ -35,8 +37,8 @@ OpsLogger::~OpsLogger()
void
OpsLogger::onClose()
{
- // Avoid getting config during shutdown
- _configFetcher.close();
+ // Avoid getting config during shutdown
+ _configFetcher->close();
}
void
diff --git a/storage/src/vespa/storage/storageserver/opslogger.h b/storage/src/vespa/storage/storageserver/opslogger.h
index cf39f51279d..039cb72969e 100644
--- a/storage/src/vespa/storage/storageserver/opslogger.h
+++ b/storage/src/vespa/storage/storageserver/opslogger.h
@@ -13,7 +13,12 @@
#include <vespa/storageapi/messageapi/storagemessage.h>
#include <vespa/storageapi/message/state.h>
#include <vespa/storage/config/config-stor-opslogger.h>
-#include <vespa/config/config.h>
+#include <vespa/config/helper/ifetchercallback.h>
+
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace storage {
@@ -40,7 +45,7 @@ private:
FILE * _targetFile;
framework::Component _component;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
};
}
diff --git a/storage/src/vespa/storage/storageserver/priorityconverter.cpp b/storage/src/vespa/storage/storageserver/priorityconverter.cpp
index 1c11edea796..49297f216ca 100644
--- a/storage/src/vespa/storage/storageserver/priorityconverter.cpp
+++ b/storage/src/vespa/storage/storageserver/priorityconverter.cpp
@@ -1,16 +1,17 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "priorityconverter.h"
-#include <vespa/documentapi/messagebus/documentprotocol.h>
#include <vespa/config/subscription/configuri.h>
+#include <vespa/config/helper/configfetcher.hpp>
+
namespace storage {
PriorityConverter::PriorityConverter(const config::ConfigUri & configUri)
- : _configFetcher(configUri.getContext())
+ : _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext()))
{
- _configFetcher.subscribe<vespa::config::content::core::StorPrioritymappingConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<vespa::config::content::core::StorPrioritymappingConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
}
PriorityConverter::~PriorityConverter() = default;
diff --git a/storage/src/vespa/storage/storageserver/priorityconverter.h b/storage/src/vespa/storage/storageserver/priorityconverter.h
index 0dcd66645cb..b1f774e4ff2 100644
--- a/storage/src/vespa/storage/storageserver/priorityconverter.h
+++ b/storage/src/vespa/storage/storageserver/priorityconverter.h
@@ -3,13 +3,16 @@
#pragma once
#include <vespa/storage/config/config-stor-prioritymapping.h>
-#include <vespa/config/helper/configfetcher.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/documentapi/messagebus/priority.h>
#include <atomic>
#include <array>
#include <mutex>
-namespace config {class ConfigUri; }
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
namespace storage {
@@ -42,7 +45,7 @@ private:
std::map<uint8_t, documentapi::Priority::Value> _reverseMapping;
mutable std::mutex _mutex;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
};
} // storage
diff --git a/storage/src/vespa/storage/storageserver/servicelayernode.h b/storage/src/vespa/storage/storageserver/servicelayernode.h
index 8f36e1d8748..f0189f943ab 100644
--- a/storage/src/vespa/storage/storageserver/servicelayernode.h
+++ b/storage/src/vespa/storage/storageserver/servicelayernode.h
@@ -13,7 +13,6 @@
#include "storagenode.h"
#include <vespa/storage/visiting/visitormessagesessionfactory.h>
#include <vespa/storage/common/visitorfactory.h>
-#include <vespa/config/config.h>
namespace storage {
diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp
index c19fca8c58c..34db3b102e7 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.cpp
+++ b/storage/src/vespa/storage/storageserver/storagenode.cpp
@@ -14,6 +14,7 @@
#include <vespa/storage/common/storage_chain_builder.h>
#include <vespa/storage/frameworkimpl/status/statuswebserver.h>
#include <vespa/storage/frameworkimpl/thread/deadlockdetector.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/exceptions.h>
diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h
index c49737af78b..2e13c0e24c0 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.h
+++ b/storage/src/vespa/storage/storageserver/storagenode.h
@@ -14,7 +14,6 @@
#include <vespa/config-stor-distribution.h>
#include <vespa/config-upgrading.h>
-#include <vespa/config/helper/configfetcher.h>
#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/config/subscription/configuri.h>
#include <vespa/document/config/config-documenttypes.h>
@@ -27,6 +26,7 @@
#include <mutex>
namespace document { class DocumentTypeRepo; }
+namespace config { class ConfigFetcher; }
namespace storage {
@@ -35,7 +35,6 @@ class CommunicationManager;
class FileStorManager;
class HostInfo;
class IStorageChainBuilder;
-class MemoryStatusViewer;
class NodeIdentity;
class StateManager;
class StateReporter;
diff --git a/storage/src/vespa/storage/tools/getidealstate.cpp b/storage/src/vespa/storage/tools/getidealstate.cpp
index 5b17fa63b5a..8b120924aaa 100644
--- a/storage/src/vespa/storage/tools/getidealstate.cpp
+++ b/storage/src/vespa/storage/tools/getidealstate.cpp
@@ -4,9 +4,9 @@
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vespalib/util/programoptions.h>
-#include <vespa/config/config.h>
#include <vespa/config/print/ostreamconfigwriter.h>
#include <vespa/config-stor-distribution.h>
+#include <vespa/config/subscription/configuri.h>
#include <vespa/config/helper/configgetter.hpp>
#include <iostream>
#include <sstream>
diff --git a/storage/src/vespa/storage/visiting/visitormanager.cpp b/storage/src/vespa/storage/visiting/visitormanager.cpp
index 8450fab5dcb..20178f601fa 100644
--- a/storage/src/vespa/storage/visiting/visitormanager.cpp
+++ b/storage/src/vespa/storage/visiting/visitormanager.cpp
@@ -8,8 +8,10 @@
#include "recoveryvisitor.h"
#include "reindexing_visitor.h"
#include <vespa/storage/common/statusmessages.h>
+#include <vespa/config/subscription/configuri.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/config/helper/configfetcher.hpp>
#include <cassert>
#include <vespa/log/log.h>
@@ -30,8 +32,8 @@ VisitorManager::VisitorManager(const config::ConfigUri & configUri,
_visitorLock(),
_visitorCond(),
_visitorCounter(0),
- _configFetcher(configUri.getContext()),
- _metrics(new VisitorMetrics),
+ _configFetcher(std::make_unique<config::ConfigFetcher>(configUri.getContext())),
+ _metrics(std::make_shared<VisitorMetrics>()),
_maxFixedConcurrentVisitors(1),
_maxVariableConcurrentVisitors(0),
_maxVisitorQueueSize(1024),
@@ -46,8 +48,8 @@ VisitorManager::VisitorManager(const config::ConfigUri & configUri,
_enforceQueueUse(false),
_visitorFactories(externalFactories)
{
- _configFetcher.subscribe<vespa::config::content::core::StorVisitorConfig>(configUri.getConfigId(), this);
- _configFetcher.start();
+ _configFetcher->subscribe<vespa::config::content::core::StorVisitorConfig>(configUri.getConfigId(), this);
+ _configFetcher->start();
_component.registerMetric(*_metrics);
_thread = _component.startThread(*this, 30s, 1s);
_component.registerMetricUpdateHook(*this, framework::SecondTime(5));
@@ -81,7 +83,7 @@ void
VisitorManager::onClose()
{
// Avoid getting config during shutdown
- _configFetcher.close();
+ _configFetcher->close();
{
std::lock_guard sync(_visitorLock);
for (CommandQueue<api::CreateVisitorCommand>::iterator it
diff --git a/storage/src/vespa/storage/visiting/visitormanager.h b/storage/src/vespa/storage/visiting/visitormanager.h
index 32237de7f36..888c0873e9c 100644
--- a/storage/src/vespa/storage/visiting/visitormanager.h
+++ b/storage/src/vespa/storage/visiting/visitormanager.h
@@ -29,12 +29,15 @@
#include <vespa/storageapi/message/datagram.h>
#include <vespa/storageapi/message/internal.h>
#include <vespa/storageapi/message/visitor.h>
-#include <vespa/config/config.h>
+#include <vespa/config/helper/ifetchercallback.h>
#include <vespa/vespalib/util/document_runnable.h>
-namespace storage {
+namespace config {
+ class ConfigUri;
+ class ConfigFetcher;
+}
-namespace api { class BucketTimeInterval; }
+namespace storage {
class RequestStatusPageReply;
@@ -63,7 +66,7 @@ private:
mutable std::mutex _visitorLock;
std::condition_variable _visitorCond;
uint64_t _visitorCounter;
- config::ConfigFetcher _configFetcher;
+ std::unique_ptr<config::ConfigFetcher> _configFetcher;
std::shared_ptr<VisitorMetrics> _metrics;
uint32_t _maxFixedConcurrentVisitors;
uint32_t _maxVariableConcurrentVisitors;
diff --git a/storageserver/src/vespa/storageserver/app/process.cpp b/storageserver/src/vespa/storageserver/app/process.cpp
index 8480f1427f2..93d19c8e6fc 100644
--- a/storageserver/src/vespa/storageserver/app/process.cpp
+++ b/storageserver/src/vespa/storageserver/app/process.cpp
@@ -5,6 +5,7 @@
#include <vespa/storage/storageserver/storagenode.h>
#include <vespa/storage/storageserver/storagenodecontext.h>
#include <vespa/vespalib/util/exceptions.h>
+#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/log/log.h>
LOG_SETUP(".process");
@@ -18,6 +19,8 @@ Process::Process(const config::ConfigUri & configUri)
_configSubscriber(_configUri.getContext())
{ }
+Process::~Process() = default;
+
void
Process::setupConfig(milliseconds subscribeTimeout)
{
diff --git a/storageserver/src/vespa/storageserver/app/process.h b/storageserver/src/vespa/storageserver/app/process.h
index 407c8cf8881..ef461714e5b 100644
--- a/storageserver/src/vespa/storageserver/app/process.h
+++ b/storageserver/src/vespa/storageserver/app/process.h
@@ -42,7 +42,7 @@ public:
using milliseconds = std::chrono::milliseconds;
Process(const config::ConfigUri & configUri);
- virtual ~Process() {}
+ virtual ~Process();
virtual void setupConfig(milliseconds subscribeTimeout);
virtual void createNode() = 0;
diff --git a/streamingvisitors/src/vespa/searchvisitor/rankmanager.cpp b/streamingvisitors/src/vespa/searchvisitor/rankmanager.cpp
index ed5d0a88bb1..13e5ad1c84b 100644
--- a/streamingvisitors/src/vespa/searchvisitor/rankmanager.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/rankmanager.cpp
@@ -6,6 +6,7 @@
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/exception.h>
#include <vespa/vsm/common/document.h>
+#include <vespa/vsm/vsm/vsm-adapter.hpp>
#include <vespa/log/log.h>
LOG_SETUP(".searchvisitor.rankmanager");
diff --git a/vdslib/src/vespa/vdslib/distribution/distribution.cpp b/vdslib/src/vespa/vdslib/distribution/distribution.cpp
index 7322c31d858..8a8d273e9db 100644
--- a/vdslib/src/vespa/vdslib/distribution/distribution.cpp
+++ b/vdslib/src/vespa/vdslib/distribution/distribution.cpp
@@ -6,13 +6,10 @@
#include <vespa/vdslib/state/random.h>
#include <vespa/vespalib/util/bobhash.h>
#include <vespa/vespalib/stllike/asciistream.h>
-#include <vespa/config/config.h>
#include <vespa/config/print/asciiconfigwriter.h>
-#include <vespa/config/print/asciiconfigreader.h>
+#include <vespa/config/print/asciiconfigreader.hpp>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/config-stor-distribution.h>
-#include <list>
-#include <algorithm>
#include <cmath>
#include <cassert>
diff --git a/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp b/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp
index de8500b3e26..8e990c81f29 100644
--- a/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp
+++ b/vespaclient/src/vespa/vespaclient/clusterlist/clusterlist.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "clusterlist.h"
-#include <vespa/config/config.h>
#include <vespa/config/helper/configgetter.hpp>
#include <sstream>
@@ -17,7 +16,7 @@ ClusterList::Cluster::Cluster(const std::string& name, const std::string& config
ClusterList::Cluster::Cluster(const Cluster &) = default;
ClusterList::Cluster & ClusterList::Cluster::operator = (const Cluster &) = default;
-ClusterList::Cluster::~Cluster() {}
+ClusterList::Cluster::~Cluster() = default;
ClusterList::ClusterList()
{
diff --git a/vespaclient/src/vespa/vespaclient/vesparoute/application.h b/vespaclient/src/vespa/vespaclient/vesparoute/application.h
index 93b287b4559..b7a33134b0e 100644
--- a/vespaclient/src/vespa/vespaclient/vesparoute/application.h
+++ b/vespaclient/src/vespa/vespaclient/vesparoute/application.h
@@ -1,12 +1,12 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/fastos/app.h>
-#include <vespa/messagebus/messagebus.h>
-#include <vespa/messagebus/routing/hopblueprint.h>
#include "mynetwork.h"
#include "params.h"
-
+#include <vespa/messagebus/messagebus.h>
+#include <vespa/messagebus/routing/hopblueprint.h>
+#include <vespa/fastos/app.h>
+#include <set>
namespace vesparoute {
/**
diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
index 0d60a5cca35..3602cbe6151 100644
--- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
+++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp
@@ -19,20 +19,23 @@ LOG_SETUP(".vespalib.stllike.asciistream");
namespace vespalib {
namespace {
- std::vector<string> getPrecisions(const char type) {
- std::vector<string> result(VESPALIB_ASCIISTREAM_MAX_PRECISION + 1);
- for (uint32_t i=0; i<result.size(); ++i) {
- char buf[8];
- int count = snprintf(buf, sizeof(buf), "%%.%u%c", i, type);
- assert(size_t(count) < sizeof(buf)); // Assert no truncation.
- (void) count;
- result[i] = buf;
- }
- return result;
+
+std::vector<string>
+getPrecisions(const char type) {
+ std::vector<string> result(VESPALIB_ASCIISTREAM_MAX_PRECISION + 1);
+ for (uint32_t i=0; i<result.size(); ++i) {
+ char buf[8];
+ int count = snprintf(buf, sizeof(buf), "%%.%u%c", i, type);
+ assert(size_t(count) < sizeof(buf)); // Assert no truncation.
+ (void) count;
+ result[i] = buf;
}
- std::vector<string> fixedPrecisions = getPrecisions('f');
- std::vector<string> scientificPrecisions = getPrecisions('e');
- std::vector<string> autoPrecisions = getPrecisions('g');
+ return result;
+}
+std::vector<string> fixedPrecisions = getPrecisions('f');
+std::vector<string> scientificPrecisions = getPrecisions('e');
+std::vector<string> autoPrecisions = getPrecisions('g');
+
}
asciistream &
@@ -93,7 +96,8 @@ asciistream::asciistream(const asciistream & rhs) :
{
}
-asciistream & asciistream::operator = (const asciistream & rhs)
+asciistream &
+asciistream::operator = (const asciistream & rhs)
{
if (this != &rhs) {
asciistream newStream(rhs);
@@ -108,7 +112,8 @@ asciistream::asciistream(asciistream && rhs) noexcept
swap(rhs);
}
-asciistream & asciistream::operator = (asciistream && rhs) noexcept
+asciistream &
+asciistream::operator = (asciistream && rhs) noexcept
{
if (this != &rhs) {
swap(rhs);
@@ -116,7 +121,8 @@ asciistream & asciistream::operator = (asciistream && rhs) noexcept
return *this;
}
-void asciistream::swap(asciistream & rhs) noexcept
+void
+asciistream::swap(asciistream & rhs) noexcept
{
std::swap(_rPos, rhs._rPos);
// If read-only, _wbuf is empty and _rbuf is set
@@ -150,7 +156,8 @@ void throwUnderflow(size_t pos) __attribute__((noinline));
template <typename T>
T strToInt(T & v, const char *begin, const char *end) __attribute__((noinline));
-void throwInputError(int e, const char * t, const char * buf)
+void
+throwInputError(int e, const char * t, const char * buf)
{
if (e == 0) {
throw IllegalArgumentException("Failed decoding a " + string(t) + " from '" + string(buf) + "'.", VESPA_STRLOC);
@@ -163,7 +170,8 @@ void throwInputError(int e, const char * t, const char * buf)
}
}
-void throwInputError(std::errc e, const char * t, const char * buf) {
+void
+throwInputError(std::errc e, const char * t, const char * buf) {
if (e == std::errc::invalid_argument) {
throw IllegalArgumentException("Illegal " + string(t) + " value '" + string(buf) + "'.", VESPA_STRLOC);
} else if (e == std::errc::result_out_of_range) {
@@ -173,12 +181,14 @@ void throwInputError(std::errc e, const char * t, const char * buf) {
}
}
-void throwUnderflow(size_t pos)
+void
+throwUnderflow(size_t pos)
{
throw IllegalArgumentException(make_string("buffer underflow at pos %ld.", pos), VESPA_STRLOC);
}
-int getValue(double & val, const char *buf)
+int
+getValue(double & val, const char *buf)
{
char *ebuf;
errno = 0;
@@ -189,7 +199,8 @@ int getValue(double & val, const char *buf)
return ebuf - buf;
}
-int getValue(float & val, const char *buf)
+int
+getValue(float & val, const char *buf)
{
char *ebuf;
errno = 0;
@@ -201,7 +212,8 @@ int getValue(float & val, const char *buf)
}
template <typename T>
-T strToInt(T & v, const char *begin, const char *end)
+T
+strToInt(T & v, const char *begin, const char *end)
{
const char * curr = begin;
for (;(curr < end) && std::isspace(*curr); curr++);
@@ -226,7 +238,8 @@ T strToInt(T & v, const char *begin, const char *end)
}
-asciistream & asciistream::operator >> (bool & v)
+asciistream &
+asciistream::operator >> (bool & v)
{
for (;(_rPos < length()) && std::isspace(_rbuf[_rPos]); _rPos++);
if (_rPos < length()) {
@@ -237,7 +250,8 @@ asciistream & asciistream::operator >> (bool & v)
return *this;
}
-asciistream & asciistream::operator >> (char & v)
+asciistream &
+asciistream::operator >> (char & v)
{
for (;(_rPos < length()) && std::isspace(_rbuf[_rPos]); _rPos++);
if (_rPos < length()) {
@@ -248,7 +262,8 @@ asciistream & asciistream::operator >> (char & v)
return *this;
}
-asciistream & asciistream::operator >> (signed char & v)
+asciistream &
+asciistream::operator >> (signed char & v)
{
for (;(_rPos < length()) && std::isspace(_rbuf[_rPos]); _rPos++);
if (_rPos < length()) {
@@ -259,7 +274,8 @@ asciistream & asciistream::operator >> (signed char & v)
return *this;
}
-asciistream & asciistream::operator >> (unsigned char & v)
+asciistream &
+asciistream::operator >> (unsigned char & v)
{
for (;(_rPos < length()) && std::isspace(_rbuf[_rPos]); _rPos++);
if (_rPos < length()) {
@@ -270,55 +286,64 @@ asciistream & asciistream::operator >> (unsigned char & v)
return *this;
}
-asciistream & asciistream::operator >> (unsigned short & v)
+asciistream &
+asciistream::operator >> (unsigned short & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (unsigned int & v)
+asciistream &
+asciistream::operator >> (unsigned int & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (unsigned long & v)
+asciistream &
+asciistream::operator >> (unsigned long & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (unsigned long long & v)
+asciistream &
+asciistream::operator >> (unsigned long long & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (short & v)
+asciistream &
+asciistream::operator >> (short & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (int & v)
+asciistream &
+asciistream::operator >> (int & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (long & v)
+asciistream &
+asciistream::operator >> (long & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (long long & v)
+asciistream &
+asciistream::operator >> (long long & v)
{
_rPos += strToInt(v, &_rbuf[_rPos], &_rbuf[length()]);
return *this;
}
-asciistream & asciistream::operator >> (double & v)
+asciistream &
+asciistream::operator >> (double & v)
{
double l(0);
_rPos += getValue(l, &_rbuf[_rPos]);
@@ -326,7 +351,8 @@ asciistream & asciistream::operator >> (double & v)
return *this;
}
-asciistream & asciistream::operator >> (float & v)
+asciistream &
+asciistream::operator >> (float & v)
{
float l(0);
_rPos += getValue(l, &_rbuf[_rPos]);
@@ -334,7 +360,8 @@ asciistream & asciistream::operator >> (float & v)
return *this;
}
-void asciistream::eatWhite()
+void
+asciistream::eatWhite()
{
for (;(_rPos < length()) && isspace(_rbuf[_rPos]); _rPos++);
}
@@ -344,7 +371,8 @@ void asciistream::eatNonWhite()
for (;(_rPos < length()) && !isspace(_rbuf[_rPos]); _rPos++);
}
-asciistream & asciistream::operator >> (std::string & v)
+asciistream &
+asciistream::operator >> (std::string & v)
{
eatWhite();
size_t start(_rPos);
@@ -353,7 +381,8 @@ asciistream & asciistream::operator >> (std::string & v)
return *this;
}
-asciistream & asciistream::operator >> (string & v)
+asciistream &
+asciistream::operator >> (string & v)
{
eatWhite();
size_t start(_rPos);
@@ -366,7 +395,8 @@ asciistream & asciistream::operator >> (string & v)
namespace {
const char * _C_char = "0123456789abcdefg";
-char * prependInt(char * tmp, Base base)
+char *
+prependInt(char * tmp, Base base)
{
if (base == bin) {
tmp[1] = 'b';
@@ -376,7 +406,8 @@ char * prependInt(char * tmp, Base base)
return tmp + 2;
}
-char * prependSign(bool sign, char * tmp)
+char *
+prependSign(bool sign, char * tmp)
{
if (sign) {
tmp[0] = '-';
@@ -389,7 +420,8 @@ template <uint8_t base>
uint8_t printInt(unsigned long long r, char * tmp, uint8_t i) __attribute__((noinline));
template <uint8_t base>
-uint8_t printInt(unsigned long long r, char * tmp, uint8_t i)
+uint8_t
+printInt(unsigned long long r, char * tmp, uint8_t i)
{
for(; r; i--, r/=base) {
uint8_t d = r%base;
@@ -401,7 +433,8 @@ uint8_t printInt(unsigned long long r, char * tmp, uint8_t i)
}
-asciistream & asciistream::operator << (long long v)
+asciistream &
+asciistream::operator << (long long v)
{
char tmp[72];
uint8_t i(sizeof(tmp));
@@ -432,14 +465,16 @@ asciistream & asciistream::operator << (long long v)
return *this;
}
-void asciistream::doReallyFill(size_t currWidth)
+void
+asciistream::doReallyFill(size_t currWidth)
{
for (; _width > currWidth; currWidth++) {
write(&_fill, 1);
}
}
-asciistream & asciistream::operator << (unsigned long long v)
+asciistream &
+asciistream::operator << (unsigned long long v)
{
char tmp[72];
uint8_t i(sizeof(tmp));
@@ -477,13 +512,15 @@ struct BaseStateSaver {
};
}
-asciistream& asciistream::operator<<(const void* p)
+asciistream &
+asciistream::operator<<(const void* p)
{
BaseStateSaver saver(*this, _base);
return *this << "0x" << hex << reinterpret_cast<uint64_t>(p);
}
-asciistream & asciistream::operator << (float v)
+asciistream &
+asciistream::operator << (float v)
{
if (_floatSpec == fixed) {
printFixed(v);
@@ -493,7 +530,8 @@ asciistream & asciistream::operator << (float v)
return *this;
}
-asciistream & asciistream::operator << (double v)
+asciistream &
+asciistream::operator << (double v)
{
if (_floatSpec == fixed) {
printFixed(v);
@@ -516,20 +554,20 @@ void asciistream::printFixed(T v)
}
namespace {
- bool hasDotOrIsScientific(const char* string, size_t len) {
- for (size_t i=0; i<len; ++i) {
- switch (string[i]) {
- case '.':
- case ',':
- case 'e':
- case 'E':
- return true;
- default:
- break;
- }
+bool hasDotOrIsScientific(const char* string, size_t len) {
+ for (size_t i=0; i<len; ++i) {
+ switch (string[i]) {
+ case '.':
+ case ',':
+ case 'e':
+ case 'E':
+ return true;
+ default:
+ break;
}
- return false;
}
+ return false;
+}
}
template <typename T>
@@ -548,7 +586,8 @@ void asciistream::printScientific(T v)
}
}
-void asciistream::write(const void * buf, size_t len)
+void
+asciistream::write(const void * buf, size_t len)
{
if (_rPos > 0 && _rPos == length()) {
clear();
@@ -612,7 +651,8 @@ asciistream::createFromFile(stringref fileName)
return is;
}
-asciistream asciistream::createFromDevice(stringref fileName)
+asciistream
+asciistream::createFromDevice(stringref fileName)
{
FastOS_File file(vespalib::string(fileName).c_str());
asciistream is;
@@ -626,7 +666,8 @@ asciistream asciistream::createFromDevice(stringref fileName)
return is;
}
-ssize_t getline(asciistream & is, string & line, char delim)
+ssize_t
+getline(asciistream & is, string & line, char delim)
{
line = is.getline(delim);
return line.size();
diff --git a/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp b/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp
index 784b5ea38ba..09594832c4a 100644
--- a/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp
+++ b/vsm/src/vespa/vsm/vsm/vsm-adapter.cpp
@@ -1,6 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "vsm-adapter.h"
+#include "vsm-adapter.hpp"
#include "docsumconfig.h"
#include "i_matching_elements_filler.h"
#include <vespa/searchlib/common/matching_elements.h>
@@ -24,7 +24,7 @@ GetDocsumsStateCallback::GetDocsumsStateCallback() :
void GetDocsumsStateCallback::FillSummaryFeatures(GetDocsumsState * state, IDocsumEnvironment * env)
{
(void) env;
- if (_summaryFeatures.get() != NULL) { // set the summary features to write to the docsum
+ if (_summaryFeatures) { // set the summary features to write to the docsum
state->_summaryFeatures = _summaryFeatures;
state->_summaryFeaturesCached = true;
}
@@ -33,7 +33,7 @@ void GetDocsumsStateCallback::FillSummaryFeatures(GetDocsumsState * state, IDocs
void GetDocsumsStateCallback::FillRankFeatures(GetDocsumsState * state, IDocsumEnvironment * env)
{
(void) env;
- if (_rankFeatures.get() != NULL) { // set the rank features to write to the docsum
+ if (_rankFeatures) { // set the rank features to write to the docsum
state->_rankFeatures = _rankFeatures;
}
}
@@ -119,10 +119,10 @@ VSMAdapter::configure(const VSMConfigSnapshot & snapshot)
std::lock_guard guard(_lock);
LOG(debug, "(re-)configure VSM (docsum tools)");
- std::shared_ptr<SummaryConfig> summary(snapshot.getConfig<SummaryConfig>().release());
- std::shared_ptr<SummarymapConfig> summaryMap(snapshot.getConfig<SummarymapConfig>().release());
- std::shared_ptr<VsmsummaryConfig> vsmSummary(snapshot.getConfig<VsmsummaryConfig>().release());
- std::shared_ptr<JuniperrcConfig> juniperrc(snapshot.getConfig<JuniperrcConfig>().release());
+ std::shared_ptr<SummaryConfig> summary(snapshot.getConfig<SummaryConfig>());
+ std::shared_ptr<SummarymapConfig> summaryMap(snapshot.getConfig<SummarymapConfig>());
+ std::shared_ptr<VsmsummaryConfig> vsmSummary(snapshot.getConfig<VsmsummaryConfig>());
+ std::shared_ptr<JuniperrcConfig> juniperrc(snapshot.getConfig<JuniperrcConfig>());
_fieldsCfg.set(snapshot.getConfig<VsmfieldsConfig>().release());
_fieldsCfg.latch();
@@ -175,6 +175,12 @@ VSMAdapter::configure(const VSMConfigSnapshot & snapshot)
}
}
+VSMConfigSnapshot::VSMConfigSnapshot(const vespalib::string & configId, const config::ConfigSnapshot & snapshot)
+ : _configId(configId),
+ _snapshot(std::make_unique<config::ConfigSnapshot>(snapshot))
+{ }
+VSMConfigSnapshot::~VSMConfigSnapshot() = default;
+
VSMAdapter::VSMAdapter(const vespalib::string & highlightindexes, const vespalib::string & configId, Fast_WordFolder & wordFolder)
: _highlightindexes(highlightindexes),
_configId(configId),
diff --git a/vsm/src/vespa/vsm/vsm/vsm-adapter.h b/vsm/src/vespa/vsm/vsm/vsm-adapter.h
index dacf01aec08..f13befa14a1 100644
--- a/vsm/src/vespa/vsm/vsm/vsm-adapter.h
+++ b/vsm/src/vespa/vsm/vsm/vsm-adapter.h
@@ -3,7 +3,6 @@
#pragma once
#include <vespa/searchlib/query/base.h>
-#include <vespa/config/retriever/configsnapshot.h>
#include <vespa/vsm/config/vsm-cfif.h>
#include <vespa/config-summary.h>
#include <vespa/config-summarymap.h>
@@ -25,6 +24,7 @@ using vespa::config::search::SummaryConfig;
using vespa::config::search::SummarymapConfig;
using vespa::config::search::summary::JuniperrcConfig;
+namespace config { class ConfigSnapshot; }
namespace vsm {
class IMatchingElementsFiller;
@@ -97,17 +97,12 @@ typedef std::shared_ptr<DocsumTools> DocsumToolsPtr;
class VSMConfigSnapshot {
private:
const vespalib::string _configId;
- const config::ConfigSnapshot _snapshot;
+ std::unique_ptr<config::ConfigSnapshot> _snapshot;
public:
- VSMConfigSnapshot(const vespalib::string & configId, const config::ConfigSnapshot & snapshot)
- : _configId(configId),
- _snapshot(snapshot)
- { }
+ VSMConfigSnapshot(const vespalib::string & configId, const config::ConfigSnapshot & snapshot);
+ ~VSMConfigSnapshot();
template <typename ConfigType>
- std::unique_ptr<ConfigType> getConfig() const
- {
- return _snapshot.getConfig<ConfigType>(_configId);
- }
+ std::unique_ptr<ConfigType> getConfig() const;
};
class VSMAdapter
diff --git a/vsm/src/vespa/vsm/vsm/vsm-adapter.hpp b/vsm/src/vespa/vsm/vsm/vsm-adapter.hpp
new file mode 100644
index 00000000000..f071dbb2015
--- /dev/null
+++ b/vsm/src/vespa/vsm/vsm/vsm-adapter.hpp
@@ -0,0 +1,18 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "vsm-adapter.h"
+#include <vespa/config/retriever/configsnapshot.hpp>
+
+namespace vsm {
+
+template <typename ConfigType>
+std::unique_ptr<ConfigType>
+VSMConfigSnapshot::getConfig() const
+{
+ return _snapshot->getConfig<ConfigType>(_configId);
+}
+
+} // namespace vsm
+