Parcourir la source

[2281] Use the new in-memory data source for the static data source

Mukund Sivaraman il y a 12 ans
Parent
commit
60a9f3a768

+ 1 - 0
src/lib/datasrc/Makefile.am

@@ -63,6 +63,7 @@ memory_ds_la_LIBADD += libb10-datasrc.la
 static_ds_la_SOURCES = static_datasrc_link.cc
 static_ds_la_LDFLAGS = -module -avoid-version
 static_ds_la_LIBADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
+static_ds_la_LIBADD += $(top_builddir)/src/lib/datasrc/memory/libdatasrc_memory.la
 static_ds_la_LIBADD += libb10-datasrc.la
 
 libb10_datasrc_la_LIBADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la

+ 9 - 7
src/lib/datasrc/static_datasrc_link.cc

@@ -14,6 +14,8 @@
 
 #include "client.h"
 #include "memory_datasrc.h"
+#include <datasrc/memory/memory_client.h>
+#include <datasrc/memory/zone_table_segment.h>
 
 #include <cc/data.h>
 #include <dns/rrclass.h>
@@ -32,16 +34,16 @@ namespace datasrc {
 DataSourceClient*
 createInstance(ConstElementPtr config, string& error) {
     try {
+        shared_ptr<memory::ZoneTableSegment> ztable_segment(
+            memory::ZoneTableSegment::create(*config, RRClass::CH()));
         // Create the data source
-        auto_ptr<InMemoryClient> client(new InMemoryClient());
-        // Hardcode the origin and class
-        shared_ptr<InMemoryZoneFinder>
-            finder(new InMemoryZoneFinder(RRClass::CH(), Name("BIND")));
+        auto_ptr<memory::InMemoryClient> client
+            (new memory::InMemoryClient(ztable_segment, RRClass::CH()));
+
         // Fill it with data
         const string path(config->stringValue());
-        finder->load(path);
-        // And put the zone inside
-        client->addZone(finder);
+        client->load(Name("BIND"), path);
+
         return (client.release());
     }
     catch (const std::exception& e) {

+ 2 - 1
src/lib/datasrc/tests/testdata/static.zone

@@ -1,2 +1,3 @@
-BIND.           3600    CH  SOA BIND. BIND. 1 3600 300 36000 3600
+BIND.           3600    CH  SOA BIND. BIND. 3 3600 300 36000 3600
+BIND.           3600    CH  NS  BIND.
 VERSION.BIND.   3600    CH  TXT "10"