Commit ed2aceb0 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2204] removed server function/template param from configureDataSourceGeneric.

This is pure cleanup.  This function already doesn't use the server.
parent b15be749
...@@ -126,7 +126,6 @@ public: ...@@ -126,7 +126,6 @@ public:
QueryBenchMark(queries, query_message, buffer) QueryBenchMark(queries, query_message, buffer)
{ {
configureDataSource( configureDataSource(
*server_,
Element::fromJSON("{\"IN\":" Element::fromJSON("{\"IN\":"
" [{\"type\": \"sqlite3\"," " [{\"type\": \"sqlite3\","
" \"params\": {" " \"params\": {"
...@@ -145,7 +144,6 @@ public: ...@@ -145,7 +144,6 @@ public:
QueryBenchMark(queries, query_message, buffer) QueryBenchMark(queries, query_message, buffer)
{ {
configureDataSource( configureDataSource(
*server_,
Element::fromJSON("{\"IN\":" Element::fromJSON("{\"IN\":"
" [{\"type\": \"MasterFiles\"," " [{\"type\": \"MasterFiles\","
" \"cache-enable\": true, " " \"cache-enable\": true, "
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
// This is a trivial specialization for the commonly used version. // This is a trivial specialization for the commonly used version.
// Defined in .cc to avoid accidental creation of multiple copies. // Defined in .cc to avoid accidental creation of multiple copies.
AuthSrv::DataSrcClientListsPtr AuthSrv::DataSrcClientListsPtr
configureDataSource(AuthSrv& server, const isc::data::ConstElementPtr& config) configureDataSource(const isc::data::ConstElementPtr& config) {
{ return (configureDataSourceGeneric<
return (configureDataSourceGeneric<AuthSrv, isc::datasrc::ConfigurableClientList>(config));
isc::datasrc::ConfigurableClientList>(server, config));
} }
...@@ -25,25 +25,23 @@ ...@@ -25,25 +25,23 @@
#include <utility> #include <utility>
#include <set> #include <set>
/// \brief Configure the authoritative server's data source lists /// \brief Configure data source client lists
/// ///
/// This will hook into the data_sources module configuration and it will /// This will hook into the data_sources module configuration and it return
/// keep the local copy of data source clients in the list in the authoritative /// a new set (in the form of a shared pointer to map) of data source client
/// server. /// lists corresponding to the configuration.
/// ///
/// This function is templated. This is simply because of easier testing. /// This function is templated. This is simply because of easier testing.
/// You don't need to pay attention to it, use the configureDataSource /// You don't need to pay attention to it, use the configureDataSource
/// specialization instead. /// specialization instead.
/// ///
/// \param server It is the server to configure.
/// \param config The configuration value to parse. It is in the form /// \param config The configuration value to parse. It is in the form
/// as an update from the config manager. /// as an update from the config manager.
template<class Server, class List> /// \return A map from RR classes to configured lists.
template<class List>
boost::shared_ptr<std::map<isc::dns::RRClass, boost::shared_ptr<std::map<isc::dns::RRClass,
boost::shared_ptr<List> > > // = ListMap below boost::shared_ptr<List> > > // = ListMap below
configureDataSourceGeneric(Server& /*server*/, configureDataSourceGeneric(const isc::data::ConstElementPtr& config) {
const isc::data::ConstElementPtr& config)
{
typedef boost::shared_ptr<List> ListPtr; typedef boost::shared_ptr<List> ListPtr;
typedef std::map<std::string, isc::data::ConstElementPtr> Map; typedef std::map<std::string, isc::data::ConstElementPtr> Map;
typedef std::map<isc::dns::RRClass, ListPtr> ListMap; typedef std::map<isc::dns::RRClass, ListPtr> ListMap;
...@@ -68,7 +66,7 @@ configureDataSourceGeneric(Server& /*server*/, ...@@ -68,7 +66,7 @@ configureDataSourceGeneric(Server& /*server*/,
/// \brief Concrete version of configureDataSource() for the /// \brief Concrete version of configureDataSource() for the
/// use with authoritative server implementation. /// use with authoritative server implementation.
AuthSrv::DataSrcClientListsPtr AuthSrv::DataSrcClientListsPtr
configureDataSource(AuthSrv& server, const isc::data::ConstElementPtr& config); configureDataSource(const isc::data::ConstElementPtr& config);
#endif // DATASRC_CONFIG_H #endif // DATASRC_CONFIG_H
......
...@@ -103,11 +103,10 @@ datasrcConfigHandler(AuthSrv* server, bool* first_time, ...@@ -103,11 +103,10 @@ datasrcConfigHandler(AuthSrv* server, bool* first_time,
assert(config_session != NULL); assert(config_session != NULL);
*first_time = false; *first_time = false;
lists = configureDataSource( lists = configureDataSource(
*auth_server,
config_session->getRemoteConfigValue("data_sources", config_session->getRemoteConfigValue("data_sources",
"classes")); "classes"));
} else { } else {
lists = configureDataSource(*server, config->get("classes")); lists = configureDataSource(config->get("classes"));
} }
// Replace the server's lists. By ignoring the return value we let the // Replace the server's lists. By ignoring the return value we let the
......
...@@ -740,7 +740,7 @@ updateDatabase(AuthSrv& server, const char* params) { ...@@ -740,7 +740,7 @@ updateDatabase(AuthSrv& server, const char* params) {
" \"type\": \"sqlite3\"," " \"type\": \"sqlite3\","
" \"params\": " + string(params) + " \"params\": " + string(params) +
"}]}")); "}]}"));
installDataSrcClientLists(server, configureDataSource(server, config)); installDataSrcClientLists(server, configureDataSource(config));
} }
void void
...@@ -757,7 +757,7 @@ updateInMemory(AuthSrv& server, const char* origin, const char* filename) { ...@@ -757,7 +757,7 @@ updateInMemory(AuthSrv& server, const char* origin, const char* filename) {
" \"type\": \"static\"," " \"type\": \"static\","
" \"params\": \"" + string(STATIC_DSRC_FILE) + "\"" " \"params\": \"" + string(STATIC_DSRC_FILE) + "\""
"}]}")); "}]}"));
installDataSrcClientLists(server, configureDataSource(server, config)); installDataSrcClientLists(server, configureDataSource(config));
} }
void void
...@@ -767,7 +767,7 @@ updateBuiltin(AuthSrv& server) { ...@@ -767,7 +767,7 @@ updateBuiltin(AuthSrv& server) {
" \"type\": \"static\"," " \"type\": \"static\","
" \"params\": \"" + string(STATIC_DSRC_FILE) + "\"" " \"params\": \"" + string(STATIC_DSRC_FILE) + "\""
"}]}")); "}]}"));
installDataSrcClientLists(server, configureDataSource(server, config)); installDataSrcClientLists(server, configureDataSource(config));
} }
// Try giving the server a TSIG signed request and see it can anwer signed as // Try giving the server a TSIG signed request and see it can anwer signed as
...@@ -965,7 +965,7 @@ TEST_F(AuthSrvTest, updateWithInMemoryClient) { ...@@ -965,7 +965,7 @@ TEST_F(AuthSrvTest, updateWithInMemoryClient) {
" \"params\": {}," " \"params\": {},"
" \"cache-enable\": true" " \"cache-enable\": true"
"}]}")); "}]}"));
installDataSrcClientLists(server, configureDataSource(server, config)); installDataSrcClientLists(server, configureDataSource(config));
// after successful configuration, we should have one (with empty zoneset). // after successful configuration, we should have one (with empty zoneset).
// The memory data source is empty, should return REFUSED rcode. // The memory data source is empty, should return REFUSED rcode.
......
...@@ -218,7 +218,7 @@ configureZones(AuthSrv& server) { ...@@ -218,7 +218,7 @@ configureZones(AuthSrv& server) {
" \"cache-enable\": true" " \"cache-enable\": true"
"}]}")); "}]}"));
installDataSrcClientLists(server, configureDataSource(server, config)); installDataSrcClientLists(server, configureDataSource(config));
zoneChecks(server); zoneChecks(server);
} }
...@@ -281,7 +281,7 @@ TEST_F(AuthCommandTest, ...@@ -281,7 +281,7 @@ TEST_F(AuthCommandTest,
" \"cache-enable\": true," " \"cache-enable\": true,"
" \"cache-zones\": [\"example.org\"]" " \"cache-zones\": [\"example.org\"]"
"}]}")); "}]}"));
installDataSrcClientLists(server_, configureDataSource(server_, config)); installDataSrcClientLists(server_, configureDataSource(config));
{ {
isc::util::thread::Mutex::Locker locker(server_.getClientListMutex()); isc::util::thread::Mutex::Locker locker(server_.getClientListMutex());
...@@ -345,7 +345,7 @@ TEST_F(AuthCommandTest, ...@@ -345,7 +345,7 @@ TEST_F(AuthCommandTest,
" \"cache-enable\": true," " \"cache-enable\": true,"
" \"cache-zones\": [\"example.com\"]" " \"cache-zones\": [\"example.com\"]"
"}]}")); "}]}"));
EXPECT_THROW(configureDataSource(server_, config2), EXPECT_THROW(configureDataSource(config2),
ConfigurableClientList::ConfigurationError); ConfigurableClientList::ConfigurationError);
result_ = execAuthServerCommand(server_, "loadzone", result_ = execAuthServerCommand(server_, "loadzone",
......
...@@ -163,10 +163,10 @@ void ...@@ -163,10 +163,10 @@ void
testConfigureDataSource(DatasrcConfigTest& test, testConfigureDataSource(DatasrcConfigTest& test,
const isc::data::ConstElementPtr& config) const isc::data::ConstElementPtr& config)
{ {
// We use the test fixture for the Server type. This makes it possible // We use customized (faked lists) for the List type. This makes it
// to easily fake all needed methods and look that they were called. // possible to easily look that they were called.
shared_ptr<std::map<dns::RRClass, ListPtr> > lists = shared_ptr<std::map<dns::RRClass, ListPtr> > lists =
configureDataSourceGeneric<DatasrcConfigTest, FakeList>(test, config); configureDataSourceGeneric<FakeList>(config);
test.swapDataSrcClientLists(lists); test.swapDataSrcClientLists(lists);
} }
......
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