BIND 10 trac2907, updated. 807607ead100bba4afa0c5af2697ebe6dd2f4ec7 [2907] add abstract method clientList::getZoneTableAccessor

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 29 18:04:51 UTC 2013


The branch, trac2907 has been updated
       via  807607ead100bba4afa0c5af2697ebe6dd2f4ec7 (commit)
      from  a292c65c3c68b9bccb2a30169e4bcb613da1ce68 (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 807607ead100bba4afa0c5af2697ebe6dd2f4ec7
Author: Paul Selkirk <pselkirk at isc.org>
Date:   Wed May 29 14:04:40 2013 -0400

    [2907] add abstract method clientList::getZoneTableAccessor
    
    Also add type ConstZoneTableAccessorPtr for convenience,
    pass smart pointer by reference in unit test.

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

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

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc
index fcafb29..e283b0c 100644
--- a/src/lib/datasrc/client_list.cc
+++ b/src/lib/datasrc/client_list.cc
@@ -24,9 +24,9 @@
 #include <datasrc/memory/zone_data_loader.h>
 #include <datasrc/memory/zone_data_updater.h>
 #include <datasrc/logger.h>
+#include <datasrc/zone_table_accessor_cache.h>
 #include <dns/masterload.h>
 #include <util/memory_segment_local.h>
-#include <datasrc/zone_table_accessor_cache.h>
 
 #include <memory>
 #include <set>
@@ -400,7 +400,7 @@ ConfigurableClientList::getStatus() const {
     return (result);
 }
 
-boost::shared_ptr<const ZoneTableAccessor>
+ConstZoneTableAccessorPtr
 ConfigurableClientList::getZoneTableAccessor(const std::string& datasrc_name,
                                              bool use_cache) const
 {
@@ -418,11 +418,11 @@ ConfigurableClientList::getZoneTableAccessor(const std::string& datasrc_name,
         const internal::CacheConfig* config(info.getCacheConfig());
         // If caching is disabled for the named data source, this will
         // return an accessor to an effectivley empty table.
-        return (boost::shared_ptr<const ZoneTableAccessor>
+        return (ConstZoneTableAccessorPtr
                 (new internal::ZoneTableAccessorCache(*config)));
     }
 
-    return (boost::shared_ptr<const ZoneTableAccessor>());
+    return (ConstZoneTableAccessorPtr());
 }
 
 }
diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h
index e226ed2..85b96d9 100644
--- a/src/lib/datasrc/client_list.h
+++ b/src/lib/datasrc/client_list.h
@@ -121,6 +121,8 @@ private:
     MemorySegmentState state_;
 };
 
+typedef boost::shared_ptr<const ZoneTableAccessor> ConstZoneTableAccessorPtr;
+
 /// \brief The list of data source clients.
 ///
 /// The purpose of this class is to hold several data source clients and search
@@ -273,6 +275,19 @@ public:
     virtual FindResult find(const dns::Name& zone,
                             bool want_exact_match = false,
                             bool want_finder = true) const = 0;
+
+    /// \brief Creates a ZoneTableAccessor object for the specified data
+    /// source.
+    ///
+    /// \param datasrc_name If not empty, the name of the data source.
+    /// \param use_cache If true, create a zone table for in-memory cache.
+    /// \throw NotImplemented if this method is not implemented.
+    /// \return A pointer to the accessor, or NULL if the requested data
+    /// source is not found.
+    virtual ConstZoneTableAccessorPtr
+    getZoneTableAccessor(const std::string& datasrc_name,
+                         bool use_cache) const = 0;
+
 };
 
 /// \brief Shared pointer to the list.
@@ -494,7 +509,7 @@ public:
     /// \throw NotImplemented if \c use_cache is false.
     /// \return A pointer to the accessor, or NULL if the requested data
     /// source is not found.
-    boost::shared_ptr<const ZoneTableAccessor>
+    ConstZoneTableAccessorPtr
     getZoneTableAccessor(const std::string& datasrc_name,
                          bool use_cache) const;
 
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index 42652e9..4ca4c9b 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2013  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -254,7 +254,7 @@ public:
     }
     ConfigurableClientList::CacheStatus doReload(
         const Name& origin, const string& datasrc_name = "");
-    void accessorIterate(boost::shared_ptr<const ZoneTableAccessor> accessor,
+    void accessorIterate(ConstZoneTableAccessorPtr& accessor,
         int numZones, const string& zoneName);
 
     const RRClass rrclass_;
@@ -1134,31 +1134,25 @@ TEST_F(ListTest, reloadByDataSourceName) {
 // through the table, and verifies that the expected number of zones are
 // present, as well as the named zone.
 void
-ListTest::accessorIterate(boost::shared_ptr<const ZoneTableAccessor> accessor,
+ListTest::accessorIterate(ConstZoneTableAccessorPtr& accessor,
                           int numZones, const string& zoneName="")
 {
     // Confirm basic iterator behavior.
     ASSERT_TRUE(accessor);
     ZoneTableAccessor::IteratorPtr it = accessor->getIterator();
     ASSERT_TRUE(it);
+    // Iterator does not guarantee ordering, so we look for the target
+    // name anywhere in the table.
+    bool found = false;
+    int i;
+    for (i = 0; !it->isLast(); ++i, it->next()) {
+	if (Name(zoneName) == it->getCurrent().origin) {
+	    found = true;
+	}
+    }
+    EXPECT_EQ(i, numZones);
     if (numZones > 0) {
-        EXPECT_FALSE(it->isLast());
-        EXPECT_EQ(0, it->getCurrent().index);
-        // Iterator does not guarantee ordering, so we look for the target
-        // name anywhere in the table.
-        bool found = false;
-        int i = 0;
-        while (!it->isLast()) {
-            ++i;
-            if (Name(zoneName) == it->getCurrent().origin) {
-                found = true;
-            }
-            it->next();
-        }
         EXPECT_TRUE(found);
-        EXPECT_EQ(i, numZones);
-    } else {
-        EXPECT_TRUE(it->isLast());
     }
 }
 
@@ -1171,8 +1165,7 @@ TEST_F(ListTest, zoneTableAccessor) {
 
     // empty list; expect it to return an empty list
     list_->configure(config_elem_, true);
-    boost::shared_ptr<const ZoneTableAccessor>
-        z(list_->getZoneTableAccessor("", true));
+    ConstZoneTableAccessorPtr z(list_->getZoneTableAccessor("", true));
     accessorIterate(z, 0);
 
     const ConstElementPtr elem2(Element::fromJSON("["



More information about the bind10-changes mailing list