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
946126b3
Commit
946126b3
authored
Mar 22, 2013
by
Michal 'vorner' Vaner
Browse files
[2835] Use string for segment type
Instead of hard-coded enum type. The data source should be agnostic to the type.
parent
8c6afd88
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/client_list.cc
View file @
946126b3
...
...
@@ -483,7 +483,7 @@ ConfigurableClientList::getStatus() const {
// SEGMENT_WAITING.
result
.
push_back
(
DataSourceStatus
(
info
.
name_
,
info
.
cache_
?
SEGMENT_INUSE
:
SEGMENT_UNUSED
,
SEGMENT_LOCAL
));
"local"
));
}
return
(
result
);
}
...
...
src/lib/datasrc/client_list.h
View file @
946126b3
...
...
@@ -64,15 +64,6 @@ enum MemorySegmentState {
SEGMENT_INUSE
};
/// \brief The type of the memory segment in cache
enum
MemorySegmentType
{
/// \brief A locally loaded, unshared cache. Normal memory.
SEGMENT_LOCAL
,
/// \brief A file image mapped into memory
SEGMENT_FILE
};
/// \brief Status of one data source.
///
/// This indicates the status a data soure is in. It is used with segment
...
...
@@ -88,10 +79,10 @@ public:
/// Sets initial values. It doesn't matter what is provided for the type
/// if state is SEGMENT_UNUSED, the value is effectively ignored.
DataSourceStatus
(
const
std
::
string
&
name
,
MemorySegmentState
state
,
MemorySegmentType
type
)
:
const
std
::
string
&
type
)
:
name_
(
name
),
state_
(
stat
e
),
type_
(
typ
e
)
type_
(
typ
e
),
state_
(
stat
e
)
{}
/// \brief Get the segment state
...
...
@@ -102,7 +93,7 @@ public:
/// \brief Get the segment type
///
/// \throw isc::InvalidOperation if called and state is SEGMENT_UNUSED.
MemorySegmentType
getSegmentType
()
const
{
const
std
::
string
&
getSegmentType
()
const
{
if
(
getSegmentState
()
==
SEGMENT_UNUSED
)
{
isc_throw
(
isc
::
InvalidOperation
,
"No segment used, no type therefore."
);
...
...
@@ -116,8 +107,8 @@ public:
}
private:
std
::
string
name_
;
std
::
string
type_
;
MemorySegmentState
state_
;
MemorySegmentType
type_
;
};
/// \brief The list of data source clients.
...
...
src/lib/datasrc/tests/client_list_unittest.cc
View file @
946126b3
...
...
@@ -579,7 +579,7 @@ TEST_F(ListTest, status) {
EXPECT_THROW
(
statuses
[
0
].
getSegmentType
(),
isc
::
InvalidOperation
);
EXPECT_EQ
(
"Test name"
,
statuses
[
1
].
getName
());
EXPECT_EQ
(
SEGMENT_INUSE
,
statuses
[
1
].
getSegmentState
());
EXPECT_EQ
(
SEGMENT_LOCAL
,
statuses
[
1
].
getSegmentType
());
EXPECT_EQ
(
"local"
,
statuses
[
1
].
getSegmentType
());
}
TEST_F
(
ListTest
,
wrongConfig
)
{
...
...
@@ -1163,14 +1163,14 @@ TYPED_TEST(ReloadTest, reloadMasterFile) {
RRType
::
TXT
())
->
code
);
}
// Check the status holds data and
the data
can
be extrac
te
d
// Check the status holds data and
can
c
h
an
ge the segment sta
te
TEST
(
DataSourceStatus
,
status
)
{
const
DataSourceStatus
status
(
"Test"
,
SEGMENT_INUSE
,
SEGMENT_LOCAL
);
const
DataSourceStatus
status
(
"Test"
,
SEGMENT_INUSE
,
"local"
);
EXPECT_EQ
(
"Test"
,
status
.
getName
());
EXPECT_EQ
(
SEGMENT_INUSE
,
status
.
getSegmentState
());
EXPECT_EQ
(
SEGMENT_LOCAL
,
status
.
getSegmentType
());
EXPECT_EQ
(
"local"
,
status
.
getSegmentType
());
const
DataSourceStatus
statusUnused
(
"Unused"
,
SEGMENT_UNUSED
,
SEGMENT_FILE
);
""
);
EXPECT_EQ
(
"Unused"
,
statusUnused
.
getName
());
EXPECT_EQ
(
SEGMENT_UNUSED
,
statusUnused
.
getSegmentState
());
EXPECT_THROW
(
statusUnused
.
getSegmentType
(),
isc
::
InvalidOperation
);
...
...
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