![]() |
Kea 3.1.1
|
ConfigCache stores ping check config per subnet. More...
#include <config_cache.h>
Public Member Functions | |
ConfigCache () | |
Constructor. | |
virtual | ~ConfigCache ()=default |
Destructor. | |
void | cacheConfig (const dhcp::SubnetID &subnet_id, PingCheckConfigPtr &config) |
Adds (or replaces) the config for a given subnet to the cache. | |
bool | findConfig (const dhcp::SubnetID &subnet_id, PingCheckConfigPtr &config) |
Get the config for a given subnet. | |
void | flush () |
Discards the subnet entries in the cache. | |
PingCheckConfigPtr & | getGlobalConfig () |
Get the global level configuration. | |
boost::posix_time::ptime | getLastFlushTime () |
Get the last time the cache was flushed. | |
PingCheckConfigPtr | parseAndCacheConfig (const dhcp::SubnetID &subnet_id, data::ConstElementPtr &user_context) |
Parses a config string and caches for the given subnet. | |
void | setGlobalConfig (PingCheckConfigPtr &config) |
Set the global level configuration. | |
size_t | size () |
Get the number of entries in the cache. | |
![]() | |
BaseStampedElement () | |
Constructor. | |
uint64_t | getId () const |
Returns element's database identifier. | |
boost::posix_time::ptime | getModificationTime () const |
Returns timestamp. | |
void | setId (const uint64_t id) |
Sets element's database identifier. | |
void | setModificationTime (const boost::posix_time::ptime ×tamp) |
Sets timestamp to the explicitly provided value. | |
void | updateModificationTime () |
Sets timestamp to the current time. | |
Additional Inherited Members | |
![]() | |
uint64_t | id_ |
Database identifier of the configuration element. | |
boost::posix_time::ptime | timestamp_ |
Holds timestamp value. | |
ConfigCache stores ping check config per subnet.
The intent is parse subnet ping-check parameters from its user-context as few times as possible rather than on every ping check request, while also allowing for run time updates via config back end or subnet cmds.
For every subnet we store:
Each time we clear the cache we update the modification time.
When presented with a subnet:
entry exists: subnet mod time >= last flush cache is stale flush it cache it
subnet mod time < last flush use it
Definition at line 50 of file config_cache.h.
|
inline |
Constructor.
Definition at line 53 of file config_cache.h.
|
virtualdefault |
Destructor.
void isc::ping_check::ConfigCache::cacheConfig | ( | const dhcp::SubnetID & | subnet_id, |
PingCheckConfigPtr & | config ) |
Adds (or replaces) the config for a given subnet to the cache.
subnet_id | ID of the subnet for which the config is desired. |
config | pointer to the config to store. This may be an empty pointer. |
Definition at line 79 of file config_cache.cc.
Referenced by parseAndCacheConfig().
bool isc::ping_check::ConfigCache::findConfig | ( | const dhcp::SubnetID & | subnet_id, |
PingCheckConfigPtr & | config ) |
Get the config for a given subnet.
subnet_id | ID of the subnet for which the config is desired. | |
[out] | config | a reference to a pointer in which to store the config if found. If there is no entry for the subnet, it will be set to an empty pointer. |
Definition at line 36 of file config_cache.cc.
void isc::ping_check::ConfigCache::flush | ( | ) |
Discards the subnet entries in the cache.
Definition at line 85 of file config_cache.cc.
References isc::data::BaseStampedElement::updateModificationTime().
PingCheckConfigPtr & isc::ping_check::ConfigCache::getGlobalConfig | ( | ) |
Get the global level configuration.
Definition at line 22 of file config_cache.cc.
Referenced by parseAndCacheConfig().
boost::posix_time::ptime isc::ping_check::ConfigCache::getLastFlushTime | ( | ) |
Get the last time the cache was flushed.
Definition at line 101 of file config_cache.cc.
References isc::data::BaseStampedElement::getModificationTime().
PingCheckConfigPtr isc::ping_check::ConfigCache::parseAndCacheConfig | ( | const dhcp::SubnetID & | subnet_id, |
data::ConstElementPtr & | user_context ) |
Parses a config string and caches for the given subnet.
subnet_id | ID of the subnet for which the config is desired. |
user_context | user-context Element map of the subnet. |
BadValue | if an error occurred during config parsing. |
Definition at line 54 of file config_cache.cc.
References cacheConfig(), and getGlobalConfig().
void isc::ping_check::ConfigCache::setGlobalConfig | ( | PingCheckConfigPtr & | config | ) |
Set the global level configuration.
config | configuration to store as the global configuration. |
Definition at line 27 of file config_cache.cc.
References isc_throw.
size_t isc::ping_check::ConfigCache::size | ( | ) |
Get the number of entries in the cache.
Definition at line 95 of file config_cache.cc.