Kea 2.5.8
isc::dhcp::CfgExpiration Class Reference

Holds configuration parameters pertaining to lease expiration and lease affinity. More...

#include <cfg_expiration.h>

+ Inheritance diagram for isc::dhcp::CfgExpiration:

Public Member Functions

 CfgExpiration (const bool test_mode=false)
 Constructor.
 
uint16_t getFlushReclaimedTimerWaitTime () const
 Returns flush-reclaimed-timer-wait-time.
 
uint32_t getHoldReclaimedTime () const
 Returns hold-reclaimed-time.
 
uint32_t getMaxReclaimLeases () const
 Returns max-reclaim-leases.
 
uint16_t getMaxReclaimTime () const
 Returns max-reclaim-time.
 
uint16_t getReclaimTimerWaitTime () const
 Returns reclaim-timer-wait-time.
 
uint16_t getUnwarnedReclaimCycles () const
 Returns unwarned-reclaim-cycles.
 
void setFlushReclaimedTimerWaitTime (const int64_t flush_reclaimed_wait_time)
 Sets flush-reclaimed-timer-wait-time.
 
void setHoldReclaimedTime (const int64_t hold_reclaimed_time)
 Sets hold-reclaimed-time.
 
void setMaxReclaimLeases (const int64_t max_reclaim_leases)
 Sets max-reclaim-leases.
 
void setMaxReclaimTime (const int64_t max_reclaim_time)
 Sets max-reclaim-time.
 
void setReclaimTimerWaitTime (const int64_t reclaim_timer_wait_time)
 Sets reclaim-timer-wait-time.
 
void setUnwarnedReclaimCycles (const int64_t unwarned_reclaim_cycles)
 Sets unwarned-reclaim-cycles.
 
template<typename Instance >
void setupTimers (void(Instance::*reclaim_fun)(const size_t, const uint16_t, const bool, const uint16_t), void(Instance::*delete_fun)(const uint32_t), Instance *instance_ptr) const
 Setup timers for the reclamation of expired leases according to the configuration parameters.
 
virtual isc::data::ElementPtr toElement () const
 Unparse a configuration object.
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor.
 
virtual isc::data::ElementPtr toElement () const =0
 Unparse a configuration object.
 

Static Public Attributes

Default values.

Default value for reclaim-timer-wait-time.

static const uint16_t DEFAULT_RECLAIM_TIMER_WAIT_TIME = 10
 
static const uint16_t DEFAULT_FLUSH_RECLAIMED_TIMER_WAIT_TIME = 25
 Default value for flush-reclaimed-timer-wait-time.
 
static const uint32_t DEFAULT_HOLD_RECLAIMED_TIME = 3600
 Default value for hold-reclaimed-time.
 
static const uint32_t DEFAULT_MAX_RECLAIM_LEASES = 100
 Default value for max-reclaim-leases.
 
static const uint16_t DEFAULT_MAX_RECLAIM_TIME = 250
 Default value for max-reclaim-time.
 
static const uint16_t DEFAULT_UNWARNED_RECLAIM_CYCLES = 5
 Default value for unwarned-reclaim-cycles.
 
Upper limits for the parameters

Maximum value for reclaim-timer-wait-time.

static const uint16_t LIMIT_RECLAIM_TIMER_WAIT_TIME
 
static const uint16_t LIMIT_FLUSH_RECLAIMED_TIMER_WAIT_TIME
 Maximum value for flush-reclaimed-timer-wait-time.
 
static const uint32_t LIMIT_HOLD_RECLAIMED_TIME
 Maximum value for hold-reclaimed-time.
 
static const uint32_t LIMIT_MAX_RECLAIM_LEASES
 Maximum value for max-reclaim-leases.
 
static const uint16_t LIMIT_MAX_RECLAIM_TIME = 10000
 Default value for max-reclaim-time.
 
static const uint16_t LIMIT_UNWARNED_RECLAIM_CYCLES
 Maximum value for unwarned-reclaim-cycles.
 
Timers' names
static const std::string RECLAIM_EXPIRED_TIMER_NAME
 Name of the timer for reclaiming expired leases.
 
static const std::string FLUSH_RECLAIMED_TIMER_NAME
 Name of the timer for flushing reclaimed leases.
 

Detailed Description

Holds configuration parameters pertaining to lease expiration and lease affinity.

This class holds the values of the following configuration parameters:

  • reclaim-timer-wait-time - is the time between two cycles of processing expired leases, expressed in seconds, i.e. the time between the end of one cycle and the beginning of the next cycle. If this value is 0, the expired leases are not processed.
  • flush-reclaimed-timer-wait-time - is the time between two cycles of recycling "expired-reclaimed" leases, expressed in seconds. If this value is 0, the expired leases are removed by the leases reclamation routine rather than recycling function. The recycling function is not executed and the value of the "hold-reclaimed-time" is ignored.
  • hold-reclaimed-time -is the time for which "expired-reclaimed" leases are held in the lease database in the "expired-reclaimed" state after they expire. If this time is set to 0, the recycling function is not executed and the value of the "recycle-timer-wait-time" is ignored. This value is expressed in seconds.
  • max-reclaim-leases - is the maximum number of leases to be processed in a single cycle. If this value is 0, all expired leases are processed in a single cycle, unless the maximum processing time (configured with the "max-time") parameter elapses first.
  • max-reclaim-time - the maximum time that a single processing cycle may last, expressed in milliseconds. If this value is 0, there is no limitation for the maximum processing time. This value is expressed in milliseconds.
  • unwarned-reclaim-cycles - is the number of consecutive processing cycles of expired leases, after which the system issues a warning if there are still expired leases in the database. If this value is 0, the warning is never issued.

The CfgExpiration class provides a collection of accessors and modifiers to manage the data. Each accessor checks if the given value is in range allowed for this value.

Definition at line 61 of file cfg_expiration.h.

Constructor & Destructor Documentation

◆ CfgExpiration()

isc::dhcp::CfgExpiration::CfgExpiration ( const bool  test_mode = false)

Constructor.

Sets all parameters to their defaults.

Parameters
test_modeIndicates if the instance should be created in the test mode. In this mode the intervals for the timers are considered to be specified in milliseconds, rather than seconds. This facilitates testing execution of timers without the delays.

Definition at line 46 of file cfg_expiration.cc.

Member Function Documentation

◆ getFlushReclaimedTimerWaitTime()

uint16_t isc::dhcp::CfgExpiration::getFlushReclaimedTimerWaitTime ( ) const
inline

Returns flush-reclaimed-timer-wait-time.

Definition at line 142 of file cfg_expiration.h.

Referenced by setupTimers().

◆ getHoldReclaimedTime()

uint32_t isc::dhcp::CfgExpiration::getHoldReclaimedTime ( ) const
inline

Returns hold-reclaimed-time.

Definition at line 152 of file cfg_expiration.h.

Referenced by setupTimers().

◆ getMaxReclaimLeases()

uint32_t isc::dhcp::CfgExpiration::getMaxReclaimLeases ( ) const
inline

Returns max-reclaim-leases.

Definition at line 162 of file cfg_expiration.h.

Referenced by setupTimers().

◆ getMaxReclaimTime()

uint16_t isc::dhcp::CfgExpiration::getMaxReclaimTime ( ) const
inline

Returns max-reclaim-time.

Definition at line 172 of file cfg_expiration.h.

Referenced by setupTimers().

◆ getReclaimTimerWaitTime()

uint16_t isc::dhcp::CfgExpiration::getReclaimTimerWaitTime ( ) const
inline

Returns reclaim-timer-wait-time.

Definition at line 132 of file cfg_expiration.h.

Referenced by setupTimers().

◆ getUnwarnedReclaimCycles()

uint16_t isc::dhcp::CfgExpiration::getUnwarnedReclaimCycles ( ) const
inline

Returns unwarned-reclaim-cycles.

Definition at line 182 of file cfg_expiration.h.

Referenced by setupTimers().

◆ setFlushReclaimedTimerWaitTime()

void isc::dhcp::CfgExpiration::setFlushReclaimedTimerWaitTime ( const int64_t  flush_reclaimed_wait_time)

Sets flush-reclaimed-timer-wait-time.

Parameters
flush_reclaimed_wait_timeNew value.

Definition at line 65 of file cfg_expiration.cc.

References LIMIT_FLUSH_RECLAIMED_TIMER_WAIT_TIME.

◆ setHoldReclaimedTime()

void isc::dhcp::CfgExpiration::setHoldReclaimedTime ( const int64_t  hold_reclaimed_time)

Sets hold-reclaimed-time.

Parameters
hold_reclaimed_timeNew value.

Definition at line 72 of file cfg_expiration.cc.

References LIMIT_HOLD_RECLAIMED_TIME.

◆ setMaxReclaimLeases()

void isc::dhcp::CfgExpiration::setMaxReclaimLeases ( const int64_t  max_reclaim_leases)

Sets max-reclaim-leases.

