Kea: cmd_http_listener.h Source File

| Kea 3.0.2-git

cmd_http_listener.h
Go to the documentation of this file.
1// Copyright (C) 2021-2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef CMD_HTTP_LISTENER_H
8#define CMD_HTTP_LISTENER_H
9
10#include <asiolink/io_address.h>
11#include <asiolink/io_service.h>
12#include <asiolink/io_service_thread_pool.h>
13#include <http/listener.h>
14#include <thread>
15#include <vector>
16
17namespace isc {
18namespace config {
19
32 class CmdHttpListener {
33public:
35 CmdHttpListener(const asiolink::IOAddress& address, const uint16_t port,
36 const uint16_t thread_pool_size = 1,
37 asiolink::TlsContextPtr context = asiolink::TlsContextPtr());
38
40 virtual ~CmdHttpListener();
41
47 void checkPermissions();
48
50 void start();
51
55 void pause();
56
60 void resume();
61
63 void stop();
64
69 bool isRunning();
70
75 bool isStopped();
76
81 bool isPaused();
82
86 isc::asiolink::IOAddress getAddress() const {
87 return (address_);
88 }
89
93 uint16_t getPort() const {
94 return (port_);
95 }
96
100 uint16_t getThreadPoolSize() const {
101 return (thread_pool_size_);
102 }
103
107 asiolink::TlsContextPtr getTlsContext() const {
108 return (tls_context_);
109 }
110
114 uint16_t getThreadCount() const {
115 if (!thread_pool_) {
116 return (0);
117 }
118
119 return (thread_pool_->getThreadCount());
120 }
121
127 asiolink::IOServicePtr getThreadIOService() const {
128 return (thread_io_service_);
129 }
130
131private:
133 isc::asiolink::IOAddress address_;
134
136 uint16_t port_;
137
139 isc::asiolink::IOServicePtr thread_io_service_;
140
142 http::HttpListenerPtr http_listener_;
143
145 std::size_t thread_pool_size_;
146
148 asiolink::IoServiceThreadPoolPtr thread_pool_;
149
151 asiolink::TlsContextPtr tls_context_;
152};
153
155 typedef boost::shared_ptr<CmdHttpListener> CmdHttpListenerPtr;
156
157} // namespace isc::config
158} // namespace isc
159
160#endif // CMD_HTTP_LISTENER_H
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:45
isc::config::CmdHttpListener::getThreadCount
uint16_t getThreadCount() const
Fetches the number of threads in the pool.
Definition cmd_http_listener.h:114
isc::config::CmdHttpListener::getThreadPoolSize
uint16_t getThreadPoolSize() const
Fetches the maximum size of the thread pool.
Definition cmd_http_listener.h:100
isc::config::CmdHttpListener::getPort
uint16_t getPort() const
Fetches the port number on which to listen.
Definition cmd_http_listener.h:93
isc::config::CmdHttpListener::checkPermissions
void checkPermissions()
Check if the current thread can perform thread pool state transition.
Definition cmd_http_listener.cc:116
isc::config::CmdHttpListener::getAddress
isc::asiolink::IOAddress getAddress() const
Fetches the IP address on which to listen.
Definition cmd_http_listener.h:86
isc::config::CmdHttpListener::start
void start()
Starts running the listener's thread pool.
Definition cmd_http_listener.cc:42
isc::config::CmdHttpListener::~CmdHttpListener
virtual ~CmdHttpListener()
Destructor.
Definition cmd_http_listener.cc:37
isc::config::CmdHttpListener::getTlsContext
asiolink::TlsContextPtr getTlsContext() const
Fetches the TLS context.
Definition cmd_http_listener.h:107
isc::config::CmdHttpListener::isPaused
bool isPaused()
Indicates if the thread pool is paused.
Definition cmd_http_listener.cc:189
isc::config::CmdHttpListener::CmdHttpListener
CmdHttpListener(const asiolink::IOAddress &address, const uint16_t port, const uint16_t thread_pool_size=1, asiolink::TlsContextPtr context=asiolink::TlsContextPtr())
Constructor.
Definition cmd_http_listener.cc:29
isc::config::CmdHttpListener::getThreadIOService
asiolink::IOServicePtr getThreadIOService() const
Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode.
Definition cmd_http_listener.h:127
isc::config::CmdHttpListener::pause
void pause()
Pauses the listener's thread pool.
Definition cmd_http_listener.cc:123
isc::config::CmdHttpListener::resume
void resume()
Resumes running the listener's thread pool.
Definition cmd_http_listener.cc:130
isc::config::CmdHttpListener::isRunning
bool isRunning()
Indicates if the thread pool is running.
Definition cmd_http_listener.cc:171
isc::config::CmdHttpListener::stop
void stop()
Stops the listener's thread pool.
Definition cmd_http_listener.cc:137
isc::config::CmdHttpListener::isStopped
bool isStopped()
Indicates if the thread pool is stopped.
Definition cmd_http_listener.cc:180
io_address.h
io_service.h
io_service_thread_pool.h
listener.h
isc::asiolink::TlsContextPtr
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
Definition common_tls.h:37
isc::asiolink::IoServiceThreadPoolPtr
boost::shared_ptr< IoServiceThreadPool > IoServiceThreadPoolPtr
Defines a pointer to a thread pool.
Definition io_service_thread_pool.h:260
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:28
isc::config
Definition command_interpreter.cc:23
isc::config::CmdHttpListenerPtr
boost::shared_ptr< CmdHttpListener > CmdHttpListenerPtr
Defines a shared pointer to CmdHttpListener.
Definition cmd_http_listener.h:155
isc::http::HttpListenerPtr
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition listener.h:156
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148