BIND 10 master, updated. 7e575b706d7cd4d9d15bc9bb6a623ea9b9077252 Merge branch 'trac2907'
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu May 30 14:54:02 UTC 2013
The branch, master has been updated
via 7e575b706d7cd4d9d15bc9bb6a623ea9b9077252 (commit)
via 5ed66be3e60157ada3a26fc2e53cac3790661c7d (commit)
via 16f7fffa1820f7e65d28e807a81d89dd59390037 (commit)
via 807607ead100bba4afa0c5af2697ebe6dd2f4ec7 (commit)
via a292c65c3c68b9bccb2a30169e4bcb613da1ce68 (commit)
via 199269b851a76501bba4ab7bd6f8c7e088b45e74 (commit)
via a6f80229344ffd81fdc3c6642b3ab5740dde4bf6 (commit)
from dbe4772246039a1257b6492936fda2a8600cd245 (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 7e575b706d7cd4d9d15bc9bb6a623ea9b9077252
Merge: dbe4772 5ed66be
Author: Paul Selkirk <pselkirk at isc.org>
Date: Thu May 30 10:52:53 2013 -0400
Merge branch 'trac2907'
-----------------------------------------------------------------------
Summary of changes:
src/bin/auth/tests/query_unittest.cc | 6 ++
src/lib/datasrc/client_list.cc | 28 +++++++-
src/lib/datasrc/client_list.h | 38 ++++++++++-
src/lib/datasrc/tests/client_list_unittest.cc | 91 ++++++++++++++++++++++++-
4 files changed, 158 insertions(+), 5 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/auth/tests/query_unittest.cc b/src/bin/auth/tests/query_unittest.cc
index 32092b0..f374a87 100644
--- a/src/bin/auth/tests/query_unittest.cc
+++ b/src/bin/auth/tests/query_unittest.cc
@@ -80,6 +80,12 @@ public:
return (FindResult());
}
}
+ virtual ConstZoneTableAccessorPtr
+ getZoneTableAccessor(const std::string&, bool) const {
+ isc_throw(isc::NotImplemented,
+ "getZoneTableAccessor not implemented for SingletonList");
+ }
+
private:
DataSourceClient& client_;
};
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index f09b504..4302905 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
@@ -24,6 +24,7 @@
#include <datasrc/memory/zone_data_loader.h>
#include <datasrc/memory/zone_data_updater.h>
#include <datasrc/logger.h>
+#include <datasrc/zone_table_accessor_cache.h>
#include <dns/masterload.h>
#include <util/memory_segment_local.h>
@@ -403,5 +404,30 @@ ConfigurableClientList::getStatus() const {
return (result);
}
+ConstZoneTableAccessorPtr
+ConfigurableClientList::getZoneTableAccessor(const std::string& datasrc_name,
+ bool use_cache) const
+{
+ if (!use_cache) {
+ isc_throw(isc::NotImplemented,
+ "getZoneTableAccessor only implemented for cache");
+ }
+
+ // Find the matching data source
+ BOOST_FOREACH(const DataSourceInfo& info, data_sources_) {
+ if (!datasrc_name.empty() && datasrc_name != info.name_) {
+ continue;
+ }
+
+ const internal::CacheConfig* config(info.getCacheConfig());
+ // If caching is disabled for the named data source, this will
+ // return an accessor to an effectivley empty table.
+ return (ConstZoneTableAccessorPtr
+ (new internal::ZoneTableAccessorCache(*config)));
+ }
+
+ return (ConstZoneTableAccessorPtr());
+}
+
}
}
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index eb1c1ec..1887ed7 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
@@ -22,6 +22,7 @@
#include <cc/data.h>
#include <exceptions/exceptions.h>
#include "memory/zone_table_segment.h"
+#include <datasrc/zone_table_accessor.h>
#include <vector>
#include <boost/shared_ptr.hpp>
@@ -120,6 +121,8 @@ private:
MemorySegmentState state_;
};
+typedef boost::shared_ptr<const ZoneTableAccessor> ConstZoneTableAccessorPtr;
+
/// \brief The list of data source clients.
///
/// The purpose of this class is to hold several data source clients and search
@@ -281,6 +284,19 @@ public:
virtual FindResult find(const dns::Name& zone,
bool want_exact_match = false,
bool want_finder = true) const = 0;
+
+ /// \brief Creates a ZoneTableAccessor object for the specified data
+ /// source.
+ ///
+ /// \param datasrc_name If not empty, the name of the data source.
+ /// \param use_cache If true, create a zone table for in-memory cache.
+ /// \throw NotImplemented if this method is not implemented.
+ /// \return A pointer to the accessor, or NULL if the requested data
+ /// source is not found.
+ virtual ConstZoneTableAccessorPtr
+ getZoneTableAccessor(const std::string& datasrc_name,
+ bool use_cache) const = 0;
+
};
/// \brief Shared pointer to the list.
@@ -288,8 +304,8 @@ typedef boost::shared_ptr<ClientList> ClientListPtr;
/// \brief Shared const pointer to the list.
typedef boost::shared_ptr<const ClientList> ConstClientListPtr;
-/// \Concrete implementation of the ClientList, which is constructed based on
-/// configuration.
+/// \brief Concrete implementation of the ClientList, which is constructed
+/// based on configuration.
///
/// This is the implementation which is expected to be used in the servers.
/// However, it is expected most of the code will use it as the ClientList,
@@ -490,6 +506,22 @@ public:
/// it might be, so it is just made public (there's no real reason to
/// hide it).
const DataSources& getDataSources() const { return (data_sources_); }
+
+ /// \brief Creates a ZoneTableAccessor object for the specified data
+ /// source.
+ ///
+ /// \param datasrc_name If not empty, the name of the data source
+ /// \param use_cache If true, create a zone table for in-memory cache.
+ /// \note At present, the only concrete implementation of
+ /// ZoneTableAccessor is ZoneTableAccessorCache, so \c use_cache must be
+ /// true.
+ /// \throw NotImplemented if \c use_cache is false.
+ /// \return A pointer to the accessor, or NULL if the requested data
+ /// source is not found.
+ ConstZoneTableAccessorPtr
+ getZoneTableAccessor(const std::string& datasrc_name,
+ bool use_cache) const;
+
private:
struct MutableResult;
/// \brief Internal implementation of find.
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index 58d410b..2701f39 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
@@ -266,6 +266,8 @@ public:
}
ConfigurableClientList::CacheStatus doReload(
const Name& origin, const string& datasrc_name = "");
+ void accessorIterate(const ConstZoneTableAccessorPtr& accessor,
+ int numZones, const string& zoneName);
const RRClass rrclass_;
shared_ptr<TestedList> list_;
@@ -1147,6 +1149,93 @@ TEST_F(ListTest, reloadByDataSourceName) {
doReload(Name("example.org"), "test_type4"));
}
+// This takes the accessor provided by getZoneTableAccessor(), iterates
+// through the table, and verifies that the expected number of zones are
+// present, as well as the named zone.
+void
+ListTest::accessorIterate(const ConstZoneTableAccessorPtr& accessor,
+ int numZones, const string& zoneName="")
+{
+ // Confirm basic iterator behavior.
+ ASSERT_TRUE(accessor);
+ ZoneTableAccessor::IteratorPtr it = accessor->getIterator();
+ ASSERT_TRUE(it);
+ // Iterator does not guarantee ordering, so we look for the target
+ // name anywhere in the table.
+ bool found = false;
+ int i;
+ for (i = 0; !it->isLast(); ++i, it->next()) {
+ if (Name(zoneName) == it->getCurrent().origin) {
+ found = true;
+ }
+ }
+ EXPECT_EQ(i, numZones);
+ if (numZones > 0) {
+ EXPECT_TRUE(found);
+ }
+}
+
+TEST_F(ListTest, zoneTableAccessor) {
+ // empty configuration
+ const ConstElementPtr elem(new ListElement);
+ list_->configure(elem, true);
+ // null pointer treated as false
+ EXPECT_FALSE(list_->getZoneTableAccessor("", true));
+
+ // empty list; expect it to return an empty list
+ list_->configure(config_elem_, true);
+ ConstZoneTableAccessorPtr z(list_->getZoneTableAccessor("", true));
+ accessorIterate(z, 0);
+
+ const ConstElementPtr elem2(Element::fromJSON("["
+ "{"
+ " \"type\": \"type1\","
+ " \"cache-enable\": true,"
+ " \"cache-zones\": [\"example.com\"],"
+ " \"params\": [\"example.com\"]"
+ "},"
+ "{"
+ " \"type\": \"type2\","
+ " \"cache-enable\": false,"
+ " \"params\": [\"example.org\"]"
+ "},"
+ "{"
+ " \"type\": \"type3\","
+ " \"cache-enable\": true,"
+ " \"cache-zones\": [\"example.net\", \"example.info\"],"
+ " \"params\": [\"example.net\", \"example.info\"]"
+ "}]"));
+
+ // allow_cache = false
+ // ask for a non-existent zone table, expect null
+ list_->configure(elem2, false);
+ EXPECT_FALSE(list_->getZoneTableAccessor("bogus", true));
+ // ask for any zone table, expect an empty list
+ z = list_->getZoneTableAccessor("", true);
+ accessorIterate(z, 0);
+
+ // allow_cache = true, use_cache = false
+ list_->configure(elem2, true);
+ EXPECT_THROW(list_->getZoneTableAccessor("", false), isc::NotImplemented);
+ EXPECT_THROW(list_->getZoneTableAccessor("type1", false),
+ isc::NotImplemented);
+
+ // datasrc not found, returns NULL pointer
+ EXPECT_FALSE(list_->getZoneTableAccessor("bogus", true));
+
+ // return first datasrc
+ z = list_->getZoneTableAccessor("", true);
+ accessorIterate(z, 1, "example.com");
+
+ // datasrc has cache disabled, returns accessor to empty list
+ z = list_->getZoneTableAccessor("type2", true);
+ accessorIterate(z, 0);
+
+ // search by name
+ z = list_->getZoneTableAccessor("type3", true);
+ accessorIterate(z, 2, "example.net");
+}
+
// Check the status holds data
TEST(DataSourceStatus, status) {
const DataSourceStatus status("Test", SEGMENT_INUSE, "local");
More information about the bind10-changes
mailing list