}
}
+\"config-fetch-wait-time\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser4Context::CONFIG_CONTROL:
+ return isc::dhcp::Dhcp4Parser::make_CONFIG_FETCH_WAIT_TIME(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp4Parser::make_STRING("config-fetch-wait-time", driver.loc_);
+ }
+}
+
\"readonly\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
NULL_TYPE "null"
DHCP4 "Dhcp4"
+
CONFIG_CONTROL "config-control"
CONFIG_DATABASES "config-databases"
+ CONFIG_FETCH_WAIT_TIME "config-fetch-wait-time"
+
INTERFACES_CONFIG "interfaces-config"
INTERFACES "interfaces"
DHCP_SOCKET_TYPE "dhcp-socket-type"
// This defines a list of allowed parameters for each subnet.
config_control_param: config_databases
+ | config_fetch_wait_time
;
config_databases: CONFIG_DATABASES {
ctx.leave();
};
+config_fetch_wait_time: CONFIG_FETCH_WAIT_TIME COLON INTEGER {
+ ElementPtr value(new IntElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("config-fetch-wait-time", value);
+};
+
// --- logging entry -----------------------------------------
// This defines the top level "Logging" object. It parses
" \"rebind-timer\": 2000, \n"
" \"renew-timer\": 1000, \n"
" \"config-control\": { \n"
+ " \"config-fetch-wait-time\": 10, \n"
" \"config-databases\": [ { \n"
" \"type\": \"mysql\", \n"
" \"name\": \"keatest1\", \n"
dblist.front().getAccessString());
EXPECT_EQ("name=keatest2 password=keatest type=mysql user=keatest",
dblist.back().getAccessString());
+
+ // Verify that the config-fetch-wait-time is correct.
+ EXPECT_FALSE(info->getConfigFetchWaitTime().unspecified());
+ EXPECT_EQ(10, info->getConfigFetchWaitTime().get());
}
// Check whether it is possible to configure server-tag
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <process/config_ctl_info.h>
using namespace isc::data;
+using namespace isc::util;
namespace isc {
namespace process {
//********* ConfiControlInfo ************//
-ConfigControlInfo::ConfigControlInfo(const ConfigControlInfo& other) {
+ConfigControlInfo::ConfigControlInfo(const ConfigControlInfo& other)
+ : config_fetch_wait_time_(other.config_fetch_wait_time_) {
for (auto db : other.db_infos_) {
addConfigDatabase(db.getAccessString());
}
void
ConfigControlInfo::clear() {
db_infos_.clear();
+ config_fetch_wait_time_ = Optional<uint16_t>(30, true);
}
void
}
result->set("config-databases", db_list);
+
+ if (!config_fetch_wait_time_.unspecified()) {
+ result->set("config-fetch-wait-time",
+ Element::create(static_cast<int>(config_fetch_wait_time_)));
+ }
+
return(result);
}
bool
ConfigControlInfo::equals(const ConfigControlInfo& other) const {
- return (db_infos_ == other.db_infos_);
+ return ((db_infos_ == other.db_infos_) &&
+ (config_fetch_wait_time_ == other.config_fetch_wait_time_));
}
} // end of namespace isc::process
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <cc/cfg_to_element.h>
#include <database/database_connection.h>
+#include <util/optional.h>
#include <boost/shared_ptr.hpp>
#include <stdint.h>
public:
/// @brief Constructor.
- ConfigControlInfo() {};
+ ConfigControlInfo()
+ : config_fetch_wait_time_(30, true) {};
/// @brief Copy Constructor.
ConfigControlInfo(const ConfigControlInfo& other);
+ /// @brief Sets new value of the config-fetch-wait-time.
+ ///
+ /// @param config_fetch_wait_time New value of the parameter which
+ /// specifies a time period in seconds between the attempts to
+ /// fetch the server configuration updates. The value of 0 disables
+ /// the periodic attempts to fetch the updates.
+ void setConfigFetchWaitTime(const util::Optional<uint16_t>& config_fetch_wait_time) {
+ config_fetch_wait_time_ = config_fetch_wait_time;
+ }
+
+ /// @brief Returns configured config-fetch-wait-time value.
+ ///
+ /// This value specifies the time period in seconds between the
+ /// attempts to fetch the server configuration updates via the
+ /// configuration backends. The value of 0 means that the
+ /// mechanism to periodically fetch the configuration updates
+ /// is disabled.
+ ///
+ /// @return Time period between the subsequent attempts to
+ /// fetch server configuration updates in seconds.
+ const util::Optional<uint16_t>& getConfigFetchWaitTime() const {
+ return (config_fetch_wait_time_);
+ }
+
/// @brief Sets configuration database access string.
///
/// @param access_str database access string.
private:
+ /// @brief Configured value of the config-fetch-wait-time.
+ util::Optional<uint16_t> config_fetch_wait_time_;
+
/// @brief List of configuration databases
ConfigDbInfoList db_infos_;
};
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <cc/dhcp_config_error.h>
#include <process/config_ctl_parser.h>
#include <database/dbaccess_parser.h>
+#include <cstdint>
#include <string>
using namespace isc;
ctl_info->addConfigDatabase(access_string);
}
}
+
+ if (config_control->contains("config-fetch-wait-time")) {
+ auto config_fetch_wait_time = getInteger(config_control,
+ "config-fetch-wait-time",
+ 0, 65535);
+ ctl_info->setConfigFetchWaitTime(static_cast<uint16_t>(config_fetch_wait_time));
+ }
+
} catch (const isc::ConfigError&) {
// Position was already added
throw;
using namespace isc::process;
using namespace isc::data;
+using namespace isc::util;
// Verifies initializing via an access string and unparsing into elements
// We just test basic unparsing, as more rigorous testing is done in
ConfigControlInfo ctl;
// We should have no dbs in the list.
EXPECT_EQ(0, ctl.getConfigDatabases().size());
+ // The default fetch time is 30 and it is unspecified.
+ EXPECT_TRUE(ctl.getConfigFetchWaitTime().unspecified());
+ EXPECT_EQ(30, ctl.getConfigFetchWaitTime().get());
+
+ // Override the default fetch time.
+ ctl.setConfigFetchWaitTime(Optional<uint16_t>(123));
+ EXPECT_EQ(123, ctl.getConfigFetchWaitTime().get());
// We should be able to add two distinct, valid dbs
std::string access_str1 = "type=mysql host=machine1.org";
const ConfigDbInfo& db_info3 = ctl.findConfigDb("type", "bogus");
EXPECT_TRUE(db_info3 == ConfigControlInfo::EMPTY_DB());
- // Verify we can clear the list of dbs.
+ // Verify we can clear the list of dbs and the fetch time.
ctl.clear();
EXPECT_EQ(0, ctl.getConfigDatabases().size());
+ EXPECT_TRUE(ctl.getConfigFetchWaitTime().unspecified());
+ EXPECT_EQ(30, ctl.getConfigFetchWaitTime().get());
}
// Verifies the copy ctor and equality functions ConfigControlInfo
ConfigControlInfo ctl1;
ASSERT_NO_THROW(ctl1.addConfigDatabase("type=mysql host=mach1.org"));
ASSERT_NO_THROW(ctl1.addConfigDatabase("type=postgresql host=mach2.org"));
+ ctl1.setConfigFetchWaitTime(Optional<uint16_t>(123));
// Clone that instance.
ConfigControlInfo ctl2(ctl1);
// They should not equal.
EXPECT_FALSE(ctl3.equals(ctl1));
}
+
-// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
std::string configs[] = {
"{}",
- "{ \"config-databases\": [] }",
+ "{ \"config-databases\": [], \n"
+ " \"config-fetch-wait-time\": 20 \n"
+ "}",
"{ \"config-databases\": [ \n"
" { \n"
" { \n"
" \"bogus\": \"param\" \n"
" } \n"
- "] } \n"
+ "] } \n",
+ "{ \"config-fetch-wait-time\": -1 }",
+ "{ \"config-fetch-wait-time\": 65537 }",
+ "{ \"config-fetch-wait-time\": \"a-string\" }",
};
for (auto config : configs) {