Kea: isc::dhcp::FreeLeaseQueueAllocator Class Reference

| Kea 3.2.0-git

isc::dhcp::FreeLeaseQueueAllocator Class Reference

An allocator maintaining a queue of free leases. More...

`#include <flq_allocator.h>`

Inheritance diagram for isc::dhcp::FreeLeaseQueueAllocator:
[legend]

## Public Member Functions
| FreeLeaseQueueAllocator (Lease::Type type, const WeakSubnetPtr &subnet)
| Constructor.
virtual double | getOccupancyRate (const asiolink::IOAddress &addr, const ClientClasses &client_classes)
| Returns the occupancy rate (v4 addresses).
virtual double | getOccupancyRate (const asiolink::IOAddress &pref, const uint8_t plen, const ClientClasses &client_classes)
| Returns the occupancy rate (v6 prefixes).
virtual std::string | getType () const
| Returns the allocator type string.
Public Member Functions inherited from isc::dhcp::Allocator
| Allocator (Lease::Type type, const WeakSubnetPtr &subnet)
| Constructor.
virtual | ~Allocator ()
| Virtual destructor.
void | initAfterConfigure ()
| Performs allocator initialization after server's reconfiguration.
virtual isc::asiolink::IOAddress | pickAddress (const ClientClasses &client_classes, const IdentifierBaseTypePtr &duid, const asiolink::IOAddress &hint)
| Picks an address.
virtual isc::asiolink::IOAddress | pickPrefix (const ClientClasses &client_classes, Pool6Ptr &pool, const IdentifierBaseTypePtr &duid, PrefixLenMatchType prefix_length_match, const asiolink::IOAddress &hint, uint8_t hint_prefix_length)
| Picks a delegated prefix.

## Additional Inherited Members
Public Types inherited from isc::dhcp::Allocator
enum | PrefixLenMatchType { PREFIX_LEN_EQUAL , PREFIX_LEN_LOWER , PREFIX_LEN_HIGHER }
| Type of preferred PD-pool prefix length selection criteria. More...
Static Public Member Functions inherited from isc::dhcp::Allocator
static bool | isValidPrefixPool (Allocator::PrefixLenMatchType prefix_length_match, PoolPtr pool, uint8_t hint_prefix_length)
| Check if the pool matches the selection criteria relative to the provided hint prefix length.
Protected Attributes inherited from isc::dhcp::Allocator
bool | inited_
| Indicates if the allocator has been initialized.
std::mutex | mutex_
| The mutex to protect the allocated lease.
Lease::Type | pool_type_
| Defines pool type allocation.
WeakSubnetPtr | subnet_
| Weak pointer to the subnet owning the allocator.
SubnetID | subnet_id_
| ID of a subnet to which the allocator belongs.

## Detailed Description

An allocator maintaining a queue of free leases.

This allocator populates the queue of free leases during the initialization. It also installs the callbacks in the `LeaseMgr`, to track the subsequent lease changes. It allows for maintaining the running queue of free leases.

The allocator offers the leases from the queue, minimizing the number of the allocation engine's attempts to check if some other client is using the offered lease. Ideally, only one check should suffice. However, when several servers share a lease database, the collisions may occur because the servers don't observe each others' allocations.

This allocator should only be used for reasonably small pools due to the overhead to populate the free leases. A reasonably small pool is an IPv4 pool (including /8) and the prefix delegation pools with similar capacity. This allocator is not suitable for a typical IPv6 address pool (e.g., /64). An attempt to populate free leases for such a giant pool would freeze the server and likely exhaust its memory.

Free leases are populated in a random order.

Definition at line 38 of file flq_allocator.h.

## Constructor & Destructor Documentation

## ◆ FreeLeaseQueueAllocator()

isc::dhcp::FreeLeaseQueueAllocator::FreeLeaseQueueAllocator | ( | Lease::Type | type,
|  | const WeakSubnetPtr & | subnet )

Constructor.

Parameters

  type | specifies the type of allocated leases.
  subnet | weak pointer to the subnet owning the allocator.

Definition at line 32 of file flq_allocator.cc.

References isc::dhcp::Allocator::Allocator().

Here is the call graph for this function:

## Member Function Documentation

## ◆ getOccupancyRate() [1/2]

double isc::dhcp::FreeLeaseQueueAllocator::getOccupancyRate | ( | const asiolink::IOAddress & | addr,
|  | const ClientClasses & | client_classes )
| virtual

Returns the occupancy rate (v4 addresses).

The method counts the total number and the number of not free addresses in the suitable pools of the subnet, and returns the occupancy rate. If the total number of addresses is over UMAX64 or the address is not from one of these pools, or by default the 0. rate is returned.

Parameters

  addr | the address.
  client_classes | list of classes client belongs to.

Reimplemented from isc::dhcp::Allocator.

Definition at line 139 of file flq_allocator.cc.

References isc::dhcp::Allocator::mutex_.

## ◆ getOccupancyRate() [2/2]

double isc::dhcp::FreeLeaseQueueAllocator::getOccupancyRate | ( | const asiolink::IOAddress & | pref,
|  | const uint8_t | plen,
|  | const ClientClasses & | client_classes )
| virtual

Returns the occupancy rate (v6 prefixes).

The method counts the total number and the number of not free prefixes in the suitable pools of the subnet, and returns the occupancy rate. If the total number of prefixes is over UMAX64 or the prefix is not from one of these pools, or by default the 0. rate is returned.

Parameters

  pref | the prefix.
  plen | the prefix length.
  client_classes | list of classes client belongs to.

Reimplemented from isc::dhcp::Allocator.

Definition at line 193 of file flq_allocator.cc.

References isc::dhcp::Allocator::mutex_.

## ◆ getType()

virtual std::string isc::dhcp::FreeLeaseQueueAllocator::getType | ( |  | ) | const
| inlinevirtual

Returns the allocator type string.

Returns
  flq string.

Implements isc::dhcp::Allocator.

Definition at line 50 of file flq_allocator.h.

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

- flq_allocator.h
- flq_allocator.cc