BIND 10 trac2207, updated. d5569a62a30b26294197381dadf4b28317fba3d9 [2207] Implementation of the getZoneReloader

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 15 10:14:56 UTC 2012


The branch, trac2207 has been updated
       via  d5569a62a30b26294197381dadf4b28317fba3d9 (commit)
       via  b06d8d764e01652ef5d3e1eb50ed482ddeae8308 (commit)
       via  51580fd1a4953d554b80306eec4f9fc89f166241 (commit)
       via  c55218e6bebfeec753b01e4cd724adcda40b3a5f (commit)
      from  c0e090f453d3a1627ccd0591e0ec0abc3e80a01b (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 d5569a62a30b26294197381dadf4b28317fba3d9
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 15 12:14:04 2012 +0200

    [2207] Implementation of the getZoneReloader
    
    The concrete version for local table segment and reloader.

commit b06d8d764e01652ef5d3e1eb50ed482ddeae8308
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 15 12:13:49 2012 +0200

    [2207] Docs and capitalization fix

commit 51580fd1a4953d554b80306eec4f9fc89f166241
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 15 12:13:06 2012 +0200

    [2207] Tests for the getZoneReloader

commit c55218e6bebfeec753b01e4cd724adcda40b3a5f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 15 11:28:35 2012 +0200

    [2207] interface of the getZoneReloader

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/memory/Makefile.am                 |    1 +
 .../datasrc/memory/{logger.cc => load_action.h}    |   21 +++++++++++++++--
 src/lib/datasrc/memory/zone_reloader.h             |   22 ++++++------------
 src/lib/datasrc/memory/zone_table_segment.h        |   21 +++++++++++++++++
 src/lib/datasrc/memory/zone_table_segment_local.cc |    9 ++++++++
 src/lib/datasrc/memory/zone_table_segment_local.h  |    4 ++++
 .../tests/memory/zone_table_segment_unittest.cc    |   24 ++++++++++++++++++++
 7 files changed, 85 insertions(+), 17 deletions(-)
 copy src/lib/datasrc/memory/{logger.cc => load_action.h} (62%)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/Makefile.am b/src/lib/datasrc/memory/Makefile.am
index 192bbce..7319602 100644
--- a/src/lib/datasrc/memory/Makefile.am
+++ b/src/lib/datasrc/memory/Makefile.am
@@ -23,6 +23,7 @@ libdatasrc_memory_la_SOURCES += zone_finder.h zone_finder.cc
 libdatasrc_memory_la_SOURCES += zone_table_segment.h zone_table_segment.cc
 libdatasrc_memory_la_SOURCES += zone_table_segment_local.h zone_table_segment_local.cc
 libdatasrc_memory_la_SOURCES += zone_reloader.h zone_reloader.cc
+libdatasrc_memory_la_SOURCES += load_action.h
 nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc
 
 EXTRA_DIST  = rdata_serialization_priv.cc
diff --git a/src/lib/datasrc/memory/load_action.h b/src/lib/datasrc/memory/load_action.h
new file mode 100644
index 0000000..e5fe004
--- /dev/null
+++ b/src/lib/datasrc/memory/load_action.h
@@ -0,0 +1,42 @@
+// Copyright (C) 2012  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
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef LOAD_ACTION_H
+#define LOAD_ACTION_H
+
+#include <boost/function.hpp>
+
+namespace isc {
+// Forward declarations
+namespace util{
+class MemorySegment;
+}
+namespace datasrc {
+namespace memory {
+class ZoneData;
+
+/// \brief Callback to load data into the memory
+///
+/// This callback should create new ZoneData (allocated from the passed
+/// memory segment) and fill it with relevant loaded data. The caller
+/// of the callback takes ownership of the ZoneData.
+///
+/// It must not return NULL.
+typedef boost::function<ZoneData*(util::MemorySegment&)> LoadAction;
+
+}
+}
+}
+
+#endif
diff --git a/src/lib/datasrc/memory/zone_reloader.h b/src/lib/datasrc/memory/zone_reloader.h
index 70572f7..b167237 100644
--- a/src/lib/datasrc/memory/zone_reloader.h
+++ b/src/lib/datasrc/memory/zone_reloader.h
@@ -12,16 +12,15 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
+#ifndef ZONE_RELOADER_H
+#define ZONE_RELOADER_H
+
+#include "load_action.h"
+
 #include <dns/rrclass.h>
 #include <dns/name.h>
 
-#include <boost/function.hpp>
-
 namespace isc {
-// Forward declarations
-namespace util{
-class MemorySegment;
-}
 namespace datasrc {
 namespace memory {
 class ZoneData;
@@ -81,15 +80,6 @@ public:
     virtual void cleanup() = 0;
 };
 
-/// \brief Callback to load data into the memory
-///
-/// This callback should create new ZoneData (allocated from the passed
-/// memory segment) and fill it with relevant loaded data. The caller
-/// of the callback takes ownership of the ZoneData.
-///
-/// It must not return NULL.
-typedef boost::function<ZoneData*(util::MemorySegment&)> LoadAction;
-
 /// \brief Reloader implementation which loads data locally.
 ///
 /// This implementation prepares a clean zone data and lets one callback
@@ -147,3 +137,5 @@ private:
 }
 }
 }
