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

[2835] The ClientList::getStatus method

So one can extract status of all the data source clients from the list
and allow using it from future management of the memory segments.
parent 2e6d5f8d
......@@ -475,5 +475,16 @@ ConfigurableClientList::getDataSourceClient(const string& type,
return (DataSourcePair(&container->getInstance(), container));
}
vector<DataSourceStatus>
ConfigurableClientList::getStatus() const {
vector<DataSourceStatus> result;
BOOST_FOREACH(const DataSourceInfo& info, data_sources_) {
// TODO: Once we support mapped cache, provide the correct MSS_ value
result.push_back(DataSourceStatus(info.name_, info.cache_ ? MSS_LOCAL :
MSS_UNUSED));
}
return (result);
}
}
}
......@@ -430,6 +430,12 @@ public:
virtual DataSourcePair getDataSourceClient(const std::string& type,
const data::ConstElementPtr&
configuration);
/// \brief Get status information of all internal data sources.
///
/// Get a DataSourceStatus for current state of each data source client
/// in this list.
std::vector<DataSourceStatus> getStatus() const;
public:
/// \brief Access to the data source clients.
///
......
......@@ -512,12 +512,12 @@ TEST_F(ListTest, configureMulti) {
const ConstElementPtr elem(Element::fromJSON("["
"{"
" \"type\": \"type1\","
" \"cache\": \"off\","
" \"cache-enable\": false,"
" \"params\": {}"
"},"
"{"
" \"type\": \"type2\","
" \"cache\": \"off\","
" \"cache-enable\": false,"
" \"params\": {}"
"}]"
));
......@@ -546,7 +546,7 @@ TEST_F(ListTest, configureParams) {
ConstElementPtr elem(Element::fromJSON(string("["
"{"
" \"type\": \"t\","
" \"cache\": \"off\","
" \"cache-enable\": false,"
" \"params\": ") + *param +
"}]"));
list_->configure(elem, true);
......@@ -555,6 +555,31 @@ TEST_F(ListTest, configureParams) {
}
}
TEST_F(ListTest, status) {
EXPECT_TRUE(list_->getStatus().empty());
const ConstElementPtr elem(Element::fromJSON("["
"{"
" \"type\": \"type1\","
" \"cache-enable\": false,"
" \"params\": {}"
"},"
"{"
" \"type\": \"type2\","
" \"cache-enable\": true,"
" \"cache-zones\": [],"
" \"name\": \"Test name\","
" \"params\": {}"
"}]"
));
list_->configure(elem, true);
const vector<DataSourceStatus> statuses(list_->getStatus());
ASSERT_EQ(2, statuses.size());
EXPECT_EQ("type1", statuses[0].getName());
EXPECT_EQ(MSS_UNUSED, statuses[0].getSegmentState());
EXPECT_EQ("Test name", statuses[1].getName());
EXPECT_EQ(MSS_LOCAL, statuses[1].getSegmentState());
}
TEST_F(ListTest, wrongConfig) {
const char* configs[] = {
// A lot of stuff missing from there
......
Supports Markdown
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