Parcourir la source

[1975] Try to use DataSourceClient name

It is supposed to be called client, not a DataSource only.
Michal 'vorner' Vaner il y a 13 ans
Parent
commit
06a3082082
3 fichiers modifiés avec 52 ajouts et 48 suppressions
  1. 11 9
      src/lib/datasrc/list.cc
  2. 36 35
      src/lib/datasrc/list.h
  3. 5 4
      src/lib/datasrc/tests/list_unittest.cc

+ 11 - 9
src/lib/datasrc/list.cc

@@ -47,7 +47,8 @@ ConfigurableClientList::configure(const Element& config, bool) {
             }
             }
             // TODO: Special-case the master files type.
             // TODO: Special-case the master files type.
             // Ask the factory to create the data source for us
             // Ask the factory to create the data source for us
-            const DataSourcePair ds(this->getDataSource(type, paramConf));
+            const DataSourcePair ds(this->getDataSourceClient(type,
+                                                              paramConf));
             // And put it into the vector
             // 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));
         }
         }
@@ -71,16 +72,16 @@ ConfigurableClientList::find(const dns::Name& name, bool want_exact_match,
     // assigned.
     // assigned.
     struct MutableResult {
     struct MutableResult {
         MutableResult() :
         MutableResult() :
-            datasrc(NULL),
+            datasrc_client(NULL),
             matched_labels(0)
             matched_labels(0)
         { }
         { }
-        DataSourceClient *datasrc;
+        DataSourceClient *datasrc_client;
         ZoneFinderPtr finder;
         ZoneFinderPtr finder;
         uint8_t matched_labels;
         uint8_t matched_labels;
         operator FindResult() {
         operator FindResult() {
             // Conversion to the right result. If we return this, there was
             // Conversion to the right result. If we return this, there was
             // a partial match at best.
             // a partial match at best.
-            return FindResult(datasrc, finder, matched_labels, false);
+            return FindResult(datasrc_client, finder, matched_labels, false);
         }
         }
     } candidate;
     } candidate;
 
 
@@ -92,7 +93,7 @@ ConfigurableClientList::find(const dns::Name& name, bool want_exact_match,
         // the cached one, provide the cached one. If it is in the external
         // the cached one, provide the cached one. If it is in the external
         // data source, use the datasource and don't provide the finder yet.
         // data source, use the datasource and don't provide the finder yet.
         const DataSourceClient::FindResult result(
         const DataSourceClient::FindResult result(
-            info.data_src_->findZone(name));
+            info.data_src_client_->findZone(name));
         switch (result.code) {
         switch (result.code) {
             case result::SUCCESS: {
             case result::SUCCESS: {
                 // If we found an exact match, we have no hope to getting
                 // If we found an exact match, we have no hope to getting
@@ -100,7 +101,7 @@ ConfigurableClientList::find(const dns::Name& name, bool want_exact_match,
 
 
                 // TODO: In case we have only the datasource and not the finder
                 // TODO: In case we have only the datasource and not the finder
                 // and the need_updater parameter is true, get the zone there.
                 // and the need_updater parameter is true, get the zone there.
-                return (FindResult(info.data_src_, result.zone_finder,
+                return (FindResult(info.data_src_client_, result.zone_finder,
                                    name.getLabelCount(), true));
                                    name.getLabelCount(), true));
             }
             }
             case result::PARTIALMATCH: {
             case result::PARTIALMATCH: {
@@ -111,7 +112,7 @@ ConfigurableClientList::find(const dns::Name& name, bool want_exact_match,
                         result.zone_finder->getOrigin().getLabelCount());
                         result.zone_finder->getOrigin().getLabelCount());
                     if (labels > candidate.matched_labels) {
                     if (labels > candidate.matched_labels) {
                         // This one is strictly better. Replace it.
                         // This one is strictly better. Replace it.
-                        candidate.datasrc = info.data_src_;
+                    candidate.datasrc_client = info.data_src_client_;
                         candidate.finder = result.zone_finder;
                         candidate.finder = result.zone_finder;
                         candidate.matched_labels = labels;
                         candidate.matched_labels = labels;
                     }
                     }
@@ -137,8 +138,9 @@ ConfigurableClientList::find(const dns::Name& name, bool want_exact_match,
 // purpose of the function is to provide a very thin wrapper to be able to
 // purpose of the function is to provide a very thin wrapper to be able to
 // replace the call to DataSourceClientContainer constructor in tests.
 // replace the call to DataSourceClientContainer constructor in tests.
 ConfigurableClientList::DataSourcePair
 ConfigurableClientList::DataSourcePair
-ConfigurableClientList::getDataSource(const string& type,
-                                      const ConstElementPtr& configuration)
+ConfigurableClientList::getDataSourceClient(const string& type,
+                                            const ConstElementPtr&
+                                            configuration)
 {
 {
     DataSourceClientContainerPtr
     DataSourceClientContainerPtr
         container(new DataSourceClientContainer(type, configuration));
         container(new DataSourceClientContainer(type, configuration));

+ 36 - 35
src/lib/datasrc/list.h

@@ -34,9 +34,9 @@ class DataSourceClientContainer;
 typedef boost::shared_ptr<DataSourceClientContainer>
 typedef boost::shared_ptr<DataSourceClientContainer>
     DataSourceClientContainerPtr;
     DataSourceClientContainerPtr;
 
 
-/// \brief The list of data sources.
+/// \brief The list of data source clients.
 ///
 ///
-/// The purpose of this class is to hold several data sources and search
+/// The purpose of this class is to hold several data source clients and search
 /// through them to find one containing a zone best matching a request.
 /// through them to find one containing a zone best matching a request.
 ///
 ///
 /// All the data source clients should be for the same class. If you need
 /// All the data source clients should be for the same class. If you need
@@ -65,10 +65,10 @@ public:
         ///
         ///
         /// It simply fills in the member variables according to the
         /// It simply fills in the member variables according to the
         /// parameters. See the member descriptions for their meaning.
         /// parameters. See the member descriptions for their meaning.
-        FindResult(DataSourceClient* datasrc,
+        FindResult(DataSourceClient* dsrc_client,
                    const ZoneFinderPtr& finder,
                    const ZoneFinderPtr& finder,
                    uint8_t matched_labels, bool exact_match) :
                    uint8_t matched_labels, bool exact_match) :
-            datasrc_(datasrc),
+            dsrc_client_(dsrc_client),
             finder_(finder),
             finder_(finder),
             matched_labels_(matched_labels),
             matched_labels_(matched_labels),
             exact_match_(exact_match)
             exact_match_(exact_match)
@@ -79,7 +79,7 @@ public:
         /// This conscructs a result for negative answer. Both pointers are
         /// This conscructs a result for negative answer. Both pointers are
         /// NULL, matched_labels_ is 0 and exact_match_ is false.
         /// NULL, matched_labels_ is 0 and exact_match_ is false.
         FindResult() :
         FindResult() :
-            datasrc_(NULL),
+            dsrc_client_(NULL),
             matched_labels_(0),
             matched_labels_(0),
             exact_match_(false)
             exact_match_(false)
         { }
         { }
@@ -89,21 +89,21 @@ public:
         /// It is needed for tests and it might be of some use elsewhere
         /// It is needed for tests and it might be of some use elsewhere
         /// too.
         /// too.
         bool operator ==(const FindResult& other) const {
         bool operator ==(const FindResult& other) const {
-            return (datasrc_ == other.datasrc_ &&
+        return (dsrc_client_ == other.dsrc_client_ &&
                     finder_ == other.finder_ &&
                     finder_ == other.finder_ &&
                     matched_labels_ == other.matched_labels_ &&
                     matched_labels_ == other.matched_labels_ &&
                     exact_match_ == other.exact_match_);
                     exact_match_ == other.exact_match_);
         }
         }
 
 
-        /// \brief The found data source.
+        /// \brief The found data source client.
         ///
         ///
-        /// The data source containing the best matching zone. If no such
-        /// data source exists, this is NULL pointer.
+        /// The client of the data source containing the best matching zone.
+        /// If no such data source exists, this is NULL pointer.
         ///
         ///
         /// Note that the pointer is valid only as long the ClientList which
         /// Note that the pointer is valid only as long the ClientList which
         /// returned is alive and was not reconfigured. The ownership is
         /// returned is alive and was not reconfigured. The ownership is
         /// preserved within the ClientList.
         /// preserved within the ClientList.
-        DataSourceClient* const datasrc_;
+        DataSourceClient* const dsrc_client_;
 
 
         /// \brief The finder for the requested zone.
         /// \brief The finder for the requested zone.
         ///
         ///
@@ -126,8 +126,8 @@ public:
 
 
     /// \brief Search for a zone through the data sources.
     /// \brief Search for a zone through the data sources.
     ///
     ///
-    /// This searches the contained data sources for a one that best matches
-    /// the zone name.
+    /// This searches the contained data source clients for a one that best
+    /// matches the zone name.
     ///
     ///
     /// There are two expected usage scenarios. One is answering queries. In
     /// There are two expected usage scenarios. One is answering queries. In
     /// this case, the zone finder is needed and the best matching superzone
     /// this case, the zone finder is needed and the best matching superzone
@@ -201,9 +201,9 @@ public:
 
 
     /// \brief Sets the configuration.
     /// \brief Sets the configuration.
     ///
     ///
-    /// This fills the ClientList with data sources corresponding to the
-    /// configuration. The data sources are newly created or recycled from
-    /// previous configuration.
+    /// This fills the ClientList with data source clients corresponding to the
+    /// configuration. The data source clients are newly created or recycled
+    /// from previous configuration.
     ///
     ///
     /// If any error is detected, an exception is thrown and the current
     /// If any error is detected, an exception is thrown and the current
     /// configuration is preserved.
     /// configuration is preserved.
@@ -214,7 +214,8 @@ public:
     ///     configuration is used and some zones are cached into an In-Memory
     ///     configuration is used and some zones are cached into an In-Memory
     ///     data source according to it. If it is false, it is ignored and
     ///     data source according to it. If it is false, it is ignored and
     ///     no In-Memory data sources are created.
     ///     no In-Memory data sources are created.
-    /// \throw DataSourceError if there's a problem creating a data source.
+    /// \throw DataSourceError if there's a problem creating a data source
+    ///     client.
     /// \throw ConfigurationError if the configuration is invalid in some
     /// \throw ConfigurationError if the configuration is invalid in some
     ///     sense.
     ///     sense.
     void configure(const data::Element& configuration, bool allow_cache);
     void configure(const data::Element& configuration, bool allow_cache);
@@ -224,7 +225,7 @@ public:
                               bool want_exact_match = false,
                               bool want_exact_match = false,
                               bool want_finder = true) const;
                               bool want_finder = true) const;
 
 
-    /// \brief This holds one data source and corresponding information.
+    /// \brief This holds one data source client and corresponding information.
     ///
     ///
     /// \todo The content yet to be defined.
     /// \todo The content yet to be defined.
     struct DataSourceInfo {
     struct DataSourceInfo {
@@ -233,14 +234,14 @@ public:
         /// Don't use directly. It is here so the structure can live in
         /// Don't use directly. It is here so the structure can live in
         /// a vector.
         /// a vector.
         DataSourceInfo() :
         DataSourceInfo() :
-            data_src_(NULL)
+            data_src_client_(NULL)
         {}
         {}
-        DataSourceInfo(DataSourceClient* data_src,
+        DataSourceInfo(DataSourceClient* data_src_client,
                        const DataSourceClientContainerPtr& container) :
                        const DataSourceClientContainerPtr& container) :
-            data_src_(data_src),
+            data_src_client_(data_src_client),
             container_(container)
             container_(container)
         { }
         { }
-        DataSourceClient* data_src_;
+        DataSourceClient* data_src_client_;
         DataSourceClientContainerPtr container_;
         DataSourceClientContainerPtr container_;
     };
     };
 
 
@@ -260,31 +261,31 @@ protected:
     typedef std::pair<DataSourceClient*, DataSourceClientContainerPtr>
     typedef std::pair<DataSourceClient*, DataSourceClientContainerPtr>
         DataSourcePair;
         DataSourcePair;
 
 
-    /// \brief Create a data source of given type and configuration.
+    /// \brief Create a data source client of given type and configuration.
     ///
     ///
     /// This is a thin wrapper around the DataSourceClientContainer
     /// This is a thin wrapper around the DataSourceClientContainer
     /// constructor. The function is here to make it possible for tests
     /// constructor. The function is here to make it possible for tests
     /// to replace the DataSourceClientContainer with something else.
     /// to replace the DataSourceClientContainer with something else.
-    /// Also, derived classes couldl want to create the data sources
-    /// in a different way, though inheriting this class is not
-    /// recommended.
+    /// Also, derived classes could want to create the data source clients
+    /// in a different way, though inheriting this class is not recommended.
     ///
     ///
     /// The parameters are the same as of the constructor.
     /// The parameters are the same as of the constructor.
-    /// \return Pair containing both the data source and the container.
+    /// \return Pair containing both the data source client and the container.
     ///     The container might be NULL in the derived class, it is
     ///     The container might be NULL in the derived class, it is
-    ///     only stored so the data source is properly destroyed when
+    ///     only stored so the data source client is properly destroyed when
     ///     not needed. However, in such case, it is the caller's
     ///     not needed. However, in such case, it is the caller's
-    ///     responsibility to ensure the data source is deleted when
+    ///     responsibility to ensure the data source client is deleted when
     ///     needed.
     ///     needed.
-    virtual DataSourcePair getDataSource(const std::string& type,
-                                         const data::ConstElementPtr&
-                                         configuration);
+    virtual DataSourcePair getDataSourceClient(const std::string& type,
+                                               const data::ConstElementPtr&
+                                               configuration);
 public:
 public:
-    /// \brief Access to the data sources.
+    /// \brief Access to the data source clients.
     ///
     ///
-    /// It can be used to examine the loaded list of data sources directly.
-    /// It is not known if it is of any use other than testing, but it might
-    /// be, so it is just made public.
+    /// It can be used to examine the loaded list of data sources clients
+    /// directly. It is not known if it is of any use other than testing, but
+    /// it might be, so it is just made public (there's no real reason to
+    /// hide it).
     const DataSources& getDataSources() const { return (data_sources_); }
     const DataSources& getDataSources() const { return (data_sources_); }
 };
 };
 
 

+ 5 - 4
src/lib/datasrc/tests/list_unittest.cc

@@ -121,8 +121,9 @@ public:
     // Overwrite the list's method to get a data source with given type
     // Overwrite the list's method to get a data source with given type
     // and configuration. We mock the data source and don't create the
     // and configuration. We mock the data source and don't create the
     // container. This is just to avoid some complexity in the tests.
     // container. This is just to avoid some complexity in the tests.
-    virtual DataSourcePair getDataSource(const string& type,
-                                         const ConstElementPtr& configuration)
+    virtual DataSourcePair getDataSourceClient(const string& type,
+                                               const ConstElementPtr&
+                                               configuration)
     {
     {
         if (type == "error") {
         if (type == "error") {
             isc_throw(DataSourceError, "The error data source type");
             isc_throw(DataSourceError, "The error data source type");
@@ -187,7 +188,7 @@ public:
                         const char* test)
                         const char* test)
     {
     {
         SCOPED_TRACE(test);
         SCOPED_TRACE(test);
-        EXPECT_EQ(dsrc.get(), result.datasrc_);
+        EXPECT_EQ(dsrc.get(), result.dsrc_client_);
         ASSERT_NE(ZoneFinderPtr(), result.finder_);
         ASSERT_NE(ZoneFinderPtr(), result.finder_);
         EXPECT_EQ(name, result.finder_->getOrigin());
         EXPECT_EQ(name, result.finder_->getOrigin());
         EXPECT_EQ(name.getLabelCount(), result.matched_labels_);
         EXPECT_EQ(name.getLabelCount(), result.matched_labels_);
@@ -226,7 +227,7 @@ public:
     void checkDS(size_t index, const string& type, const string& params) {
     void checkDS(size_t index, const string& type, const string& params) {
         ASSERT_GT(list_->getDataSources().size(), index);
         ASSERT_GT(list_->getDataSources().size(), index);
         MockDataSourceClient* ds(dynamic_cast<MockDataSourceClient*>(
         MockDataSourceClient* ds(dynamic_cast<MockDataSourceClient*>(
-            list_->getDataSources()[index].data_src_));
+            list_->getDataSources()[index].data_src_client_));
         // Comparing with NULL does not work
         // Comparing with NULL does not work
         ASSERT_NE(ds, static_cast<const MockDataSourceClient*>(NULL));
         ASSERT_NE(ds, static_cast<const MockDataSourceClient*>(NULL));
         EXPECT_EQ(type, ds->type_);
         EXPECT_EQ(type, ds->type_);