Kea 2.7.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.
 

Public Member Functions

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

Protected Member Functions

template<typename ReturnValue , typename... FnPtrArgs, typename... Args>
ReturnValue createUpdateDeleteBackendProperty (ReturnValue(ConfigBackendType::*MethodPointer)(FnPtrArgs...), const db::BackendSelector &backend_selector, Args... input)
 Add, update or delete property from the backend.
 
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.
 
template<typename PropertyCollectionType >
void getAllBackendPropertiesConst (PropertyCollectionType(ConfigBackendType::*MethodPointer)() const, const db::BackendSelector &backend_selector, PropertyCollectionType &properties) const
 Get all configuration properties from the backend.
 
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.
 
template<typename PropertyType , typename... FnPtrArgs, typename... Args>
void getBackendPropertyPtrConst (PropertyType(ConfigBackendType::*MethodPointer)(FnPtrArgs...) const, const db::BackendSelector &backend_selector, PropertyType &property, Args... input) const
 Retrieve a single configuration property from the backend.
 
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.
 
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.
 
std::list< ConfigBackendTypePtrselectBackends (const db::BackendSelector &backend_selector) const
 Selects existing backends matching the selector.
 

Protected Attributes

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

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 44 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 48 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 51 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 56 of file base_config_backend_pool.h.

References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_.

◆ createUpdateDeleteBackendProperty()

template<typename ConfigBackendType >
template<typename ReturnValue , typename... FnPtrArgs, typename... Args>
ReturnValue isc::cb::BaseConfigBackendPool< ConfigBackendType >::createUpdateDeleteBackendProperty ( ReturnValue(ConfigBackendType::*)(FnPtrArgs...) MethodPointer,
const db::BackendSelector & backend_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 without specifying the server selector. The server specific backends call this method. For example, the DHCPv4 configuration backend pool may use this function to implement the createUpdateServer4 method:

void createUpdateServer4(const BackendSelector& backend_selector,
const ServerSelector& server_selector,
const ServerPtr& server) {
createUpdateDeleteBackendProperty<void, const ServerPtr&>
(&ConfigBackendDHCPv4::createUpdateServer4, backend_selector,
server);
}

where ConfigBackendDHCPv4::createUpdateServer4 has the following signature:

void createUpdateServer4(const ServerPtr&);

This method is used in cases when server selector is not applicable.

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.
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 571 of file base_config_backend_pool.h.

References isc_throw.

◆ 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 509 of file base_config_backend_pool.h.

References isc_throw.

◆ del()

template<typename ConfigBackendType >
bool isc::cb::BaseConfigBackendPool< ConfigBackendType >::del ( const std::string & db_type,
const std::string & dbaccess,
bool if_unusable )
inline

Deletes all backends of the given type from the pool.

Parameters
db_typeBackend to remove.
dbaccessDatabase access string being a collection of key=value pairs.
if_unusableFlag which indicates if the config backend should be deleted only if it is unusable.
Returns
false when not removed because it is not found or because it is still usable (if_unusable is true), true otherwise.

Definition at line 89 of file base_config_backend_pool.h.

References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_, and isc::db::DatabaseConnection::parse().

+ Here is the call graph for this function:

◆ delAllBackends() [1/2]

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

Deletes all backends from the pool.

Definition at line 61 of file base_config_backend_pool.h.

References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_.

◆ 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 68 of file base_config_backend_pool.h.

References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_.

◆ getAllBackendPropertiesConst()

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

Get all configuration properties from the backend.

This is a common method for retrieving all configuration properties from the selected database without specifying the server selector. 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 getAllServers4 method:

ServerCollection getAllServers4(const BackendSelector&) const {
ServerCollection servers;
getAllBackendPropertiesConst<ServerCollection>
(&ConfigBackendDHCPv4::getAllServers4, backend_selector, servers);
return (servers);
}

where ConfigBackendDHCPv4::getAllServers4 has the following signature:

ServerCollection getAllServers4() const;

This method is used in cases when server selector is not applicable.

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

Definition at line 446 of file base_config_backend_pool.h.

References isc_throw.

◆ 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 {
Subnet4Collection subnets;
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 379 of file base_config_backend_pool.h.

◆ getBackendPropertyPtrConst()

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

Retrieve a single configuration property from the backend.

This is common method for retrieving a single configuration property from the selected database without specifying the server selector. 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 getServer4 method:

ServerPtr getServer4(const BackendSelector& backend_selector,
const std::string& server_tag) const {
ServerPtr server;
getPropertyPtrConst<ServerPtr, const std::string&>
(&ConfigBackendDHCPv4::getServer4, backend_selector,
server_tag);
return (server);
}

where ConfigBackendDHCPv4::getServer4 has the following signature:

ServerPtr getServer4(const std::string&) const;

This method is used in cases when server selector is not applicable.

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.
[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.
db::AmbiguousDatabaseif multiple databases matching the selector were found.

Definition at line 243 of file base_config_backend_pool.h.

References isc_throw.

◆ 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 {
Subnet6Collection subnets;
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 308 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 164 of file base_config_backend_pool.h.

References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_.

◆ 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 595 of file base_config_backend_pool.h.

Member Data Documentation

◆ backends_


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