Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
2afbc7d3
Commit
2afbc7d3
authored
Nov 09, 2011
by
JINMEI Tatuya
Browse files
[1332] [1332] added a minimal framework for ZoneJournalReader. It's currently
almost empty with bootstrap tests.
parent
ce28b51d
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/client.h
View file @
2afbc7d3
...
...
@@ -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
;
};
}
}
...
...
src/lib/datasrc/database.cc
View file @
2afbc7d3
...
...
@@ -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
()));
}
}
}
src/lib/datasrc/database.h
View file @
2afbc7d3
...
...
@@ -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_
;
...
...
src/lib/datasrc/memory_datasrc.cc
View file @
2afbc7d3
...
...
@@ -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
...
...
src/lib/datasrc/memory_datasrc.h
View file @
2afbc7d3
...
...
@@ -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)?
...
...
src/lib/datasrc/tests/client_unittest.cc
View file @
2afbc7d3
...
...
@@ -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
{
...
...
src/lib/datasrc/tests/database_unittest.cc
View file @
2afbc7d3
...
...
@@ -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
);
}
}
src/lib/datasrc/zone.h
View file @
2afbc7d3
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment