Commit 0d2c2842 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac1060] Some more renaming

zone->zone_finder in many cases
parent 11944200
......@@ -163,10 +163,10 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) {
isc_throw(AuthConfigError, "Missing zone file for zone: "
<< origin->str());
}
shared_ptr<InMemoryZoneFinder> new_zone(new
InMemoryZoneFinder(rrclass_,
shared_ptr<InMemoryZoneFinder> zone_finder(new
InMemoryZoneFinder(rrclass_,
Name(origin->stringValue())));
const result::Result result = memory_client_->addZone(new_zone);
const result::Result result = memory_client_->addZone(zone_finder);
if (result == result::EXIST) {
isc_throw(AuthConfigError, "zone "<< origin->str()
<< " already exists");
......@@ -178,7 +178,7 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) {
* need the load method to be split into some kind of build and
* commit/abort parts.
*/
new_zone->load(file->stringValue());
zone_finder->load(file->stringValue());
}
}
......
......@@ -136,20 +136,21 @@ 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<InMemoryZoneFinder> newzone(
new InMemoryZoneFinder(oldzone->getClass(), oldzone->getOrigin()));
newzone->load(oldzone->getFileName());
oldzone->swap(*newzone);
shared_ptr<InMemoryZoneFinder> zone_finder(
new InMemoryZoneFinder(old_zone_finder->getClass(),
old_zone_finder->getOrigin()));
newzone->load(old_zone_finder->getFileName());
old_zone_finder->swap(*newzone);
LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_LOAD_ZONE)
.arg(newzone->getOrigin()).arg(newzone->getClass());
}
private:
// zone finder to be updated with the new file.
shared_ptr<InMemoryZoneFinder> oldzone;
shared_ptr<InMemoryZoneFinder> old_zone_finder;
// A helper private method to parse and validate command parameters.
// On success, it sets 'oldzone' to the zone to be updated.
// On success, it sets 'old_zone_finder' to the zone to be updated.
// It returns true if everything is okay; and false if the command is
// valid but there's no need for further process.
bool validate(AuthSrv& server, isc::data::ConstElementPtr args) {
......@@ -195,7 +196,7 @@ private:
" is not found in data source");
}
oldzone = boost::dynamic_pointer_cast<InMemoryZoneFinder>(
old_zone_finder = boost::dynamic_pointer_cast<InMemoryZoneFinder>(
result.zone_finder);
return (true);
......
......@@ -644,10 +644,10 @@ InMemoryZoneFinder::load(const string& filename) {
}
void
InMemoryZoneFinder::swap(InMemoryZoneFinder& zone) {
InMemoryZoneFinder::swap(InMemoryZoneFinder& zone_finder) {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_SWAP).arg(getOrigin()).
arg(zone.getOrigin());
std::swap(impl_, zone.impl_);
arg(zone_finder.getOrigin());
std::swap(impl_, zone_finder.impl_);
}
const string
......@@ -681,16 +681,16 @@ InMemoryClient::getZoneCount() const {
}
result::Result
InMemoryClient::addZone(ZoneFinderPtr zone) {
if (!zone) {
InMemoryClient::addZone(ZoneFinderPtr zone_finder) {
if (!zone_finder) {
isc_throw(InvalidParameter,
"Null pointer is passed to InMemoryClient::addZone()");
}
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_MEM_ADD_ZONE).
arg(zone->getOrigin()).arg(zone->getClass().toText());
arg(zone_finder->getOrigin()).arg(zone_finder->getClass().toText());
const result::Result result = impl_->zone_table.addZone(zone);
const result::Result result = impl_->zone_table.addZone(zone_finder);
if (result == result::SUCCESS) {
++impl_->zone_count;
}
......
......@@ -30,7 +30,7 @@ class RRsetList;
namespace datasrc {
/// A derived zone class intended to be used with the memory data source.
/// A derived zone finder class intended to be used with the memory data source.
///
/// Conceptually this "finder" maintains a local in-memory copy of all RRs
/// of a single zone from some kind of source (right now it's a textual
......@@ -51,7 +51,7 @@ public:
/// \param rrclass The RR class of the zone.
/// \param origin The origin name of the zone.
InMemoryZoneFinder(const isc::dns::RRClass& rrclass,
const isc::dns::Name& origin);
const isc::dns::Name& origin);
/// The destructor.
virtual ~InMemoryZoneFinder();
......@@ -131,14 +131,14 @@ public:
/// 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 zone has successfully
/// loaded a zone.
/// The returned string will be an empty unless the zone finder has
/// successfully loaded a zone.
///
/// 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 zone, or an empty
/// \return The name of the zone file loaded in the zone finder, or an empty
/// string if the zone hasn't loaded any file.
const std::string getFileName() const;
......@@ -167,13 +167,14 @@ public:
/// configuration reloading is written.
void load(const std::string& filename);
/// Exchanges the content of \c this zone with that of the given \c zone.
/// Exchanges the content of \c this zone finder with that of the given
/// \c zone_finder.
///
/// This method never throws an exception.
///
/// \param zone Another \c InMemoryZone object which is to be swapped with
/// \c this zone.
void swap(InMemoryZoneFinder& zone);
/// \param zone_finder Another \c InMemoryZone object which is to
/// be swapped with \c this zone finder.
void swap(InMemoryZoneFinder& zone_finder);
private:
/// \name Hidden private data
......@@ -237,20 +238,21 @@ public:
/// Add a zone (in the form of \c ZoneFinder) to the \c InMemoryClient.
///
/// \c zone must not be associated with a NULL pointer; otherwise
/// \c zone_finder must not be associated with a NULL pointer; otherwise
/// an exception of class \c InvalidParameter will be thrown.
/// If internal resource allocation fails, a corresponding standard
/// exception will be thrown.
/// This method never throws an exception otherwise.
///
/// \param zone A \c ZoneFinder object to be added.
/// \return \c result::SUCCESS If the zone is successfully
/// \param zone_finder A \c ZoneFinder object to be added.
/// \return \c result::SUCCESS If the zone_finder is successfully
/// added to the client.
/// \return \c result::EXIST The memory data source already
/// stores a zone that has the same origin.
result::Result addZone(ZoneFinderPtr zone);
result::Result addZone(ZoneFinderPtr zone_finder);
/// Returns a \c ZoneFinder for a zone that best matches the given name.
/// Returns a \c ZoneFinder for a zone_finder that best matches the given
/// name.
///
/// This derived version of the method never throws an exception.
/// For other details see \c DataSourceClient::findZone().
......
......@@ -236,7 +236,7 @@ public:
// Some data to test with
const RRClass class_;
const Name origin_;
// The zone to torture by tests
// The zone finder to torture by tests
InMemoryZoneFinder zone_finder_;
/*
......@@ -274,9 +274,9 @@ public:
RRsetPtr rr_not_wild_another_;
/**
* \brief Test one find query to the zone.
* \brief Test one find query to the zone finder.
*
* Asks a query to the zone and checks it does not throw and returns
* Asks a query to the zone finder and checks it does not throw and returns
* expected results. It returns nothing, it just signals failures
* to GTEST.
*
......@@ -286,8 +286,8 @@ public:
* \param check_answer Should a check against equality of the answer be
* done?
* \param answer The expected rrset, if any should be returned.
* \param zone Check different InMemoryZoneFinder object than zone_ (if NULL,
* uses zone_)
* \param zone_finder Check different InMemoryZoneFinder object than
* zone_finder_ (if NULL, uses zone_finder_)
* \param check_wild_answer Checks that the answer has the same RRs, type
* class and TTL as the eqxpected answer and that the name corresponds
* to the one searched. It is meant for checking answers for wildcard
......@@ -353,7 +353,7 @@ public:
/**
* \brief Test InMemoryZoneFinder::InMemoryZoneFinder constructor.
*
* Takes the created zone and checks its properties they are the same
* Takes the created zone finder and checks its properties they are the same
* as passed parameters.
*/
TEST_F(InMemoryZoneFinderTest, constructor) {
......@@ -1004,34 +1004,34 @@ TEST_F(InMemoryZoneFinderTest, loadBadWildcard) {
}
TEST_F(InMemoryZoneFinderTest, swap) {
// build one zone with some data
InMemoryZoneFinder zone1(class_, origin_);
EXPECT_EQ(result::SUCCESS, zone1.add(rr_ns_));
EXPECT_EQ(result::SUCCESS, zone1.add(rr_ns_aaaa_));
// build one zone finder with some data
InMemoryZoneFinder finder1(class_, origin_);
EXPECT_EQ(result::SUCCESS, finder1.add(rr_ns_));
EXPECT_EQ(result::SUCCESS, finder1.add(rr_ns_aaaa_));
// build another zone of a different RR class with some other data
// build another zone finder of a different RR class with some other data
const Name other_origin("version.bind");
ASSERT_NE(origin_, other_origin); // make sure these two are different
InMemoryZoneFinder zone2(RRClass::CH(), other_origin);
InMemoryZoneFinder finder2(RRClass::CH(), other_origin);
EXPECT_EQ(result::SUCCESS,
zone2.add(RRsetPtr(new RRset(Name("version.bind"),
finder2.add(RRsetPtr(new RRset(Name("version.bind"),
RRClass::CH(), RRType::TXT(),
RRTTL(0)))));
zone1.swap(zone2);
EXPECT_EQ(other_origin, zone1.getOrigin());
EXPECT_EQ(origin_, zone2.getOrigin());
EXPECT_EQ(RRClass::CH(), zone1.getClass());
EXPECT_EQ(RRClass::IN(), zone2.getClass());
finder1.swap(finder2);
EXPECT_EQ(other_origin, finder1.getOrigin());
EXPECT_EQ(origin_, finder2.getOrigin());
EXPECT_EQ(RRClass::CH(), finder1.getClass());
EXPECT_EQ(RRClass::IN(), finder2.getClass());
// make sure the zone data is swapped, too
findTest(origin_, RRType::NS(), ZoneFinder::NXDOMAIN, false,
ConstRRsetPtr(), NULL, &zone1);
ConstRRsetPtr(), NULL, &finder1);
findTest(other_origin, RRType::TXT(), ZoneFinder::SUCCESS, false,
ConstRRsetPtr(), NULL, &zone1);
ConstRRsetPtr(), NULL, &finder1);
findTest(origin_, RRType::NS(), ZoneFinder::SUCCESS, false,
ConstRRsetPtr(), NULL, &zone2);
ConstRRsetPtr(), NULL, &finder2);
findTest(other_origin, RRType::TXT(), ZoneFinder::NXDOMAIN, false,
ConstRRsetPtr(), NULL, &zone2);
ConstRRsetPtr(), NULL, &finder2);
}
TEST_F(InMemoryZoneFinderTest, getFileName) {
......
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