Kea 2.7.5
|
Queue holding a backlog of unsent lease updates. More...
#include <lease_update_backlog.h>
Public Types | |
enum | OpType { ADD , DELETE } |
Type of the lease update (operation type). More... | |
Public Member Functions | |
LeaseUpdateBacklog (const size_t limit) | |
Constructor. | |
void | clear () |
Removes all lease updates from the queue. | |
dhcp::LeasePtr | pop (OpType &op_type) |
Returns the next lease update and removes it from the queue. | |
bool | push (const OpType op_type, const dhcp::LeasePtr &lease) |
Appends lease update to the queue. | |
size_t | size () |
Returns the current size of the queue. | |
bool | wasOverflown () |
Checks if the queue was overflown. | |
Queue holding a backlog of unsent lease updates.
Lease updates are appended to this queue when the service is in the communication-recovery state. In this state, the server temporarily lost communication with the partner and can't send lease updates. The server keeps responding to DHCP queries but it must store unsent lease updates and later send them when the communication is resumed. The lease updates are stored in this queue.
This queue has configurable size. If the number of leases appended to the queue reaches the limit, no more updates can be added to it. This prevents inifinite growth of the queue and excessive memory consumption.
There are two types of lease updates: "Add" and "Delete". The type is specified when the lease is appended to the queue.
The backlog queue holds both "Add" and "Delete" lease updates in a single std::deque container, which allows for ordering them chronologically and using this ordering for queue optimizations in the future. For example, if the queue contains consecutive "Delete" updates for a particular IP address, the server could only delete the lease once. If the queue contains multiple "Delete" lease updates followed by an "Add" update, the server could skip sending "Delete" updates.
Queue optimizations will be subject to future work!
Definition at line 45 of file lease_update_backlog.h.
Type of the lease update (operation type).
Enumerator | |
---|---|
ADD | |
DELETE |
Definition at line 49 of file lease_update_backlog.h.
isc::ha::LeaseUpdateBacklog::LeaseUpdateBacklog | ( | const size_t | limit | ) |
Constructor.
limit | specifies the maximum number of lease updates which can be stored in the queue. |
Definition at line 17 of file lease_update_backlog.cc.
void isc::ha::LeaseUpdateBacklog::clear | ( | ) |
Removes all lease updates from the queue.
It also resets the flag indicating that the queue was overflown.
Definition at line 49 of file lease_update_backlog.cc.
References isc::util::MultiThreadingMgr::instance().
LeasePtr isc::ha::LeaseUpdateBacklog::pop | ( | LeaseUpdateBacklog::OpType & | op_type | ) |
Returns the next lease update and removes it from the queue.
[out] | op_type | reference to the value receiving lease update type. |
Definition at line 31 of file lease_update_backlog.cc.
References isc::util::MultiThreadingMgr::instance().
bool isc::ha::LeaseUpdateBacklog::push | ( | const OpType | op_type, |
const dhcp::LeasePtr & | lease ) |
Appends lease update to the queue.
op_type | type of the lease update (operation type). |
lease | pointer to the lease being added, or deleted. |
Definition at line 22 of file lease_update_backlog.cc.
References isc::util::MultiThreadingMgr::instance().
Referenced by isc::ha::HAService::asyncSendLeaseUpdates(), and isc::ha::HAService::asyncSendLeaseUpdates().
size_t isc::ha::LeaseUpdateBacklog::size | ( | ) |
Returns the current size of the queue.
Definition at line 60 of file lease_update_backlog.cc.
References isc::util::MultiThreadingMgr::instance().
bool isc::ha::LeaseUpdateBacklog::wasOverflown | ( | ) |
Checks if the queue was overflown.
This method returns true if the number of lease updates exceeded the queue size limit at any point. The HA service checks this flag when the communication with the partner is resumed to make decisions about lease synchronization. If the queue was not overflown, the server will send lease updates which are sitting in the queue. Otherwise, it will go over the fully blown lease database synchronization process.
This flag is reset to false when clear
is called.
Definition at line 40 of file lease_update_backlog.cc.
References isc::util::MultiThreadingMgr::instance().