BIND 10 trac2044, updated. 98d893ecdff8ee42d270a9548f91fe3dffdf6c43 [1976] Hold a cache in the DataSourceInfo

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Jun 25 18:12:14 UTC 2012


The branch, trac2044 has been updated
       via  98d893ecdff8ee42d270a9548f91fe3dffdf6c43 (commit)
      from  4d67ce9015c75a7b8d7fa986037f9e2f428cf657 (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 98d893ecdff8ee42d270a9548f91fe3dffdf6c43
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Jun 25 20:11:43 2012 +0200

    [1976] Hold a cache in the DataSourceInfo
    
    It is not created now, but there's the place to put it.

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

Summary of changes:
 src/lib/datasrc/client_list.cc                |   15 +++++++++++++-
 src/lib/datasrc/client_list.h                 |    8 ++++----
 src/lib/datasrc/tests/client_list_unittest.cc |   27 ++++++++++++++-----------
 3 files changed, 33 insertions(+), 17 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index 549b216..d1d47f8 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -15,6 +15,7 @@
 #include "client_list.h"
 #include "client.h"
 #include "factory.h"
+#include "memory_datasrc.h"
 
 #include <memory>
 #include <boost/foreach.hpp>
@@ -25,6 +26,17 @@ using namespace std;
 namespace isc {
 namespace datasrc {
 
+ConfigurableClientList::DataSourceInfo::DataSourceInfo(
+    DataSourceClient* data_src_client,
+    const DataSourceClientContainerPtr& container, bool hasCache) :
+    data_src_client_(data_src_client),
+    container_(container)
+{
+    if (hasCache) {
+        cache_.reset(new InMemoryClient);
+    }
+}
+
 void
 ConfigurableClientList::configure(const Element& config, bool) {
     // TODO: Implement the cache
@@ -50,7 +62,8 @@ ConfigurableClientList::configure(const Element& config, bool) {
             const DataSourcePair ds(this->getDataSourceClient(type,
                                                               paramConf));
             // And put it into the vector
-            new_data_sources.push_back(DataSourceInfo(ds.first, ds.second));
+            new_data_sources.push_back(DataSourceInfo(ds.first, ds.second,
+                                                      false));
         }
         // If everything is OK up until now, we have the new configuration
         // ready. So just put it there and let the old one die when we exit
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index 599dca8..1b59b68 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -33,6 +33,7 @@ typedef boost::shared_ptr<DataSourceClient> DataSourceClientPtr;
 class DataSourceClientContainer;
 typedef boost::shared_ptr<DataSourceClientContainer>
     DataSourceClientContainerPtr;
+class InMemoryClient;
 
 /// \brief The list of data source clients.
 ///
@@ -231,12 +232,11 @@ public:
             data_src_client_(NULL)
         {}
         DataSourceInfo(DataSourceClient* data_src_client,
-                       const DataSourceClientContainerPtr& container) :
-            data_src_client_(data_src_client),
-            container_(container)
-        {}
+                       const DataSourceClientContainerPtr& container,
+                       bool hasCache);
         DataSourceClient* data_src_client_;
         DataSourceClientContainerPtr container_;
+        boost::shared_ptr<InMemoryClient> cache_;
     };
 
     /// \brief The collection of data sources.
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index ae22470..608ccc7 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -175,7 +175,7 @@ public:
                 ds(new MockDataSourceClient(ds_zones[i]));
             ds_.push_back(ds);
             ds_info_.push_back(ConfigurableClientList::DataSourceInfo(ds.get(),
-                DataSourceClientContainerPtr()));
+                DataSourceClientContainerPtr(), false));
         }
     }
     // Check the positive result is as we expect it.
@@ -220,7 +220,8 @@ public:
                 FAIL() << "Unknown configuration index " << index;
         }
     }
-    void checkDS(size_t index, const string& type, const string& params) const
+    void checkDS(size_t index, const string& type, const string& params,
+                 bool cache) const
     {
         ASSERT_GT(list_->getDataSources().size(), index);
         MockDataSourceClient* ds(dynamic_cast<MockDataSourceClient*>(
@@ -230,6 +231,8 @@ public:
         ASSERT_NE(ds, static_cast<const MockDataSourceClient*>(NULL));
         EXPECT_EQ(type, ds->type_);
         EXPECT_TRUE(Element::fromJSON(params)->equals(*ds->configuration_));
+        EXPECT_EQ(cache, list_->getDataSources()[index].cache_ !=
+                  shared_ptr<InMemoryClient>());
     }
     shared_ptr<TestedList> list_;
     const ClientList::FindResult negativeResult_;
@@ -370,8 +373,8 @@ TEST_F(ListTest, configureMulti) {
     ));
     list_->configure(*elem, true);
     EXPECT_EQ(2, list_->getDataSources().size());
-    checkDS(0, "type1", "{}");
-    checkDS(1, "type2", "{}");
+    checkDS(0, "type1", "{}", false);
+    checkDS(1, "type2", "{}", false);
 }
 
 // Check we can pass whatever we want to the params
@@ -396,7 +399,7 @@ TEST_F(ListTest, configureParams) {
             "}]"));
         list_->configure(*elem, true);
         EXPECT_EQ(1, list_->getDataSources().size());
-        checkDS(0, "t", *param);
+        checkDS(0, "t", *param, false);
     }
 }
 
@@ -423,14 +426,14 @@ TEST_F(ListTest, wrongConfig) {
     };
     // Put something inside to see it survives the exception
     list_->configure(*config_elem_, true);
-    checkDS(0, "test_type", "{}");
+    checkDS(0, "test_type", "{}", false);
     for (const char** config(configs); *config; ++config) {
         SCOPED_TRACE(*config);
         ConstElementPtr elem(Element::fromJSON(*config));
         EXPECT_THROW(list_->configure(*elem, true),
                      ConfigurableClientList::ConfigurationError);
         // Still untouched
-        checkDS(0, "test_type", "{}");
+        checkDS(0, "test_type", "{}", false);
         EXPECT_EQ(1, list_->getDataSources().size());
     }
 }
@@ -443,18 +446,18 @@ TEST_F(ListTest, defaults) {
         "}]"));
     list_->configure(*elem, true);
     EXPECT_EQ(1, list_->getDataSources().size());
-    checkDS(0, "type1", "null");
+    checkDS(0, "type1", "null", false);
 }
 
 // Check we can call the configure multiple times, to change the configuration
 TEST_F(ListTest, reconfigure) {
     ConstElementPtr empty(new ListElement);
     list_->configure(*config_elem_, true);
-    checkDS(0, "test_type", "{}");
+    checkDS(0, "test_type", "{}", false);
     list_->configure(*empty, true);
     EXPECT_TRUE(list_->getDataSources().empty());
     list_->configure(*config_elem_, true);
-    checkDS(0, "test_type", "{}");
+    checkDS(0, "test_type", "{}", false);
 }
 
 // Make sure the data source error exception from the factory is propagated
@@ -464,9 +467,9 @@ TEST_F(ListTest, dataSrcError) {
         "   \"type\": \"error\""
         "}]"));
     list_->configure(*config_elem_, true);
-    checkDS(0, "test_type", "{}");
+    checkDS(0, "test_type", "{}", false);
     EXPECT_THROW(list_->configure(*elem, true), DataSourceError);
-    checkDS(0, "test_type", "{}");
+    checkDS(0, "test_type", "{}", false);
 }
 
 }



More information about the bind10-changes mailing list