]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5484] Changes after review:
authorTomek Mrugalski <tomasz@isc.org>
Wed, 14 Mar 2018 00:46:45 +0000 (00:46 +0000)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 14 Mar 2018 00:46:45 +0000 (00:46 +0000)
- unit-test improvements
- examples changes to tcp-keepalive 1200 seconds

doc/examples/kea4/cassandra.json
doc/examples/kea6/cassandra.json
doc/guide/dhcp4-srv.xml
doc/guide/install.xml
src/lib/dhcpsrv/parsers/dbaccess_parser.cc
src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc
src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc

index a827c9f63ee6d023efa3d1bc35a2e0d4653d8b75..e26c79a352ec0c1e3feb429a44dc33b6a360de82 100644 (file)
@@ -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.
index 617c713b89c745378b36207daed38d50976446dc..27331059135c123afd06b01a07218d1dbd2a0947 100644 (file)
@@ -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.
index ce3dc318a73c9582839e6b56a3e9fb27b04593d7..63147ff7ade7c6a8304b345309e01e7822ac4c9f 100644 (file)
@@ -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>,
         ...
     },
index 2eebb3cb948bb7c1b6654a632c073a368f123c05..ff384fdf76a7dadd45106c716428fde15f5a49a6 100644 (file)
@@ -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
index cb4b0f3b75ae4114d242ec7f7082454a32b5c640..b1dcfc8d4611ce424b63bc57a7b2e730c377e963 100644 (file)
@@ -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() << ")");
     }
 
index a3c1c0cd4c52b72c3eed118fc6643ad1bade53b7..17bac48b8c4f3539ece18614b072c69a6ef23742 100644 (file)
@@ -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();
index 3d6bf79fb82e97023802ec3a3985c66eb4320aa6..58be7a15ad4184b91a0390d35160e2efd9cbc8e5 100644 (file)
@@ -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();