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) {
49 " when multi-threading is disabled");
59 thread_io_service_.reset(
new IOService());
68 http_listener_.reset(
new HttpListener(thread_io_service_, address_,
69 port_, tls_context_, rcf,
75 http_listener_->start();
82 .arg(thread_pool_size_)
85 .arg(tls_context_ ?
"true" :
"false");
86 }
catch (
const std::exception& ex) {
94 http_listener_->stop();
97 if (thread_io_service_) {
98 thread_io_service_->stopAndPoll();
99 thread_io_service_->stop();
103 thread_pool_.reset();
106 http_listener_.reset();
109 thread_io_service_.reset();
118 thread_pool_->checkPausePermissions();
125 thread_pool_->pause();
139 if (!thread_io_service_) {
148 thread_pool_->stop();
151 http_listener_->stop();
153 thread_io_service_->stopAndPoll();
154 thread_io_service_->stop();
157 thread_pool_.reset();
160 http_listener_.reset();
163 thread_io_service_.reset();
173 return (thread_pool_->isRunning());
182 return (thread_pool_->isStopped());
191 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.
Implements a pausable pool of IOService driven threads.
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.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
#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.