+
+#endif
diff --git a/src/lib/datasrc/memory/zone_table_segment.h b/src/lib/datasrc/memory/zone_table_segment.h
index 3c927e7..239d8dd 100644
--- a/src/lib/datasrc/memory/zone_table_segment.h
+++ b/src/lib/datasrc/memory/zone_table_segment.h
@@ -16,6 +16,7 @@
 #define __ZONE_TABLE_SEGMENT_H__
 
 #include <datasrc/memory/zone_table.h>
+#include "load_action.h"
 #include <cc/data.h>
 #include <util/memory_segment.h>
 
@@ -24,8 +25,14 @@
 #include <stdlib.h>
 
 namespace isc {
+// Some forward declarations
+namespace dns {
+class Name;
+class RRClass;
+}
 namespace datasrc {
 namespace memory {
+class ZoneReloader;
 
 /// \brief Memory-management independent entry point that contains a
 /// pointer to a zone table in memory.
@@ -121,6 +128,20 @@ public:
     ///
     /// \param segment The segment to destroy.
     static void destroy(ZoneTableSegment* segment);
+
+    /// \brief Create a reloader corresponding to this segment
+    ///
+    /// This creates a new reloader that can be used to reload zones
+    /// inside this zone table segment.
+    ///
+    /// \param loadAction Callback to provide the actual data.
+    /// \param origin The origin of the zone to reload.
+    /// \param rrclass The class of the zone to reload.
+    /// \return New instance of a zone reloader. The ownership is passed
+    ///     onto the caller.
+    virtual ZoneReloader* getZoneReloader(const LoadAction& load_action,
+                                          const dns::Name& origin,
+                                          const dns::RRClass& rrclass) = 0;
 };
 
 } // namespace memory
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.cc b/src/lib/datasrc/memory/zone_table_segment_local.cc
index 589c9af..3a19d86 100644
--- a/src/lib/datasrc/memory/zone_table_segment_local.cc
+++ b/src/lib/datasrc/memory/zone_table_segment_local.cc
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <datasrc/memory/zone_table_segment_local.h>
+#include "zone_reloader.h"
 
 using namespace isc::util;
 
@@ -38,6 +39,14 @@ ZoneTableSegmentLocal::getMemorySegment() {
      return (mem_sgmt_);
 }
 
+ZoneReloader*
+ZoneTableSegmentLocal::getZoneReloader(const LoadAction& load_action,
+                                       const dns::Name& name,
+                                       const dns::RRClass& rrclass)
+{
+    return (new ZoneReloaderLocal(this, load_action, name, rrclass));
+}
+
 } // namespace memory
 } // namespace datasrc
 } // namespace isc
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.h b/src/lib/datasrc/memory/zone_table_segment_local.h
index de776a9..5db4a08 100644
--- a/src/lib/datasrc/memory/zone_table_segment_local.h
+++ b/src/lib/datasrc/memory/zone_table_segment_local.h
@@ -54,6 +54,10 @@ public:
     /// implementation (a MemorySegmentLocal instance).
     virtual isc::util::MemorySegment& getMemorySegment();
 
+    /// \brief Concrete implementation of ZoneTableSegment::getZoneReloader
+    virtual ZoneReloader* getZoneReloader(const LoadAction& load_action,
+                                          const dns::Name& origin,
+                                          const dns::RRClass& rrclass);
 private:
     ZoneTableHeader header_;
     isc::util::MemorySegmentLocal mem_sgmt_;
diff --git a/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
index 6bdd737..3082644 100644
--- a/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
@@ -13,8 +13,14 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <datasrc/memory/zone_table_segment.h>
+#include <datasrc/memory/zone_reloader.h>
 #include <gtest/gtest.h>
 
+#include <boost/scoped_ptr.hpp>
+
+using boost::scoped_ptr;
+using isc::dns::Name;
+using isc::dns::RRClass;
 using namespace isc::datasrc::memory;
 using namespace isc::data;
 using namespace isc::util;
@@ -80,4 +86,22 @@ TEST_F(ZoneTableSegmentTest, getMemorySegment) {
     EXPECT_TRUE(mem_sgmt.allMemoryDeallocated());
 }
 
+ZoneData*
+load_action(MemorySegment&) {
+    // The function won't be called, so this is OK
+    return (NULL);
+}
+
+// Test we can get a reloader.
+TEST_F(ZoneTableSegmentTest, getZoneReloader) {
+    scoped_ptr<ZoneReloader>
+        reloader(segment_->getZoneReloader(load_action, Name("example.org"),
+                                           RRClass::IN()));
+    // We have to get something
+    EXPECT_NE(static_cast<void*>(NULL), reloader.get());
+    // And for now, it should be the local reloader
+    EXPECT_NE(static_cast<void*>(NULL),
+              dynamic_cast<ZoneReloaderLocal*>(reloader.get()));
+}
+
 } // anonymous namespace



More information about the bind10-changes mailing list