Commit a6709a42 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2378] Implement the master file loading

parent 807b5a13
......@@ -13,6 +13,7 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <datasrc/zone_loader.h>
#include <datasrc/master_loader_callbacks.h>
#include <datasrc/client.h>
#include <datasrc/data_source.h>
......@@ -23,6 +24,7 @@
using isc::dns::Name;
using isc::dns::ConstRRsetPtr;
using isc::dns::MasterLoader;
namespace isc {
namespace datasrc {
......@@ -54,6 +56,21 @@ ZoneLoader::ZoneLoader(DataSourceClient& destination, const Name& zone_name,
}
}
ZoneLoader::ZoneLoader(DataSourceClient& destination, const Name& zone_name,
const char* filename) :
updater_(destination.getUpdater(zone_name, true, false)),
loader_(new MasterLoader(filename, zone_name,
// TODO: Maybe we should have getClass() on the
// data source?
updater_->getFinder().getClass(),
createMasterLoaderCallbacks(zone_name,
updater_->getFinder().getClass(),
&loaded_ok_),
createMasterLoaderAddCallback(*updater_))),
complete_(false),
loaded_ok_(true)
{
}
namespace {
......@@ -86,7 +103,20 @@ ZoneLoader::loadIncremental(size_t limit) {
"Loading has been completed previously");
}
if (iterator_ != ZoneIteratorPtr()) {
if (iterator_ == ZoneIteratorPtr()) {
assert(loader_.get() != NULL);
if (loader_->loadIncremental(limit)) {
complete_ = true;
if (!loaded_ok_) {
isc_throw(MasterFileError, "Error while loading master file");
} else {
updater_->commit();
}
return (true);
} else {
return (false);
}
} else {
if (copyRRsets(updater_, iterator_, limit)) {
updater_->commit();
complete_ = true;
......@@ -94,8 +124,6 @@ ZoneLoader::loadIncremental(size_t limit) {
} else {
return (false);
}
} else {
isc_throw(isc::NotImplemented, "The master file way is not ready yet");
}
}
......
......@@ -17,8 +17,11 @@
#include <datasrc/data_source.h>
#include <dns/master_loader.h>
#include <cstdlib> // For size_t
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
namespace isc {
namespace dns {
......@@ -136,8 +139,12 @@ private:
const ZoneIteratorPtr iterator_;
/// \brief The destination zone updater
const ZoneUpdaterPtr updater_;
/// \brief The master loader (for the loader mode)
const boost::scoped_ptr<isc::dns::MasterLoader> loader_;
/// \brief Indicator if loading was completed
bool complete_;
/// \brief Was the loading successful?
bool loaded_ok_;
};
}
......
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