From: Mukund Sivaraman Date: Thu, 18 Oct 2012 05:22:38 +0000 (+0530) Subject: [2208] Update ConfigurableClientList and other bits accordingly X-Git-Tag: trac2487_base~21^2~8^2~8^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b598ee429c070c4c784e41822a4904ee71ebf95;p=thirdparty%2Fkea.git [2208] Update ConfigurableClientList and other bits accordingly --- diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc index e248e81483..402f8b824f 100644 --- a/src/bin/auth/tests/auth_srv_unittest.cc +++ b/src/bin/auth/tests/auth_srv_unittest.cc @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -1401,7 +1400,10 @@ public: real_list, ThrowWhen throw_when, bool isc_exception, ConstRRsetPtr fake_rrset = ConstRRsetPtr()) : ConfigurableClientList(RRClass::IN()), - real_(real_list) + real_(real_list), + config_(Element::fromJSON("{}")), + segment_(isc::datasrc::memory::ZoneTableSegment::create( + (*config_.get()))) { BOOST_FOREACH(const DataSourceInfo& info, real_->getDataSources()) { const isc::datasrc::DataSourceClientPtr @@ -1413,13 +1415,14 @@ public: data_sources_.push_back( DataSourceInfo(client.get(), isc::datasrc::DataSourceClientContainerPtr(), - false, RRClass::IN(), mem_sgmt_)); + false, RRClass::IN(), segment_)); } } private: const boost::shared_ptr real_; + const ConstElementPtr config_; + boost::shared_ptr segment_; vector clients_; - MemorySegmentLocal mem_sgmt_; }; } // end anonymous namespace for throwing proxy classes diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc index 865a1ce4b9..c76ac9c936 100644 --- a/src/lib/datasrc/client_list.cc +++ b/src/lib/datasrc/client_list.cc @@ -32,6 +32,7 @@ using boost::lexical_cast; using boost::shared_ptr; using boost::dynamic_pointer_cast; using isc::datasrc::memory::InMemoryClient; +using isc::datasrc::memory::ZoneTableSegment; namespace isc { namespace datasrc { @@ -39,21 +40,22 @@ namespace datasrc { ConfigurableClientList::DataSourceInfo::DataSourceInfo( DataSourceClient* data_src_client, const DataSourceClientContainerPtr& container, bool has_cache, - const RRClass& rrclass, MemorySegment& mem_sgmt) : + const RRClass& rrclass, shared_ptr& segment) : data_src_client_(data_src_client), container_(container) { if (has_cache) { - cache_.reset(new InMemoryClient(mem_sgmt, rrclass)); + cache_.reset(new InMemoryClient(segment, rrclass)); } } ConfigurableClientList::DataSourceInfo::DataSourceInfo( - const RRClass& rrclass, MemorySegment& mem_sgmt, bool has_cache) : + const RRClass& rrclass, shared_ptr& segment, + bool has_cache) : data_src_client_(NULL) { if (has_cache) { - cache_.reset(new InMemoryClient(mem_sgmt, rrclass)); + cache_.reset(new InMemoryClient(segment, rrclass)); } } @@ -90,6 +92,8 @@ ConfigurableClientList::configure(const ConstElementPtr& config, size_t i(0); // Outside of the try to be able to access it in the catch try { vector new_data_sources; + shared_ptr ztable_segment( + ZoneTableSegment::create(*config.get())); for (; i < config->size(); ++i) { // Extract the parameters const ConstElementPtr dconf(config->get(i)); @@ -126,7 +130,8 @@ ConfigurableClientList::configure(const ConstElementPtr& config, isc_throw(ConfigurationError, "The cache must be enabled " "for the MasterFiles type"); } - new_data_sources.push_back(DataSourceInfo(rrclass_, *mem_sgmt_, + new_data_sources.push_back(DataSourceInfo(rrclass_, + ztable_segment, true)); } else { // Ask the factory to create the data source for us @@ -135,7 +140,7 @@ ConfigurableClientList::configure(const ConstElementPtr& config, // And put it into the vector new_data_sources.push_back(DataSourceInfo(ds.first, ds.second, want_cache, rrclass_, - *mem_sgmt_)); + ztable_segment)); } if (want_cache) { diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h index 61544efb4a..70de66db12 100644 --- a/src/lib/datasrc/client_list.h +++ b/src/lib/datasrc/client_list.h @@ -21,6 +21,7 @@ #include #include #include +#include "memory/zone_table_segment.h" #include #include @@ -299,13 +300,14 @@ public: /// \todo The content yet to be defined. struct DataSourceInfo { // Plays a role of default constructor too (for vector) - DataSourceInfo(const dns::RRClass& rrclass, - util::MemorySegment& mem_sgmt, + DataSourceInfo(const dns::RRClass& rrclass, boost::shared_ptr + & segment, bool has_cache = false); DataSourceInfo(DataSourceClient* data_src_client, const DataSourceClientContainerPtr& container, bool has_cache, const dns::RRClass& rrclass, - util::MemorySegment& mem_sgmt); + boost::shared_ptr + & segment); DataSourceClient* data_src_client_; DataSourceClientContainerPtr container_; diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc index d995d5c910..8df18fce6b 100644 --- a/src/lib/datasrc/tests/client_list_unittest.cc +++ b/src/lib/datasrc/tests/client_list_unittest.cc @@ -12,13 +12,12 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. -#include - #include #include #include #include #include +#include #include #include @@ -32,6 +31,7 @@ using namespace isc::datasrc; using isc::datasrc::memory::InMemoryClient; +using isc::datasrc::memory::ZoneTableSegment; using isc::datasrc::memory::InMemoryZoneFinder; using namespace isc::data; using namespace isc::dns; @@ -255,7 +255,9 @@ public: " \"type\": \"test_type\"," " \"params\": [\"example.org\", \"example.com\", " " \"noiter.org\", \"null.org\"]" - "}]")) + "}]")), + config_(Element::fromJSON("{}")), + segment_(ZoneTableSegment::create((*config_.get()))) { for (size_t i(0); i < ds_count; ++ i) { shared_ptr @@ -263,7 +265,7 @@ public: ds_.push_back(ds); ds_info_.push_back(ConfigurableClientList::DataSourceInfo( ds.get(), DataSourceClientContainerPtr(), - false, rrclass_, mem_sgmt_)); + false, rrclass_, segment_)); } } @@ -283,7 +285,7 @@ public: // Create cache from the temporary data source, and push it to the // client list. - const shared_ptr cache(new InMemoryClient(mem_sgmt_, + const shared_ptr cache(new InMemoryClient(segment_, rrclass_)); cache->load(zone, *mock_client.getIterator(zone, false)); @@ -362,12 +364,12 @@ public: shared_ptr()); } const RRClass rrclass_; - isc::util::MemorySegmentLocal mem_sgmt_; shared_ptr list_; const ClientList::FindResult negative_result_; vector > ds_; vector ds_info_; - const ConstElementPtr config_elem_, config_elem_zones_; + const ConstElementPtr config_elem_, config_elem_zones_, config_; + shared_ptr segment_; }; // Test the test itself diff --git a/src/lib/datasrc/tests/zone_finder_context_unittest.cc b/src/lib/datasrc/tests/zone_finder_context_unittest.cc index 14429aea51..e89d7fc077 100644 --- a/src/lib/datasrc/tests/zone_finder_context_unittest.cc +++ b/src/lib/datasrc/tests/zone_finder_context_unittest.cc @@ -14,14 +14,13 @@ #include -#include - #include #include #include #include #include +#include #include #include @@ -41,10 +40,12 @@ using namespace std; using boost::shared_ptr; +using namespace isc::data; using namespace isc::util; using namespace isc::dns; using namespace isc::datasrc; using isc::datasrc::memory::InMemoryClient; +using isc::datasrc::memory::ZoneTableSegment; using namespace isc::testutils; namespace { @@ -58,15 +59,17 @@ typedef shared_ptr DataSourceClientPtr; // This is the type used as the test parameter. Note that this is // intentionally a plain old type (i.e. a function pointer), not a class; // otherwise it could cause initialization fiasco at the instantiation time. -typedef DataSourceClientPtr (*ClientCreator)(MemorySegment&, RRClass, - const Name&); +typedef DataSourceClientPtr (*ClientCreator)(RRClass, const Name&); // Creator for the in-memory client to be tested DataSourceClientPtr -createInMemoryClient(MemorySegment& mem_sgmt, RRClass zclass, - const Name& zname) +createInMemoryClient(RRClass zclass, const Name& zname) { - shared_ptr client(new InMemoryClient(mem_sgmt, zclass)); + const ElementPtr config(Element::fromJSON("{}")); + shared_ptr ztable_segment( + ZoneTableSegment::create(*config.get())); + shared_ptr client(new InMemoryClient(ztable_segment, + zclass)); client->load(zname, TEST_ZONE_FILE); return (client); @@ -78,7 +81,7 @@ addRRset(ZoneUpdaterPtr updater, ConstRRsetPtr rrset) { } DataSourceClientPtr -createSQLite3Client(MemorySegment&, RRClass zclass, const Name& zname) { +createSQLite3Client(RRClass zclass, const Name& zname) { // We always begin with an empty template SQLite3 DB file and install // the zone data from the zone file to ensure both cases have the // same test data. @@ -105,7 +108,7 @@ class ZoneFinderContextTest : { protected: ZoneFinderContextTest() : qclass_(RRClass::IN()), qzone_("example.org") { - client_ = (*GetParam())(mem_sgmt_, qclass_, qzone_); + client_ = (*GetParam())(qclass_, qzone_); REQUESTED_A.push_back(RRType::A()); REQUESTED_AAAA.push_back(RRType::AAAA()); REQUESTED_BOTH.push_back(RRType::A()); @@ -116,7 +119,6 @@ protected: ASSERT_TRUE(finder_); } - MemorySegmentLocal mem_sgmt_; const RRClass qclass_; const Name qzone_; DataSourceClientPtr client_;