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

[trac1060] Rename MemoryZoneFinder to InMemoryZoneFinder

To preserve consistency.
parent feae0b93
......@@ -163,7 +163,8 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) {
isc_throw(AuthConfigError, "Missing zone file for zone: "
<< origin->str());
}
shared_ptr<MemoryZoneFinder> new_zone(new MemoryZoneFinder(rrclass_,
shared_ptr<InMemoryZoneFinder> new_zone(new
InMemoryZoneFinder(rrclass_,
Name(origin->stringValue())));
const result::Result result = memory_client_->addZone(new_zone);
if (result == result::EXIST) {
......
......@@ -136,8 +136,8 @@ public:
// that doesn't block other server operations.
// TODO: we may (should?) want to check the "last load time" and
// the timestamp of the file and skip loading if the file isn't newer.
shared_ptr<MemoryZoneFinder> newzone(
new MemoryZoneFinder(oldzone->getClass(), oldzone->getOrigin()));
shared_ptr<InMemoryZoneFinder> newzone(
new InMemoryZoneFinder(oldzone->getClass(), oldzone->getOrigin()));
newzone->load(oldzone->getFileName());
oldzone->swap(*newzone);
LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_LOAD_ZONE)
......@@ -146,7 +146,7 @@ public:
private:
// zone finder to be updated with the new file.
shared_ptr<MemoryZoneFinder> oldzone;
shared_ptr<InMemoryZoneFinder> oldzone;
// A helper private method to parse and validate command parameters.
// On success, it sets 'oldzone' to the zone to be updated.
......@@ -195,7 +195,7 @@ private:
" is not found in data source");
}
oldzone = boost::dynamic_pointer_cast<MemoryZoneFinder>(
oldzone = boost::dynamic_pointer_cast<InMemoryZoneFinder>(
result.zone_finder);
return (true);
......
......@@ -32,10 +32,10 @@ using namespace isc::dns;
namespace isc {
namespace datasrc {
// Private data and hidden methods of MemoryZoneFinder
struct MemoryZoneFinder::MemoryZoneFinderImpl {
// Private data and hidden methods of InMemoryZoneFinder
struct InMemoryZoneFinder::InMemoryZoneFinderImpl {
// Constructor
MemoryZoneFinderImpl(const RRClass& zone_class, const Name& origin) :
InMemoryZoneFinderImpl(const RRClass& zone_class, const Name& origin) :
zone_class_(zone_class), origin_(origin), origin_data_(NULL),
domains_(true)
{
......@@ -223,7 +223,7 @@ struct MemoryZoneFinder::MemoryZoneFinderImpl {
* Implementation of longer methods. We put them here, because the
* access is without the impl_-> and it will get inlined anyway.
*/
// Implementation of MemoryZoneFinder::add
// Implementation of InMemoryZoneFinder::add
result::Result add(const ConstRRsetPtr& rrset, DomainTree* domains) {
// Sanitize input. This will cause an exception to be thrown
// if the input RRset is empty.
......@@ -409,7 +409,7 @@ struct MemoryZoneFinder::MemoryZoneFinderImpl {
}
}
// Implementation of MemoryZoneFinder::find
// Implementation of InMemoryZoneFinder::find
FindResult find(const Name& name, RRType type,
RRsetList* target, const FindOptions options) const
{
......@@ -593,50 +593,50 @@ struct MemoryZoneFinder::MemoryZoneFinderImpl {
}
};
MemoryZoneFinder::MemoryZoneFinder(const RRClass& zone_class, const Name& origin) :
impl_(new MemoryZoneFinderImpl(zone_class, origin))
InMemoryZoneFinder::InMemoryZoneFinder(const RRClass& zone_class, const Name& origin) :
impl_(new InMemoryZoneFinderImpl(zone_class, origin))
{
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_CREATE).arg(origin).
arg(zone_class);
}
MemoryZoneFinder::~MemoryZoneFinder() {
InMemoryZoneFinder::~InMemoryZoneFinder() {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_DESTROY).arg(getOrigin()).
arg(getClass());
delete impl_;
}
const Name&
MemoryZoneFinder::getOrigin() const {
InMemoryZoneFinder::getOrigin() const {
return (impl_->origin_);
}
const RRClass&
MemoryZoneFinder::getClass() const {
InMemoryZoneFinder::getClass() const {
return (impl_->zone_class_);
}
ZoneFinder::FindResult
MemoryZoneFinder::find(const Name& name, const RRType& type,
InMemoryZoneFinder::find(const Name& name, const RRType& type,
RRsetList* target, const FindOptions options) const
{
return (impl_->find(name, type, target, options));
}
result::Result
MemoryZoneFinder::add(const ConstRRsetPtr& rrset) {
InMemoryZoneFinder::add(const ConstRRsetPtr& rrset) {
return (impl_->add(rrset, &impl_->domains_));
}
void
MemoryZoneFinder::load(const string& filename) {
InMemoryZoneFinder::load(const string& filename) {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_LOAD).arg(getOrigin()).
arg(filename);
// Load it into a temporary tree
MemoryZoneFinderImpl::DomainTree tmp;
InMemoryZoneFinderImpl::DomainTree tmp;
masterLoad(filename.c_str(), getOrigin(), getClass(),
boost::bind(&MemoryZoneFinderImpl::addFromLoad, impl_, _1, &tmp));
boost::bind(&InMemoryZoneFinderImpl::addFromLoad, impl_, _1, &tmp));
// If it went well, put it inside
impl_->file_name_ = filename;
tmp.swap(impl_->domains_);
......@@ -644,14 +644,14 @@ MemoryZoneFinder::load(const string& filename) {
}
void
MemoryZoneFinder::swap(MemoryZoneFinder& zone) {
InMemoryZoneFinder::swap(InMemoryZoneFinder& zone) {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_SWAP).arg(getOrigin()).
arg(zone.getOrigin());
std::swap(impl_, zone.impl_);
}
const string
MemoryZoneFinder::getFileName() const {
InMemoryZoneFinder::getFileName() const {
return (impl_->file_name_);
}
......@@ -659,7 +659,7 @@ MemoryZoneFinder::getFileName() const {
/// interface.
///
/// For now, \c InMemoryClient only contains a \c ZoneTable object, which
/// consists of (pointers to) \c MemoryZoneFinder objects, we may add more
/// consists of (pointers to) \c InMemoryZoneFinder objects, we may add more
/// member variables later for new features.
class InMemoryClient::InMemoryClientImpl {
public:
......
......@@ -38,7 +38,7 @@ namespace datasrc {
/// backend). This is why the class has methods like \c load() or \c add().
///
/// This class is non copyable.
class MemoryZoneFinder : boost::noncopyable, public ZoneFinder {
class InMemoryZoneFinder : boost::noncopyable, public ZoneFinder {
///
/// \name Constructors and Destructor.
public:
......@@ -50,11 +50,11 @@ public:
///
/// \param rrclass The RR class of the zone.
/// \param origin The origin name of the zone.
MemoryZoneFinder(const isc::dns::RRClass& rrclass,
InMemoryZoneFinder(const isc::dns::RRClass& rrclass,
const isc::dns::Name& origin);
/// The destructor.
virtual ~MemoryZoneFinder();
virtual ~InMemoryZoneFinder();
//@}
/// \brief Returns the origin of the zone.
......@@ -171,15 +171,15 @@ public:
///
/// This method never throws an exception.
///
/// \param zone Another \c MemoryZone object which is to be swapped with
/// \param zone Another \c InMemoryZone object which is to be swapped with
/// \c this zone.
void swap(MemoryZoneFinder& zone);
void swap(InMemoryZoneFinder& zone);
private:
/// \name Hidden private data
//@{
struct MemoryZoneFinderImpl;
MemoryZoneFinderImpl* impl_;
struct InMemoryZoneFinderImpl;
InMemoryZoneFinderImpl* impl_;
//@}
};
......@@ -208,7 +208,7 @@ private:
/// backend.
///
/// The findZone() method takes a domain name and returns the best matching
/// \c MemoryZoneFinder in the form of (Boost) shared pointer, so that it can
/// \c InMemoryZoneFinder in the form of (Boost) shared pointer, so that it can
/// provide the general interface for all data sources.
class InMemoryClient : public DataSourceClient {
public:
......
......@@ -18,7 +18,7 @@
#include <dns/rrclass.h>
#include <datasrc/zonetable.h>
// We use MemoryZone to put something into the table
// We use InMemoryZone to put something into the table
#include <datasrc/memory_datasrc.h>
#include <gtest/gtest.h>
......@@ -28,29 +28,29 @@ using namespace isc::datasrc;
namespace {
TEST(ZoneTest, init) {
MemoryZoneFinder zone(RRClass::IN(), Name("example.com"));
InMemoryZoneFinder zone(RRClass::IN(), Name("example.com"));
EXPECT_EQ(Name("example.com"), zone.getOrigin());
EXPECT_EQ(RRClass::IN(), zone.getClass());
MemoryZoneFinder ch_zone(RRClass::CH(), Name("example"));
InMemoryZoneFinder ch_zone(RRClass::CH(), Name("example"));
EXPECT_EQ(Name("example"), ch_zone.getOrigin());
EXPECT_EQ(RRClass::CH(), ch_zone.getClass());
}
TEST(ZoneTest, find) {
MemoryZoneFinder zone(RRClass::IN(), Name("example.com"));
InMemoryZoneFinder zone(RRClass::IN(), Name("example.com"));
EXPECT_EQ(ZoneFinder::NXDOMAIN,
zone.find(Name("www.example.com"), RRType::A()).code);
}
class ZoneTableTest : public ::testing::Test {
protected:
ZoneTableTest() : zone1(new MemoryZoneFinder(RRClass::IN(),
Name("example.com"))),
zone2(new MemoryZoneFinder(RRClass::IN(),
Name("example.net"))),
zone3(new MemoryZoneFinder(RRClass::IN(),
Name("example")))
ZoneTableTest() : zone1(new InMemoryZoneFinder(RRClass::IN(),
Name("example.com"))),
zone2(new InMemoryZoneFinder(RRClass::IN(),
Name("example.net"))),
zone3(new InMemoryZoneFinder(RRClass::IN(),
Name("example")))
{}
ZoneTable zone_table;
ZoneFinderPtr zone1, zone2, zone3;
......@@ -61,8 +61,8 @@ TEST_F(ZoneTableTest, addZone) {
EXPECT_EQ(result::EXIST, zone_table.addZone(zone1));
// names are compared in a case insensitive manner.
EXPECT_EQ(result::EXIST, zone_table.addZone(
ZoneFinderPtr(new MemoryZoneFinder(RRClass::IN(),
Name("EXAMPLE.COM")))));
ZoneFinderPtr(new InMemoryZoneFinder(RRClass::IN(),
Name("EXAMPLE.COM")))));
EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone2));
EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone3));
......@@ -70,8 +70,8 @@ TEST_F(ZoneTableTest, addZone) {
// Zone table is indexed only by name. Duplicate origin name with
// different zone class isn't allowed.
EXPECT_EQ(result::EXIST, zone_table.addZone(
ZoneFinderPtr(new MemoryZoneFinder(RRClass::CH(),
Name("example.com")))));
ZoneFinderPtr(new InMemoryZoneFinder(RRClass::CH(),
Name("example.com")))));
/// Bogus zone (NULL)
EXPECT_THROW(zone_table.addZone(ZoneFinderPtr()), isc::InvalidParameter);
......@@ -109,7 +109,7 @@ TEST_F(ZoneTableTest, findZone) {
// make sure the partial match is indeed the longest match by adding
// a zone with a shorter origin and query again.
ZoneFinderPtr zone_com(new MemoryZoneFinder(RRClass::IN(), Name("com")));
ZoneFinderPtr zone_com(new InMemoryZoneFinder(RRClass::IN(), Name("com")));
EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone_com));
EXPECT_EQ(Name("example.com"),
zone_table.findZone(Name("www.example.com")).zone->getOrigin());
......
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