BIND 10 trac2835, updated. c009be784c417b1b0a2c91307e861634155eb011 [1835] Read name from configuration
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Mar 15 09:36:12 UTC 2013
The branch, trac2835 has been updated
via c009be784c417b1b0a2c91307e861634155eb011 (commit)
from 739735c08bb30957be78506bc4cf0d6c5f01745d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c009be784c417b1b0a2c91307e861634155eb011
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Fri Mar 15 10:34:36 2013 +0100
[1835] Read name from configuration
Read the name of the data source client from configuration or guess it.
Throw in case it isn't unique.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/client_list.cc | 25 +++++++++++++++++++------
src/lib/datasrc/client_list.h | 5 +++--
src/lib/datasrc/tests/client_list_unittest.cc | 2 +-
3 files changed, 23 insertions(+), 9 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index 0750fb6..3c01555 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -27,6 +27,7 @@
#include <util/memory_segment_local.h>
#include <memory>
+#include <set>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
@@ -47,9 +48,11 @@ namespace datasrc {
ConfigurableClientList::DataSourceInfo::DataSourceInfo(
DataSourceClient* data_src_client,
const DataSourceClientContainerPtr& container, bool has_cache,
- const RRClass& rrclass, const shared_ptr<ZoneTableSegment>& segment) :
+ const RRClass& rrclass, const shared_ptr<ZoneTableSegment>& segment,
+ const string& name) :
data_src_client_(data_src_client),
- container_(container)
+ container_(container),
+ name_(name)
{
if (has_cache) {
cache_.reset(new InMemoryClient(segment, rrclass));
@@ -59,8 +62,9 @@ ConfigurableClientList::DataSourceInfo::DataSourceInfo(
ConfigurableClientList::DataSourceInfo::DataSourceInfo(
const RRClass& rrclass, const shared_ptr<ZoneTableSegment>& segment,
- bool has_cache) :
- data_src_client_(NULL)
+ bool has_cache, const string& name) :
+ data_src_client_(NULL),
+ name_(name)
{
if (has_cache) {
cache_.reset(new InMemoryClient(segment, rrclass));
@@ -92,6 +96,7 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
vector<DataSourceInfo> new_data_sources;
shared_ptr<ZoneTableSegment> ztable_segment(
ZoneTableSegment::create(*config, rrclass_));
+ set<string> used_names;
for (; i < config->size(); ++i) {
// Extract the parameters
const ConstElementPtr dconf(config->get(i));
@@ -108,6 +113,13 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
const bool want_cache(allow_cache &&
dconf->contains("cache-enable") &&
dconf->get("cache-enable")->boolValue());
+ // Get the name (either explicit, or guess)
+ const ConstElementPtr nameElem(dconf->get("name"));
+ const string name(nameElem ? nameElem->stringValue() : type);
+ if (!used_names.insert(name).second) {
+ isc_throw(ConfigurationError, "Duplicit name in client list: "
+ << name);
+ }
if (type == "MasterFiles") {
// In case the cache is not allowed, we just skip the master
@@ -130,7 +142,7 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
}
new_data_sources.push_back(DataSourceInfo(rrclass_,
ztable_segment,
- true));
+ true, name));
} else {
// Ask the factory to create the data source for us
const DataSourcePair ds(this->getDataSourceClient(type,
@@ -138,7 +150,8 @@ ConfigurableClientList::configure(const ConstElementPtr& config,
// And put it into the vector
new_data_sources.push_back(DataSourceInfo(ds.first, ds.second,
want_cache, rrclass_,
- ztable_segment));
+ ztable_segment,
+ name));
}
if (want_cache) {
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index 3cfe1b9..e97ee46 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -332,13 +332,14 @@ public:
const boost::shared_ptr
<isc::datasrc::memory::ZoneTableSegment>&
ztable_segment,
- bool has_cache = false);
+ bool has_cache = false,
+ const std::string& name = std::string());
DataSourceInfo(DataSourceClient* data_src_client,
const DataSourceClientContainerPtr& container,
bool has_cache, const dns::RRClass& rrclass,
const boost::shared_ptr
<isc::datasrc::memory::ZoneTableSegment>&
- ztable_segment);
+ ztable_segment, const std::string& name);
DataSourceClient* data_src_client_;
DataSourceClientContainerPtr container_;
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index 9365d30..fe42ebf 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -278,7 +278,7 @@ public:
ds_.push_back(ds);
ds_info_.push_back(ConfigurableClientList::DataSourceInfo(
ds.get(), DataSourceClientContainerPtr(),
- false, rrclass_, ztable_segment_));
+ false, rrclass_, ztable_segment_, ""));
}
}
More information about the bind10-changes
mailing list