Commit cb2d8080 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[5484] Changes after review:

- unit-test improvements
- examples changes to tcp-keepalive 1200 seconds
parent 3b5414bc
......@@ -40,8 +40,9 @@
"request-timeout": 12000,
// This parameter governs the TCP keep-alive mechanism. Expressed
// in seconds of delay. The default is disabled.
"tcp-keepalive": 1,
// in seconds of delay. The default is disabled. In this example
// it is set to 20 minutes.
"tcp-keepalive": 1200,
// This parameter enables/disables Nagle's algorithm on connections.
// The default is true.
......
......@@ -39,8 +39,9 @@
"request-timeout": 12000,
// This parameter governs the TCP keep-alive mechanism. Expressed
// in seconds of delay. The default is disabled.
"tcp-keepalive": 1,
// in seconds of delay. The default is disabled. In this example it is
// set to 20 minutes.
"tcp-keepalive": 1200,
// This parameter enables/disables Nagle's algorithm on connections.
// The default is true.
......
......@@ -503,6 +503,7 @@ If a timeout is given though, it should be an integer greater than zero.
<screen>
"Dhcp4": {
"lease-database": {
"type": "cql",
<userinput>"contact-points": "<replaceable>ip-address1, ip-address2 [,...]</replaceable>"</userinput>,
...
},
......
......@@ -612,9 +612,7 @@ $ <userinput>make</userinput>
cql_config_define.sh.sample available, you may copy it over to
cql_config_defines.sh and edit path specified in it) and change the
environment variable CPP_DRIVER_PATH to point to the directory, where
cpp-driver sources are located. (If the cpp-driver sources already
provide cql_config script please use that rather than the version from
Kea sources.)
cpp-driver sources are located.
</para>
<para>
Build and install Kea as described in <xref linkend="installation"/>, with
......
......@@ -58,7 +58,9 @@ DbAccessParser::parse(CfgDbAccessPtr& cfg_db,
int64_t port = 0;
int64_t max_reconnect_tries = 0;
int64_t reconnect_wait_time = 0;
int64_t request_timeout = 0;
int64_t tcp_keepalive = 0;
// 2. Update the copy with the passed keywords.
BOOST_FOREACH(ConfigPair param, database_config->mapValue()) {
try {
......@@ -88,14 +90,14 @@ DbAccessParser::parse(CfgDbAccessPtr& cfg_db,
boost::lexical_cast<std::string>(reconnect_wait_time);
} else if (param.first == "request-timeout") {
timeout = param.second->intValue();
request_timeout = param.second->intValue();
values_copy[param.first] =
boost::lexical_cast<std::string>(timeout);
boost::lexical_cast<std::string>(request_timeout);
} else if (param.first == "tcp-keepalive") {
timeout = param.second->intValue();
tcp_keepalive = param.second->intValue();
values_copy[param.first] =
boost::lexical_cast<std::string>(timeout);
boost::lexical_cast<std::string>(tcp_keepalive);
} else if (param.first == "port") {
port = param.second->intValue();
......@@ -171,15 +173,33 @@ DbAccessParser::parse(CfgDbAccessPtr& cfg_db,
// Check that the max-reconnect-retries reasonable.
if (max_reconnect_tries < 0) {
ConstElementPtr value = database_config->get("max-reconnect-tries");
isc_throw(DhcpConfigError, "max-reconnect-tries cannot be less than zero: "
isc_throw(DhcpConfigError, "max-reconnect-tries cannot be less than zero: "
<< " (" << value->getPosition() << ")");
}
// Check that the reconnect-wait-time reasonable.
if ((reconnect_wait_time < 0) ||
(port > std::numeric_limits<uint16_t>::max())) {
(reconnect_wait_time > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DhcpConfigError, "reconnect-wait-time " << reconnect_wait_time
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
}
// Check that request_timeout value makes sense.
if ((reconnect_wait_time < 0) ||
(reconnect_wait_time > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DhcpConfigError, "reconnect-wait-time " << reconnect_wait_time
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
}
// Check that tcp_keepalive value makes sense.
if ((tcp_keepalive < 0) ||
(tcp_keepalive > std::numeric_limits<uint32_t>::max())) {
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DhcpConfigError, "reconnect-wait-time cannot be less than zero: "
isc_throw(DhcpConfigError, "tcp-keepalive " << tcp_keepalive
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
}
......
......@@ -202,8 +202,10 @@ TEST(CqlHostDataSource, OpenDatabase) {
// Check that lease manager open the database opens correctly with a longer
// timeout. If it fails, print the error message.
try {
// CQL specifies the timeout values in ms, not seconds. Therefore
// we need to add extra 000 to the "connect-timeout=10" string.
string connection_string = validCqlConnectionString() + string(" ") +
string(VALID_TIMEOUT);
string(VALID_TIMEOUT) + string("000");
HostDataSourceFactory::create(connection_string);
EXPECT_NO_THROW((void) HostDataSourceFactory::getHostDataSourcePtr());
HostDataSourceFactory::destroy();
......
......@@ -358,8 +358,10 @@ TEST(CqlOpenTest, OpenDatabase) {
// Check that lease manager open the database opens correctly with a longer
// timeout. If it fails, print the error message.
try {
// CQL specifies the timeout values in ms, not seconds. Therefore
// we need to add extra 000 to the "connect-timeout=10" string.
string connection_string = validCqlConnectionString() + string(" ") +
string(VALID_TIMEOUT);
string(VALID_TIMEOUT) + "000";
LeaseMgrFactory::create(connection_string);
EXPECT_NO_THROW((void) LeaseMgrFactory::instance());
LeaseMgrFactory::destroy();
......
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