aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-06-08 14:41:50 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-06-08 14:41:50 +0200
commit135eb2f993346c5cbc360b4bb874381cf73ecc24 (patch)
treee3fd0c8a20a7f5bc7b6ae26fb8efde2110bd2371 /config
parent18d779a4cf527c22b3898a6501cb266505c77ee0 (diff)
Reduce exposure to config internals.
Diffstat (limited to 'config')
-rw-r--r--config/src/tests/configparser/configparser.cpp1
-rw-r--r--config/src/tests/configretriever/configretriever.cpp1
-rw-r--r--config/src/tests/file_subscription/file_subscription.cpp1
-rw-r--r--config/src/tests/functiontest/functiontest.cpp1
-rw-r--r--config/src/tests/subscriber/subscriber.cpp1
-rw-r--r--config/src/vespa/config/print/fileconfigsnapshotreader.cpp6
-rw-r--r--config/src/vespa/config/print/fileconfigsnapshotwriter.cpp3
-rw-r--r--config/src/vespa/config/retriever/configretriever.cpp2
-rw-r--r--config/src/vespa/config/retriever/configsnapshot.cpp50
-rw-r--r--config/src/vespa/config/retriever/configsnapshot.h13
-rw-r--r--config/src/vespa/config/retriever/configsnapshot.hpp14
11 files changed, 49 insertions, 44 deletions
diff --git a/config/src/tests/configparser/configparser.cpp b/config/src/tests/configparser/configparser.cpp
index 40c0a5b99bd..f9e36a11def 100644
--- a/config/src/tests/configparser/configparser.cpp
+++ b/config/src/tests/configparser/configparser.cpp
@@ -2,6 +2,7 @@
#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 "config-foo.h"
#include <fstream>
#include <vespa/vespalib/stllike/asciistream.h>
diff --git a/config/src/tests/configretriever/configretriever.cpp b/config/src/tests/configretriever/configretriever.cpp
index 8273eee2c73..8e2d38e3c4d 100644
--- a/config/src/tests/configretriever/configretriever.cpp
+++ b/config/src/tests/configretriever/configretriever.cpp
@@ -9,6 +9,7 @@
#include <vespa/config/retriever/simpleconfigurer.h>
#include <vespa/config/common/configholder.h>
#include <vespa/config/subscription/configsubscription.h>
+#include <vespa/config/common/exceptions.h>
#include "config-bootstrap.h"
#include "config-foo.h"
#include "config-bar.h"
diff --git a/config/src/tests/file_subscription/file_subscription.cpp b/config/src/tests/file_subscription/file_subscription.cpp
index 622610ac1b5..25d27bcf905 100644
--- a/config/src/tests/file_subscription/file_subscription.cpp
+++ b/config/src/tests/file_subscription/file_subscription.cpp
@@ -3,6 +3,7 @@
#include <vespa/config/config.h>
#include <vespa/config/common/configholder.h>
#include <vespa/config/file/filesource.h>
+#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/util/sync.h>
#include <fstream>
#include <config-my.h>
diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp
index 28b688c189e..34429ab4016 100644
--- a/config/src/tests/functiontest/functiontest.cpp
+++ b/config/src/tests/functiontest/functiontest.cpp
@@ -1,6 +1,7 @@
// Copyright 2016 Yahoo Inc. 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>
diff --git a/config/src/tests/subscriber/subscriber.cpp b/config/src/tests/subscriber/subscriber.cpp
index f0b7fe18930..ce9a8fcbb6a 100644
--- a/config/src/tests/subscriber/subscriber.cpp
+++ b/config/src/tests/subscriber/subscriber.cpp
@@ -4,6 +4,7 @@
#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 <fstream>
#include "config-foo.h"
#include "config-bar.h"
diff --git a/config/src/vespa/config/print/fileconfigsnapshotreader.cpp b/config/src/vespa/config/print/fileconfigsnapshotreader.cpp
index 0cc7fe9fe38..951619aee6f 100644
--- a/config/src/vespa/config/print/fileconfigsnapshotreader.cpp
+++ b/config/src/vespa/config/print/fileconfigsnapshotreader.cpp
@@ -1,10 +1,10 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <fstream>
-#include <sstream>
#include "fileconfigsnapshotreader.h"
#include "jsonconfigformatter.h"
-#include <iostream>
+#include <vespa/config/common/exceptions.h>
+#include <fstream>
+#include <sstream>
namespace config {
diff --git a/config/src/vespa/config/print/fileconfigsnapshotwriter.cpp b/config/src/vespa/config/print/fileconfigsnapshotwriter.cpp
index de5c3af065d..5717e5e9781 100644
--- a/config/src/vespa/config/print/fileconfigsnapshotwriter.cpp
+++ b/config/src/vespa/config/print/fileconfigsnapshotwriter.cpp
@@ -1,8 +1,9 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <fstream>
#include "fileconfigsnapshotwriter.h"
#include "jsonconfigformatter.h"
+#include <vespa/config/common/exceptions.h>
+#include <fstream>
namespace config {
diff --git a/config/src/vespa/config/retriever/configretriever.cpp b/config/src/vespa/config/retriever/configretriever.cpp
index 240ba3bac00..9d49ad3324e 100644
--- a/config/src/vespa/config/retriever/configretriever.cpp
+++ b/config/src/vespa/config/retriever/configretriever.cpp
@@ -1,6 +1,8 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "configretriever.h"
+#include <vespa/config/common/exceptions.h>
+
namespace config {
diff --git a/config/src/vespa/config/retriever/configsnapshot.cpp b/config/src/vespa/config/retriever/configsnapshot.cpp
index b04f44bf600..717c10d30e0 100644
--- a/config/src/vespa/config/retriever/configsnapshot.cpp
+++ b/config/src/vespa/config/retriever/configsnapshot.cpp
@@ -1,10 +1,12 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "configsnapshot.h"
-#include <vespa/vespalib/stllike/asciistream.h>
+#include <vespa/config/subscription/configsubscription.h>
+#include <vespa/config/print/configdatabuffer.h>
+#include <vespa/config/common/exceptions.h>
#include <vespa/config/common/misc.h>
#include <vespa/vespalib/data/slime/slime.h>
-#include <vespa/vespalib/data/memory.h>
+#include <vespa/vespalib/stllike/asciistream.h>
using vespalib::Slime;
using vespalib::slime::Cursor;
@@ -16,23 +18,19 @@ namespace config {
const int64_t ConfigSnapshot::SNAPSHOT_FORMAT_VERSION = 1;
ConfigSnapshot::ConfigSnapshot()
- : _valueMap(),
- _generation(0)
-{}
+ : _valueMap(),
+ _generation(0) {}
-ConfigSnapshot::~ConfigSnapshot()
-{
+ConfigSnapshot::~ConfigSnapshot() {
}
-ConfigSnapshot::ConfigSnapshot(const ConfigSnapshot & rhs) :
- _valueMap(rhs._valueMap),
- _generation(rhs._generation)
-{
+ConfigSnapshot::ConfigSnapshot(const ConfigSnapshot &rhs) :
+ _valueMap(rhs._valueMap),
+ _generation(rhs._generation) {
}
ConfigSnapshot &
-ConfigSnapshot::operator = (const ConfigSnapshot & rhs)
-{
+ConfigSnapshot::operator=(const ConfigSnapshot &rhs) {
if (&rhs != this) {
ConfigSnapshot tmp(rhs);
tmp.swap(*this);
@@ -41,25 +39,31 @@ ConfigSnapshot::operator = (const ConfigSnapshot & rhs)
}
void
-ConfigSnapshot::swap(ConfigSnapshot & rhs)
-{
+ConfigSnapshot::swap(ConfigSnapshot &rhs) {
_valueMap.swap(rhs._valueMap);
std::swap(_generation, rhs._generation);
}
-ConfigSnapshot::ConfigSnapshot(const SubscriptionList & subscriptionList, int64_t generation)
- : _valueMap(),
- _generation(generation)
-{
+ConfigSnapshot::ConfigSnapshot(const SubscriptionList &subscriptionList, int64_t 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());
}
}
-ConfigSnapshot::ConfigSnapshot(const ValueMap & valueMap, int64_t generation)
- : _valueMap(valueMap),
- _generation(generation)
-{
+ConfigSnapshot::ConfigSnapshot(const ValueMap &valueMap, int64_t generation)
+ : _valueMap(valueMap),
+ _generation(generation) {
+}
+
+ConfigSnapshot::ValueMap::const_iterator
+ConfigSnapshot::find(const ConfigKey &key) const {
+ ValueMap::const_iterator it(_valueMap.find(key));
+ if (it == _valueMap.end()) {
+ throw IllegalConfigKeyException("Unable to find config for key " + key.toString());
+ }
+ return it;
}
ConfigSnapshot
diff --git a/config/src/vespa/config/retriever/configsnapshot.h b/config/src/vespa/config/retriever/configsnapshot.h
index 4cb4eeb3e23..24a16876720 100644
--- a/config/src/vespa/config/retriever/configsnapshot.h
+++ b/config/src/vespa/config/retriever/configsnapshot.h
@@ -1,14 +1,16 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/config/subscription/configsubscription.h>
-#include <vespa/config/print/configdatabuffer.h>
+#include "configkeyset.h"
+#include <vespa/config/common/configvalue.h>
#include <vespa/vespalib/stllike/string.h>
#include <map>
-#include "configkeyset.h"
namespace config {
+class ConfigSubscription;
+class ConfigDataBuffer;
+
/**
* A ConfigSnapshot contains a map of config keys to config instances. You may
* request an instance of a config by calling the getConfig method.
@@ -16,7 +18,7 @@ namespace config {
class ConfigSnapshot
{
public:
- typedef std::vector<ConfigSubscription::SP> SubscriptionList;
+ typedef std::vector<std::shared_ptr<ConfigSubscription>> SubscriptionList;
/**
* Construct an empty config snapshot.
@@ -112,6 +114,8 @@ private:
void deserializeV2(vespalib::slime::Inspector & root);
Value deserializeValueV2(vespalib::slime::Inspector & inspector) const;
+ ValueMap::const_iterator find(const ConfigKey & key) const;
+
ValueMap _valueMap;
int64_t _generation;
};
@@ -119,4 +123,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 395d36bb4f6..bb07431cdef 100644
--- a/config/src/vespa/config/retriever/configsnapshot.hpp
+++ b/config/src/vespa/config/retriever/configsnapshot.hpp
@@ -1,7 +1,5 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/config/common/exceptions.h>
-
namespace config {
template <typename ConfigType>
@@ -9,11 +7,7 @@ std::unique_ptr<ConfigType>
ConfigSnapshot::getConfig(const vespalib::string & configId) const
{
ConfigKey key(ConfigKey::create<ConfigType>(configId));
- ValueMap::const_iterator it(_valueMap.find(key));
- if (it == _valueMap.end()) {
- throw IllegalConfigKeyException("Unable to find config for key " + key.toString());
- }
- return it->second.second.newInstance<ConfigType>();
+ return find(key)->second.second.newInstance<ConfigType>();
}
template <typename ConfigType>
@@ -21,11 +15,7 @@ bool
ConfigSnapshot::isChanged(const vespalib::string & configId, int64_t currentGeneration) const
{
ConfigKey key(ConfigKey::create<ConfigType>(configId));
- ValueMap::const_iterator it(_valueMap.find(key));
- if (it == _valueMap.end()) {
- throw IllegalConfigKeyException("Unable to find config for key " + key.toString());
- }
- return currentGeneration < it->second.first;
+ return currentGeneration < find(key)->second.first;
}
template <typename ConfigType>