Kea 2.7.6
|
Container that maintains counts of leases per class and lease type. More...
#include <memfile_lease_limits.h>
Public Types | |
typedef std::unordered_map< ClientClass, size_t > | ClassCountMap |
Defines ClassCountMap as an unordered map of counts. | |
Public Member Functions | |
ClassLeaseCounter ()=default | |
Constructor. | |
~ClassLeaseCounter ()=default | |
Destructor. | |
void | addLease (LeasePtr lease) |
Increment the counts for all of a lease's classes by one. | |
void | adjustClassCount (const ClientClass &client_class, int offset, const Lease::Type <ype=Lease::TYPE_V4) |
Adjust the count for a given class and lease type by a signed offset. | |
void | adjustClassCounts (data::ConstElementPtr classes, int offset, const Lease::Type <ype=Lease::TYPE_V4) |
Adjust the count for a list of classes for a lease type by a signed offset. | |
void | clear () |
Remove all entries. | |
size_t | getClassCount (const ClientClass &client_class, const Lease::Type <ype=Lease::TYPE_V4) const |
Fetches the lease count for the given class and lease type. | |
void | removeLease (LeasePtr lease) |
Decrement the counts for all of a lease's classes by one. | |
void | setClassCount (const ClientClass &client_class, size_t count, const Lease::Type <ype=Lease::TYPE_V4) |
Sets the lease count for the given class and lease type to a value. | |
size_t | size (const Lease::Type <ype=Lease::TYPE_V4) const |
Get the number of entries for a given lease type. | |
void | updateLease (LeasePtr new_lease, LeasePtr old_lease) |
Adjust class lease counts given a new and old version of a lease. | |
Static Public Member Functions | |
static data::ConstElementPtr | getLeaseClientClasses (LeasePtr lease) |
Fetches the list of classes from the lease's user-context. | |
Container that maintains counts of leases per class and lease type.
For methods on this class which accept the lease type as a parameter the value is one of the following Lease::TYPE_V4, Lease::TYPE_NA, Lease::TYPE_PD. Kea does not support Lease::TYPE_TA leases and this value is treated as invalid. Note that for simplicity and performance an instance of container is assumed to be used either only for DHCPv4 processing or DHCPv6 processing but not both concurrently.
Definition at line 30 of file memfile_lease_limits.h.
std::unordered_map<ClientClass, size_t> isc::dhcp::ClassLeaseCounter::ClassCountMap |
Defines ClassCountMap as an unordered map of counts.
Definition at line 33 of file memfile_lease_limits.h.
|
default |
Constructor.
|
default |
Destructor.
void isc::dhcp::ClassLeaseCounter::addLease | ( | LeasePtr | lease | ) |
Increment the counts for all of a lease's classes by one.
Function is intended to be whenever a new lease is being added.
lease | lease whose classes are to be incremented |
Definition at line 93 of file memfile_lease_limits.cc.
References adjustClassCounts(), getLeaseClientClasses(), isc_throw, and isc::dhcp::Lease::STATE_DEFAULT.
Referenced by isc::dhcp::Memfile_LeaseMgr::recountClassLeases4(), and isc::dhcp::Memfile_LeaseMgr::recountClassLeases6().
void isc::dhcp::ClassLeaseCounter::adjustClassCount | ( | const ClientClass & | client_class, |
int | offset, | ||
const Lease::Type & | ltype = Lease::TYPE_V4 ) |
Adjust the count for a given class and lease type by a signed offset.
If no entry exists in container for the class and type, a new one is created.
client_class | client class to adjust |
offset | signed amount to add to the current count |
ltype | lease type for which the count is desired, defaults to Lease::TYPE_V4 |
Definition at line 37 of file memfile_lease_limits.cc.
Referenced by adjustClassCounts().
void isc::dhcp::ClassLeaseCounter::adjustClassCounts | ( | data::ConstElementPtr | classes, |
int | offset, | ||
const Lease::Type & | ltype = Lease::TYPE_V4 ) |
Adjust the count for a list of classes for a lease type by a signed offset.
classes | list of classes to adjust |
offset | signed amount to add the current count |
ltype | lease type for which the count is desired, defaults to Lease::TYPE_V4 |
Definition at line 80 of file memfile_lease_limits.cc.
References adjustClassCount().
Referenced by addLease(), removeLease(), and updateLease().
|
inline |
Remove all entries.
Definition at line 112 of file memfile_lease_limits.h.
Referenced by isc::dhcp::Memfile_LeaseMgr::clearClassLeaseCounts(), isc::dhcp::Memfile_LeaseMgr::recountClassLeases4(), and isc::dhcp::Memfile_LeaseMgr::recountClassLeases6().
size_t isc::dhcp::ClassLeaseCounter::getClassCount | ( | const ClientClass & | client_class, |
const Lease::Type & | ltype = Lease::TYPE_V4 ) const |
Fetches the lease count for the given class and lease type.
client_class | class for which the count is desired |
ltype | lease type for which the count is desired, defaults to Lease::TYPE_V4 |
Definition at line 17 of file memfile_lease_limits.cc.
Referenced by isc::dhcp::Memfile_LeaseMgr::getClassLeaseCount().
|
static |
Fetches the list of classes from the lease's user-context.
lease | lease from which to fetch classes |
Definition at line 57 of file memfile_lease_limits.cc.
References isc_throw, isc::data::Element::list, and isc::data::prettyPrint().
Referenced by addLease(), removeLease(), and updateLease().
void isc::dhcp::ClassLeaseCounter::removeLease | ( | LeasePtr | lease | ) |
Decrement the counts for all of a lease's classes by one.
Function is intended to be whenever an existing lease is being deleted.
lease | lease whose classes are to be decremented |
Definition at line 144 of file memfile_lease_limits.cc.
References adjustClassCounts(), getLeaseClientClasses(), isc_throw, and isc::dhcp::Lease::STATE_DEFAULT.
void isc::dhcp::ClassLeaseCounter::setClassCount | ( | const ClientClass & | client_class, |
size_t | count, | ||
const Lease::Type & | ltype = Lease::TYPE_V4 ) |
Sets the lease count for the given class and lease type to a value.
client_class | class for which the count is desired |
count | new count value for the class and lease type. |
ltype | lease type for which the count is desired, defaults to Lease::TYPE_V4 |
Definition at line 30 of file memfile_lease_limits.cc.
|
inline |
Get the number of entries for a given lease type.
ltype | type of lease for which the number of entries is desired, defaults to Lease::TYPE_V4 |
Definition at line 123 of file memfile_lease_limits.h.
References size().
Referenced by size().
Adjust class lease counts given a new and old version of a lease.
Function is intended to be used whenever an existing lease is being updated. If, upon comparison of the two leases, either the lease states or the class lists are different then:
new_lease | new version of the lease |
old_lease | old version of the lease |
Definition at line 110 of file memfile_lease_limits.cc.
References adjustClassCounts(), getLeaseClientClasses(), isc_throw, and isc::dhcp::Lease::STATE_DEFAULT.