Kea  2.3.2-git
isc::db::ServerSelector Class Reference

Server selector for associating objects in a database with specific servers. More...

#include <server_selector.h>

Public Types

enum  Type { Type::UNASSIGNED, Type::ALL, Type::SUBSET, Type::ANY }
 Type of the server selection. More...
 

Public Member Functions

bool amAll () const
 Convenience method checking if the server selector is "all". More...
 
bool amAny () const
 Convenience method checking if the server selector is "any". More...
 
bool amUnassigned () const
 Convenience method checking if the server selector is "unassigned". More...
 
std::set< data::ServerTaggetTags () const
 Returns tags associated with the selector. More...
 
Type getType () const
 Returns type of the selector. More...
 
bool hasMultipleTags () const
 Convenience method checking if the server selector has multiple tags. More...
 
bool hasNoTags () const
 Convenience method checking if the server selector has no tags. More...
 

Static Public Member Functions

static ServerSelector ALL ()
 Factory returning "all servers" selector. More...
 
static ServerSelector ANY ()
 Factory returning "any server" selector. More...
 
static ServerSelector MULTIPLE (const std::set< std::string > &server_tags)
 Factory returning "multiple servers" selector. More...
 
static ServerSelector ONE (const std::string &server_tag)
 Factory returning selector of one server. More...
 
static ServerSelector UNASSIGNED ()
 Factory returning "unassigned" server selector. More...
 

Detailed Description

Server selector for associating objects in a database with specific servers.

Configuration information stored in the configuration backends can be associated with selected servers, all servers or no particular server. For example: a particular subnet definition in the database may be associated with one server or can be shared by multiple servers. In the latter case, a subnet may be associated with a subset of servers or all servers. An administrator may also add the configuration data into the database and do not associate this data with any particular server.

When fetching the configuration data from a database or when storing data in the database there is a need to specify which servers this data is associated with. The ServerSelector class represents such associations.

It includes three modes of selection: UNASSIGNED, ALL and SUBSET and several factory functions making associations described above.

The ServerSelector class should be used in objects derived from BaseConfigBackendPool and in objects derived from BaseConfigBackend to indicate which servers the specific calls exposed by these objects refer to.

Todo:
Add server selector for selecting only those configuration elements that are associated with all servers (and not with any particular server tags). Translating this to SQL queries it would probably be an empty or non-existing server tag.

Definition at line 46 of file server_selector.h.

Member Enumeration Documentation

◆ Type

Type of the server selection.

Enumerator
UNASSIGNED 
ALL 
SUBSET 
ANY 

Definition at line 50 of file server_selector.h.

Member Function Documentation

◆ ALL()

static ServerSelector isc::db::ServerSelector::ALL ( )
inlinestatic

Factory returning "all servers" selector.

Definition at line 64 of file server_selector.h.

References ALL.

Referenced by isc::process::CBControlBase< ConfigBackendDHCPv4Mgr >::databaseConfigFetch().

◆ amAll()

bool isc::db::ServerSelector::amAll ( ) const
inline

Convenience method checking if the server selector is "all".

Returns
true if the selector is "all", false otherwise.

Definition at line 119 of file server_selector.h.

References ALL, and getType().

+ Here is the call graph for this function:

◆ amAny()

bool isc::db::ServerSelector::amAny ( ) const
inline

Convenience method checking if the server selector is "any".

Returns
true if the selector is "any", false otherwise.

Definition at line 126 of file server_selector.h.

References ANY, and getType().

+ Here is the call graph for this function:

◆ amUnassigned()

bool isc::db::ServerSelector::amUnassigned ( ) const
inline

Convenience method checking if the server selector is "unassigned".

Returns
true if the selector is "unassigned", false otherwise.

Definition at line 112 of file server_selector.h.

References getType(), and UNASSIGNED.

+ Here is the call graph for this function:

◆ ANY()

static ServerSelector isc::db::ServerSelector::ANY ( )
inlinestatic

Factory returning "any server" selector.

Definition at line 84 of file server_selector.h.

References ANY.

◆ getTags()

std::set<data::ServerTag> isc::db::ServerSelector::getTags ( ) const
inline

Returns tags associated with the selector.

Returns
server tags for multiple selections and for one server, empty set for all servers and and unassigned.

Definition at line 98 of file server_selector.h.

◆ getType()

Type isc::db::ServerSelector::getType ( ) const
inline

Returns type of the selector.

Definition at line 90 of file server_selector.h.

Referenced by amAll(), amAny(), and amUnassigned().

◆ hasMultipleTags()

bool isc::db::ServerSelector::hasMultipleTags ( ) const
inline

Convenience method checking if the server selector has multiple tags.

Returns
true if it has multiple tags, false otherwise.

Definition at line 133 of file server_selector.h.

◆ hasNoTags()

bool isc::db::ServerSelector::hasNoTags ( ) const
inline

Convenience method checking if the server selector has no tags.

Returns
true when the server selector has no tags, false otherwise.

Definition at line 105 of file server_selector.h.

◆ MULTIPLE()

ServerSelector isc::db::ServerSelector::MULTIPLE ( const std::set< std::string > &  server_tags)
static

Factory returning "multiple servers" selector.

Parameters
server_tagsset of server tags to be selected.
Exceptions
InvalidOperationif no server tags provided.

Definition at line 18 of file server_selector.cc.

References isc::data::ServerTag::amAll(), and isc_throw.

Referenced by ONE().

+ Here is the call graph for this function:

◆ ONE()

static ServerSelector isc::db::ServerSelector::ONE ( const std::string &  server_tag)
inlinestatic

Factory returning selector of one server.

Parameters
server_tagtag of the single server to be selected.

Definition at line 72 of file server_selector.h.

References MULTIPLE().

Referenced by isc::process::CBControlBase< ConfigBackendDHCPv4Mgr >::databaseConfigFetch().

+ Here is the call graph for this function:

◆ UNASSIGNED()

static ServerSelector isc::db::ServerSelector::UNASSIGNED ( )
inlinestatic

Factory returning "unassigned" server selector.

Definition at line 58 of file server_selector.h.

References UNASSIGNED.


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