Kea  1.5.0
isc::cb::BaseConfigBackendPool< ConfigBackendType > Class Template Reference

Base class for configuration backend pools. More...

#include <base_config_backend_pool.h>

Public Types

typedef boost::shared_ptr< ConfigBackendType > ConfigBackendTypePtr
 Shared pointer to the Configuration Backend used. More...
 

Public Member Functions

virtual ~BaseConfigBackendPool ()
 Virtual destructor. More...
 
void addBackend (ConfigBackendTypePtr backend)
 Adds a backend to the pool. More...
 
void delAllBackends ()
 Deletes all backends from the pool. More...
 
void delAllBackends (const std::string &db_type)
 Deletes all backends of the given type from the pool. More...
 

Protected Member Functions

template<typename ReturnValue , typename... FnPtrArgs, typename... Args>
ReturnValue createUpdateDeleteProperty (ReturnValue(ConfigBackendType::*MethodPointer)(const db::ServerSelector &, FnPtrArgs...), const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, Args... input)
 Add, update or delete property from the backend. More...
 
template<typename PropertyCollectionType >
void getAllPropertiesConst (PropertyCollectionType(ConfigBackendType::*MethodPointer)(const db::ServerSelector &) const, const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, PropertyCollectionType &properties) const
 Retrieve all configuration properties from the pool. More...
 
template<typename PropertyCollectionType , typename... FnPtrArgs, typename... Args>
void getMultiplePropertiesConst (PropertyCollectionType(ConfigBackendType::*MethodPointer)(const db::ServerSelector &, FnPtrArgs...) const, const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, PropertyCollectionType &properties, Args... input) const
 Retrieve multiple configuration properties from the pool. More...
 
template<typename PropertyType , typename... FnPtrArgs, typename... Args>
void getPropertyPtrConst (PropertyType(ConfigBackendType::*MethodPointer)(const db::ServerSelector &, FnPtrArgs...) const, const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, PropertyType &property, Args... input) const
 Retrieve a single configuration property from the pool. More...
 
std::list< ConfigBackendTypePtrselectBackends (const db::BackendSelector &backend_selector) const
 Selects existing backends matching the selector. More...
 

Protected Attributes

std::list< ConfigBackendTypePtrbackends_
 Holds configuration backends belonging to the pool. More...
 

Detailed Description

template<typename ConfigBackendType>
class isc::cb::BaseConfigBackendPool< ConfigBackendType >

Base class for configuration backend pools.

Each Kea server supporting databases as a configuration repository can use multiple database instances simultaneously. A pool is a collection of database backends used by a particular server. Different Kea servers use different pools because they store and fetch different configuration information. For example: DHCPv4 server stores and fetches IPv4 subnets, and DHCPv6 server stores and fetches IPv6 subnets. Therefore, each pool type will expose a different API calls.

This template class is a base class for all pools used by various servers. It implements mechanisms for managing multiple backends and for forwarding API calls to one or many database backends depending on the selections made via BackendSelector class.

Template Parameters
ConfigBackendTypeType of the configuration backend. This must be a class deriving from BaseConfigBackend class. It is a class dedicated to a particular server type, e.g. DHCPv4 server, and from which database specific backends derive.

Definition at line 43 of file base_config_backend_pool.h.

Member Typedef Documentation

◆ ConfigBackendTypePtr

template<typename ConfigBackendType >
typedef boost::shared_ptr<ConfigBackendType> isc::cb::BaseConfigBackendPool< ConfigBackendType >::ConfigBackendTypePtr

Shared pointer to the Configuration Backend used.

Definition at line 47 of file base_config_backend_pool.h.

Constructor & Destructor Documentation

◆ ~BaseConfigBackendPool()

template<typename ConfigBackendType >
virtual isc::cb::BaseConfigBackendPool< ConfigBackendType >::~BaseConfigBackendPool ( )
inlinevirtual

Virtual destructor.

Definition at line 50 of file base_config_backend_pool.h.

Member Function Documentation

◆ addBackend()

template<typename ConfigBackendType >
void isc::cb::BaseConfigBackendPool< ConfigBackendType >::addBackend ( ConfigBackendTypePtr  backend)
inline

Adds a backend to the pool.

Parameters
backendPointer to a backend to be added.

Definition at line 55 of file base_config_backend_pool.h.

◆ createUpdateDeleteProperty()

template<typename ConfigBackendType >
template<typename ReturnValue , typename... FnPtrArgs, typename... Args>
ReturnValue isc::cb::BaseConfigBackendPool< ConfigBackendType >::createUpdateDeleteProperty ( ReturnValue(ConfigBackendType::*)(const db::ServerSelector &, FnPtrArgs...)  MethodPointer,
const db::BackendSelector backend_selector,
const db::ServerSelector server_selector,
Args...  input 
)
inlineprotected

Add, update or delete property from the backend.

This is a common method for storing a single configuration property in a database, updating an existing property or deleting the property. The server specific backends call this method. For example, the DHCPv6 configuration backend pool may use this function to implement a createUpdateSubnet6 method:

