Commit f2349562 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2441] Remove the grouping vectors from ZoneDataLoader

It is now a thin wrapper around the ZoneDataUpdater.
parent 28ebeea1
......@@ -49,22 +49,6 @@ typedef boost::function<void(isc::dns::ConstRRsetPtr)> LoadCallback;
// A helper internal class for \c loadZoneData(). make it non-copyable
// to avoid accidental copy.
//
// The current internal implementation expects that both a normal
// (non RRSIG) RRset and (when signed) its RRSIG are added at once.
// Also in the current implementation, the input sequence of RRsets
// are grouped with their owner name (so once a new owner name is encountered,
// no subsequent RRset has the previous owner name), but the ordering
// in the same group is not fixed. So we hold all RRsets of the same
// owner name in node_rrsets_ and node_rrsigsets_, and add the matching
// pairs of RRsets to the zone when we see a new owner name.
//
// The caller is responsible for adding the RRsets of the last group
// in the input sequence by explicitly calling flushNodeRRsets() at the
// end. It's cleaner and more robust if we let the destructor of this class
// do it, but since we cannot guarantee the adding operation is exception free,
// we don't choose that option to maintain the common expectation for
// destructors.
class ZoneDataLoader : boost::noncopyable {
public:
ZoneDataLoader(util::MemorySegment& mem_sgmt,
......@@ -74,66 +58,24 @@ public:
{}
void addFromLoad(const isc::dns::ConstRRsetPtr& rrset);
void flushNodeRRsets();
private:
typedef std::vector<isc::dns::ConstRRsetPtr> NodeRRsets;
// A helper to identify the covered type of an RRSIG.
const isc::dns::Name& getCurrentName() const;
private:
NodeRRsets node_rrsets_;
NodeRRsets node_rrsigsets_;
ZoneDataUpdater updater_;
};
void
ZoneDataLoader::addFromLoad(const ConstRRsetPtr& rrset) {
// If we see a new name, flush the temporary holders, adding the
// pairs of RRsets and RRSIGs of the previous name to the zone.
if ((!node_rrsets_.empty() || !node_rrsigsets_.empty()) &&
(getCurrentName() != rrset->getName())) {
flushNodeRRsets();
if (rrset->getType() == RRType::RRSIG()) {
updater_.add(ConstRRsetPtr(), rrset);
} else {
updater_.add(rrset, ConstRRsetPtr());
}
// Store this RRset until it can be added to the zone. The current
// implementation requires RRs of the same RRset should be added at
// once, so we check the "duplicate" here.
const bool is_rrsig = rrset->getType() == RRType::RRSIG();
NodeRRsets& node_rrsets = is_rrsig ? node_rrsigsets_ : node_rrsets_;
// Store this RRset until it can be added to the zone.
node_rrsets.insert(node_rrsets.begin(), rrset);
if (rrset->getRRsig()) {
addFromLoad(rrset->getRRsig());
}
}
void
ZoneDataLoader::flushNodeRRsets() {
BOOST_FOREACH(ConstRRsetPtr rrset, node_rrsets_) {
updater_.add(rrset, ConstRRsetPtr());
}
BOOST_FOREACH(ConstRRsetPtr rrset, node_rrsigsets_) {
updater_.add(ConstRRsetPtr(), rrset);
}
node_rrsets_.clear();
node_rrsigsets_.clear();
}
const Name&
ZoneDataLoader::getCurrentName() const {
if (!node_rrsets_.empty()) {
return (node_rrsets_.front()->getName());
}
assert(!node_rrsigsets_.empty());
return (node_rrsigsets_.front()->getName());
}
void
logWarning(const dns::Name* zone_name, const dns::RRClass* rrclass,
const std::string& reason)
......@@ -161,8 +103,6 @@ loadZoneDataInternal(util::MemorySegment& mem_sgmt,
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* rdataset = origin_node->getData();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment