Kea 2.5.8
isc::ha::LeaseUpdateBacklog Class Reference

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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ OpType

Type of the lease update (operation type).

Enumerator
ADD 
DELETE 

Definition at line 49 of file lease_update_backlog.h.

Constructor & Destructor Documentation

◆ LeaseUpdateBacklog()

isc::ha::LeaseUpdateBacklog::LeaseUpdateBacklog ( const size_t  limit)

Constructor.

Parameters
limitspecifies the maximum number of lease updates which can be stored in the queue.

Definition at line 17 of file lease_update_backlog.cc.

Member Function Documentation

◆ clear()

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().

+ Here is the call graph for this function:

◆ pop()

LeasePtr isc::ha::LeaseUpdateBacklog::pop ( LeaseUpdateBacklog::OpType op_type)

Returns the next lease update and removes it from the queue.

Parameters
[out]op_typereference to the value receiving lease update type.
Returns
pointer to the next lease update in the queue or null pointer when the queue is empty.

Definition at line 31 of file lease_update_backlog.cc.

References isc::util::MultiThreadingMgr::instance().

Referenced by isc::ha::CommandCreator::createLease6BulkApply().

+ Here is the call graph for this function:

◆ push()

bool isc::ha::LeaseUpdateBacklog::push ( const OpType  op_type,
const dhcp::LeasePtr lease 
)

Appends lease update to the queue.

Parameters
op_typetype of the lease update (operation type).
leasepointer to the lease being added, or deleted.
Returns
boolean value indicating whether the lease was successfully appended to the queue (if true) or not (if false).

Definition at line 22 of file lease_update_backlog.cc.

References isc::util::MultiThreadingMgr::instance().

Referenced by isc::ha::HAService::asyncSendLeaseUpdates().

+ Here is the call graph for this function:

◆ size()

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().

+ Here is the call graph for this function:

◆ wasOverflown()

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.

Returns
true if the queue was overflown, false otherwise.

Definition at line 40 of file lease_update_backlog.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: