7#ifndef CFG_EXPIRATION_H
8#define CFG_EXPIRATION_H
13#include <boost/shared_ptr.hpp>
133 return (reclaim_timer_wait_time_);
143 return (flush_reclaimed_timer_wait_time_);
153 return (hold_reclaimed_time_);
163 return (max_reclaim_leases_);
173 return (max_reclaim_time_);
183 return (unwarned_reclaim_cycles_);
221 template<
typename Instance>
222 void setupTimers(
void (Instance::*reclaim_fun)(const size_t, const uint16_t,
223 const bool, const uint16_t),
224 void (Instance::*delete_fun)(const uint32_t),
225 Instance* instance_ptr) const;
244 void rangeCheck(
const int64_t value,
const uint64_t max_value,
245 const std::string& config_parameter_name)
const;
248 uint16_t reclaim_timer_wait_time_;
251 uint16_t flush_reclaimed_timer_wait_time_;
254 uint32_t hold_reclaimed_time_;
257 uint32_t max_reclaim_leases_;
260 uint16_t max_reclaim_time_;
263 uint16_t unwarned_reclaim_cycles_;
282template<
typename Instance>
288 void (Instance::*delete_fun)(const uint32_t),
289 Instance* instance_ptr) const {
295 const bool flush_timer_disabled = (getFlushReclaimedTimerWaitTime() == 0);
299 if (getReclaimTimerWaitTime() > 0) {
302 const long reclaim_interval = test_mode_ ? getReclaimTimerWaitTime() :
303 1000 * getReclaimTimerWaitTime();
305 timer_mgr_->registerTimer(RECLAIM_EXPIRED_TIMER_NAME,
306 std::bind(reclaim_fun, instance_ptr,
307 getMaxReclaimLeases(),
309 flush_timer_disabled,
310 getUnwarnedReclaimCycles()),
313 timer_mgr_->setup(RECLAIM_EXPIRED_TIMER_NAME);
318 if (!flush_timer_disabled) {
321 const long flush_interval = test_mode_ ?
322 getFlushReclaimedTimerWaitTime() :
323 1000 * getFlushReclaimedTimerWaitTime();
325 timer_mgr_->registerTimer(FLUSH_RECLAIMED_TIMER_NAME,
326 std::bind(delete_fun, instance_ptr,
327 getHoldReclaimedTime()),
330 timer_mgr_->setup(FLUSH_RECLAIMED_TIMER_NAME);
Holds configuration parameters pertaining to lease expiration and lease affinity.
void setReclaimTimerWaitTime(const int64_t reclaim_timer_wait_time)
Sets reclaim-timer-wait-time.
static const uint16_t LIMIT_FLUSH_RECLAIMED_TIMER_WAIT_TIME
Maximum value for flush-reclaimed-timer-wait-time.
static const std::string FLUSH_RECLAIMED_TIMER_NAME
Name of the timer for flushing reclaimed leases.
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.
void setMaxReclaimLeases(const int64_t max_reclaim_leases)
Sets max-reclaim-leases.
void setUnwarnedReclaimCycles(const int64_t unwarned_reclaim_cycles)
Sets unwarned-reclaim-cycles.
static const uint32_t LIMIT_MAX_RECLAIM_LEASES
Maximum value for max-reclaim-leases.
void setHoldReclaimedTime(const int64_t hold_reclaimed_time)
Sets hold-reclaimed-time.
static const uint16_t DEFAULT_RECLAIM_TIMER_WAIT_TIME
uint16_t getFlushReclaimedTimerWaitTime() const
Returns flush-reclaimed-timer-wait-time.
static const uint16_t LIMIT_UNWARNED_RECLAIM_CYCLES
Maximum value for unwarned-reclaim-cycles.
static const uint16_t LIMIT_RECLAIM_TIMER_WAIT_TIME
uint32_t getHoldReclaimedTime() const
Returns hold-reclaimed-time.
uint16_t getMaxReclaimTime() const
Returns max-reclaim-time.
static const uint32_t LIMIT_HOLD_RECLAIMED_TIME
Maximum value for hold-reclaimed-time.
CfgExpiration(const bool test_mode=false)
Constructor.
static const uint16_t DEFAULT_UNWARNED_RECLAIM_CYCLES
Default value for unwarned-reclaim-cycles.
void setMaxReclaimTime(const int64_t max_reclaim_time)
Sets max-reclaim-time.
static const uint16_t DEFAULT_FLUSH_RECLAIMED_TIMER_WAIT_TIME
Default value for flush-reclaimed-timer-wait-time.
static const uint16_t DEFAULT_MAX_RECLAIM_TIME
Default value for max-reclaim-time.
uint32_t getMaxReclaimLeases() const
Returns max-reclaim-leases.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
static const uint16_t LIMIT_MAX_RECLAIM_TIME
Default value for max-reclaim-time.
static const std::string RECLAIM_EXPIRED_TIMER_NAME
Name of the timer for reclaiming expired leases.
uint16_t getReclaimTimerWaitTime() const
Returns reclaim-timer-wait-time.
void setFlushReclaimedTimerWaitTime(const int64_t flush_reclaimed_wait_time)
Sets flush-reclaimed-timer-wait-time.
static const uint32_t DEFAULT_HOLD_RECLAIMED_TIME
Default value for hold-reclaimed-time.
uint16_t getUnwarnedReclaimCycles() const
Returns unwarned-reclaim-cycles.
static const uint32_t DEFAULT_MAX_RECLAIM_LEASES
Default value for max-reclaim-leases.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< const CfgExpiration > ConstCfgExpirationPtr
Pointer to the const object.
boost::shared_ptr< TimerMgr > TimerMgrPtr
Type definition of the shared pointer to TimerMgr.
boost::shared_ptr< CfgExpiration > CfgExpirationPtr
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.