BIND 10 trac2108_3, updated. bd22127826c2286adfc28583c8f14c688391dc2c [2108] Save file name during load() and implement getFileName()
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Sep 3 00:54:03 UTC 2012
The branch, trac2108_3 has been updated
via bd22127826c2286adfc28583c8f14c688391dc2c (commit)
from ae9a4acc8822f21b32a89ebf5504e79f2f37d5c8 (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 bd22127826c2286adfc28583c8f14c688391dc2c
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon Sep 3 06:23:36 2012 +0530
[2108] Save file name during load() and implement getFileName()
getFileName() is used by the client list when reloading a zone.
We may also want to add a reload() method in the future.
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/memory/memory_client.cc | 51 ++++++++++++++++++++++++++++++-
src/lib/datasrc/memory/memory_client.h | 14 +++++++++
2 files changed, 64 insertions(+), 1 deletion(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/memory_client.cc b/src/lib/datasrc/memory/memory_client.cc
index 4168d77..8a0bb4d 100644
--- a/src/lib/datasrc/memory/memory_client.cc
+++ b/src/lib/datasrc/memory/memory_client.cc
@@ -18,6 +18,7 @@
#include <datasrc/memory/zone_data.h>
#include <datasrc/memory/rdata_serialization.h>
#include <datasrc/memory/rdataset.h>
+#include <datasrc/memory/domaintree.h>
#include <util/memory_segment_local.h>
@@ -60,6 +61,8 @@ namespace memory {
namespace {
// Some type aliases
+typedef DomainTree<std::string> FileNameTree;
+typedef DomainTreeNode<std::string> FileNameNode;
// A functor type used for loading.
typedef boost::function<void(ConstRRsetPtr)> LoadCallback;
@@ -73,13 +76,26 @@ typedef boost::function<void(ConstRRsetPtr)> LoadCallback;
/// consists of (pointers to) \c InMemoryZoneFinder objects, we may add more
/// member variables later for new features.
class InMemoryClient::InMemoryClientImpl {
+private:
+ // The deleter for the filenames stored in the tree.
+ struct FileNameDeleter {
+ FileNameDeleter() {}
+ void operator()(std::string* filename) const {
+ delete filename;
+ }
+ };
+
public:
InMemoryClientImpl(RRClass rrclass) :
rrclass_(rrclass),
zone_count(0),
- zone_table_(ZoneTable::create(local_mem_sgmt, rrclass))
+ zone_table_(ZoneTable::create(local_mem_sgmt, rrclass)),
+ file_name_tree_(FileNameTree::create(local_mem_sgmt, false))
{}
~InMemoryClientImpl() {
+ FileNameDeleter deleter;
+ FileNameTree::destroy(local_mem_sgmt, file_name_tree_, deleter);
+
ZoneTable::destroy(local_mem_sgmt, zone_table_, rrclass_);
// see above for the assert().
@@ -93,6 +109,7 @@ public:
RRClass rrclass_;
unsigned int zone_count;
ZoneTable* zone_table_;
+ FileNameTree* file_name_tree_;
// Common process for zone load.
// rrset_installer is a functor that takes another functor as an argument,
@@ -590,6 +607,26 @@ InMemoryClient::InMemoryClientImpl::load(
arg(zone_name).arg(getClass().toText());
++impl_->zone_count;
+
+ // Set the filename in file_name_tree_ now, so that getFileName()
+ // can use it (during zone reloading).
+ FileNameNode* node(NULL);
+ switch (impl_->file_name_tree_->insert(impl_->local_mem_sgmt,
+ zone_name, &node)) {
+ case FileNameTree::SUCCESS:
+ case FileNameTree::ALREADYEXISTS:
+ // These are OK
+ break;
+ default:
+ // Can Not Happen
+ assert(false);
+ }
+ // node must point to a valid node now
+ assert(node != NULL);
+
+ std::string* tstr = node->setData(new std::string(filename));
+ delete tstr;
+
return (result.code);
}
@@ -682,6 +719,18 @@ InMemoryClient::load(const isc::dns::Name& zone_name,
&iterator, _1)));
}
+const std::string
+InMemoryClient::getFileName(const isc::dns::Name& zone_name) const {
+ FileNameNode* node(NULL);
+ FileNameTree::Result result = impl_->file_name_tree_->find(zone_name,
+ &node);
+ if (result == FileNameTree::EXACTMATCH) {
+ return (*node->getData());
+ } else {
+ return (std::string());
+ }
+}
+
result::Result
InMemoryClient::add(const isc::dns::Name& zone_name,
const ConstRRsetPtr& rrset) {
diff --git a/src/lib/datasrc/memory/memory_client.h b/src/lib/datasrc/memory/memory_client.h
index f2ae1c6..31cfa01 100644
--- a/src/lib/datasrc/memory/memory_client.h
+++ b/src/lib/datasrc/memory/memory_client.h
@@ -118,6 +118,20 @@ public:
result::Result load(const isc::dns::Name& zone_name,
ZoneIterator& iterator);
+ /// Return the master file name of the zone
+ ///
+ /// This method returns the name of the zone's master file to be loaded.
+ /// The returned string will be an empty unless the data source client has
+ /// successfully loaded the zone before.
+ ///
+ /// This method should normally not throw an exception. But the creation
+ /// of the return string may involve a resource allocation, and if it
+ /// fails, the corresponding standard exception will be thrown.
+ ///
+ /// \return The name of the zone file loaded in the client, or an empty
+ /// string if the client hasn't loaded any file.
+ const std::string getFileName(const isc::dns::Name& zone_name) const;
+
/// \brief Inserts an rrset into the zone.
///
/// It puts another RRset into the zone.
More information about the bind10-changes
mailing list