Parameters
max_reclaim_leasesNew value.

Definition at line 78 of file cfg_expiration.cc.

References LIMIT_MAX_RECLAIM_LEASES.

◆ setMaxReclaimTime()

void isc::dhcp::CfgExpiration::setMaxReclaimTime ( const int64_t  max_reclaim_time)

Sets max-reclaim-time.

Parameters
max_reclaim_timeNew value.

Definition at line 84 of file cfg_expiration.cc.

References LIMIT_MAX_RECLAIM_TIME.

◆ setReclaimTimerWaitTime()

void isc::dhcp::CfgExpiration::setReclaimTimerWaitTime ( const int64_t  reclaim_timer_wait_time)

Sets reclaim-timer-wait-time.

Parameters
reclaim_timer_wait_timeNew value.

Definition at line 58 of file cfg_expiration.cc.

References LIMIT_RECLAIM_TIMER_WAIT_TIME.

◆ setUnwarnedReclaimCycles()

void isc::dhcp::CfgExpiration::setUnwarnedReclaimCycles ( const int64_t  unwarned_reclaim_cycles)

Sets unwarned-reclaim-cycles.

Parameters
unwarned_reclaim_cyclesNew value.

Definition at line 90 of file cfg_expiration.cc.

References LIMIT_UNWARNED_RECLAIM_CYCLES.

◆ setupTimers()

template<typename Instance >
void isc::dhcp::CfgExpiration::setupTimers ( void(Instance::*)(const size_t, const uint16_t, const bool, const uint16_t)  reclaim_fun,
void(Instance::*)(const uint32_t)  delete_fun,
Instance *  instance_ptr 
) const

Setup timers for the reclamation of expired leases according to the configuration parameters.

This method includes the logic for setting the interval timers performing the reclamation of the expired leases and the removal of expired-reclaimed leases.

The following is the sample code illustrating how to call this function to setup the leases reclamation for the DHCPv4 server.

(set some cfg values here)
AllocEnginePtr alloc_engine(new AllocEngine(...));
alloc_engine.get());
DHCPv4 and DHCPv6 allocation engine.
Definition: alloc_engine.h:47
void deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes reclaimed leases expired more than specified amount of time ago.
void reclaimExpiredLeases4(const size_t max_leases, const uint16_t timeout, const bool remove_lease, const uint16_t max_unwarned_cycles=0)
Reclaims expired IPv4 leases.
Holds configuration parameters pertaining to lease expiration and lease affinity.
void setupTimers(void(Instance::*reclaim_fun)(const size_t, const uint16_t, const bool, const uint16_t), void(Instance::*delete_fun)(const uint32_t), Instance *instance_ptr) const
Setup timers for the reclamation of expired leases according to the configuration parameters.
boost::shared_ptr< AllocEngine > AllocEnginePtr
A pointer to the AllocEngine object.
Parameters
reclaim_funPointer to the leases reclamation routine.
delete_funPointer to the function which removes the expired-reclaimed leases from the lease database.
instance_ptrPointer to the instance of the object which implements the lease reclamation routine. Typically it will be the pointer to the AllocEngine. In case of unit tests it will be a pointer to some test class which provides stub implementation of the leases reclamation routines.
Template Parameters
InstanceInstance of the object in which both functions are implemented.

Definition at line 284 of file cfg_expiration.h.

References FLUSH_RECLAIMED_TIMER_NAME, getFlushReclaimedTimerWaitTime(), getHoldReclaimedTime(), getMaxReclaimLeases(), getMaxReclaimTime(), getReclaimTimerWaitTime(), getUnwarnedReclaimCycles(), isc::asiolink::IntervalTimer::ONE_SHOT, and RECLAIM_EXPIRED_TIMER_NAME.

+ Here is the call graph for this function:

◆ toElement()

ElementPtr isc::dhcp::CfgExpiration::toElement ( ) const
virtual

Unparse a configuration object.

Returns
a pointer to unparsed configuration

Implements isc::data::CfgToElement.

Definition at line 111 of file cfg_expiration.cc.

References isc::data::Element::create(), and isc::data::Element::createMap().

+ Here is the call graph for this function:

Member Data Documentation

◆ DEFAULT_FLUSH_RECLAIMED_TIMER_WAIT_TIME

const uint16_t isc::dhcp::CfgExpiration::DEFAULT_FLUSH_RECLAIMED_TIMER_WAIT_TIME = 25
static

Default value for flush-reclaimed-timer-wait-time.

Definition at line 71 of file cfg_expiration.h.

