18 #include <boost/pointer_cast.hpp> 29 CmdHttpListener::CmdHttpListener(
const IOAddress& address,
const uint16_t port,
30 const uint16_t thread_pool_size ,
32 : address_(address), port_(port), thread_io_service_(), http_listener_(),
33 thread_pool_size_(thread_pool_size), thread_pool_(),
34 tls_context_(context) {
44 if (!MultiThreadingMgr::instance().getMode()) {
46 " when multi-threading is disabled");
56 thread_io_service_.reset(
new IOService());
65 http_listener_.reset(
new HttpListener(*thread_io_service_, address_,
66 port_, tls_context_, rcf,
72 http_listener_->start();
79 .arg(thread_pool_size_)
82 .arg(tls_context_ ?
"true" :
"false");
83 }
catch (
const std::exception& ex) {
91 thread_pool_->checkPausePermissions();
98 thread_pool_->pause();
112 if (!thread_io_service_) {
121 thread_pool_->stop();
124 http_listener_.reset();
127 thread_io_service_.reset();
137 return (thread_pool_->isRunning());
146 return (thread_pool_->isStopped());
155 return (thread_pool_->isPaused());
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
bool isStopped()
Indicates if the thread pool is stopped.
virtual ~CmdHttpListener()
Destructor.
HTTP response creator factory for an API listener.
const isc::log::MessageID COMMAND_HTTP_LISTENER_STARTED
const isc::log::MessageID COMMAND_HTTP_LISTENER_STOPPED
void stop()
Stops the listener's thread pool.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOService class is a wrapper for the ASIO io_service class.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::log::Logger command_logger("commands")
Command processing Logger.
A generic exception that is thrown when an unexpected error condition occurs.
bool isPaused()
Indicates if the thread pool is paused.
const isc::log::MessageID COMMAND_HTTP_LISTENER_STOPPING
constexpr long TIMEOUT_AGENT_RECEIVE_COMMAND
Timeout for the Control Agent to receive command over the RESTful interface.
Defines the logger used by the top-level component of kea-lfc.
bool isRunning()
Indicates if the thread pool is running.
A generic exception that is thrown if a function is called in a prohibited way.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
void checkPermissions()
Check if the current thread can perform thread pool state transition.
constexpr long TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT
Timeout for the idle connection to be closed.
The IOAddress class represents an IP addresses (version agnostic)
void start()
Starts running the listener's thread pool.
void resume()
Resumes running the listener's thread pool.
void pause()
Pauses the listener's thread pool.
HTTP request timeout value.
Implements a pausable pool of IOService driven threads.