 |
Kea
1.5.0
|
Go to the documentation of this file.
17 #include <boost/pointer_cast.hpp>
29 CtrlAgentProcess::CtrlAgentProcess(
const char* name,
49 boost::dynamic_pointer_cast<CtrlAgentController>(
51 controller->registerCommands();
59 garbageCollectListeners();
63 }
catch (
const std::exception& ex) {
71 "Process run method failed: " << ex.
what());
77 boost::dynamic_pointer_cast<CtrlAgentController>(
79 controller->deregisterCommands();
80 }
catch (
const std::exception&) {
88 CtrlAgentProcess::runIO() {
120 ctx = boost::dynamic_pointer_cast<CtrlAgentCfgContext>(base_ctx);
129 server_address =
IOAddress(ctx->getHttpHost());
133 <<
" to IP address:" << e.
what());
136 uint16_t server_port = ctx->getHttpPort();
139 if (http_listeners_.empty() ||
140 (http_listeners_.back()->getLocalAddress() != server_address) ||
141 (http_listeners_.back()->getLocalPort() != server_port)) {
157 http_listener->start();
162 http_listeners_.push_back(http_listener);
167 .arg(server_address.
toText()).arg(server_port);
177 CtrlAgentProcess::garbageCollectListeners() {
181 if (http_listeners_.size() > 1) {
183 for (
auto l = http_listeners_.begin(); l != http_listeners_.end() - 1;
191 http_listeners_.erase(http_listeners_.begin(),
192 http_listeners_.end() - 1);
199 return (boost::dynamic_pointer_cast<CtrlAgentCfgMgr>(
getCfgMgr()));
206 http_listeners_.back());
void stopIOService()
Convenience method for stopping IOservice processing.
asiolink::IOServicePtr & getIoService()
Fetches the controller's IOService.
virtual void run()
Implements the process's event loop.
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
boost::shared_ptr< const HttpListener > ConstHttpListenerPtr
Pointer to the const HttpListener.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
virtual isc::data::ConstElementPtr configure(isc::data::ConstElementPtr config_set, bool check_only=false)
Processes the given configuration.
isc::log::Logger agent_logger("ctrl-agent")
Control Agent logger.
boost::shared_ptr< CtrlAgentCfgMgr > CtrlAgentCfgMgrPtr
Defines a shared pointer to CtrlAgentCfgMgr.
virtual isc::data::ConstElementPtr shutdown(isc::data::ConstElementPtr args)
Initiates the process's shutdown process.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the SrvConfig.
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool isListening() const
Checks if the process is listening to the HTTP requests.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception thrown if the process encountered an operational error.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
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...
virtual ~CtrlAgentProcess()
Destructor.
bool shouldShutdown() const
Checks if the process has been instructed to shut down.
#define LOG_FATAL(LOGGER, MESSAGE)
Macro to conveniently test fatal output and log it.
constexpr long TIMEOUT_AGENT_RECEIVE_COMMAND
Timeout for the Control Agent to receive command over the RESTful interface.
Application Process Interface.
boost::shared_ptr< CtrlAgentController > CtrlAgentControllerPtr
void setShutdownFlag(bool value)
Sets the process shut down flag to the given value.
static process::DControllerBasePtr & instance()
Static singleton instance method.
CtrlAgentCfgMgrPtr getCtrlAgentCfgMgr()
Returns a pointer to the configuration manager.
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
HTTP request timeout value.
std::string toText() const
Convert the address to a string.
boost::shared_ptr< DCfgMgrBase > DCfgMgrBasePtr
Defines a shared pointer to DCfgMgrBase.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
boost::shared_ptr< CtrlAgentCfgContext > CtrlAgentCfgContextPtr
Pointer to a configuration context.
ConstElementPtr parseAnswer(int &rcode, const ConstElementPtr &msg)
HTTP response creator factory for Control Agent.
virtual void init()
Initialize the Control Agent process.
DCfgMgrBasePtr & getCfgMgr()
Fetches the process's configuration manager.
constexpr long TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT
Timeout for the idle connection to be closed.
An exception that is thrown if an error occurs within the IO module.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Ctrl Agent Configuration Manager.
http::ConstHttpListenerPtr getHttpListener() const
Returns a const pointer to the HTTP listener used by the process.