22 : io_service_(io_service), max_queue_size_(max_queue_size),
23 mgr_state_(NOT_INITTED), target_stop_state_(NOT_INITTED) {
57 .arg(ncr->getRequestId());
65 .arg(max_queue_size_);
95 }
catch (
const std::exception& ex) {
106 const bool reuse_address) {
110 "D2QueueMgr listener is already initialized");
116 shared_from_this(), reuse_address));
125 "listener is not initialized, cannot start listening");
132 "cannot call startListening from the RUNNING state");
137 listener_->startListening(io_service_);
153 if (target_stop_state !=
STOPPED &&
157 "D2QueueMgr invalid value for stop state: "
158 << target_stop_state);
162 target_stop_state_ = target_stop_state;
168 listener_->stopListening();
169 if (listener_->isIoPending()) {
178D2QueueMgr::updateStopState() {
179 mgr_state_ = target_stop_state_;
189 "D2QueueMgr cannot delete listener while state is RUNNING");
200 "D2QueueMgr peek attempted on an empty queue");
203 return (ncr_queue_.front());
210 "D2QueueMgr peek beyond end of queue attempted"
211 <<
" index: " << index <<
" queue size: " <<
getQueueSize());
214 return (ncr_queue_.at(index));
221 "D2QueueMgr dequeue beyond end of queue attempted"
222 <<
" index: " << index <<
" queue size: " <<
getQueueSize());
225 RequestQueue::iterator pos = ncr_queue_.begin() + index;
226 ncr_queue_.erase(pos);
233 "D2QueueMgr dequeue attempted on an empty queue");
236 ncr_queue_.pop_front();
241 ncr_queue_.push_back(ncr);
251 if (new_queue_max < 1) {
253 "D2QueueMgr maximum queue size must be greater than zero");
258 " be less than the current queue size :" <<
getQueueSize());
261 max_queue_size_ = new_queue_max;
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.
The IOAddress class represents an IP addresses (version agnostic)
Thrown if the queue manager encounters a general error.
Thrown if a queue index is beyond the end of the queue.
Thrown if the request queue empty and a read is attempted.
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.
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.
Result
Defines the outcome of an asynchronous NCR receive.
Provides the ability to receive NameChangeRequests via UDP socket.
static StatsMgr & instance()
Statistics Manager accessor method.
This file defines the class D2QueueMgr.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void addValue(const std::string &name, const int64_t value)
Records incremental integer observation.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_RECV_ERROR
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_QUEUE_RECEIVE
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_UNEXPECTED_HANDLER_ERROR
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_UNEXPECTED_STOP
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_STARTED
isc::log::Logger dhcp_to_d2_logger("dhcp-to-d2")
isc::log::Logger d2_logger("dhcpddns")
Defines the logger used within D2.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_QUEUE_FULL
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_STOPPED
NameChangeFormat
Defines the list of data wire formats supported.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
const int DBGLVL_START_SHUT
This is given a value of 0 as that is the level selected if debugging is enabled without giving a lev...
const int DBGLVL_TRACE_DETAIL_DATA
Trace data associated with detailed operations.
Defines the logger used by the top-level component of kea-lfc.
This file provides UDP socket based implementation for sending and receiving NameChangeRequests.