BIND 10 trac1217, updated. c5f69488232bd0464cd7e2174be96b30b51b7e83 [1217] and adjust wrappers
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Nov 2 14:59:19 UTC 2011
The branch, trac1217 has been updated
via c5f69488232bd0464cd7e2174be96b30b51b7e83 (commit)
via 64d4ac8b0fee6702093428b855f3d878d7306468 (commit)
via 687b0e5483e088ca07d5f7249b109cc377d04bd2 (commit)
from 701ffebae5b357a693e764bbef904dc374ebb591 (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 c5f69488232bd0464cd7e2174be96b30b51b7e83
Author: Jelte Jansen <jelte at isc.org>
Date: Wed Nov 2 15:33:11 2011 +0100
[1217] and adjust wrappers
commit 64d4ac8b0fee6702093428b855f3d878d7306468
Author: Jelte Jansen <jelte at isc.org>
Date: Wed Nov 2 15:12:45 2011 +0100
[1217] change 'individual_rrs' to 'adjust_ttl'
with a slightly different interpretation; if false, treat differing TTLs as an indicator of different RRsets
commit 687b0e5483e088ca07d5f7249b109cc377d04bd2
Author: Jelte Jansen <jelte at isc.org>
Date: Wed Nov 2 11:42:54 2011 +0100
[1217] extend wrapper for individual_rrs argument
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/client.h | 12 +++++---
src/lib/datasrc/database.cc | 32 +++++++++++----------
src/lib/datasrc/database.h | 10 ++++---
src/lib/datasrc/memory_datasrc.cc | 4 +++
src/lib/datasrc/memory_datasrc.h | 2 +-
src/lib/datasrc/tests/database_unittest.cc | 7 +++-
src/lib/python/isc/datasrc/client_inc.cc | 7 ++++-
src/lib/python/isc/datasrc/client_python.cc | 14 +++++++--
src/lib/python/isc/datasrc/tests/datasrc_test.py | 29 ++++++++++++++++++-
9 files changed, 84 insertions(+), 33 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client.h b/src/lib/datasrc/client.h
index 3ab4b16..2c3f709 100644
--- a/src/lib/datasrc/client.h
+++ b/src/lib/datasrc/client.h
@@ -215,16 +215,18 @@ public:
///
/// \param name The name of zone apex to be traversed. It doesn't do
/// nearest match as findZone.
- /// \param individual_rrs If true, the iterator will return each RR found
- /// in the data as a separate RRset, instead of combining them into
- /// RRsets.
+ /// \param adjust_ttl If true, the iterator will treat RRs with the same
+ /// name and type but different TTL values to be of the
+ /// same RRset, and will adjust the TTL to the lowest
+ /// value found. If false, it will consider the RR to
+ /// belong to a different RRset.
/// \return Pointer to the iterator.
virtual ZoneIteratorPtr getIterator(const isc::dns::Name& name,
- bool individual_rrs = false) const {
+ bool adjust_ttl = true) const {
// This is here to both document the parameter in doxygen (therefore it
// needs a name) and avoid unused parameter warning.
static_cast<void>(name);
- static_cast<void>(individual_rrs);
+ static_cast<void>(adjust_ttl);
isc_throw(isc::NotImplemented,
"Data source doesn't support iteration");
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index a30fe00..e5ff7e9 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -705,11 +705,11 @@ namespace {
class DatabaseIterator : public ZoneIterator {
public:
DatabaseIterator(const DatabaseAccessor::IteratorContextPtr& context,
- const RRClass& rrclass, bool individual_rrs) :
+ const RRClass& rrclass, bool adjust_ttl) :
context_(context),
class_(rrclass),
ready_(true),
- individual_rrs_(individual_rrs)
+ adjust_ttl_(adjust_ttl)
{
// Prepare data for the next time
getData();
@@ -731,19 +731,20 @@ public:
RRType rtype(rtype_str);
RRsetPtr rrset(new RRset(name, class_, rtype, RRTTL(ttl)));
while (data_ready_ && name_ == name_str && rtype_str == rtype_) {
- if (ttl_ != ttl) {
- if (ttl < ttl_) {
- ttl_ = ttl;
- rrset->setTTL(RRTTL(ttl));
+ if (adjust_ttl_) {
+ if (ttl_ != ttl) {
+ if (ttl < ttl_) {
+ ttl_ = ttl;
+ rrset->setTTL(RRTTL(ttl));
+ }
+ LOG_WARN(logger, DATASRC_DATABASE_ITERATE_TTL_MISMATCH).
+ arg(name_).arg(class_).arg(rtype_).arg(rrset->getTTL());
}
- LOG_WARN(logger, DATASRC_DATABASE_ITERATE_TTL_MISMATCH).
- arg(name_).arg(class_).arg(rtype_).arg(rrset->getTTL());
+ } else if (ttl_ != ttl) {
+ break;
}
rrset->addRdata(rdata::createRdata(rtype, class_, rdata_));
getData();
- if (individual_rrs_) {
- break;
- }
}
LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ITERATE_NEXT).
arg(rrset->getName()).arg(rrset->getType());
@@ -768,15 +769,16 @@ private:
bool ready_, data_ready_;
// Data of the next row
string name_, rtype_, rdata_, ttl_;
- // Whether to return individual RRsets
- bool individual_rrs_;
+ // Whether to modify differing TTL values, or treat a different TTL as
+ // a different RRset
+ bool adjust_ttl_;
};
}
ZoneIteratorPtr
DatabaseClient::getIterator(const isc::dns::Name& name,
- bool individual_rrs) const
+ bool adjust_ttl) const
{
// Get the zone
std::pair<bool, int> zone(accessor_->getZone(name.toText()));
@@ -802,7 +804,7 @@ DatabaseClient::getIterator(const isc::dns::Name& name,
LOG_DEBUG(logger, DBG_TRACE_DETAILED, DATASRC_DATABASE_ITERATE).
arg(name);
return (ZoneIteratorPtr(new DatabaseIterator(context, RRClass::IN(),
- individual_rrs)));
+ adjust_ttl)));
}
//
diff --git a/src/lib/datasrc/database.h b/src/lib/datasrc/database.h
index 6325914..4d1a0db 100644
--- a/src/lib/datasrc/database.h
+++ b/src/lib/datasrc/database.h
@@ -741,13 +741,15 @@ public:
* \exception Anything else the underlying DatabaseConnection might
* want to throw.
* \param name The origin of the zone to iterate.
- * \param individual_rrs If true, the iterator will return each RR found
- * in the data as a separate RRset, instead of combining them into
- * RRsets.
+ * \param adjust_ttl If true, the iterator will treat RRs with the same
+ * name and type but different TTL values to be of the
+ * same RRset, and will adjust the TTL to the lowest
+ * value found. If false, it will consider the RR to
+ * belong to a different RRset.
* \return Shared pointer to the iterator (it will never be NULL)
*/
virtual ZoneIteratorPtr getIterator(const isc::dns::Name& name,
- bool individual_rrs = false) const;
+ bool adjust_ttl = true) const;
/// This implementation internally clones the accessor from the one
/// used in the client and starts a separate transaction using the cloned
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 6612a28..ebb32ea 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -786,6 +786,10 @@ public:
ZoneIteratorPtr
InMemoryClient::getIterator(const Name& name, bool) const {
+ // note: adjust_ttl argument is ignored, as the RRsets are already
+ // individually stored, and hence cannot have different TTLs anymore at
+ // this point
+
ZoneTable::FindResult result(impl_->zone_table.findZone(name));
if (result.code != result::SUCCESS) {
isc_throw(DataSourceError, "No such zone: " + name.toText());
diff --git a/src/lib/datasrc/memory_datasrc.h b/src/lib/datasrc/memory_datasrc.h
index d980bac..1b6c120 100644
--- a/src/lib/datasrc/memory_datasrc.h
+++ b/src/lib/datasrc/memory_datasrc.h
@@ -273,7 +273,7 @@ public:
/// \brief Implementation of the getIterator method
virtual ZoneIteratorPtr getIterator(const isc::dns::Name& name,
- bool individual_rrs = false) const;
+ bool adjust_ttl = true) const;
/// In-memory data source is read-only, so this derived method will
/// result in a NotImplemented exception.
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 8c292d9..3fc799c 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -1120,8 +1120,8 @@ TEST_F(MockDatabaseClientTest, ttldiff) {
// Unless we ask for individual RRs in our iterator request. In that case
// every RR should go into its own 'rrset'
-TEST_F(MockDatabaseClientTest, ttldiff_individual) {
- ZoneIteratorPtr it(this->client_->getIterator(Name("example.org"), true));
+TEST_F(MockDatabaseClientTest, ttldiff_no_adjust_ttl) {
+ ZoneIteratorPtr it(this->client_->getIterator(Name("example.org"), false));
// Walk through the full iterator, we should see 1 rrset with name
// ttldiff1.example.org., and two rdatas. Same for ttldiff2
@@ -1139,6 +1139,9 @@ TEST_F(MockDatabaseClientTest, ttldiff_individual) {
} else if (rrset->getTTL() == RRTTL(600)) {
ASSERT_FALSE(found2);
found2 = true;
+ } else {
+ FAIL() << "Found unexpected TTL: " <<
+ rrset->getTTL().toText();
}
}
rrset = it->getNextRRset();
diff --git a/src/lib/python/isc/datasrc/client_inc.cc b/src/lib/python/isc/datasrc/client_inc.cc
index b81f48d..6465bf3 100644
--- a/src/lib/python/isc/datasrc/client_inc.cc
+++ b/src/lib/python/isc/datasrc/client_inc.cc
@@ -89,7 +89,7 @@ None\n\
";
const char* const DataSourceClient_getIterator_doc = "\
-get_iterator(name) -> ZoneIterator\n\
+get_iterator(name, adjust_ttl=True) -> ZoneIterator\n\
\n\
Returns an iterator to the given zone.\n\
\n\
@@ -111,6 +111,11 @@ anything else.\n\
Parameters:\n\
isc.dns.Name The name of zone apex to be traversed. It doesn't do\n\
nearest match as find_zone.\n\
+ adjust_ttl If True, the iterator will treat RRs with the same\n\
+ name and type but different TTL values to be of the\n\
+ same RRset, and will adjust the TTL to the lowest\n\
+ value found. If false, it will consider the RR to\n\
+ belong to a different RRset.\n\
\n\
Return Value(s): Pointer to the iterator.\n\
";
diff --git a/src/lib/python/isc/datasrc/client_python.cc b/src/lib/python/isc/datasrc/client_python.cc
index caebd25..8613d84 100644
--- a/src/lib/python/isc/datasrc/client_python.cc
+++ b/src/lib/python/isc/datasrc/client_python.cc
@@ -83,11 +83,19 @@ DataSourceClient_findZone(PyObject* po_self, PyObject* args) {
PyObject*
DataSourceClient_getIterator(PyObject* po_self, PyObject* args) {
s_DataSourceClient* const self = static_cast<s_DataSourceClient*>(po_self);
- PyObject *name_obj;
- if (PyArg_ParseTuple(args, "O!", &name_type, &name_obj)) {
+ PyObject* name_obj;
+ PyObject* adjust_ttl_obj = NULL;
+ if (PyArg_ParseTuple(args, "O!|O", &name_type, &name_obj,
+ &adjust_ttl_obj)) {
try {
+ bool adjust_ttl = true;
+ if (adjust_ttl_obj != NULL &&
+ PyObject_Not(adjust_ttl_obj)) {
+ adjust_ttl = false;
+ }
return (createZoneIteratorObject(
- self->cppobj->getInstance().getIterator(PyName_ToName(name_obj)),
+ self->cppobj->getInstance().getIterator(PyName_ToName(name_obj),
+ adjust_ttl),
po_self));
} catch (const isc::NotImplemented& ne) {
PyErr_SetString(getDataSourceException("NotImplemented"),
diff --git a/src/lib/python/isc/datasrc/tests/datasrc_test.py b/src/lib/python/isc/datasrc/tests/datasrc_test.py
index dcb8904..eaca67f 100644
--- a/src/lib/python/isc/datasrc/tests/datasrc_test.py
+++ b/src/lib/python/isc/datasrc/tests/datasrc_test.py
@@ -63,7 +63,7 @@ def check_for_rrset(expected_rrsets, rrset):
class DataSrcClient(unittest.TestCase):
- def test_constructors(self):
+ def test_(self):
# can't construct directly
self.assertRaises(TypeError, isc.datasrc.ZoneIterator)
@@ -87,7 +87,7 @@ class DataSrcClient(unittest.TestCase):
# for RRSIGS, the TTL's are currently modified. This test should
# start failing when we fix that.
- rrs = dsc.get_iterator(isc.dns.Name("sql1.example.com."))
+ rrs = dsc.get_iterator(isc.dns.Name("sql1.example.com."), False)
# we do not know the order in which they are returned by the iterator
# but we do want to check them, so we put all records into one list
@@ -137,6 +137,13 @@ class DataSrcClient(unittest.TestCase):
])
# For RRSIGS, we can't add the fake data through the API, so we
# simply pass no rdata at all (which is skipped by the check later)
+
+ # Since we passed adjust_ttl = False to get_iterator, we get several
+ # sets of RRSIGs, one for each TTL
+ add_rrset(expected_rrset_list, name, rrclass,
+ isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+ add_rrset(expected_rrset_list, name, rrclass,
+ isc.dns.RRType.RRSIG(), isc.dns.RRTTL(7200), None)
add_rrset(expected_rrset_list, name, rrclass,
isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
add_rrset(expected_rrset_list, name, rrclass,
@@ -158,6 +165,8 @@ class DataSrcClient(unittest.TestCase):
])
add_rrset(expected_rrset_list, name, rrclass,
isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+ add_rrset(expected_rrset_list, name, rrclass,
+ isc.dns.RRType.RRSIG(), isc.dns.RRTTL(7200), None)
# rrs is an iterator, but also has direct get_next_rrset(), use
# the latter one here
@@ -179,10 +188,26 @@ class DataSrcClient(unittest.TestCase):
# instead of failing?
self.assertRaises(isc.datasrc.Error, rrs.get_next_rrset)
+ # Without the adjust_ttl argument, it should return 55 RRsets
+ dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
rrets = dsc.get_iterator(isc.dns.Name("example.com"))
# there are more than 80 RRs in this zone... let's just count them
# (already did a full check of the smaller zone above)
self.assertEqual(55, len(list(rrets)))
+
+ # same test, but now with explicit True argument for adjust_ttl
+ dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
+ rrets = dsc.get_iterator(isc.dns.Name("example.com"), True)
+ # there are more than 80 RRs in this zone... let's just count them
+ # (already did a full check of the smaller zone above)
+ self.assertEqual(55, len(list(rrets)))
+
+ # Count should be 71 if we request individual rrsets for differing ttls
+ dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
+ rrets = dsc.get_iterator(isc.dns.Name("example.com"), False)
+ # there are more than 80 RRs in this zone... let's just count them
+ # (already did a full check of the smaller zone above)
+ self.assertEqual(71, len(list(rrets)))
# TODO should we catch this (iterating past end) and just return None
# instead of failing?
self.assertRaises(isc.datasrc.Error, rrs.get_next_rrset)
More information about the bind10-changes
mailing list