17 #include <boost/pointer_cast.hpp>
29 CtrlAgentProcess::CtrlAgentProcess(
const char* name,
59 garbageCollectListeners(1);
63 garbageCollectListeners(0);
65 }
catch (
const std::exception& ex) {
73 "Process run method failed: " << ex.
what());
82 }
catch (
const std::exception&) {
90 CtrlAgentProcess::runIO() {
131 server_address =
IOAddress(ctx->getHttpHost());
135 <<
" to IP address:" << e.
what());
138 uint16_t server_port = ctx->getHttpPort();
139 bool use_https =
false;
142 if (http_listeners_.empty() ||
143 (http_listeners_.back()->getLocalAddress() != server_address) ||
144 (http_listeners_.back()->getLocalPort() != server_port)) {
148 if (!ctx->getCertFile().empty()) {
149 TlsContext::configure(tls_context,
151 ctx->getTrustAnchor(),
154 ctx->getCertRequired());
167 server_port, tls_context, rcf,
173 http_listener->start();
178 http_listeners_.push_back(http_listener);
184 .arg(server_address.
toText()).arg(server_port);
187 .arg(server_address.
toText()).arg(server_port);
197 CtrlAgentProcess::garbageCollectListeners(
size_t leaving) {
201 if (http_listeners_.size() > leaving) {
203 for (
auto l = http_listeners_.begin();
204 l != http_listeners_.end() - leaving;
212 http_listeners_.erase(http_listeners_.begin(),
213 http_listeners_.end() - leaving);
220 return (boost::dynamic_pointer_cast<CtrlAgentCfgMgr>(
getCfgMgr()));
227 http_listeners_.back());
const isc::log::MessageID CTRL_AGENT_STARTED
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
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)
boost::shared_ptr< DCfgMgrBase > DCfgMgrBasePtr
Defines a shared pointer to DCfgMgrBase.
boost::shared_ptr< const HttpListener > ConstHttpListenerPtr
Pointer to the const HttpListener.
static process::DControllerBasePtr & instance()
Static singleton instance method.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
virtual isc::data::ConstElementPtr shutdown(isc::data::ConstElementPtr args)
Initiates the process's shutdown process.
boost::shared_ptr< CtrlAgentCfgMgr > CtrlAgentCfgMgrPtr
Defines a shared pointer to CtrlAgentCfgMgr.
virtual void run()
Implements the process's event loop.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
isc::log::Logger agent_logger("ctrl-agent")
Control Agent logger.
bool isListening() const
Checks if the process is listening to the HTTP requests.
HTTP response creator factory for Control Agent.
bool shouldShutdown() const
Checks if the process has been instructed to shut down.
const isc::log::MessageID CTRL_AGENT_FAILED
const isc::log::MessageID CTRL_AGENT_HTTPS_SERVICE_STARTED
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void registerCommands()
Register commands.
DCfgMgrBasePtr & getCfgMgr()
Fetches the process's configuration manager.
void deregisterCommands()
Deregister commands.
A generic exception that is thrown when an unexpected error condition occurs.
CtrlAgentCfgMgrPtr getCtrlAgentCfgMgr()
Returns a pointer to the configuration manager.
Process Controller for Control Agent Process.
boost::shared_ptr< const Element > ConstElementPtr
constexpr long TIMEOUT_AGENT_RECEIVE_COMMAND
Timeout for the Control Agent to receive command over the RESTful interface.
const isc::log::MessageID CTRL_AGENT_RUN_EXIT
virtual isc::data::ConstElementPtr configure(isc::data::ConstElementPtr config_set, bool check_only=false)
Processes the given configuration.
void stopIOService()
Convenience method for stopping IOservice processing.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
http::ConstHttpListenerPtr getHttpListener() const
Returns a const pointer to the HTTP listener used by the process.
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
Defines the logger used by the top-level component of kea-dhcp-ddns.
const isc::log::MessageID CTRL_AGENT_HTTP_SERVICE_STARTED
This file contains several functions and constants that are used for handling commands and responses ...
asiolink::IOServicePtr & getIoService()
Fetches the controller's IOService.
Ctrl Agent Configuration Manager.
Exception thrown if the process encountered an operational error.
virtual ~CtrlAgentProcess()
Destructor.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
std::string toText() const
Convert the address to a string.
An exception that is thrown if an error occurs within the IO module.
boost::shared_ptr< CtrlAgentController > CtrlAgentControllerPtr
Application Process Interface.
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
virtual void init()
Initialize the Control Agent process.
boost::shared_ptr< CtrlAgentCfgContext > CtrlAgentCfgContextPtr
Pointer to a configuration context.
constexpr long TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT
Timeout for the idle connection to be closed.
The IOAddress class represents an IP addresses (version agnostic)
Control Agent Configuration Context.
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...
HTTP request timeout value.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.