Kea 3.1.1
isc::ping_check::ConfigCache Class Reference

ConfigCache stores ping check config per subnet. More...

#include <config_cache.h>

+ Inheritance diagram for isc::ping_check::ConfigCache:

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.
 
PingCheckConfigPtrgetGlobalConfig ()
 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.
 
- Public Member Functions inherited from isc::data::BaseStampedElement
 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 &timestamp)
 Sets timestamp to the explicitly provided value.
 
void updateModificationTime ()
 Sets timestamp to the current time.
 

Additional Inherited Members

- Protected Attributes inherited from isc::data::BaseStampedElement
uint64_t id_
 Database identifier of the configuration element.
 
boost::posix_time::ptime timestamp_
 Holds timestamp value.
 

Detailed Description

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:

  1. subnet id
  2. PingCheckConfig pointer where:
    • empty config pointer means that subnet does not specify ping check config
    • non-empty means subnet specifies at least some ping check parameters

Each time we clear the cache we update the modification time.

When presented with a subnet:

  1. no cache entry: cache it
  2. 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.

Constructor & Destructor Documentation

◆ ConfigCache()

isc::ping_check::ConfigCache::ConfigCache ( )
inline

Constructor.

Definition at line 53 of file config_cache.h.

◆ ~ConfigCache()

virtual isc::ping_check::ConfigCache::~ConfigCache ( )
virtualdefault

Destructor.

Member Function Documentation

◆ cacheConfig()

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.

Parameters
subnet_idID of the subnet for which the config is desired.
configpointer to the config to store. This may be an empty pointer.

Definition at line 79 of file config_cache.cc.

Referenced by parseAndCacheConfig().

◆ findConfig()

bool isc::ping_check::ConfigCache::findConfig ( const dhcp::SubnetID & subnet_id,
PingCheckConfigPtr & config )

Get the config for a given subnet.

Parameters
subnet_idID of the subnet for which the config is desired.
[out]configa 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.
Returns
True if an entry for subnet was found, false otherwise. This allows callers to distinguish between unknown subnets (entries that do not exist) and subnets that are known but do not define a config.

Definition at line 36 of file config_cache.cc.

◆ flush()

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().

+ Here is the call graph for this function:

◆ getGlobalConfig()

PingCheckConfigPtr & isc::ping_check::ConfigCache::getGlobalConfig ( )

Get the global level configuration.

Returns
pointer to the global configuration.

Definition at line 22 of file config_cache.cc.

Referenced by parseAndCacheConfig().

◆ getLastFlushTime()

boost::posix_time::ptime isc::ping_check::ConfigCache::getLastFlushTime ( )

Get the last time the cache was flushed.

Returns
the last time the cache was flushed (or the time it was created if it has never been flushed).

Definition at line 101 of file config_cache.cc.

References isc::data::BaseStampedElement::getModificationTime().

+ Here is the call graph for this function:

◆ parseAndCacheConfig()

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.

Parameters
subnet_idID of the subnet for which the config is desired.
user_contextuser-context Element map of the subnet.
Returns
pointer to the parsed config.
Exceptions
BadValueif an error occurred during config parsing.

Definition at line 54 of file config_cache.cc.

References cacheConfig(), and getGlobalConfig().

+ Here is the call graph for this function:

◆ setGlobalConfig()

void isc::ping_check::ConfigCache::setGlobalConfig ( PingCheckConfigPtr & config)

Set the global level configuration.

Parameters
configconfiguration to store as the global configuration.

Definition at line 27 of file config_cache.cc.

References isc_throw.

◆ size()

size_t isc::ping_check::ConfigCache::size ( )

Get the number of entries in the cache.

Returns
number of entries in the cache.

Definition at line 95 of file config_cache.cc.


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