Kea 1.9.11
cmd_http_listener.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 <http/listener.h>
14#include <thread>
15#include <vector>
16
17namespace isc {
18namespace config {
19
33public:
35 CmdHttpListener(const asiolink::IOAddress& address, const uint16_t port,
36 const uint16_t thread_pool_size = 1);
37
39 virtual ~CmdHttpListener();
40
46 void checkPermissions();
47
49 void start();
50
54 void pause();
55
59 void resume();
60
62 void stop();
63
68 bool isRunning();
69
74 bool isStopped();
75
80 bool isPaused();
81
86 return (address_);
87 }
88
92 uint16_t getPort() const {
93 return (port_);
94 }
95
99 uint16_t getThreadPoolSize() const {
100 return (thread_pool_size_);
101 }
102
106 uint16_t getThreadCount() const {
107 if (!thread_pool_) {
108 return (0);
109 }
110
111 return (thread_pool_->getThreadCount());
112 }
113
120 return (thread_io_service_);
121 }
122
123private:
126
128 uint16_t port_;
129
131 isc::asiolink::IOServicePtr thread_io_service_;
132
134 http::HttpListenerPtr http_listener_;
135
137 std::size_t thread_pool_size_;
138
140 http::HttpThreadPoolPtr thread_pool_;
141};
142
144typedef boost::shared_ptr<CmdHttpListener> CmdHttpListenerPtr;
145
146} // namespace isc::config
147} // namespace isc
148
149#endif // CMD_HTTP_LISTENER_H
A multi-threaded HTTP listener that can process API commands requests.
uint16_t getThreadCount() const
Fetches the number of threads in the pool.
uint16_t getThreadPoolSize() const
Fetches the maximum size of the thread pool.
uint16_t getPort() const
Fetches the port number on which to listen.
void checkPermissions()
Check if the current thread can perform thread pool state transition.
isc::asiolink::IOAddress getAddress() const
Fetches the IP address on which to listen.
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)
Constructor.
asiolink::IOServicePtr getThreadIOService() const
Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode.
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.
boost::shared_ptr< CmdHttpListener > CmdHttpListenerPtr
Defines a shared pointer to CmdHttpListener.
boost::shared_ptr< HttpThreadPool > HttpThreadPoolPtr
Defines a pointer to a thread pool.
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition: listener.h:139
Defines the logger used by the top-level component of kea-lfc.