◆ DEFAULT_HOLD_RECLAIMED_TIME

const uint32_t isc::dhcp::CfgExpiration::DEFAULT_HOLD_RECLAIMED_TIME = 3600
static

Default value for hold-reclaimed-time.

Definition at line 74 of file cfg_expiration.h.

◆ DEFAULT_MAX_RECLAIM_LEASES

const uint32_t isc::dhcp::CfgExpiration::DEFAULT_MAX_RECLAIM_LEASES = 100
static

Default value for max-reclaim-leases.

Definition at line 77 of file cfg_expiration.h.

◆ DEFAULT_MAX_RECLAIM_TIME

const uint16_t isc::dhcp::CfgExpiration::DEFAULT_MAX_RECLAIM_TIME = 250
static

Default value for max-reclaim-time.

Definition at line 80 of file cfg_expiration.h.

◆ DEFAULT_RECLAIM_TIMER_WAIT_TIME

const uint16_t isc::dhcp::CfgExpiration::DEFAULT_RECLAIM_TIMER_WAIT_TIME = 10
static

Definition at line 68 of file cfg_expiration.h.

◆ DEFAULT_UNWARNED_RECLAIM_CYCLES

const uint16_t isc::dhcp::CfgExpiration::DEFAULT_UNWARNED_RECLAIM_CYCLES = 5
static

Default value for unwarned-reclaim-cycles.

Definition at line 83 of file cfg_expiration.h.

◆ FLUSH_RECLAIMED_TIMER_NAME

const std::string isc::dhcp::CfgExpiration::FLUSH_RECLAIMED_TIMER_NAME
static
Initial value:
=
"flush-reclaimed-leases"

Name of the timer for flushing reclaimed leases.

Definition at line 117 of file cfg_expiration.h.

Referenced by setupTimers().

◆ LIMIT_FLUSH_RECLAIMED_TIMER_WAIT_TIME

const uint16_t isc::dhcp::CfgExpiration::LIMIT_FLUSH_RECLAIMED_TIMER_WAIT_TIME
static
Initial value:
=
std::numeric_limits<uint16_t>::max()

Maximum value for flush-reclaimed-timer-wait-time.

Definition at line 94 of file cfg_expiration.h.

Referenced by setFlushReclaimedTimerWaitTime().

◆ LIMIT_HOLD_RECLAIMED_TIME

const uint32_t isc::dhcp::CfgExpiration::LIMIT_HOLD_RECLAIMED_TIME
static
Initial value:
=
std::numeric_limits<uint32_t>::max()

Maximum value for hold-reclaimed-time.

Definition at line 97 of file cfg_expiration.h.

Referenced by setHoldReclaimedTime().

◆ LIMIT_MAX_RECLAIM_LEASES

const uint32_t isc::dhcp::CfgExpiration::LIMIT_MAX_RECLAIM_LEASES
static
Initial value:
=
std::numeric_limits<uint32_t>::max()

Maximum value for max-reclaim-leases.

Definition at line 100 of file cfg_expiration.h.

Referenced by setMaxReclaimLeases().

◆ LIMIT_MAX_RECLAIM_TIME

const uint16_t isc::dhcp::CfgExpiration::LIMIT_MAX_RECLAIM_TIME = 10000
static

Default value for max-reclaim-time.

Definition at line 103 of file cfg_expiration.h.

Referenced by setMaxReclaimTime().

◆ LIMIT_RECLAIM_TIMER_WAIT_TIME

const uint16_t isc::dhcp::CfgExpiration::LIMIT_RECLAIM_TIMER_WAIT_TIME
static
Initial value:
=
std::numeric_limits<uint16_t>::max()

Definition at line 91 of file cfg_expiration.h.

Referenced by setReclaimTimerWaitTime().

◆ LIMIT_UNWARNED_RECLAIM_CYCLES

const uint16_t isc::dhcp::CfgExpiration::LIMIT_UNWARNED_RECLAIM_CYCLES
static
Initial value:
=
std::numeric_limits<uint16_t>::max()

Maximum value for unwarned-reclaim-cycles.

Definition at line 106 of file cfg_expiration.h.

Referenced by setUnwarnedReclaimCycles().

◆ RECLAIM_EXPIRED_TIMER_NAME

const std::string isc::dhcp::CfgExpiration::RECLAIM_EXPIRED_TIMER_NAME
static
Initial value:
=
"reclaim-expired-leases"

Name of the timer for reclaiming expired leases.

Definition at line 114 of file cfg_expiration.h.

Referenced by setupTimers().


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