18#include <boost/pointer_cast.hpp>
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,
71 thread_pool_.reset(
new HttpThreadPool(thread_io_service_, thread_pool_size_));
75 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());
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
The IOService class is a wrapper for the ASIO io_service class.
void checkPermissions()
Check if the current thread can perform thread pool state transition.
void start()
Starts running the listener's thread pool.
virtual ~CmdHttpListener()
Destructor.
bool isPaused()
Indicates if the thread pool is paused.
CmdHttpListener(const asiolink::IOAddress &address, const uint16_t port, const uint16_t thread_pool_size=1, asiolink::TlsContextPtr context=asiolink::TlsContextPtr())
Constructor.
void pause()
Pauses the listener's thread pool.
void resume()
Resumes running the listener's thread pool.
bool isRunning()
Indicates if the thread pool is running.
void stop()
Stops the listener's thread pool.
bool isStopped()
Indicates if the thread pool is stopped.
HTTP response creator factory for an API listener.
Implements a pausable pool of IOService driven threads.
#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.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
constexpr long TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT
Timeout for the idle connection to be closed.
const isc::log::MessageID COMMAND_HTTP_LISTENER_STARTED
const isc::log::MessageID COMMAND_HTTP_LISTENER_STOPPED
const isc::log::MessageID COMMAND_HTTP_LISTENER_STOPPING
isc::log::Logger command_logger("commands")
Command processing Logger.
constexpr long TIMEOUT_AGENT_RECEIVE_COMMAND
Timeout for the Control Agent to receive command over the RESTful interface.
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
Defines the logger used by the top-level component of kea-lfc.
HTTP request timeout value.