BIND 10 trac2209, updated. a92defd1deceebc13a7bcc93cee6579ed42be41e [2209] Hack the ZoneTableSegment into MemoryClient
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Oct 23 16:04:49 UTC 2012
The branch, trac2209 has been updated
via a92defd1deceebc13a7bcc93cee6579ed42be41e (commit)
via a09e57e212a102d719315aff8d0f3c4ce74268d8 (commit)
from 1eda789420a1914f61ee720043a15516157f23b4 (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 a92defd1deceebc13a7bcc93cee6579ed42be41e
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Oct 23 17:00:29 2012 +0200
[2209] Hack the ZoneTableSegment into MemoryClient
This branch needs the MemoryClient to have its Zonetablesegment. But it
doesn't have one now and it is not the task of this branch to put it in
there. So I added it inside in somewhat ad-hoc manner.
This is hairy and adds bunch of temporary methods. If there's a better
approach, let's use it. But taking this for now to be cleaned up in some
follow-up ticket.
commit a09e57e212a102d719315aff8d0f3c4ce74268d8
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Oct 23 16:49:05 2012 +0200
[2209] Unrelated fix: don't c-string + int
It doesn't produce the expected result (which was obviously expected
in the code). Changed to lexical_cast, which should be enough.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/memory/memory_client.cc | 16 +++++++++++++++-
src/lib/datasrc/memory/memory_client.h | 15 +++++++++++++++
src/lib/datasrc/memory/zone_table_segment.cc | 5 +++++
src/lib/datasrc/memory/zone_table_segment.h | 12 ++++++++++++
src/lib/datasrc/memory/zone_table_segment_local.h | 11 +++++++++--
.../datasrc/tests/memory/memory_client_unittest.cc | 13 ++++++++++++-
6 files changed, 68 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/memory_client.cc b/src/lib/datasrc/memory/memory_client.cc
index 2f5fe67..7a367e2 100644
--- a/src/lib/datasrc/memory/memory_client.cc
+++ b/src/lib/datasrc/memory/memory_client.cc
@@ -22,6 +22,7 @@
#include <datasrc/memory/treenode_rrset.h>
#include <datasrc/memory/zone_finder.h>
#include <datasrc/memory/zone_data_loader.h>
+#include <datasrc/memory/zone_table_segment.h>
#include <util/memory_segment_local.h>
@@ -66,7 +67,14 @@ public:
InMemoryClient::InMemoryClient(util::MemorySegment& mem_sgmt,
RRClass rrclass) :
- mem_sgmt_(mem_sgmt),
+ // FIXME: We currently use the temporary and "unsupported"
+ // constructor of the zone table segment. Once we clarify
+ // how the config thing, we want to change it.
+ zone_table_segment_(ZoneTableSegment::create(mem_sgmt)),
+ // Use the memory segment from the zone table segment. Currently,
+ // it is the same one as the one in parameter, but that will
+ // probably change.
+ mem_sgmt_(zone_table_segment_->getMemorySegment()),
rrclass_(rrclass),
zone_count_(0)
{
@@ -76,13 +84,19 @@ InMemoryClient::InMemoryClient(util::MemorySegment& mem_sgmt,
file_name_tree_ = FileNameTree::create(mem_sgmt_, false);
zone_table_ = holder.release();
+ // TODO: Once the table is created inside the zone table segment, use that
+ // one.
+ zone_table_segment_->getHeader().setTable(zone_table_);
}
InMemoryClient::~InMemoryClient() {
FileNameDeleter deleter;
FileNameTree::destroy(mem_sgmt_, file_name_tree_, deleter);
+ // TODO: Once the table is created inside the zone table segment, do not
+ // destroy it here.
ZoneTable::destroy(mem_sgmt_, zone_table_, rrclass_);
+ ZoneTableSegment::destroy(zone_table_segment_);
}
result::Result
diff --git a/src/lib/datasrc/memory/memory_client.h b/src/lib/datasrc/memory/memory_client.h
index 3313c5b..dd74a72 100644
--- a/src/lib/datasrc/memory/memory_client.h
+++ b/src/lib/datasrc/memory/memory_client.h
@@ -34,6 +34,8 @@ class RRsetList;
namespace datasrc {
namespace memory {
+class ZoneTableSegment;
+
/// \brief A data source client that holds all necessary data in memory.
///
/// The \c InMemoryClient class provides an access to a conceptual data
@@ -175,6 +177,18 @@ public:
getJournalReader(const isc::dns::Name& zone, uint32_t begin_serial,
uint32_t end_serial) const;
+ /// \brief Get the zone table segment used
+ ///
+ /// This is a low-level function, used to some internal handling when,
+ /// for example, reloading the data inside the in-memory data source.
+ /// It should not be generally used.
+ ///
+ /// \todo Consider making this private and add a friend declaration
+ /// for the ClientList.
+ ZoneTableSegment& getZoneTableSegment() {
+ return (*zone_table_segment_);
+ }
+
private:
// Some type aliases
typedef DomainTree<std::string> FileNameTree;
@@ -186,6 +200,7 @@ private:
const std::string& filename,
ZoneData* zone_data);
+ ZoneTableSegment* zone_table_segment_;
util::MemorySegment& mem_sgmt_;
const isc::dns::RRClass rrclass_;
unsigned int zone_count_;
diff --git a/src/lib/datasrc/memory/zone_table_segment.cc b/src/lib/datasrc/memory/zone_table_segment.cc
index 7a80e3c..db8ea26 100644
--- a/src/lib/datasrc/memory/zone_table_segment.cc
+++ b/src/lib/datasrc/memory/zone_table_segment.cc
@@ -28,6 +28,11 @@ ZoneTableSegment::create(const isc::data::Element&) {
return (new ZoneTableSegmentLocal);
}
+ZoneTableSegment*
+ZoneTableSegment::create(isc::util::MemorySegment& segment) {
+ return (new ZoneTableSegmentLocal(segment));
+}
+
void
ZoneTableSegment::destroy(ZoneTableSegment *segment) {
delete segment;
diff --git a/src/lib/datasrc/memory/zone_table_segment.h b/src/lib/datasrc/memory/zone_table_segment.h
index 8731718..0e728b8 100644
--- a/src/lib/datasrc/memory/zone_table_segment.h
+++ b/src/lib/datasrc/memory/zone_table_segment.h
@@ -121,6 +121,18 @@ public:
/// \return Returns a ZoneTableSegment object
static ZoneTableSegment* create(const isc::data::Element& config);
+ /// \brief Temporary/Testing version of create.
+ ///
+ /// This exists as a temporary solution during the migration phase
+ /// towards using the ZoneTableSegment. It doesn't take a config,
+ /// but a memory segment instead. If you can, you should use the
+ /// other version, this one will be gone soon.
+ ///
+ /// \param segment The memory segment to use.
+ /// \return Returns a new ZoneTableSegment object.
+ /// \todo Remove this method.
+ static ZoneTableSegment* create(isc::util::MemorySegment& segment);
+
/// \brief Destroy a ZoneTableSegment
///
/// This method destroys the passed ZoneTableSegment. It must be
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.h b/src/lib/datasrc/memory/zone_table_segment_local.h
index b83bd49..903bbe6 100644
--- a/src/lib/datasrc/memory/zone_table_segment_local.h
+++ b/src/lib/datasrc/memory/zone_table_segment_local.h
@@ -37,7 +37,13 @@ protected:
/// Instances are expected to be created by the factory method
/// (\c ZoneTableSegment::create()), so this constructor is
/// protected.
- ZoneTableSegmentLocal()
+ ZoneTableSegmentLocal() :
+ mem_sgmt_(mem_sgmt_local_)
+ {}
+ // TODO: A temporary constructor, for tests for now. Needs to
+ // be removed.
+ ZoneTableSegmentLocal(isc::util::MemorySegment& segment) :
+ mem_sgmt_(segment)
{}
public:
/// \brief Destructor
@@ -60,7 +66,8 @@ public:
const dns::RRClass& rrclass);
private:
ZoneTableHeader header_;
- isc::util::MemorySegmentLocal mem_sgmt_;
+ isc::util::MemorySegmentLocal mem_sgmt_local_;
+ isc::util::MemorySegment& mem_sgmt_;
};
} // namespace memory
diff --git a/src/lib/datasrc/tests/memory/memory_client_unittest.cc b/src/lib/datasrc/tests/memory/memory_client_unittest.cc
index 8785a10..6b41d84 100644
--- a/src/lib/datasrc/tests/memory/memory_client_unittest.cc
+++ b/src/lib/datasrc/tests/memory/memory_client_unittest.cc
@@ -39,6 +39,8 @@
#include <gtest/gtest.h>
+#include <boost/lexical_cast.hpp>
+
#include <new> // for bad_alloc
using namespace isc::dns;
@@ -289,7 +291,8 @@ TEST_F(MemoryClientTest, loadMemoryAllocationFailures) {
// Just to check that things get cleaned up
for (int i = 1; i < 16; i++) {
- SCOPED_TRACE("For throw count = " + i);
+ SCOPED_TRACE("For throw count = " +
+ boost::lexical_cast<std::string>(i));
mem_sgmt_.setThrowCount(i);
EXPECT_THROW({
// Include the InMemoryClient construction too here. Now,
@@ -762,4 +765,12 @@ TEST_F(MemoryClientTest, getJournalReaderNotImplemented) {
isc::NotImplemented);
}
+TEST_F(MemoryClientTest, getZoneTableSegment) {
+ // It's hard to test this method. It returns a reference, so we can't even
+ // check for non-NULL. Checking it doesn't throw/crash is good enough for
+ // now, the method will be used in other functions, so checked it works
+ // implicitly.
+ EXPECT_NO_THROW(client_->getZoneTableSegment());
+}
+
}
More information about the bind10-changes
mailing list