24 struct D2ProcessHooks {
25 int hooks_index_d2_srv_configured_;
47 const unsigned int D2Process::QUEUE_RESTART_PERCENT = 80;
51 reconf_queue_flag_(false), shutdown_type_(SD_NORMAL) {
104 "Primary IO service stopped unexpectedly");
107 }
catch (
const std::exception& ex) {
109 controller->deregisterCommands();
111 "Process run method failed: " << ex.
what());
118 controller->deregisterCommands();
136 boost::asio::io_service& asio_io_service = io->get_io_service();
140 size_t cnt = asio_io_service.poll();
145 cnt = asio_io_service.run_one();
153 bool all_clear =
false;
157 switch (shutdown_type_) {
163 && (update_mgr_->getTransactionCount() == 0));
171 && (queue_mgr_->getQueueSize() == 0)
172 && (update_mgr_->getTransactionCount() == 0));
200 .arg(args ? args->str() :
"(no arguments)");
208 args->contains(
"type")) {
209 type_str = args->get(
"type")->stringValue();
234 .arg(check_only ?
"check" :
"update")
238 answer =
getCfgMgr()->simpleParseConfig(config_set, check_only,
252 reconf_queue_flag_ =
false;
267 reconf_queue_flag_ =
true;
274 if (HooksManager::calloutsPresent(
Hooks.hooks_index_d2_srv_configured_)) {
277 callout_handle->setArgument(
"io_context",
getIoService());
278 callout_handle->setArgument(
"json_config", config_set);
279 callout_handle->setArgument(
"server_config",
282 HooksManager::callCallouts(
Hooks.hooks_index_d2_srv_configured_,
297 switch (queue_mgr_->getMgrState()){
307 .arg(reconf_queue_flag_ ?
"reconfiguration" :
"shutdown");
308 queue_mgr_->stopListening();
322 size_t threshold = (((queue_mgr_->getMaxQueueSize()
324 if (queue_mgr_->getQueueSize() <= threshold) {
326 .arg(threshold).arg(queue_mgr_->getMaxQueueSize());
328 queue_mgr_->startListening();
363 if (reconf_queue_flag_) {
383 reconf_queue_flag_ =
false;
386 queue_mgr_->removeListener();
393 std::string ip_address = d2_params->getIpAddress().toText();
394 if (ip_address !=
"127.0.0.1" && ip_address !=
"::1") {
400 queue_mgr_->initUDPListener(d2_params->getIpAddress(),
401 d2_params->getPort(),
402 d2_params->getNcrFormat(),
true);
414 queue_mgr_->startListening();
431 return (boost::dynamic_pointer_cast<D2CfgMgr>(
getCfgMgr()));
435 const char* str =
"invalid";
461 bool sock_changed = (sock_cfg && current_control_socket_ &&
462 !sock_cfg->equals(*current_control_socket_));
469 if (!sock_cfg || !current_control_socket_ || sock_changed) {
471 if (current_control_socket_) {
473 current_control_socket_.reset();
483 current_control_socket_ = sock_cfg;
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
virtual isc::data::ConstElementPtr shutdown(isc::data::ConstElementPtr args)
Initiates the D2Process shutdown process.
void registerCommands()
Register commands.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
const isc::log::MessageID DHCP_DDNS_SHUTDOWN_COMMAND
void setShutdownFlag(bool value)
Sets the process shut down flag to the given value.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
const isc::log::MessageID DHCP_DDNS_STARTED
boost::shared_ptr< DCfgMgrBase > DCfgMgrBasePtr
Defines a shared pointer to DCfgMgrBase.
D2QueueMgr creates and manages a queue of DNS update requests.
virtual void init()
Called after instantiation to perform initialization unique to D2.
ConstElementPtr redactConfig(ConstElementPtr const &element, list< string > const &json_path)
Redact a configuration.
static const char * getShutdownTypeStr(const ShutdownType &type)
Returns a text label for the given shutdown type.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
D2CfgMgrPtr getD2CfgMgr()
Returns a pointer to the configuration manager.
D2UpdateMgr creates and manages update transactions.
static int registerHook(const std::string &name)
Register Hook.
const isc::log::MessageID DHCP_DDNS_CONFIGURE
const isc::log::MessageID DHCP_DDNS_RUN_EXIT
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_RECOVERING
static process::DControllerBasePtr & instance()
Static singleton instance method.
void reconfigureCommandChannel()
(Re-)Configure the command channel.
virtual void checkQueueStatus()
Monitors current queue manager state, takes action accordingly.
boost::shared_ptr< D2Controller > D2ControllerPtr
Pointer to a process controller.
bool shouldShutdown() const
Checks if the process has been instructed to shut down.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
virtual ~D2Process()
Destructor.
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_RESUME_ERROR
DCfgMgrBasePtr & getCfgMgr()
Fetches the process's configuration manager.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_START_ERROR
void closeCommandSocket()
Shuts down any open control sockets.
const isc::log::MessageID DHCP_DDNS_NOT_ON_LOOPBACK
virtual bool canShutdown() const
Indicates whether or not the process can perform a shutdown.
const isc::log::MessageID DHCP_DDNS_CLEARED_FOR_SHUTDOWN
const isc::log::MessageID DHCP_DDNS_FAILED
virtual void run()
Implements the process's event loop.
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
boost::shared_ptr< const Element > ConstElementPtr
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_STOP_ERROR
void setIOService(const asiolink::IOServicePtr &io_service)
Sets IO service to be used by the command manager.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
ShutdownType
Defines the shutdown types supported by D2Process.
This is a base class for exceptions thrown from the DNS library module.
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
void openCommandSocket(const isc::data::ConstElementPtr &socket_info)
Opens control socket with parameters specified in socket_info.
Defines the logger used by the top-level component of kea-dhcp-ddns.
isc::log::Logger d2_logger("dhcpddns")
Defines the logger used within D2.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
This file contains several functions and constants that are used for handling commands and responses ...
asiolink::IOServicePtr & getIoService()
Fetches the controller's IOService.
Exception thrown if the process encountered an operational error.
virtual void reconfigureQueueMgr()
Initializes then starts the queue manager.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_STOPPING
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_RECONFIGURING
virtual isc::data::ConstElementPtr configure(isc::data::ConstElementPtr config_set, bool check_only=false)
Processes the given configuration.
Application Process Interface.
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
DHCP-DDNS Configuration Manager.
const int DBGLVL_START_SHUT
This is given a value of 0 as that is the level selected if debugging is enabled without giving a lev...
static CommandMgr & instance()
CommandMgr is a singleton class.
Process Controller for D2 Process This class is the DHCP-DDNS specific derivation of DControllerBase...
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_RESUMING
static const unsigned int QUEUE_RESTART_PERCENT
Defines the point at which to resume receiving requests.
virtual size_t runIO()
Allows IO processing to run until at least callback is invoked.