void createUpdateSubnet6(const Subnet6Ptr& subnet,
const BackendSelector& backend_selector,
const ServerSelector& server_selector) {
createUpdateDeleteProperty<void, const Subnet6Ptr&>
(&ConfigBackendDHCPv6::createUpdateSubnet6, backend_selector,
server_selector, subnet, selector);
}

where ConfigBackendDHCPv6::createUpdateSubnet6 has the following signature:

void createUpdateSubnet6(const ServerSelector&, const Subnet6Ptr&);

The backend selector must point to exactly one backend. If more than one backend is selected, an exception is thrown. If no backend is selected an exception is thrown either.

Template Parameters
ReturnValueReturned value, typically void or uint64_t.
FnPtrArgsParameter pack holding argument types of the backend method to be invoked.
ArgsParameter pack holding types of the arguments provided in the call to this method.
Parameters
MethodPointerPointer to the backend method to be called.
backend_selectorBackend selector.
server_selectorServer selector.
inputObjects used as arguments to the backend method to be called.
Exceptions
db::NoSuchDatabaseif no database matching the given selector was found.
db::AmbiguousDatabaseif multiple databases matching the selector were found.
Returns
Number of affected properties, if the value is non void.

Definition at line 360 of file base_config_backend_pool.h.

◆ delAllBackends() [1/2]

template<typename ConfigBackendType >
void isc::cb::BaseConfigBackendPool< ConfigBackendType >::delAllBackends ( )
inline

Deletes all backends from the pool.

Definition at line 60 of file base_config_backend_pool.h.

◆ delAllBackends() [2/2]

template<typename ConfigBackendType >
void isc::cb::BaseConfigBackendPool< ConfigBackendType >::delAllBackends ( const std::string &  db_type)
inline

Deletes all backends of the given type from the pool.

Parameters
db_typebackend to remove

Definition at line 67 of file base_config_backend_pool.h.

◆ getAllPropertiesConst()

template<typename ConfigBackendType >
template<typename PropertyCollectionType >
void isc::cb::BaseConfigBackendPool< ConfigBackendType >::getAllPropertiesConst ( PropertyCollectionType(ConfigBackendType::*)(const db::ServerSelector &) const  MethodPointer,
const db::BackendSelector backend_selector,
const db::ServerSelector server_selector,
PropertyCollectionType &  properties 
) const
inlineprotected

Retrieve all configuration properties from the pool.

This is a common method for retrieving all configuration properties from the databases. The server specific backends call this method to retrieve all objects of the same type. For example, the DHCPv4 configuration backend pool may use this function to implement a getAllSubnets4 method:

Subnet4Collection getAllSubnets4(const BackendSelector&, const ServerSelector&) const {
getAllPropertiesConst<Subnet6Collection>
(&ConfigBackendDHCPv4::getAllSubnets4, subnets, backend_selector,
server_selector);
return (subnets);
}

where ConfigBackendDHCPv4::getAllSubnets4 has the following signature:

Subnet4Collection getAllSubnets4(const ServerSelector&) const;

If the backend selector is set to "unspecified", this method will iterate over existing backends and call the MethodPointer method on each backend. It will return the first non-empty list returned by one of the backends.

Template Parameters
PropertyCollectionTypeType of the container into which the properties are stored.
Parameters
MethodPointerPointer to the backend method to be called.
backend_selectorBackend selector.
server_selectorServer selector.
[out]propertiesReference to the collection of retrieved properties.
Exceptions
db::NoSuchDatabaseif no database matching the given selector was found.

Definition at line 282 of file base_config_backend_pool.h.

◆ getMultiplePropertiesConst()

template<typename ConfigBackendType >
template<typename PropertyCollectionType , typename... FnPtrArgs, typename... Args>
void isc::cb::BaseConfigBackendPool< ConfigBackendType >::getMultiplePropertiesConst ( PropertyCollectionType(ConfigBackendType::*)(const db::ServerSelector &, FnPtrArgs...) const  MethodPointer,
const db::BackendSelector backend_selector,
const db::ServerSelector server_selector,
PropertyCollectionType &  properties,
Args...  input 
) const
inlineprotected

Retrieve multiple configuration properties from the pool.

This is a common method for retrieving multiple configuration properties from the databases. The server specific backends call this method to retrieve multiple objects of the same type. For example, the DHCPv6 configuration backend pool may use this function to implement a getSubnets6 method:

Subnet6Collection getModifiedSubnets6(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
const ptime& modification_time) const {
getMultiplePropertiesConst<Subnet6Collection, const ptime&>
(&ConfigBackendDHCPv6::getSubnets6, backend_selector, server_selector,
subnets, modification_time);
return (subnets);
}

where ConfigBackendDHCPv6::getSubnets6 has the following signature:

Subnet6Collection getSubnets6(const ServerSelector&, const ptime&) const;

If the backend selector is set to "unspecified", this method will iterate over existing backends and call the MethodPointer method on each backend. It will return the first non-empty list returned by one of the backends.

