Commit 2afbc7d3 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1332] [1332] added a minimal framework for ZoneJournalReader. It's currently

almost empty with bootstrap tests.
parent ce28b51d
......@@ -309,6 +309,10 @@ public:
virtual ZoneUpdaterPtr getUpdater(const isc::dns::Name& name,
bool replace, bool journaling = false)
const = 0;
virtual ZoneJournalReaderPtr
getJournalReader(const isc::dns::Name& zone, uint32_t begin_serial,
uint32_t end_serial) const = 0;
};
}
}
......
......@@ -1089,5 +1089,32 @@ DatabaseClient::getUpdater(const isc::dns::Name& name, bool replace,
return (ZoneUpdaterPtr(new DatabaseUpdater(update_accessor, zone.second,
name, rrclass_, journaling)));
}
//
// Zone journal reader using some database system as the underlying data
// source.
//
class DatabaseJournalReader : public ZoneJournalReader {
public:
DatabaseJournalReader() {}
virtual ~DatabaseJournalReader() {}
virtual ConstRRsetPtr getNextDiff() {
return (ConstRRsetPtr());
}
};
// The JournalReader factory
ZoneJournalReaderPtr
DatabaseClient::getJournalReader(const isc::dns::Name& zone,
uint32_t, uint32_t) const
{
const pair<bool, int> zoneinfo(accessor_->getZone(zone.toText()));
if (!zoneinfo.first) {
// No such zone, can't continue
isc_throw(DataSourceError, "Zone " << zone << "/" << rrclass_ <<
" doesn't exist in database: " + accessor_->getDBName());
}
return (ZoneJournalReaderPtr(new DatabaseJournalReader()));
}
}
}
......@@ -931,6 +931,11 @@ public:
bool replace,
bool journaling = false) const;
/// TBD
virtual ZoneJournalReaderPtr
getJournalReader(const isc::dns::Name& zone, uint32_t begin_serial,
uint32_t end_serial) const;
private:
/// \brief The RR class that this client handles.
const isc::dns::RRClass rrclass_;
......
......@@ -819,6 +819,13 @@ InMemoryClient::getUpdater(const isc::dns::Name&, bool, bool) const {
isc_throw(isc::NotImplemented, "Update attempt on in memory data source");
}
ZoneJournalReaderPtr
InMemoryClient::getJournalReader(const isc::dns::Name&, uint32_t,
uint32_t) const
{
isc_throw(isc::NotImplemented, "Journaling isn't supported for "
"in memory data source");
}
namespace {
// convencience function to add an error message to a list of those
......
......@@ -287,6 +287,10 @@ public:
bool replace, bool journaling = false)
const;
virtual ZoneJournalReaderPtr
getJournalReader(const isc::dns::Name& zone, uint32_t begin_serial,
uint32_t end_serial) const;
private:
// TODO: Do we still need the PImpl if nobody should manipulate this class
// directly any more (it should be handled through DataSourceClient)?
......
......@@ -37,6 +37,10 @@ public:
{
return (ZoneUpdaterPtr());
}
virtual ZoneJournalReaderPtr
getJournalReader(const isc::dns::Name&, uint32_t, uint32_t) const {
return (ZoneJournalReaderPtr());
}
};
class ClientTest : public ::testing::Test {
......
......@@ -2972,4 +2972,14 @@ TEST_F(MockDatabaseClientTest, journalException) {
EXPECT_THROW(updater_->deleteRRset(*soa_), DataSourceError);
}
TYPED_TEST(DatabaseClientTest, getJournalReader) {
ZoneJournalReaderPtr jnl_reader(this->client_->getJournalReader(
this->zname_, 0, 1));
EXPECT_FALSE(jnl_reader->getNextDiff());
EXPECT_THROW(this->client_->getJournalReader(Name("nosuchzone"), 0, 1),
DataSourceError);
}
}
......@@ -560,6 +560,25 @@ public:
/// \brief A pointer-like type pointing to a \c ZoneUpdater object.
typedef boost::shared_ptr<ZoneUpdater> ZoneUpdaterPtr;
/// The base class to retrieve differences between two versions of a zone.
class ZoneJournalReader {
protected:
/// The default constructor.
///
/// This is intentionally defined as protected to ensure that this base
/// class is never instantiated directly.
ZoneJournalReader() {}
public:
/// The destructor
virtual ~ZoneJournalReader() {}
virtual isc::dns::ConstRRsetPtr getNextDiff() = 0;
};
/// \brief A pointer-like type pointing to a \c ZoneUpdater object.
typedef boost::shared_ptr<ZoneJournalReader> ZoneJournalReaderPtr;
} // end of datasrc
} // end of isc
......
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