Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
0d2c2842
Commit
0d2c2842
authored
Jul 28, 2011
by
Michal 'vorner' Vaner
Browse files
[trac1060] Some more renaming
zone->zone_finder in many cases
parent
11944200
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/bin/auth/auth_config.cc
View file @
0d2c2842
...
...
@@ -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
());
}
}
...
...
src/bin/auth/command.cc
View file @
0d2c2842
...
...
@@ -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
);
...
...
src/lib/datasrc/memory_datasrc.cc
View file @
0d2c2842
...
...
@@ -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
;
}
...
...
src/lib/datasrc/memory_datasrc.h
View file @
0d2c2842
...
...
@@ -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().
...
...
src/lib/datasrc/tests/memory_datasrc_unittest.cc
View file @
0d2c2842
...
...
@@ -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
zone
1
(
class_
,
origin_
);
EXPECT_EQ
(
result
::
SUCCESS
,
zone
1
.
add
(
rr_ns_
));
EXPECT_EQ
(
result
::
SUCCESS
,
zone
1
.
add
(
rr_ns_aaaa_
));
// build one zone
finder
with some data
InMemoryZoneFinder
finder
1
(
class_
,
origin_
);
EXPECT_EQ
(
result
::
SUCCESS
,
finder
1
.
add
(
rr_ns_
));
EXPECT_EQ
(
result
::
SUCCESS
,
finder
1
.
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
zone
2
(
RRClass
::
CH
(),
other_origin
);
InMemoryZoneFinder
finder
2
(
RRClass
::
CH
(),
other_origin
);
EXPECT_EQ
(
result
::
SUCCESS
,
zone
2
.
add
(
RRsetPtr
(
new
RRset
(
Name
(
"version.bind"
),
finder
2
.
add
(
RRsetPtr
(
new
RRset
(
Name
(
"version.bind"
),
RRClass
::
CH
(),
RRType
::
TXT
(),
RRTTL
(
0
)))));
zone
1
.
swap
(
zone
2
);
EXPECT_EQ
(
other_origin
,
zone
1
.
getOrigin
());
EXPECT_EQ
(
origin_
,
zone
2
.
getOrigin
());
EXPECT_EQ
(
RRClass
::
CH
(),
zone
1
.
getClass
());
EXPECT_EQ
(
RRClass
::
IN
(),
zone
2
.
getClass
());
finder
1
.
swap
(
finder
2
);
EXPECT_EQ
(
other_origin
,
finder
1
.
getOrigin
());
EXPECT_EQ
(
origin_
,
finder
2
.
getOrigin
());
EXPECT_EQ
(
RRClass
::
CH
(),
finder
1
.
getClass
());
EXPECT_EQ
(
RRClass
::
IN
(),
finder
2
.
getClass
());
// make sure the zone data is swapped, too
findTest
(
origin_
,
RRType
::
NS
(),
ZoneFinder
::
NXDOMAIN
,
false
,
ConstRRsetPtr
(),
NULL
,
&
zone
1
);
ConstRRsetPtr
(),
NULL
,
&
finder
1
);
findTest
(
other_origin
,
RRType
::
TXT
(),
ZoneFinder
::
SUCCESS
,
false
,
ConstRRsetPtr
(),
NULL
,
&
zone
1
);
ConstRRsetPtr
(),
NULL
,
&
finder
1
);
findTest
(
origin_
,
RRType
::
NS
(),
ZoneFinder
::
SUCCESS
,
false
,
ConstRRsetPtr
(),
NULL
,
&
zone
2
);
ConstRRsetPtr
(),
NULL
,
&
finder
2
);
findTest
(
other_origin
,
RRType
::
TXT
(),
ZoneFinder
::
NXDOMAIN
,
false
,
ConstRRsetPtr
(),
NULL
,
&
zone
2
);
ConstRRsetPtr
(),
NULL
,
&
finder
2
);
}
TEST_F
(
InMemoryZoneFinderTest
,
getFileName
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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