#include <dhcp4/json_config_parser.h>
#include <dhcp4/parser_context.h>
#include <dhcpsrv/cfg_db_access.h>
+#include <dhcpsrv/cfg_multi_threading.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/db_type.h>
#include <hooks/hooks.h>
// Configure multi threading
try {
- data::ConstElementPtr mt;
- // command line parameters overwrite file and database configuration
- bool enabled = false;
- uint32_t thread_pool_size = 0;
- uint32_t thread_queue_size = 0;
- if (Dhcpv4Srv::srv_thread_count_ >= 0) {
- enabled = true;
- }
- if (enabled) {
- thread_pool_size = Dhcpv4Srv::srv_thread_count_;
+ CfgMultiThreading::apply(Dhcpv4Srv::srv_thread_count_,
+ CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
+ if (MultiThreadingMgr::instance().getMode()) {
LOG_FATAL(dhcp4_logger, DHCP4_MULTI_THREADING_WARNING);
- } else {
- enabled = false; // todo parse
- thread_pool_size = 0; // todo parse
- thread_queue_size = 0; // todo parse
}
- MultiThreadingMgr::instance().apply(enabled, thread_pool_size,
- thread_queue_size);
} catch (const std::exception& ex) {
err << "Error applying multi threading settings: "
<< ex.what();
#include <dhcp6/json_config_parser.h>
#include <dhcp6/parser_context.h>
#include <dhcpsrv/cfg_db_access.h>
+#include <dhcpsrv/cfg_multi_threading.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/db_type.h>
#include <hooks/hooks.h>
// Configure multi threading
try {
- data::ConstElementPtr mt;
- // command line parameters overwrite file and database configuration
- bool enabled = false;
- uint32_t thread_pool_size = 0;
- uint32_t thread_queue_size = 0;
- if (Dhcpv6Srv::srv_thread_count_ >= 0) {
- enabled = true;
- }
- if (enabled) {
- thread_pool_size = Dhcpv6Srv::srv_thread_count_;
+ CfgMultiThreading::apply(Dhcpv6Srv::srv_thread_count_,
+ CfgMgr::instance().getStagingCfg()->getDHCPMultiThreading());
+ if (MultiThreadingMgr::instance().getMode()) {
LOG_FATAL(dhcp6_logger, DHCP6_MULTI_THREADING_WARNING);
- } else {
- enabled = false; // todo parse
- thread_pool_size = 0; // todo parse
- thread_queue_size = 0; // todo parse
}
- MultiThreadingMgr::instance().apply(enabled, thread_pool_size,
- thread_queue_size);
} catch (const std::exception& ex) {
err << "Error applying multi threading settings: "
<< ex.what();
libkea_dhcpsrv_la_SOURCES += cfg_subnets4.cc cfg_subnets4.h
libkea_dhcpsrv_la_SOURCES += cfg_subnets6.cc cfg_subnets6.h
libkea_dhcpsrv_la_SOURCES += cfg_mac_source.cc cfg_mac_source.h
+libkea_dhcpsrv_la_SOURCES += cfg_multi_threading.cc cfg_multi_threading.h
libkea_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
libkea_dhcpsrv_la_SOURCES += client_class_def.cc client_class_def.h
libkea_dhcpsrv_la_SOURCES += config_backend_dhcp4.h
cfg_hosts_util.h \
cfg_iface.h \
cfg_mac_source.h \
+ cfg_multi_threading.h \
cfg_option.h \
cfg_option_def.h \
cfg_rsoo.h \
--- /dev/null
+// Copyright (C) 2020 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
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <cc/data.h>
+#include <cc/simple_parser.h>
+#include <cfg_multi_threading.h>
+#include <util/multi_threading_mgr.h>
+
+using namespace isc::data;
+using namespace isc::util;
+
+namespace isc {
+namespace dhcp {
+
+void
+CfgMultiThreading::apply(int32_t overwrite, ConstElementPtr value) {
+ // command line parameters overwrite file and database configuration
+ bool enabled = false;
+ uint32_t thread_pool_size = 0;
+ uint32_t thread_queue_size = 0;
+ if (overwrite >= 0) {
+ enabled = true;
+ }
+ if (enabled) {
+ thread_pool_size = overwrite;
+ } else {
+ if (value->get("enable-multi-threading")) {
+ enabled = SimpleParser::getBoolean(value, "enable-multi-threading");
+ }
+ if (value->get("thread-pool-size")) {
+ thread_pool_size = SimpleParser::getInteger(value, "thread-pool-size");
+ }
+ if (value->get("packet-queue-size")) {
+ thread_queue_size = SimpleParser::getInteger(value, "packet-queue-size");
+ }
+ }
+ MultiThreadingMgr::instance().apply(enabled, thread_pool_size,
+ thread_queue_size);
+ }
+
+} // namespace dhcp
+} // namespace isc
--- /dev/null
+// Copyright (C) 2020 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
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef CFG_MULTI_THREADING_H
+#define CFG_MULTI_THREADING_H
+
+#include <cc/data.h>
+
+namespace isc {
+namespace dhcp {
+
+/// @brief Utility class to apply multi threading configurations
+class CfgMultiThreading {
+public:
+
+ /// @brief apply multi threading configuration
+ ///
+ /// @param overwrite The value used to overwrite configuration
+ /// @param value The multi-threading configuration
+ static void apply(int32_t overwrite, data::ConstElementPtr value);
+};
+
+} // namespace dhcp
+} // namespace isc
+
+#endif // CFG_MULTI_THREADING_H