BIND 10 trac1975, updated. 170c72d67a741e958611e7267826679b0629286a [1975] Interface of the ConfigurableContainer

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Jun 2 11:39:16 UTC 2012


The branch, trac1975 has been updated
       via  170c72d67a741e958611e7267826679b0629286a (commit)
       via  128271198f60e6b1f045d6080ef4040760b6ec58 (commit)
       via  57e92cc0aff7f42885c0e100116ec85e9eb21dc7 (commit)
      from  1a56963435c6a771d76c4ab44814564150ba8247 (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 170c72d67a741e958611e7267826679b0629286a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Sat Jun 2 13:38:41 2012 +0200

    [1975] Interface of the ConfigurableContainer
    
    The constructor and the virtual method.

commit 128271198f60e6b1f045d6080ef4040760b6ec58
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Sat Jun 2 13:16:22 2012 +0200

    [1975] Run the header through compilation
    
    Added a .cc file so something includes the header file. This is used as
    a syntax check for now, there's no useful code yet anyway.

commit 57e92cc0aff7f42885c0e100116ec85e9eb21dc7
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Sat Jun 2 13:14:10 2012 +0200

    [1975] Description of expected usage

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

Summary of changes:
 src/lib/datasrc/Makefile.am                        |    1 +
 .../common.cc => lib/datasrc/container.cc}         |    4 +-
 src/lib/datasrc/container.h                        |   73 +++++++++++++++++++-
 3 files changed, 73 insertions(+), 5 deletions(-)
 copy src/{bin/resolver/common.cc => lib/datasrc/container.cc} (91%)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/Makefile.am b/src/lib/datasrc/Makefile.am
index 2cdb8ea..3ee3337 100644
--- a/src/lib/datasrc/Makefile.am
+++ b/src/lib/datasrc/Makefile.am
@@ -30,6 +30,7 @@ libdatasrc_la_SOURCES += logger.h logger.cc
 libdatasrc_la_SOURCES += client.h iterator.h
 libdatasrc_la_SOURCES += database.h database.cc
 libdatasrc_la_SOURCES += factory.h factory.cc
+libdatasrc_la_SOURCES += container.h container.cc
 nodist_libdatasrc_la_SOURCES = datasrc_messages.h datasrc_messages.cc
 libdatasrc_la_LDFLAGS = -no-undefined -version-info 1:0:1
 
diff --git a/src/lib/datasrc/container.cc b/src/lib/datasrc/container.cc
new file mode 100644
index 0000000..c568827
--- /dev/null
+++ b/src/lib/datasrc/container.cc
@@ -0,0 +1,15 @@
+// Copyright (C) 2012  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
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include "container.h"
diff --git a/src/lib/datasrc/container.h b/src/lib/datasrc/container.h
index 7d30f5c..5a42646 100644
--- a/src/lib/datasrc/container.h
+++ b/src/lib/datasrc/container.h
@@ -16,6 +16,8 @@
 #define DATASRC_CONTAINER_H
 
 #include <dns/name.h>
+#include <cc/data.h>
+#include <exceptions/exceptions.h>
 
 #include <boost/shared_ptr.hpp>
 #include <boost/noncopyable.hpp>
@@ -62,7 +64,7 @@ public:
             datasrc_(datasrc),
             finder_(finder),
             matched_labels_(matched_labels),
-            exact_match(exact_match)
+            exact_match_(exact_match)
         { }
         /// \brief Negative answer constructor.
         ///
@@ -98,6 +100,28 @@ public:
     /// This searches the contained data sources for a one that best matches
     /// the zone name.
     ///
+    /// There are two expected usage scenarios. One is answering queries. In
+    /// this case, the zone finder is needed and the best matching superzone
+    /// of the searched name is needed. Therefore, the call would look like:
+    ///
+    ///   SearchResult result(container->search(queried_name));
+    ///   if (result.datasrc_) {
+    ///       createTheAnswer(result.finder_);
+    ///   } else {
+    ///       createNotAuthAnswer();
+    ///   }
+    ///
+    /// The other scenario is manipulating zone data (XfrOut, XfrIn, DDNS,
+    /// ...). In this case, the finder itself is not so important. However,
+    /// we need an exact match (if we want to manipulate zone data, we must
+    /// know exactly, which zone we are about to manipulate). Then the call
+    ///
+    ///   SearchResult result(container->search(zone_name, true, false));
+    ///   if (result.datasrc_) {
+    ///       ZoneUpdaterPtr updater(result.datasrc_->getUpdater(zone_name);
+    ///       ...
+    ///   }
+    ///
     /// \param zone The name of the zone to search.
     /// \param want_exact_match If it is true, it returns only exact matches.
     ///     If the best possible match is partial, a negative result is
@@ -122,8 +146,53 @@ public:
                                 bool want_finder = true) const = 0;
 };
 
-class ConfigurableContainer : public Container {
+/// \brief Shared pointer to the container.
+typedef boost::shared_ptr<Container> ContainerPtr;
+/// \brief Shared const pointer to the container.
+typedef boost::shared_ptr<const Container> ConstContainerPtr;
 
+/// \Concrete implementation of the Container, which is constructed based on
+///     configuration.
+///
+/// This is the implementation which is expected to be used in the servers.
+/// However, it is expected most of the code will use it as the Container,
+/// only the creation is expected to be direct.
+class ConfigurableContainer : public Container {
+public:
+    /// \brief Exception thrown when there's an error in configuration.
+    class ConfigurationError : public Exception {
+    public:
+        ConfigurationError(const char* file, size_t line, const char* what) :
+            Exception(file, line, what)
+        { }
+    };
+    /// \brief Constructor.
+    ///
+    /// This creates the container and fills it with data sources corresponding
+    /// to the configuration. The data sources are newly created or taken from
+    /// the container passed as old.
+    ///
+    /// \param configuration The JSON element describing the configuration to
+    ///     use.
+    /// \param allow_cache If it is true, the 'cache' option of the
+    ///     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
+    ///     no In-Memory data sources are created.
+    /// \param old This can be set to a previous container. It will be used as
+    ///     a source of data sources that were already created in the previous
+    ///     configuration. The designed use is when there's an update to
+    ///     configuration, so not all things would have to be re-created from
+    ///     scratch. Note that the old data source must not be used any more.
+    /// \throw DataSourceError if there's a problem creating a data source.
+    /// \throw ConfigurationError if the configuration is invalid in some
+    ///     sense.
+    ConfigurableContainer(const data::ConstElementPtr& configuration,
+                          bool allow_cache,
+                          const ConstContainerPtr& old = ConstContainerPtr());
+    /// \brief Implementation of the Container::search.
+    virtual SearchResult search(const dns::Name& zone,
+                                bool want_exact_match = false,
+                                bool want_finder = true) const;
 };
 
 } // namespace datasrc



More information about the bind10-changes mailing list