Template Parameters
PropertyCollectionTypeType of the container into which the properties are stored.
FnPtrArgsParameter pack holding argument types of the backend method to be invoked.
ArgsParameter pack holding types of the arguments provided in the call to this method.
Parameters
MethodPointerPointer to the backend method to be called.
backend_selectorBackend selector.
server_selectorServer selector.
[out]propertiesReference to the collection of retrieved properties.
inputValues to be used as input to the backend call.
Exceptions
db::NoSuchDatabaseif no database matching the given selector was found.

Definition at line 211 of file base_config_backend_pool.h.

◆ getPropertyPtrConst()

template<typename ConfigBackendType >
template<typename PropertyType , typename... FnPtrArgs, typename... Args>
void isc::cb::BaseConfigBackendPool< ConfigBackendType >::getPropertyPtrConst ( PropertyType(ConfigBackendType::*)(const db::ServerSelector &, FnPtrArgs...) const  MethodPointer,
const db::BackendSelector backend_selector,
const db::ServerSelector server_selector,
PropertyType &  property,
Args...  input 
) const
inlineprotected

Retrieve a single configuration property from the pool.

This is common method for retrieving a single configuration property from the databases. The server specific backends call this method to retrieve a single object. For example, the DHCPv4 configuration backend pool may use this function to implement a getSubnet4 method:

Subnet4Ptr getSubnet4(const SubnetID& subnet_id,
const BackendSelector& backend_selector,
const ServerSelector& server_selector) const {
Subnet4Ptr subnet;
getPropertyPtrConst<Subnet4Ptr, const SubnetID&>
(&ConfigBackendDHCPv4::getSubnet4, backend_selector,
server_selector, subnet, subnet_id);
return (subnet);
}

where ConfigBackendDHCPv4::getSubnet4 has the following signature:

Subnet4Ptr getSubnet4(const ServerSelector&, const SubnetID&) const;

If the backend selector is set to "unspecified", this method will iterate over the existing backends and call the MethodPointer method on each backend. It will return the first non-null (or non-zero) value returned by this call. For example: if the first backend returns non-null value, this value is returned via property argument and the calls for the rest of the backends are skipped.

Template Parameters
PropertyTypeType of the object returned by the backend call.
FnPtrArgsParameter pack holding argument types of the backend method to be invoked.
ArgsParameter pack holding types of the arguments provided in the call to this method.
Parameters
MethodPointerPointer to the backend method to be called.
backend_selectorBackend selector.
server_selectorServer selector.
[out]propertyReference to the shared pointer where retrieved property should be assigned.
inputValues to be used as input to the backend call.
Exceptions
db::NoSuchDatabaseif no database matching the given selector was found.

Definition at line 129 of file base_config_backend_pool.h.

◆ selectBackends()

template<typename ConfigBackendType >
std::list<ConfigBackendTypePtr> isc::cb::BaseConfigBackendPool< ConfigBackendType >::selectBackends ( const db::BackendSelector backend_selector) const
inlineprotected

Selects existing backends matching the selector.

This method selects backends matching the selector. If the selector is "unspecified" or there is no backend in the pool, an empty list is returned.

Parameters
backend_selectorSelector for which matching backends should be selected.

Definition at line 385 of file base_config_backend_pool.h.

Referenced by isc::cb::BaseConfigBackendPool< ConfigBackendDHCPv4 >::createUpdateDeleteProperty(), isc::cb::BaseConfigBackendPool< ConfigBackendDHCPv4 >::getAllPropertiesConst(), isc::cb::BaseConfigBackendPool< ConfigBackendDHCPv4 >::getMultiplePropertiesConst(), and isc::cb::BaseConfigBackendPool< ConfigBackendDHCPv4 >::getPropertyPtrConst().

Member Data Documentation

◆ backends_


The documentation for this class was generated from the following file:
isc::dhcp::Subnet6Collection
boost::multi_index_container< Subnet6Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SubnetRandomAccessIndexTag > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > > >> Subnet6Collection
A collection of Subnet6 objects.
Definition: subnet.h:843
isc::dhcp::Subnet4Ptr
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
Definition: subnet.h:464
isc::dhcp::Subnet6Ptr
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
Definition: subnet.h:629
isc::dhcp::SubnetID
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
Definition: lease.h:24
isc::dhcp::Subnet4Collection
boost::multi_index_container< Subnet4Ptr, boost::multi_index::indexed_by< boost::multi_index::random_access< boost::multi_index::tag< SubnetRandomAccessIndexTag > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetSubnetIdIndexTag >, boost::multi_index::const_mem_fun< Subnet, SubnetID, &Subnet::getID > >, boost::multi_index::ordered_unique< boost::multi_index::tag< SubnetPrefixIndexTag >, boost::multi_index::const_mem_fun< Subnet, std::string, &Subnet::toText > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< SubnetServerIdIndexTag >, boost::multi_index::const_mem_fun< Network4, asiolink::IOAddress, &Network4::getServerId > > >> Subnet4Collection
A collection of Subnet4 objects.
Definition: subnet.h:798