Kea 2.7.5
|
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< ConfigBackendTypePtr > | selectBackends (const db::BackendSelector &backend_selector) const |
Selects existing backends matching the selector. | |
Protected Attributes | |
std::list< ConfigBackendTypePtr > | backends_ |
Holds configuration backends belonging to the pool. | |
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.
ConfigBackendType | Type 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.
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.
|
inlinevirtual |
Virtual destructor.
Definition at line 51 of file base_config_backend_pool.h.
|
inline |
Adds a backend to the pool.
backend | Pointer to a backend to be added. |
Definition at line 56 of file base_config_backend_pool.h.
References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_.
|
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:
where ConfigBackendDHCPv4::createUpdateServer4
has the following signature:
This method is used in cases when server selector is not applicable.
ReturnValue | Returned value, typically void or uint64_t. |
FnPtrArgs | Parameter pack holding argument types of the backend method to be invoked. |
Args | Parameter pack holding types of the arguments provided in the call to this method. |
MethodPointer | Pointer to the backend method to be called. |
backend_selector | Backend selector. |
input | Objects used as arguments to the backend method to be called. |
db::NoSuchDatabase | if no database matching the given selector was found. |
db::AmbiguousDatabase | if multiple databases matching the selector were found. |
Definition at line 571 of file base_config_backend_pool.h.
References isc_throw.
|
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:
where ConfigBackendDHCPv6::createUpdateSubnet6
has the following signature:
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.
ReturnValue | Returned value, typically void or uint64_t. |
FnPtrArgs | Parameter pack holding argument types of the backend method to be invoked. |
Args | Parameter pack holding types of the arguments provided in the call to this method. |
MethodPointer | Pointer to the backend method to be called. |
backend_selector | Backend selector. |
server_selector | Server selector. |
input | Objects used as arguments to the backend method to be called. |
db::NoSuchDatabase | if no database matching the given selector was found. |
db::AmbiguousDatabase | if multiple databases matching the selector were found. |
Definition at line 509 of file base_config_backend_pool.h.
References isc_throw.
|
inline |
Deletes all backends of the given type from the pool.
db_type | Backend to remove. |
dbaccess | Database access string being a collection of key=value pairs. |
if_unusable | Flag which indicates if the config backend should be deleted only if it is unusable. |
Definition at line 89 of file base_config_backend_pool.h.
References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_, and isc::db::DatabaseConnection::parse().
|
inline |
Deletes all backends from the pool.
Definition at line 61 of file base_config_backend_pool.h.
References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_.
|
inline |
Deletes all backends of the given type from the pool.
db_type | Backend to remove. |
Definition at line 68 of file base_config_backend_pool.h.
References isc::cb::BaseConfigBackendPool< ConfigBackendType >::backends_.
|
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:
where ConfigBackendDHCPv4::getAllServers4
has the following signature:
This method is used in cases when server selector is not applicable.
PropertyCollectionType | Type of the container into which the properties are stored. |
MethodPointer | Pointer to the backend method to be called. | |
backend_selector | Backend selector. | |
[out] | properties | Reference to the collection of retrieved properties. |
db::NoSuchDatabase | if no database matching the given selector was found. |
db::AmbiguousDatabase | if multiple databases matching the selector were found. |
Definition at line 446 of file base_config_backend_pool.h.
References isc_throw.
|
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:
where ConfigBackendDHCPv4::getAllSubnets4
has the following signature:
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.
PropertyCollectionType | Type of the container into which the properties are stored. |
MethodPointer | Pointer to the backend method to be called. | |
backend_selector | Backend selector. | |
server_selector | Server selector. | |
[out] | properties | Reference to the collection of retrieved properties. |
db::NoSuchDatabase | if no database matching the given selector was found. |
Definition at line 379 of file base_config_backend_pool.h.
|
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:
where ConfigBackendDHCPv4::getServer4
has the following signature:
This method is used in cases when server selector is not applicable.
PropertyType | Type of the object returned by the backend call. |
FnPtrArgs | Parameter pack holding argument types of the backend method to be invoked. |
Args | Parameter pack holding types of the arguments provided in the call to this method. |
MethodPointer | Pointer to the backend method to be called. | |
backend_selector | Backend selector. | |
[out] | property | Reference to the shared pointer where retrieved property should be assigned. |
input | Values to be used as input to the backend call. |
db::NoSuchDatabase | if no database matching the given selector was found. |
db::AmbiguousDatabase | if multiple databases matching the selector were found. |
Definition at line 243 of file base_config_backend_pool.h.
References isc_throw.
|
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:
where ConfigBackendDHCPv6::getSubnets6
has the following signature:
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.
PropertyCollectionType | Type of the container into which the properties are stored. |
FnPtrArgs | Parameter pack holding argument types of the backend method to be invoked. |
Args | Parameter pack holding types of the arguments provided in the call to this method. |
MethodPointer | Pointer to the backend method to be called. | |
backend_selector | Backend selector. | |
server_selector | Server selector. | |
[out] | properties | Reference to the collection of retrieved properties. |
input | Values to be used as input to the backend call. |
db::NoSuchDatabase | if no database matching the given selector was found. |
Definition at line 308 of file base_config_backend_pool.h.
|
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:
where ConfigBackendDHCPv4::getSubnet4
has the following signature:
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.
PropertyType | Type of the object returned by the backend call. |
FnPtrArgs | Parameter pack holding argument types of the backend method to be invoked. |
Args | Parameter pack holding types of the arguments provided in the call to this method. |
MethodPointer | Pointer to the backend method to be called. | |
backend_selector | Backend selector. | |
server_selector | Server selector. | |
[out] | property | Reference to the shared pointer where retrieved property should be assigned. |
input | Values to be used as input to the backend call. |
db::NoSuchDatabase | if 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_.
|
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.
backend_selector | Selector for which matching backends should be selected. |
Definition at line 595 of file base_config_backend_pool.h.
|
protected |
Holds configuration backends belonging to the pool.
Definition at line 643 of file base_config_backend_pool.h.
Referenced by isc::cb::BaseConfigBackendPool< ConfigBackendType >::addBackend(), isc::cb::BaseConfigBackendPool< ConfigBackendType >::del(), isc::cb::BaseConfigBackendPool< ConfigBackendType >::delAllBackends(), isc::cb::BaseConfigBackendPool< ConfigBackendType >::delAllBackends(), and isc::cb::BaseConfigBackendPool< ConfigBackendType >::getPropertyPtrConst().