[svn] commit: r3246 - in /branches/trac232/src/lib: datasrc/ datasrc/python/ datasrc/python/tests/ datasrc/tests/ dns/ dns/tests/ python/isc/config/

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 18 08:01:21 UTC 2010


Author: jelte
Date: Mon Oct 18 08:01:20 2010
New Revision: 3246

Log:
removed rrsetcontainer (wasn't used or necessary anymore, a standard vector sufficed in the one case where it was used now)

Removed:
    branches/trac232/src/lib/dns/rrsetcontainer.cc
    branches/trac232/src/lib/dns/rrsetcontainer.h
    branches/trac232/src/lib/dns/tests/rrsetcontainer_unittest.cc
Modified:
    branches/trac232/src/lib/datasrc/data_source.cc
    branches/trac232/src/lib/datasrc/data_source.h
    branches/trac232/src/lib/datasrc/python/libdata_source_python.cc
    branches/trac232/src/lib/datasrc/python/tests/data_source_python_test.py
    branches/trac232/src/lib/datasrc/sqlite3_datasrc.cc
    branches/trac232/src/lib/datasrc/sqlite3_datasrc.h
    branches/trac232/src/lib/datasrc/tests/sqlite3_unittest.cc
    branches/trac232/src/lib/dns/Makefile.am
    branches/trac232/src/lib/dns/tests/Makefile.am
    branches/trac232/src/lib/python/isc/config/module_spec.py

Modified: branches/trac232/src/lib/datasrc/data_source.cc
==============================================================================
--- branches/trac232/src/lib/datasrc/data_source.cc (original)
+++ branches/trac232/src/lib/datasrc/data_source.cc Mon Oct 18 08:01:20 2010
@@ -37,7 +37,6 @@
 #include <dns/rdataclass.h>
 #include <dns/rrset.h>
 #include <dns/rrsetlist.h>
-#include <dns/rrsetcontainer.h>
 #include <dns/util/sha1.h>
 
 #include <cc/data.h>
@@ -1298,13 +1297,6 @@
 
 DataSrc::WriteResult
 DataSrc::replaceZone(DataSrcTransaction& transaction UNUSED_PARAM,
-                     const RRsetContainer& UNUSED_PARAM)
-{
-    return (W_NOT_IMPLEMENTED);
-}
-
-DataSrc::WriteResult
-DataSrc::replaceZone(DataSrcTransaction& transaction UNUSED_PARAM,
                      isc::dns::RRsetPtr nextRRset(void*, void*) UNUSED_PARAM,
                      void* arg1 UNUSED_PARAM, void* arg2 UNUSED_PARAM)
 {
@@ -1530,8 +1522,7 @@
         }
     } else {
         // Not a SOA, then this must be an AXFR-type response
-        RRsetContainer empty;
-        replaceZone(transaction, empty);
+        replaceZone(transaction, NULL);
         
         while (next_rrset = nextRRset(arg1, arg2)) {
             addRRset(transaction, next_rrset);
@@ -1737,13 +1728,6 @@
 
 DataSrc::WriteResult
 MetaDataSrc::replaceZone(DataSrcTransaction& transaction UNUSED_PARAM,
-                         const isc::dns::RRsetContainer& rrsets UNUSED_PARAM)
-{
-    return (W_NOT_IMPLEMENTED);
-}
-
-DataSrc::WriteResult
-MetaDataSrc::replaceZone(DataSrcTransaction& transaction UNUSED_PARAM,
                          isc::dns::RRsetPtr nextRRset(void*, void*) UNUSED_PARAM,
                          void* arg1 UNUSED_PARAM, void* arg2 UNUSED_PARAM)
 {

Modified: branches/trac232/src/lib/datasrc/data_source.h
==============================================================================
--- branches/trac232/src/lib/datasrc/data_source.h (original)
+++ branches/trac232/src/lib/datasrc/data_source.h Mon Oct 18 08:01:20 2010
@@ -38,7 +38,6 @@
 class RRType;
 class RRset;
 class RRsetList;
-class RRsetContainer;
 }
 
 namespace datasrc {
@@ -66,11 +65,22 @@
 /// the iterator is advanced. If the last element is reached, and
 /// empty RRsetPtr is returned.
 ///
-/// \param arg1, pointer to an RRsetIterator object, for instance as
-///              returned by isc::dns::message::beginSection(). This
-///              iterator is advanced on each call to this function
-/// \param arg2, pointer to an RRsetIterator end object, for instance
-///              as returned by isc::dns::message::endSection().
+/// Example usage:
+///
+/// \code
+/// isc::dns::Message ixfr_response = some_other_function();
+/// isc::dns::RRsetIterator begin = ixfr_response.beginSection(isc::dns::Section::ANSWER());
+/// isc::dns::RRsetIterator end = ixfr_response.endSection(isc::dns::Section::ANSWER());
+/// data_source.doIXFR(transaction,
+///                    isc::datasrc::callbackHelperRRsetIterator,
+///                    &begin, &end);
+/// \endcode
+///
+/// \param arg1 pointer to an RRsetIterator object, for instance as
+///             returned by isc::dns::message::beginSection(). This
+///             iterator is advanced on each call to this function
+/// \param arg2 pointer to an RRsetIterator end object, for instance
+///             as returned by isc::dns::message::endSection().
 /// \return The RRsetPtr as pointed to by the iterator in arg1, or
 ///         an empty RRsetPtr if the end is reached.
 isc::dns::RRsetPtr
@@ -449,20 +459,17 @@
     /// \return W_SUCCESS on success
     virtual WriteResult delZone(DataSrcTransaction&  transaction);
 
-    /// \brief Replace the contents of the zone by the given list of
-    /// rrsets.
-    /// This deletes *all* current RRsets in the zone.
-    /// \param transaction The transaction to perform the operations on
-    /// \param rrsets The full set of rrsets to replace the zone with
-    /// \return W_SUCCESS on success
-    virtual WriteResult replaceZone(DataSrcTransaction&  transaction,
-                                    const isc::dns::RRsetContainer& rrsets);
-
     /// \brief Replace the contents of the zone by the rrsets returned
     /// by the given function callback.
     /// The provided function should return exactly one RRsetPtr on
-    /// each call. It 
+    /// each call.
     /// This deletes *all* current RRsets in the zone.
+    ///
+    /// Note: Developers do not necessarily need to write a callback
+    /// function. For instance, if you have an std::vector of rrsets,
+    /// you can use the helper function callbackHelperRRsetVector. See its
+    /// description for more information on how to do this.
+    ///
     /// \param transaction The transaction to perform the operations on
     /// \param nextRRset Function that returns the next RRsetPtr on
     ///        each call to it
@@ -520,6 +527,12 @@
     ///        given function.
     /// The given function should return one RRset at a time, which
     /// are processed as described in RFC1995
+    ///
+    /// Note: if you have an isc::dns::Message object that contains
+    /// a complete IXFR response, you can use the helper function
+    /// callbackHelperRRsetIterator() here. See the documentation
+    /// of that function on how to use it.
+    ///
     /// \param transaction the transaction to perform the operation in
     /// \param nextRRset Function that returns the next RRsetPtr on
     ///        each call to it
@@ -529,7 +542,7 @@
     ///             nextRRset function (defaults to NULL)
     /// \return SUCCESS on success, ERROR on failure.
     virtual Result doIXFR(DataSrcTransaction& transaction,
-                          isc::dns::RRsetPtr nextRRset(void*, void*),
+                          isc::dns::RRsetPtr (*nextRRset)(void*, void*),
                           void* arg1 = NULL, void* arg2 = NULL);
 
     /// \brief Perform a DNS Dynamic update as desribed in RFC2136
@@ -622,8 +635,6 @@
     virtual WriteResult delRRset(DataSrcTransaction&  transaction,
                                        isc::dns::ConstRRsetPtr rrset);
     virtual WriteResult delZone(DataSrcTransaction&  transaction);
-    virtual WriteResult replaceZone(DataSrcTransaction&  transaction,
-                                    const isc::dns::RRsetContainer& rrsets);
     virtual WriteResult replaceZone(DataSrcTransaction& transaction,
                                     isc::dns::RRsetPtr nextRRset(void*, void*),
                                     void* arg1 = NULL, void* arg2 = NULL);

Modified: branches/trac232/src/lib/datasrc/python/libdata_source_python.cc
==============================================================================
--- branches/trac232/src/lib/datasrc/python/libdata_source_python.cc (original)
+++ branches/trac232/src/lib/datasrc/python/libdata_source_python.cc Mon Oct 18 08:01:20 2010
@@ -24,7 +24,6 @@
 #include <datasrc/sqlite3_datasrc.h>
 #include <dns/rcode.h>
 #include <dns/rrsetlist.h>
-#include <dns/rrsetcontainer.h>
 #include <dns/rrset.h>
 
 #include <boost/foreach.hpp>
@@ -960,7 +959,7 @@
                          &rrset_list_or_function_obj,
                          &arg1, &arg2)) {
         if (PyList_Check(rrset_list_or_function_obj)) {
-            isc::dns::RRsetContainer rrset_list;
+            std::vector<isc::dns::RRsetPtr> rrset_list;
             for (int i = 0; i < PyList_Size(rrset_list_or_function_obj); ++i) {
                 PyObject* rrset_obj = PyList_GET_ITEM(rrset_list_or_function_obj, i);
                 if (!PyRRset_Check(rrset_obj)) {
@@ -968,12 +967,14 @@
                         "non-RRset object in argument 2 of replace_zone()");
                     return (NULL);
                 }
-                rrset_list.addRRset(PyRRset_AsRRsetPtr(rrset_obj));
+                rrset_list.push_back(PyRRset_AsRRsetPtr(rrset_obj));
             }
+            size_t i = 0;
             PyObject* result = Py_BuildValue("I",
                                   self->datasrc->replaceZone(
                                   *(transaction->datasrc_transaction),
-                                  rrset_list));
+                                  isc::datasrc::callbackHelperRRsetVector,
+                                  &rrset_list, &i));
             return (result);
         } else if (PyCallable_Check(rrset_list_or_function_obj)) {
             PyObject* iterator = PyObject_CallFunctionObjArgs(rrset_list_or_function_obj, arg1, arg2, NULL);

Modified: branches/trac232/src/lib/datasrc/python/tests/data_source_python_test.py
==============================================================================
--- branches/trac232/src/lib/datasrc/python/tests/data_source_python_test.py (original)
+++ branches/trac232/src/lib/datasrc/python/tests/data_source_python_test.py Mon Oct 18 08:01:20 2010
@@ -23,8 +23,8 @@
 from libdata_source_python import *
 from pydnspp import *
 
+# test function for callback test in replace_zone
 def get_new_rrs(list):
-    print("[XX] GET_NEW_RRS CALLED")
     for l in list:
         yield l
 
@@ -395,7 +395,6 @@
 
         new_rrs = [ rrset1, rrset2, rrset3 ]
 
-        print("[XX] About to call replace_zone with function")
         result = self.ds.replace_zone(transaction, get_new_rrs, new_rrs)
         self.assertEqual(DataSrc.W_SUCCESS, result)
 

Modified: branches/trac232/src/lib/datasrc/sqlite3_datasrc.cc
==============================================================================
--- branches/trac232/src/lib/datasrc/sqlite3_datasrc.cc (original)
+++ branches/trac232/src/lib/datasrc/sqlite3_datasrc.cc Mon Oct 18 08:01:20 2010
@@ -28,7 +28,6 @@
 #include <dns/rdataclass.h>
 #include <dns/rrset.h>
 #include <dns/rrsetlist.h>
-#include <dns/rrsetcontainer.h>
 
 #include <cc/data.h>
 
@@ -1122,7 +1121,8 @@
 
 DataSrc::WriteResult
 Sqlite3DataSrc::replaceZone(DataSrcTransaction& transaction,
-                            const isc::dns::RRsetContainer& rrsets)
+                            isc::dns::RRsetPtr nextRRset(void*, void*),
+                            void* arg1, void* arg2)
 {
     if (transaction.getState() != DataSrcTransaction::RUNNING) {
         return DataSrc::W_ERROR;
@@ -1135,39 +1135,16 @@
         return result;
     }
 
-    RRsetContainer::const_iterator it = rrsets.begin();
-    while (it != rrsets.end()) {
-        result = addRRset(transaction, *it);
-        if (result != DataSrc::W_SUCCESS) {
-            return result;
-        }
-        it++;
-    }
-    return DataSrc::W_SUCCESS;
-}
-
-DataSrc::WriteResult
-Sqlite3DataSrc::replaceZone(DataSrcTransaction& transaction,
-                            isc::dns::RRsetPtr nextRRset(void*, void*),
-                            void* arg1, void* arg2)
-{
-    if (transaction.getState() != DataSrcTransaction::RUNNING) {
-        return DataSrc::W_ERROR;
-    }
-
-    int zone_id = transaction.getData()->get("zone_id")->intValue();
-
-    DataSrc::WriteResult result = delAll(zone_id);
-    if (result != DataSrc::W_SUCCESS) {
-        return result;
-    }
-
-    RRsetPtr next_rrset;
-    while (next_rrset = nextRRset(arg1, arg2)) {
+    if (!nextRRset) {
+        return DataSrc::W_SUCCESS;
+    }
+    RRsetPtr next_rrset = nextRRset(arg1, arg2);
+    while (next_rrset) {
         result = addRRset(transaction, next_rrset);
         if (result != DataSrc::W_SUCCESS) {
             return result;
         }
+        next_rrset = nextRRset(arg1, arg2);
     }
     return DataSrc::W_SUCCESS;
 }

Modified: branches/trac232/src/lib/datasrc/sqlite3_datasrc.h
==============================================================================
--- branches/trac232/src/lib/datasrc/sqlite3_datasrc.h (original)
+++ branches/trac232/src/lib/datasrc/sqlite3_datasrc.h Mon Oct 18 08:01:20 2010
@@ -117,8 +117,6 @@
     WriteResult delRRset(DataSrcTransaction& transaction,
                                isc::dns::ConstRRsetPtr rrset);
     WriteResult replaceZone(DataSrcTransaction& transaction,
-                            const isc::dns::RRsetContainer& rrsets);
-    WriteResult replaceZone(DataSrcTransaction& transaction,
                             isc::dns::RRsetPtr nextRRset(void*, void*),
                             void* arg1 = NULL, void* arg2 = NULL);
     WriteResult delZone(DataSrcTransaction& transaction);

Modified: branches/trac232/src/lib/datasrc/tests/sqlite3_unittest.cc
==============================================================================
--- branches/trac232/src/lib/datasrc/tests/sqlite3_unittest.cc (original)
+++ branches/trac232/src/lib/datasrc/tests/sqlite3_unittest.cc Mon Oct 18 08:01:20 2010
@@ -35,7 +35,6 @@
 #include <dns/rrtype.h>
 #include <dns/rdataclass.h>
 #include <dns/rrsetlist.h>
-#include <dns/rrsetcontainer.h>
 #include <cc/data.h>
 
 #include <datasrc/query.h>
@@ -986,9 +985,8 @@
     EXPECT_EQ(DataSrc::W_ERROR,
               data_source.addRRset(transaction, new_rrset));
     RRsetIterator rrset_it = RRsetIterator();
-    RRsetContainer empty_list;
     EXPECT_EQ(DataSrc::W_ERROR,
-              data_source.replaceZone(transaction, empty_list));
+              data_source.replaceZone(transaction, NULL));
     EXPECT_EQ(DataSrc::W_ERROR,
               data_source.delZone(transaction));
     EXPECT_EQ(DataSrc::W_ERROR,
@@ -1012,7 +1010,7 @@
     EXPECT_EQ(DataSrc::W_ERROR,
               data_source.addRRset(transaction, new_rrset));
     EXPECT_EQ(DataSrc::W_ERROR,
-              data_source.replaceZone(transaction, empty_list));
+              data_source.replaceZone(transaction, NULL));
     EXPECT_EQ(DataSrc::W_ERROR,
               data_source.delZone(transaction));
     EXPECT_EQ(DataSrc::W_ERROR,
@@ -1123,12 +1121,10 @@
     EXPECT_EQ(DataSrc::SUCCESS, find_flags);
     EXPECT_EQ(1, result_sets.size());
 
-    RRsetContainer empty_list;
-
     // Replace them, roll back
     DataSrcTransaction transaction1(&data_source, zone_name, RRClass::IN());
     ASSERT_EQ(DataSrc::W_SUCCESS, data_source.startTransaction(transaction1));
-    ASSERT_EQ(DataSrc::W_SUCCESS, data_source.replaceZone(transaction1, empty_list));
+    ASSERT_EQ(DataSrc::W_SUCCESS, data_source.replaceZone(transaction1, NULL));
     ASSERT_EQ(DataSrc::W_SUCCESS, data_source.rollbackTransaction(transaction1));
 
     // check whether it still exists
@@ -1141,7 +1137,7 @@
     // Replace them, commit
     DataSrcTransaction transaction2(&data_source, zone_name, RRClass::IN());
     ASSERT_EQ(DataSrc::W_SUCCESS, data_source.startTransaction(transaction2));
-    ASSERT_EQ(DataSrc::W_SUCCESS, data_source.replaceZone(transaction2, empty_list));
+    ASSERT_EQ(DataSrc::W_SUCCESS, data_source.replaceZone(transaction2, NULL));
     ASSERT_EQ(DataSrc::W_SUCCESS, data_source.commitTransaction(transaction2));
     
     // check whether it's gone now
@@ -1639,7 +1635,7 @@
     end = ixfr_msg.endSection(Section::ANSWER());
     EXPECT_EQ(DataSrc::SUCCESS,
               data_source.doIXFR(transaction1,
-                                 isc::datasrc::callbackHelperRRsetIterator,
+                                 callbackHelperRRsetIterator,
                                  &begin,
                                  &end)
     );

Modified: branches/trac232/src/lib/dns/Makefile.am
==============================================================================
--- branches/trac232/src/lib/dns/Makefile.am (original)
+++ branches/trac232/src/lib/dns/Makefile.am Mon Oct 18 08:01:20 2010
@@ -76,7 +76,6 @@
 libdns___la_SOURCES += rrparamregistry.h
 libdns___la_SOURCES += rrset.h rrset.cc
 libdns___la_SOURCES += rrsetlist.h rrsetlist.cc
-libdns___la_SOURCES += rrsetcontainer.h rrsetcontainer.cc
 libdns___la_SOURCES += rrttl.h rrttl.cc
 libdns___la_SOURCES += rrtype.cc
 libdns___la_SOURCES += question.h question.cc

Modified: branches/trac232/src/lib/dns/tests/Makefile.am
==============================================================================
--- branches/trac232/src/lib/dns/tests/Makefile.am (original)
+++ branches/trac232/src/lib/dns/tests/Makefile.am Mon Oct 18 08:01:20 2010
@@ -38,7 +38,6 @@
 run_unittests_SOURCES += rdata_nsec3param_unittest.cc
 run_unittests_SOURCES += rdata_rrsig_unittest.cc
 run_unittests_SOURCES += rrset_unittest.cc rrsetlist_unittest.cc
-run_unittests_SOURCES += rrsetcontainer_unittest.cc
 run_unittests_SOURCES += question_unittest.cc
 run_unittests_SOURCES += rrparamregistry_unittest.cc
 run_unittests_SOURCES += message_unittest.cc

Modified: branches/trac232/src/lib/python/isc/config/module_spec.py
==============================================================================
--- branches/trac232/src/lib/python/isc/config/module_spec.py (original)
+++ branches/trac232/src/lib/python/isc/config/module_spec.py Mon Oct 18 08:01:20 2010
@@ -49,7 +49,6 @@
         elif type(spec_file) == str:
             file = open(spec_file)
             json_str = file.read()
-            print("[XX] LOADING: " + spec_file)
             module_spec = json.loads(json_str)
             file.close()
         else:




More information about the bind10-changes mailing list