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