From: Razvan Becheriu Date: Tue, 18 Aug 2020 18:47:18 +0000 (+0300) Subject: [#1305] addresses comments X-Git-Tag: Kea-1.8.0~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d86ef62b6c3aa3c5c9815a70c3e99dc4f35006de;p=thirdparty%2Fkea.git [#1305] addresses comments --- diff --git a/doc/sphinx/api/status-get.json b/doc/sphinx/api/status-get.json index e2facef985..3a61d75baa 100644 --- a/doc/sphinx/api/status-get.json +++ b/doc/sphinx/api/status-get.json @@ -39,7 +39,10 @@ " }", " }", " }", - " ]", + " ],", + " \"multi-threading-enabled\": true,", + " \"thread-pool-size\": 4,", + " \"packet-queue-size\": 64", " }", "}" ], diff --git a/doc/sphinx/arm/ctrl-channel.rst b/doc/sphinx/arm/ctrl-channel.rst index 35cc66ec63..da0b421566 100644 --- a/doc/sphinx/arm/ctrl-channel.rst +++ b/doc/sphinx/arm/ctrl-channel.rst @@ -580,11 +580,22 @@ The ``status-get`` command returns server's runtime information: * remote: for the remote server the last known state, served HA scopes and the role of the server in HA relationship. -The ``high-availability`` information is only returned when the command is + - multi-threading-enabled: flag indicating if multi-threading is enabled. + + - thread-pool-size: number of dhcp service threads. + + - packet-queue-size: size of the packet queue size. + +The ``high-availability`` information is returned only when the command is sent to the DHCP servers being in the HA setup. This parameter is never returned when the ``status-get`` command is sent to the Control Agent or DDNS deamon. +The ``thread-pool-size`` and ``packet-queue-size`` information is returned only +when the command is send to DHCP servers with multi-threading enabled. This +parameter is never returned when the ``status-get`` command is sent to the +Control Agent or DDNS deamon. + To learn more about the HA status information returned by the ``status-get`` command please refer to the the :ref:`command-ha-status-get` section. diff --git a/doc/sphinx/arm/hooks-ha.rst b/doc/sphinx/arm/hooks-ha.rst index 3de24d56c5..0da4ea04ed 100644 --- a/doc/sphinx/arm/hooks-ha.rst +++ b/doc/sphinx/arm/hooks-ha.rst @@ -1617,7 +1617,10 @@ the HA status of two load balancing servers: } } } - ] + ], + "multi-threading-enabled": true, + "thread-pool-size": 4, + "packet-queue-size": 64 } } diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index f6a06b8a89..c38966d2e7 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -661,10 +661,13 @@ ControlledDhcpv4Srv::commandStatusGetHandler(const string&, } if (MultiThreadingMgr::instance().getMode()) { - status->set("thread-pool-size", Element::create( - long(MultiThreadingMgr::instance().getThreadPoolSize()))); - status->set("packet-queue-size", Element::create( - long(MultiThreadingMgr::instance().getPacketQueueSize()))); + status->set("multi-threading-enabled", Element::create(true)); + status->set("thread-pool-size", Element::create(static_cast( + MultiThreadingMgr::instance().getThreadPoolSize()))); + status->set("packet-queue-size", Element::create(static_cast( + MultiThreadingMgr::instance().getPacketQueueSize()))); + } else { + status->set("multi-threading-enabled", Element::create(false)); } return (createAnswer(0, status)); diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index 22efe381e0..e601e8d309 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -1120,6 +1120,16 @@ TEST_F(CtrlChannelDhcpv4SrvTest, statusGet) { EXPECT_LE(found_reload->intValue(), 5); EXPECT_GE(found_reload->intValue(), 0); + auto found_multi_threading = arguments->get("multi-threading-enabled"); + ASSERT_TRUE(found_multi_threading); + EXPECT_EQ(false, found_multi_threading->boolValue()); + + auto found_thread_count = arguments->get("thread-pool-size"); + ASSERT_FALSE(found_thread_count); + + auto found_queue_size = arguments->get("packet-queue-size"); + ASSERT_FALSE(found_queue_size); + MultiThreadingMgr::instance().setMode(true); MultiThreadingMgr::instance().setThreadPoolSize(4); MultiThreadingMgr::instance().setPacketQueueSize(64); @@ -1153,11 +1163,15 @@ TEST_F(CtrlChannelDhcpv4SrvTest, statusGet) { EXPECT_LE(found_reload->intValue(), 5); EXPECT_GE(found_reload->intValue(), 0); - auto found_thread_count = arguments->get("thread-pool-size"); + found_multi_threading = arguments->get("multi-threading-enabled"); + ASSERT_TRUE(found_multi_threading); + EXPECT_EQ(true, found_multi_threading->boolValue()); + + found_thread_count = arguments->get("thread-pool-size"); ASSERT_TRUE(found_thread_count); EXPECT_EQ(found_thread_count->intValue(), 4); - auto found_queue_size = arguments->get("packet-queue-size"); + found_queue_size = arguments->get("packet-queue-size"); ASSERT_TRUE(found_queue_size); EXPECT_EQ(found_queue_size->intValue(), 64); } diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 7a316363dd..bcb9d3992d 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -664,10 +664,13 @@ ControlledDhcpv6Srv::commandStatusGetHandler(const string&, } if (MultiThreadingMgr::instance().getMode()) { - status->set("thread-pool-size", Element::create( - long(MultiThreadingMgr::instance().getThreadPoolSize()))); - status->set("packet-queue-size", Element::create( - long(MultiThreadingMgr::instance().getPacketQueueSize()))); + status->set("multi-threading-enabled", Element::create(true)); + status->set("thread-pool-size", Element::create(static_cast( + MultiThreadingMgr::instance().getThreadPoolSize()))); + status->set("packet-queue-size", Element::create(static_cast( + MultiThreadingMgr::instance().getPacketQueueSize()))); + } else { + status->set("multi-threading-enabled", Element::create(false)); } return (createAnswer(0, status)); diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index ac6ea65c7c..50d5987c21 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -1010,6 +1010,16 @@ TEST_F(CtrlChannelDhcpv6SrvTest, statusGet) { EXPECT_LE(found_reload->intValue(), 5); EXPECT_GE(found_reload->intValue(), 0); + auto found_multi_threading = arguments->get("multi-threading-enabled"); + ASSERT_TRUE(found_multi_threading); + EXPECT_EQ(false, found_multi_threading->boolValue()); + + auto found_thread_count = arguments->get("thread-pool-size"); + ASSERT_FALSE(found_thread_count); + + auto found_queue_size = arguments->get("packet-queue-size"); + ASSERT_FALSE(found_queue_size); + MultiThreadingMgr::instance().setMode(true); MultiThreadingMgr::instance().setThreadPoolSize(4); MultiThreadingMgr::instance().setPacketQueueSize(64); @@ -1043,11 +1053,15 @@ TEST_F(CtrlChannelDhcpv6SrvTest, statusGet) { EXPECT_LE(found_reload->intValue(), 5); EXPECT_GE(found_reload->intValue(), 0); - auto found_thread_count = arguments->get("thread-pool-size"); + found_multi_threading = arguments->get("multi-threading-enabled"); + ASSERT_TRUE(found_multi_threading); + EXPECT_EQ(true, found_multi_threading->boolValue()); + + found_thread_count = arguments->get("thread-pool-size"); ASSERT_TRUE(found_thread_count); EXPECT_EQ(found_thread_count->intValue(), 4); - auto found_queue_size = arguments->get("packet-queue-size"); + found_queue_size = arguments->get("packet-queue-size"); ASSERT_TRUE(found_queue_size); EXPECT_EQ(found_queue_size->intValue(), 64); }