Parcourir la source

[2209] Store the segment in client list

So the memory client doesn't have to provide an interface to return it.
It was hairy to some extent.
Michal 'vorner' Vaner il y a 12 ans
Parent
commit
f4dd53d74d

+ 5 - 3
src/lib/datasrc/client_list.cc

@@ -44,22 +44,24 @@ namespace datasrc {
 ConfigurableClientList::DataSourceInfo::DataSourceInfo(
     DataSourceClient* data_src_client,
     const DataSourceClientContainerPtr& container, bool has_cache,
-    const RRClass& rrclass, shared_ptr<ZoneTableSegment>& segment) :
+    const RRClass& rrclass, const shared_ptr<ZoneTableSegment>& segment) :
     data_src_client_(data_src_client),
     container_(container)
 {
     if (has_cache) {
         cache_.reset(new InMemoryClient(segment, rrclass));
+        segment_ = segment;
     }
 }
 
 ConfigurableClientList::DataSourceInfo::DataSourceInfo(
-    const RRClass& rrclass, shared_ptr<ZoneTableSegment>& segment,
+    const RRClass& rrclass, const shared_ptr<ZoneTableSegment>& segment,
     bool has_cache) :
     data_src_client_(NULL)
 {
     if (has_cache) {
         cache_.reset(new InMemoryClient(segment, rrclass));
+        segment_ = segment;
     }
 }
 
@@ -446,7 +448,7 @@ ConfigurableClientList::getCachedZoneWriter(const Name& name) {
     }
     return (ZoneWriterPair(ZONE_SUCCESS,
                            ZoneWriterPtr(
-                               result.info->cache_->getZoneTableSegment().
+                               result.info->segment_->
                                getZoneWriter(load_action, name, rrclass_))));
 }
 

+ 3 - 2
src/lib/datasrc/client_list.h

@@ -333,14 +333,14 @@ public:
     struct DataSourceInfo {
         // Plays a role of default constructor too (for vector)
         DataSourceInfo(const dns::RRClass& rrclass,
-                       boost::shared_ptr
+                       const boost::shared_ptr
                            <isc::datasrc::memory::ZoneTableSegment>&
                                ztable_segment,
                        bool has_cache = false);
         DataSourceInfo(DataSourceClient* data_src_client,
                        const DataSourceClientContainerPtr& container,
                        bool has_cache, const dns::RRClass& rrclass,
-                       boost::shared_ptr
+                       const boost::shared_ptr
                            <isc::datasrc::memory::ZoneTableSegment>&
                                ztable_segment);
         DataSourceClient* data_src_client_;
@@ -353,6 +353,7 @@ public:
         // No other applications or tests may use it.
         const DataSourceClient* getCacheClient() const;
         boost::shared_ptr<memory::InMemoryClient> cache_;
+        boost::shared_ptr<memory::ZoneTableSegment> segment_;
     };
 
     /// \brief The collection of data sources.

+ 0 - 12
src/lib/datasrc/memory/memory_client.h

@@ -179,18 +179,6 @@ 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 (*ztable_segment_);
-    }
-
 private:
     // Some type aliases
     typedef DomainTree<std::string> FileNameTree;

+ 0 - 8
src/lib/datasrc/tests/memory/memory_client_unittest.cc

@@ -775,12 +775,4 @@ 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());
-}
-
 }