Kea 2.7.6
d2_queue_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2013-2024 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 D2_QUEUE_MGR_H
8#define D2_QUEUE_MGR_H
9
11
12#include <asiolink/io_service.h>
14#include <dhcp_ddns/ncr_msg.h>
15#include <dhcp_ddns/ncr_io.h>
16
17#include <boost/noncopyable.hpp>
18#include <deque>
19
20namespace isc {
21namespace d2 {
22
25typedef std::deque<dhcp_ddns::NameChangeRequestPtr> RequestQueue;
26
29public:
30 D2QueueMgrError(const char* file, size_t line, const char* what) :
31 isc::Exception(file, line, what) { }
32};
33
38public:
39 D2QueueMgrReceiveError(const char* file, size_t line, const char* what) :
40 isc::Exception(file, line, what) { }
41};
42
46public:
47 D2QueueMgrQueueFull(const char* file, size_t line, const char* what) :
48 isc::Exception(file, line, what) { }
49};
50
53public:
54 D2QueueMgrQueueEmpty(const char* file, size_t line, const char* what) :
55 isc::Exception(file, line, what) { }
56};
57
60public:
61 D2QueueMgrInvalidIndex(const char* file, size_t line, const char* what) :
62 isc::Exception(file, line, what) { }
63};
64
130 boost::noncopyable {
131public:
135 static const size_t MAX_QUEUE_DEFAULT = 1024;
136
147
161 const size_t max_queue_size = MAX_QUEUE_DEFAULT);
162
164 virtual ~D2QueueMgr();
165
177 void initUDPListener(const isc::asiolink::IOAddress& ip_address,
178 const uint32_t port,
179 const dhcp_ddns::NameChangeFormat format,
180 const bool reuse_address = false);
181
189 void startListening();
190
218 virtual void operator()(const dhcp_ddns::NameChangeListener::Result result,
220
233 void stopListening(const State target_stop_state = STOPPED);
234
242 void removeListener();
243
245 size_t getQueueSize() const {
246 return (ncr_queue_.size());
247 };
248
250 size_t getMaxQueueSize() const {
251 return (max_queue_size_);
252 }
253
261 void setMaxQueueSize(const size_t max_queue_size);
262
265 return (mgr_state_);
266 }
267
278
289 const dhcp_ddns::NameChangeRequestPtr& peekAt(const size_t index) const;
290
298 void dequeueAt(const size_t index);
299
303 void dequeue();
304
309
311 void clearQueue();
312
313 private:
318 void updateStopState();
319
321 asiolink::IOServicePtr io_service_;
322
324 size_t max_queue_size_;
325
327 RequestQueue ncr_queue_;
328
330 boost::shared_ptr<dhcp_ddns::NameChangeListener> listener_;
331
333 State mgr_state_;
334
336 State target_stop_state_;
337};
338
340typedef boost::shared_ptr<D2QueueMgr> D2QueueMgrPtr;
341
342} // namespace isc::d2
343} // namespace isc
344
345#endif
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Thrown if the queue manager encounters a general error.
D2QueueMgrError(const char *file, size_t line, const char *what)
Thrown if a queue index is beyond the end of the queue.
D2QueueMgrInvalidIndex(const char *file, size_t line, const char *what)
Thrown if the request queue empty and a read is attempted.
D2QueueMgrQueueEmpty(const char *file, size_t line, const char *what)
Thrown if the request queue is full when an enqueue is attempted.
D2QueueMgrQueueFull(const char *file, size_t line, const char *what)
Thrown if the queue manager's receive handler is passed a failure result.
D2QueueMgrReceiveError(const char *file, size_t line, const char *what)
D2QueueMgr creates and manages a queue of DNS update requests.
const dhcp_ddns::NameChangeRequestPtr & peek() const
Returns the entry at the front of the queue.
D2QueueMgr(asiolink::IOServicePtr &io_service, const size_t max_queue_size=MAX_QUEUE_DEFAULT)
Constructor.
virtual ~D2QueueMgr()
Destructor.
size_t getMaxQueueSize() const
Returns the maximum number of entries allowed in the queue.
State getMgrState() const
Returns the current state.
static const size_t MAX_QUEUE_DEFAULT
Maximum number of entries allowed in the request queue.
void dequeue()
Removes the entry at the front of the queue.
State
Defines the list of possible states for D2QueueMgr.
const dhcp_ddns::NameChangeRequestPtr & peekAt(const size_t index) const
Returns the entry at a given position in the queue.
void removeListener()
Deletes the current listener.
void enqueue(dhcp_ddns::NameChangeRequestPtr &ncr)
Adds a request to the end of the queue.
void startListening()
Starts actively listening for requests.
void setMaxQueueSize(const size_t max_queue_size)
Sets the maximum number of entries allowed in the queue.
size_t getQueueSize() const
Returns the number of entries in the queue.
virtual void operator()(const dhcp_ddns::NameChangeListener::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Function operator implementing the NCR receive callback.
void clearQueue()
Removes all entries from the queue.
void initUDPListener(const isc::asiolink::IOAddress &ip_address, const uint32_t port, const dhcp_ddns::NameChangeFormat format, const bool reuse_address=false)
Initializes the listener as a UDP listener.
void dequeueAt(const size_t index)
Removes the entry at a given position in the queue.
void stopListening(const State target_stop_state=STOPPED)
Stops listening for requests.
Abstract class for defining application layer receive callbacks.
Definition ncr_io.h:183
Result
Defines the outcome of an asynchronous NCR receive.
Definition ncr_io.h:171
Defines a State within the State Model.
Definition state_model.h:61
std::deque< dhcp_ddns::NameChangeRequestPtr > RequestQueue
Defines a queue of requests.
boost::shared_ptr< D2QueueMgr > D2QueueMgrPtr
Defines a pointer for manager instances.
NameChangeFormat
Defines the list of data wire formats supported.
Definition ncr_msg.h:59
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition ncr_msg.h:241
Defines the logger used by the top-level component of kea-lfc.
This file defines abstract classes for exchanging NameChangeRequests.
This file provides the classes needed to embody, compose, and decompose DNS update requests that are ...