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()) {
175 D2QueueMgr::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;
size_t getMaxQueueSize() const
Returns the maximum number of entries allowed in the queue.
State
Defines the list of possible states for D2QueueMgr.
void dequeue()
Removes the entry at the front of the queue.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
static const size_t MAX_QUEUE_DEFAULT
Maximum number of entries allowed in the request queue.
Thrown if the request queue empty and a read is attempted.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_QUEUE_RECEIVE
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
NameChangeFormat
Defines the list of data wire formats supported.
This file provides UDP socket based implementation for sending and receiving NameChangeRequests.
void dequeueAt(const size_t index)
Removes the entry at a given position in the queue.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
virtual void operator()(const dhcp_ddns::NameChangeListener::Result result, dhcp_ddns::NameChangeRequestPtr &ncr)
Function operator implementing the NCR receive callback.
void startListening()
Starts actively listening for requests.
void stopListening(const State target_stop_state=STOPPED)
Stops listening for requests.
D2QueueMgr(asiolink::IOServicePtr &io_service, const size_t max_queue_size=MAX_QUEUE_DEFAULT)
Constructor.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const dhcp_ddns::NameChangeRequestPtr & peekAt(const size_t index) const
Returns the entry at a given position in the queue.
void clearQueue()
Removes all entries from the queue.
void enqueue(dhcp_ddns::NameChangeRequestPtr &ncr)
Adds a request to the end of the queue.
const int DBGLVL_TRACE_DETAIL_DATA
Trace data associated with detailed operations.
isc::log::Logger dhcp_to_d2_logger("dhcp-to-d2")
size_t getQueueSize() const
Returns the number of entries in the queue.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_UNEXPECTED_STOP
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_UNEXPECTED_HANDLER_ERROR
Thrown if the queue manager encounters a general error.
isc::log::Logger d2_logger("dhcpddns")
Defines the logger used within D2.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_STARTED
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
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.
This file defines the class D2QueueMgr.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_STOPPED
void setMaxQueueSize(const size_t max_queue_size)
Sets the maximum number of entries allowed in the queue.
virtual ~D2QueueMgr()
Destructor.
The IOAddress class represents an IP addresses (version agnostic)
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_RECV_ERROR
const dhcp_ddns::NameChangeRequestPtr & peek() const
Returns the entry at the front of the queue.
void removeListener()
Deletes the current listener.
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...
Thrown if a queue index is beyond the end of the queue.
const isc::log::MessageID DHCP_DDNS_QUEUE_MGR_QUEUE_FULL
Result
Defines the outcome of an asynchronous NCR receive.
std::string format(const std::string &format, const std::vector< std::string > &args)
Apply Formatting.