BIND 10 trac2435, updated. 137cfc9037a103e5c5ec814a798dbc56db6ae835 [2435] Make ZoneUpdater return a corresponding RRsetCollection for itself
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jan 9 12:45:21 UTC 2013
The branch, trac2435 has been updated
via 137cfc9037a103e5c5ec814a798dbc56db6ae835 (commit)
from 3ea93cc724f87d47c024f895650853f284daf9a1 (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 137cfc9037a103e5c5ec814a798dbc56db6ae835
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Jan 9 18:11:35 2013 +0530
[2435] Make ZoneUpdater return a corresponding RRsetCollection for itself
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/database.cc | 5 +++
src/lib/datasrc/rrset_collection.cc | 2 +-
src/lib/datasrc/rrset_collection.h | 11 +++--
src/lib/datasrc/tests/database_unittest.cc | 46 ++++++++++----------
.../datasrc/tests/master_loader_callbacks_test.cc | 3 ++
src/lib/datasrc/tests/zone_loader_unittest.cc | 3 ++
src/lib/datasrc/zone.h | 4 ++
src/lib/dns/rrset_collection_base.h | 2 +
8 files changed, 47 insertions(+), 29 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index d791fbc..12c3f87 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -31,6 +31,7 @@
#include <datasrc/data_source.h>
#include <datasrc/logger.h>
+#include <datasrc/rrset_collection.h>
#include <boost/foreach.hpp>
#include <boost/scoped_ptr.hpp>
@@ -1411,6 +1412,10 @@ public:
virtual ZoneFinder& getFinder() { return (*finder_); }
+ virtual RRsetCollectionPtr getRRsetCollection() {
+ return (RRsetCollectionPtr(new RRsetCollection(*this, zone_class_)));
+ }
+
virtual void addRRset(const AbstractRRset& rrset);
virtual void deleteRRset(const AbstractRRset& rrset);
virtual void commit();
diff --git a/src/lib/datasrc/rrset_collection.cc b/src/lib/datasrc/rrset_collection.cc
index 771ce7d..0651dec 100644
--- a/src/lib/datasrc/rrset_collection.cc
+++ b/src/lib/datasrc/rrset_collection.cc
@@ -35,7 +35,7 @@ RRsetCollection::find(const isc::dns::Name& name,
return (ConstRRsetPtr());
}
- ZoneFinder& finder = updater_->getFinder();
+ ZoneFinder& finder = updater_.getFinder();
try {
ZoneFinderContextPtr result =
finder.find(name, rrtype,
diff --git a/src/lib/datasrc/rrset_collection.h b/src/lib/datasrc/rrset_collection.h
index ec3dcf0..0907323 100644
--- a/src/lib/datasrc/rrset_collection.h
+++ b/src/lib/datasrc/rrset_collection.h
@@ -27,14 +27,13 @@ class RRsetCollection : public isc::dns::RRsetCollectionBase {
public:
/// \brief Constructor.
///
- /// A reference to the \c updater (via \c shared_ptr) is taken when
- /// the collection is constructed. As long as the collection object
- /// is alive, the reference to the updater is kept and it cannot be
- /// destroyed by the client.
+ /// No reference (count via \c shared_ptr) to the ZoneUpdater is
+ /// acquired. As long as the collection object is alive, the
+ /// corresponding \c ZoneUpdater should be kept alive.
///
/// \param updater The ZoneUpdater to wrap around.
/// \param rrclass The RRClass of the records in the zone.
- RRsetCollection(ZoneUpdaterPtr updater, const isc::dns::RRClass& rrclass) :
+ RRsetCollection(ZoneUpdater& updater, const isc::dns::RRClass& rrclass) :
updater_(updater),
rrclass_(rrclass)
{}
@@ -58,7 +57,7 @@ public:
const isc::dns::RRType& rrtype) const;
private:
- ZoneUpdaterPtr updater_;
+ ZoneUpdater& updater_;
isc::dns::RRClass rrclass_;
protected:
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 3aff9ca..0c85aea 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -4162,17 +4162,18 @@ class RRsetCollectionTest : public DatabaseClientTest<ACCESSOR_TYPE> {
public:
RRsetCollectionTest() :
DatabaseClientTest<ACCESSOR_TYPE>(),
- collection(this->client_->getUpdater(this->zname_, false),
- this->qclass_)
+ updater(this->client_->getUpdater(this->zname_, false)),
+ collection(updater->getRRsetCollection())
{}
- RRsetCollection collection;
+ ZoneUpdaterPtr updater;
+ RRsetCollectionPtr collection;
};
TYPED_TEST(RRsetCollectionTest, find) {
// Test the find() that returns ConstRRsetPtr
- ConstRRsetPtr rrset = this->collection.find(Name("www.example.org."),
- RRClass::IN(), RRType::A());
+ ConstRRsetPtr rrset = this->collection->find(Name("www.example.org."),
+ RRClass::IN(), RRType::A());
ASSERT_TRUE(rrset);
EXPECT_EQ(RRType::A(), rrset->getType());
EXPECT_EQ(RRTTL(3600), rrset->getTTL());
@@ -4180,46 +4181,47 @@ TYPED_TEST(RRsetCollectionTest, find) {
EXPECT_EQ(Name("www.example.org"), rrset->getName());
// foo.example.org doesn't exist
- rrset = this->collection.find(Name("foo.example.org"), this->qclass_,
- RRType::A());
+ rrset = this->collection->find(Name("foo.example.org"), this->qclass_,
+ RRType::A());
EXPECT_FALSE(rrset);
// www.example.org exists, but not with MX
- rrset = this->collection.find(Name("www.example.org"), this->qclass_,
- RRType::MX());
+ rrset = this->collection->find(Name("www.example.org"), this->qclass_,
+ RRType::MX());
EXPECT_FALSE(rrset);
// www.example.org exists, with AAAA
- rrset = this->collection.find(Name("www.example.org"), this->qclass_,
- RRType::AAAA());
+ rrset = this->collection->find(Name("www.example.org"), this->qclass_,
+ RRType::AAAA());
EXPECT_TRUE(rrset);
// www.example.org with AAAA does not exist in RRClass::CH()
- rrset = this->collection.find(Name("www.example.org"), RRClass::CH(),
- RRType::AAAA());
+ rrset = this->collection->find(Name("www.example.org"), RRClass::CH(),
+ RRType::AAAA());
EXPECT_FALSE(rrset);
// Out of zone find()s must not throw.
- rrset = this->collection.find(Name("www.example.com"), this->qclass_,
- RRType::A());
+ rrset = this->collection->find(Name("www.example.com"), this->qclass_,
+ RRType::A());
EXPECT_FALSE(rrset);
}
TYPED_TEST(RRsetCollectionTest, iteratorTest) {
// Iterators are currently not implemented.
- EXPECT_THROW(this->collection.begin(), isc::NotImplemented);
- EXPECT_THROW(this->collection.end(), isc::NotImplemented);
+ EXPECT_THROW(this->collection->begin(), isc::NotImplemented);
+ EXPECT_THROW(this->collection->end(), isc::NotImplemented);
}
class MockRRsetCollectionTest : public DatabaseClientTest<MockAccessor> {
public:
MockRRsetCollectionTest() :
DatabaseClientTest<MockAccessor>(),
- collection(this->client_->getUpdater(this->zname_, false),
- this->qclass_)
+ updater(this->client_->getUpdater(this->zname_, false)),
+ collection(updater->getRRsetCollection())
{}
- RRsetCollection collection;
+ ZoneUpdaterPtr updater;
+ RRsetCollectionPtr collection;
};
TEST_F(MockRRsetCollectionTest, findError) {
@@ -4230,8 +4232,8 @@ TEST_F(MockRRsetCollectionTest, findError) {
// The "dsexception.example.org." name is rigged by the MockAccessor
// to throw a DataSourceError.
EXPECT_THROW({
- this->collection.find(Name("dsexception.example.org"), this->qclass_,
- RRType::A());
+ this->collection->find(Name("dsexception.example.org"), this->qclass_,
+ RRType::A());
}, RRsetCollectionBase::FindError);
}
diff --git a/src/lib/datasrc/tests/master_loader_callbacks_test.cc b/src/lib/datasrc/tests/master_loader_callbacks_test.cc
index 19ec4d2..ecc0f28 100644
--- a/src/lib/datasrc/tests/master_loader_callbacks_test.cc
+++ b/src/lib/datasrc/tests/master_loader_callbacks_test.cc
@@ -65,6 +65,9 @@ public:
virtual ZoneFinder& getFinder() {
isc_throw(isc::NotImplemented, "Not to be called in this test");
}
+ virtual isc::dns::RRsetCollectionPtr getRRsetCollection() {
+ isc_throw(isc::NotImplemented, "Not to be called in this test");
+ }
virtual void deleteRRset(const isc::dns::AbstractRRset&) {
isc_throw(isc::NotImplemented, "Not to be called in this test");
}
diff --git a/src/lib/datasrc/tests/zone_loader_unittest.cc b/src/lib/datasrc/tests/zone_loader_unittest.cc
index b19a843..b8517f4 100644
--- a/src/lib/datasrc/tests/zone_loader_unittest.cc
+++ b/src/lib/datasrc/tests/zone_loader_unittest.cc
@@ -89,6 +89,9 @@ public:
virtual ZoneFinder& getFinder() {
return (finder_);
}
+ virtual isc::dns::RRsetCollectionPtr getRRsetCollection() {
+ isc_throw(isc::NotImplemented, "Method not used in tests");
+ }
virtual void addRRset(const isc::dns::AbstractRRset& rrset) {
if (client_->commit_called_) {
isc_throw(DataSourceError, "Add after commit");
diff --git a/src/lib/datasrc/zone.h b/src/lib/datasrc/zone.h
index 0d7438d..3b61cd8 100644
--- a/src/lib/datasrc/zone.h
+++ b/src/lib/datasrc/zone.h
@@ -18,6 +18,7 @@
#include <dns/name.h>
#include <dns/rrset.h>
#include <dns/rrtype.h>
+#include <dns/rrset_collection_base.h>
#include <datasrc/exceptions.h>
#include <datasrc/result.h>
@@ -802,6 +803,9 @@ public:
/// \return A reference to a \c ZoneFinder for the updated zone
virtual ZoneFinder& getFinder() = 0;
+ /// Return an RRsetCollection for the updater.
+ virtual isc::dns::RRsetCollectionPtr getRRsetCollection() = 0;
+
/// Add an RRset to a zone via the updater
///
/// This may be revisited in a future version, but right now the intended
diff --git a/src/lib/dns/rrset_collection_base.h b/src/lib/dns/rrset_collection_base.h
index ff2617f..fbcbeeb 100644
--- a/src/lib/dns/rrset_collection_base.h
+++ b/src/lib/dns/rrset_collection_base.h
@@ -167,6 +167,8 @@ public:
}
};
+typedef boost::shared_ptr<RRsetCollectionBase> RRsetCollectionPtr;
+
} // end of namespace dns
} // end of namespace isc
More information about the bind10-changes
mailing list