Kea  1.9.9-git
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>
13 #include <http/http_thread_pool.h>
14 #include <thread>
15 #include <vector>
16 
17 namespace isc {
18 namespace config {
19 
33 public:
35  CmdHttpListener(const asiolink::IOAddress& address, const uint16_t port,
36  const uint16_t thread_pool_size = 1);
37 
39  virtual ~CmdHttpListener();
40 
42  void start();
43 
47  void pause();
48 
52  void resume();
53 
55  void stop();
56 
61  bool isRunning();
62 
67  bool isStopped();
68 
73  bool isPaused();
74 
79  return (address_);
80  }
81 
85  uint16_t getPort() const {
86  return (port_);
87  }
88 
92  uint16_t getThreadPoolSize() const {
93  return (thread_pool_size_);
94  }
95 
99  uint16_t getThreadCount() const {
100  if (!thread_pool_) {
101  return (0);
102  }
103 
104  return (thread_pool_->getThreadCount());
105  }
106 
113  return (thread_io_service_);
114  }
115 
116 private:
118  isc::asiolink::IOAddress address_;
119 
121  uint16_t port_;
122 
124  isc::asiolink::IOServicePtr thread_io_service_;
125 
127  http::HttpListenerPtr http_listener_;
128 
130  std::size_t thread_pool_size_;
131 
133  http::HttpThreadPoolPtr thread_pool_;
134 };
135 
137 typedef boost::shared_ptr<CmdHttpListener> CmdHttpListenerPtr;
138 
139 } // namespace isc::config
140 } // namespace isc
141 
142 #endif // CMD_HTTP_LISTENER_H
bool isStopped()
Indicates if the thread pool is stopped.
virtual ~CmdHttpListener()
Destructor.
boost::shared_ptr< CmdHttpListener > CmdHttpListenerPtr
Defines a shared pointer to CmdHttpListener.
void stop()
Stops the listener's thread pool.
asiolink::IOServicePtr getThreadIOService() const
Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode...
uint16_t getThreadPoolSize() const
Fetches the maximum size of the thread pool.
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.
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool isRunning()
Indicates if the thread pool is running.
A multi-threaded HTTP listener that can process API commands requests.
boost::shared_ptr< HttpThreadPool > HttpThreadPoolPtr
Defines a pointer to a thread pool.
uint16_t getThreadCount() const
Fetches the number of threads in the pool.
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition: listener.h:139
uint16_t getPort() const
Fetches the port number on which to listen.
void start()
Starts running the listener's thread pool.
isc::asiolink::IOAddress getAddress() const
Fetches the IP address on which to listen.
void resume()
Resumes running the listener's thread pool.
void pause()
Pauses the listener's thread pool.