Browse Source

[2207] interface of the getZoneReloader

Michal 'vorner' Vaner 12 years ago
parent
commit
c55218e6be

+ 1 - 0
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

+ 42 - 0
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

+ 7 - 15
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

+ 19 - 0
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,18 @@ 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.
+    virtual ZoneReloader* getZoneReloader(const LoadAction& loadAction,
+                                          const dns::Name& origin,
+                                          const dns::RRClass& rrclass) = 0;
 };
 
 } // namespace memory

+ 4 - 0
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& loadAction,
+                                          const dns::Name& origin,
+                                          const dns::RRClass& rrclass);
 private:
     ZoneTableHeader header_;
     isc::util::MemorySegmentLocal mem_sgmt_;