19 : io_service_(io_service), max_queue_size_(max_queue_size),
20 mgr_state_(NOT_INITTED), target_stop_state_(NOT_INITTED) {
54 .arg(ncr->getRequestId());
62 .arg(max_queue_size_);
91 }
catch (
const std::exception& ex) {
102 const bool reuse_address) {
106 "D2QueueMgr listener is already initialized");
111 listener_.reset(
new dhcp_ddns::
112 NameChangeUDPListener(ip_address, port,
format, *
this,
122 "listener is not initialized, cannot start listening");
129 "cannot call startListening from the RUNNING state");
134 listener_->startListening(*io_service_);
150 if (target_stop_state !=
STOPPED &&
154 "D2QueueMgr invalid value for stop state: "
155 << target_stop_state);
159 target_stop_state_ = target_stop_state;
165 listener_->stopListening();
166 if (listener_->isIoPending()) {
175D2QueueMgr::updateStopState() {
176 mgr_state_ = target_stop_state_;
187 "D2QueueMgr cannot delete listener while state is RUNNING");
198 "D2QueueMgr peek attempted on an empty queue");
201 return (ncr_queue_.front());
208 "D2QueueMgr peek beyond end of queue attempted"
209 <<
" index: " << index <<
" queue size: " <<
getQueueSize());
212 return (ncr_queue_.at(index));
219 "D2QueueMgr dequeue beyond end of queue attempted"
220 <<
" index: " << index <<
" queue size: " <<
getQueueSize());
223 RequestQueue::iterator pos = ncr_queue_.begin() + index;
224 ncr_queue_.erase(pos);
232 "D2QueueMgr dequeue attempted on an empty queue");
235 ncr_queue_.pop_front();
240 ncr_queue_.push_back(ncr);
250 if (new_queue_max < 1) {
252 "D2QueueMgr maximum queue size must be greater than zero");
257 " be less than the current queue size :" <<
getQueueSize());
260 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.
This file defines the class D2QueueMgr.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#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.
std::string format(const std::string &format, const std::vector< std::string > &args)
Apply Formatting.
Defines the logger used by the top-level component of kea-lfc.
This file provides UDP socket based implementation for sending and receiving NameChangeRequests.