22 : io_service_(io_service), max_queue_size_(max_queue_size),
51 size_t chain_length = 0;
55 tmp = tmp->getNextNcr();
63 .arg(max_queue_size_);
78 .arg(ncr->getRequestId());
84 ncr = ncr->getNextNcr();
115 }
catch (
const std::exception& ex) {
126 const bool reuse_address) {
130 "D2QueueMgr listener is already initialized");
136 shared_from_this(), reuse_address));
145 "listener is not initialized, cannot start listening");
152 "cannot call startListening from the RUNNING state");
157 listener_->startListening(io_service_);
173 if (target_stop_state !=
STOPPED &&
177 "D2QueueMgr invalid value for stop state: "
178 << target_stop_state);
182 target_stop_state_ = target_stop_state;
188 listener_->stopListening();
189 if (listener_->isIoPending()) {
198D2QueueMgr::updateStopState() {
199 mgr_state_ = target_stop_state_;
209 "D2QueueMgr cannot delete listener while state is RUNNING");
220 "D2QueueMgr peek attempted on an empty queue");
223 return (ncr_queue_.front());
230 "D2QueueMgr peek beyond end of queue attempted"
231 <<
" index: " << index <<
" queue size: " <<
getQueueSize());
234 return (ncr_queue_.at(index));
241 "D2QueueMgr dequeue beyond end of queue attempted"
242 <<
" index: " << index <<
" queue size: " <<
getQueueSize());
245 RequestQueue::iterator pos = ncr_queue_.begin() + index;
246 ncr_queue_.erase(pos);
253 "D2QueueMgr dequeue attempted on an empty queue");
256 ncr_queue_.pop_front();
261 ncr_queue_.push_back(ncr);
271 if (new_queue_max < 1) {
273 "D2QueueMgr maximum queue size must be greater than zero");
278 " be less than the current queue size :" <<
getQueueSize());
281 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.
State
Defines the list of possible states for D2QueueMgr.
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.
const dhcp_ddns::NameChangeRequestPtr & peekAt(const size_t index) const
Returns the entry at a given position in the queue.
static std::string const & stateToText(State const &state)
Convert enum to string.
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.