#include <datasrc/memory/segment_object_holder.h>
#include <datasrc/memory/treenode_rrset.h>
#include <datasrc/memory/zone_finder.h>
-#include <datasrc/memory/zone_data_updater.h>
#include <datasrc/memory/zone_data_loader.h>
#include <util/memory_segment_local.h>
#include <dns/name.h>
#include <dns/rdataclass.h>
#include <dns/rrclass.h>
-#include <dns/masterload.h>
-
-#include <boost/bind.hpp>
#include <algorithm>
#include <utility>
}
result::Result
-InMemoryClient::loadInternal(const Name& zone_name,
- const string& filename,
- boost::function<void(internal::LoadCallback)>
- rrset_installer)
+InMemoryClient::loadInternal(const isc::dns::Name& zone_name,
+ const std::string& filename,
+ ZoneData* zone_data)
{
SegmentObjectHolder<ZoneData, RRClass> holder(
- mem_sgmt_, ZoneData::create(mem_sgmt_, zone_name), rrclass_);
-
- ZoneDataLoader loader(mem_sgmt_, rrclass_, zone_name, *holder.get());
- rrset_installer(boost::bind(&ZoneDataLoader::addFromLoad, &loader, _1));
- // Add any last RRsets that were left
- loader.flushNodeRRsets();
-
- const ZoneNode* origin_node = holder.get()->getOriginNode();
- const RdataSet* set = origin_node->getData();
- // If the zone is NSEC3-signed, check if it has NSEC3PARAM
- if (holder.get()->isNSEC3Signed()) {
- if (RdataSet::find(set, RRType::NSEC3PARAM()) == NULL) {
- LOG_WARN(logger, DATASRC_MEMORY_MEM_NO_NSEC3PARAM).
- arg(zone_name).arg(rrclass_);
- }
- }
-
- // When an empty zone file is loaded, the origin doesn't even have
- // an SOA RR. This condition should be avoided, and hence load()
- // should throw when an empty zone is loaded.
- if (RdataSet::find(set, RRType::SOA()) == NULL) {
- isc_throw(EmptyZone,
- "Won't create an empty zone for: " << zone_name);
- }
+ mem_sgmt_, zone_data, rrclass_);
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEMORY_MEM_ADD_ZONE).
arg(zone_name).arg(rrclass_);
return (result.code);
}
-namespace {
-// A wrapper for dns::masterLoad used by load() below. Essentially it
-// converts the two callback types. Note the mostly redundant wrapper of
-// boost::bind. It converts function<void(ConstRRsetPtr)> to
-// function<void(RRsetPtr)> (masterLoad() expects the latter). SunStudio
-// doesn't seem to do this conversion if we just pass 'callback'.
-void
-masterLoadWrapper(const char* const filename, const Name& origin,
- const RRClass& zone_class,
- internal::LoadCallback callback)
-{
- masterLoad(filename, origin, zone_class, boost::bind(callback, _1));
-}
-
-// The installer called from load() for the iterator version of load().
-void
-generateRRsetFromIterator(ZoneIterator* iterator,
- internal::LoadCallback callback)
-{
- ConstRRsetPtr rrset;
- while ((rrset = iterator->getNextRRset()) != NULL) {
- callback(rrset);
- }
-}
-}
-
RRClass
InMemoryClient::getClass() const {
return (rrclass_);
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEMORY_MEM_LOAD).arg(zone_name).
arg(filename);
- return (loadInternal(zone_name, filename,
- boost::bind(masterLoadWrapper, filename.c_str(),
- zone_name, getClass(), _1)));
+ ZoneData* zone_data = loadZoneData(mem_sgmt_, rrclass_, zone_name,
+ filename);
+ return (loadInternal(zone_name, filename, zone_data));
}
result::Result
InMemoryClient::load(const isc::dns::Name& zone_name,
ZoneIterator& iterator) {
- return (loadInternal(zone_name, string(),
- boost::bind(generateRRsetFromIterator,
- &iterator, _1)));
+ ZoneData* zone_data = loadZoneData(mem_sgmt_, rrclass_, zone_name,
+ iterator);
+ return (loadInternal(zone_name, string(), zone_data));
}
const std::string
#include <datasrc/memory/zone_table.h>
#include <datasrc/memory/zone_data.h>
-#include <boost/function.hpp>
-
#include <string>
namespace isc {
namespace datasrc {
namespace memory {
-namespace internal {
- // Please don't use anything from here outside the InMemoryClient
- // implementation.
-
- // A functor type used for loading.
- typedef boost::function<void(isc::dns::ConstRRsetPtr)> LoadCallback;
-} // end of internal namespace
-
/// \brief A data source client that holds all necessary data in memory.
///
/// The \c InMemoryClient class provides an access to a conceptual data
/// \return The number of zones stored in the client.
virtual unsigned int getZoneCount() const;
- /// \brief Zone is empty exception.
- ///
- /// This is thrown if we have an empty zone created as a result of
- /// load().
- struct EmptyZone : public InvalidParameter {
- EmptyZone(const char* file, size_t line, const char* what) :
- InvalidParameter(file, line, what)
- {}
- };
-
/// \brief Load zone from masterfile.
///
/// This loads data from masterfile specified by filename. It replaces
typedef DomainTree<std::string> FileNameTree;
typedef DomainTreeNode<std::string> FileNameNode;
- // Common process for zone load.
- // rrset_installer is a functor that takes another functor as an argument,
- // and expected to call the latter for each RRset of the zone. How the
- // sequence of the RRsets is generated depends on the internal
- // details of the loader: either from a textual master file or from
- // another data source.
- // filename is the file name of the master file or empty if the zone is
- // loaded from another data source.
+ // Common process for zone load. Registers filename internally and
+ // adds the ZoneData to the ZoneTable.
result::Result loadInternal(const isc::dns::Name& zone_name,
const std::string& filename,
- boost::function<void(internal::LoadCallback)>
- rrset_installer);
+ ZoneData* zone_data);
util::MemorySegment& mem_sgmt_;
const isc::dns::RRClass rrclass_;