Kea  1.5.0
isc::dhcp::CqlHostDataSourceImpl Class Reference

Implementation of the CqlHostDataSource. More...

Public Member Functions

 CqlHostDataSourceImpl (const CqlConnection::ParameterMap &parameters)
 Constructor. More...
 
virtual ~CqlHostDataSourceImpl ()
 Destructor. More...
 
virtual ConstHostPtr get4 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const
 Implementation of CqlHostDataSource::get4() More...
 
virtual ConstHostPtr get4 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Implementation of CqlHostDataSource::get4() More...
 
virtual ConstHostPtr get6 (const asiolink::IOAddress &prefix, const uint8_t prefix_len) const
 Retrieves a host by its reserved IPv6 address or prefix. More...
 
virtual ConstHostPtr get6 (const SubnetID &subnet_id, const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Implementation of CqlHostDataSource::get6() More...
 
virtual ConstHostPtr get6 (const SubnetID &subnet_id, const asiolink::IOAddress &address) const
 Implementation of CqlHostDataSource::get6() More...
 
virtual ConstHostCollection getAll (const Host::IdentifierType &identifier_type, const uint8_t *identifier_begin, const size_t identifier_len) const
 Implementation of CqlHostDataSource::getAll() More...
 
virtual ConstHostCollection getAll4 (const asiolink::IOAddress &address) const
 Implementation of CqlHostDataSource::getAll4() More...
 
virtual ConstHostCollection getAllHosts () const
 Implementation of CqlHostDataSource::getAllHosts() More...
 
virtual std::string getName () const
 Implementation of CqlHostDataSource::getName() More...
 
virtual VersionPair getVersion () const
 Implementation of CqlHostDataSource::getVersion() More...
 
virtual bool insertOrDelete (const HostPtr &host, bool insert)
 Implementation of CqlHostDataSource::add() and del() More...
 

Protected Member Functions

virtual ConstHostPtr getHost (StatementTag statement_tag, AnyArray &where_values) const
 Retrieves a single host. More...
 
virtual ConstHostCollection getHostCollection (StatementTag statement_tag, AnyArray &where_values) const
 Retrieves a collection of hosts. More...
 
virtual bool insertOrDeleteHost (bool insert, const HostPtr &host, const OptionalValue< SubnetID > &subnet_id=OptionalValue< SubnetID >(), const IPv6Resrv *const reservation=NULL, const std::string &option_space=NULL_OPTION_SPACE, const OptionDescriptor &option_descriptor=OptionDescriptor(false))
 Inserts or deletes a single host. More...
 
virtual bool insertOrDeleteHostWithOptions (bool insert, const HostPtr &host, const IPv6Resrv *const reservation=NULL, const std::list< std::string > &option_spaces=std::list< std::string >(), const ConstCfgOptionPtr cfg_option=ConstCfgOptionPtr())
 Adds/deletes any options found in the Host object to/from a separate table entry. More...
 
virtual bool insertOrDeleteHostWithReservations (bool insert, const HostPtr &host, const IPv6Resrv *const reservation, const std::list< std::string > &option_spaces4, const ConstCfgOptionPtr cfg_option4, const std::list< std::string > &option_spaces6, const ConstCfgOptionPtr cfg_option6)
 Adds/deletes any reservations found in the Host object to/from a separate table entry. More...
 
virtual void mergeHosts (const ConstHostPtr &source_host, HostPtr &target_host) const
 Merge denormalized table entries that belong to the same host into a single host, one by one. More...
 

Detailed Description

Implementation of the CqlHostDataSource.

This class is encapsulate all the Cassandra communication details.

Definition at line 1346 of file cql_host_data_source.cc.

Constructor & Destructor Documentation

◆ CqlHostDataSourceImpl()

isc::dhcp::CqlHostDataSourceImpl::CqlHostDataSourceImpl ( const CqlConnection::ParameterMap &  parameters)
explicit

Constructor.

This constructor opens database connection and initializes prepared statements used in the queries.

Parameters
parametersparameters passed to the CQL connection.

Definition at line 1594 of file cql_host_data_source.cc.

References isc::db::CQL_SCHEMA_VERSION_MAJOR, isc::db::CQL_SCHEMA_VERSION_MINOR, getVersion(), isc_throw, isc::db::CqlConnection::openDatabase(), isc::db::CqlConnection::prepareStatements(), and isc::dhcp::CqlHostExchange::tagged_statements_.

+ Here is the call graph for this function:

◆ ~CqlHostDataSourceImpl()

isc::dhcp::CqlHostDataSourceImpl::~CqlHostDataSourceImpl ( )
virtual

Destructor.

Definition at line 1617 of file cql_host_data_source.cc.

Member Function Documentation

◆ get4() [1/2]

ConstHostPtr isc::dhcp::CqlHostDataSourceImpl::get4 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
virtual

Implementation of CqlHostDataSource::get4()

See CqlHostDataSource::get4() for parameter details.

Parameters
subnet_idId of the subnet to look into
addressIPv4 address to be retrieved

Definition at line 1667 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS, getHost(), isc_throw, isc::asiolink::IOAddress::isV4(), and isc::asiolink::IOAddress::toUint32().

Referenced by isc::dhcp::CqlHostDataSource::del(), isc::dhcp::CqlHostDataSource::del4(), and isc::dhcp::CqlHostDataSource::get4().

+ Here is the call graph for this function:

◆ get4() [2/2]

ConstHostPtr isc::dhcp::CqlHostDataSourceImpl::get4 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
virtual

Implementation of CqlHostDataSource::get4()

See CqlHostDataSource::get4() for parameter details.

Parameters
subnet_idId of the subnet to look into
identifier_typetype of the identifier
identifier_beginpointer to the first byte of the identifier
identifier_lenlength of the identifier

Definition at line 1690 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID, and getHost().

+ Here is the call graph for this function:

◆ get6() [1/3]

ConstHostPtr isc::dhcp::CqlHostDataSourceImpl::get6 ( const asiolink::IOAddress prefix,
const uint8_t  prefix_len 
) const
virtual

Retrieves a host by its reserved IPv6 address or prefix.

See CqlHostDataSource::get6() for parameter details.

Parameters
prefixIPv6 address or prefix
prefix_lenlength of the prefix (or 128 for address)

Definition at line 1713 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV6_PREFIX, getAll(), getHost(), isc_throw, and isc::asiolink::IOAddress::toText().

Referenced by isc::dhcp::CqlHostDataSource::del6(), and isc::dhcp::CqlHostDataSource::get6().

+ Here is the call graph for this function:

◆ get6() [2/3]

ConstHostPtr isc::dhcp::CqlHostDataSourceImpl::get6 ( const SubnetID subnet_id,
const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
virtual

Implementation of CqlHostDataSource::get6()

See CqlHostDataSource::get6() for parameter details.

Parameters
subnet_idId of the subnet to look into
identifier_typetype of the identifier (duid, hwaddr, flex, etc.)
identifier_beginpointer to the first byte of the identifier
identifier_lenlength of the identifier

Definition at line 1756 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID, and getHost().

+ Here is the call graph for this function:

◆ get6() [3/3]

ConstHostPtr isc::dhcp::CqlHostDataSourceImpl::get6 ( const SubnetID subnet_id,
const asiolink::IOAddress address 
) const
virtual

Implementation of CqlHostDataSource::get6()

See CqlHostDataSource::get6() for parameter details.

Parameters
subnet_idId of the subnet to look into
addressIPv6 address to be retrieved

Definition at line 1779 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS, getHost(), and isc::asiolink::IOAddress::toText().

+ Here is the call graph for this function:

◆ getAll()

ConstHostCollection isc::dhcp::CqlHostDataSourceImpl::getAll ( const Host::IdentifierType identifier_type,
const uint8_t *  identifier_begin,
const size_t  identifier_len 
) const
virtual

Implementation of CqlHostDataSource::getAll()

See CqlHostDataSource::getAll() for parameter details.

Parameters
identifier_typetype of the identifier (duid, hwaddr, flex, etc.)
identifier_beginpointer to the first byte of the identifier
identifier_lenlength of the identifier

Definition at line 1797 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlHostExchange::GET_HOST_BY_HOST_ID, and getHostCollection().

Referenced by get6(), and isc::dhcp::CqlHostDataSource::getAll().

+ Here is the call graph for this function:

◆ getAll4()

ConstHostCollection isc::dhcp::CqlHostDataSourceImpl::getAll4 ( const asiolink::IOAddress address) const
virtual

Implementation of CqlHostDataSource::getAll4()

See CqlHostDataSource::getAll4() for parameter details.

Parameters
addressIPv4 address of the reservation to be retrieved

Definition at line 1817 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV4_ADDRESS, getHostCollection(), and isc::asiolink::IOAddress::toUint32().

Referenced by isc::dhcp::CqlHostDataSource::getAll4().

+ Here is the call graph for this function:

◆ getAllHosts()

ConstHostCollection isc::dhcp::CqlHostDataSourceImpl::getAllHosts ( ) const
virtual

Implementation of CqlHostDataSource::getAllHosts()

See CqlHostDataSource::getAllHosts() for parameter details.

Definition at line 1833 of file cql_host_data_source.cc.

References isc::dhcp::CqlHostExchange::GET_HOST, and getHostCollection().

Referenced by isc::dhcp::CqlHostDataSource::getAllHosts().

+ Here is the call graph for this function:

◆ getHost()

ConstHostPtr isc::dhcp::CqlHostDataSourceImpl::getHost ( StatementTag  statement_tag,
AnyArray where_values 
) const
protectedvirtual

Retrieves a single host.

Calls getHostCollection() and checks if a single host was returned.

Parameters
where_valuesarray of bound objects used to filter the results
statement_tagprepared statement being executed
Returns
one host or a null pointer to a host
Exceptions
MultipleRecordsexception if two or more hosts are returned

Definition at line 1935 of file cql_host_data_source.cc.

References getHostCollection(), and isc_throw.

Referenced by get4(), and get6().

+ Here is the call graph for this function:

◆ getHostCollection()

ConstHostCollection isc::dhcp::CqlHostDataSourceImpl::getHostCollection ( StatementTag  statement_tag,
AnyArray where_values 
) const
protectedvirtual

Retrieves a collection of hosts.

Calls db::CqlExchange::executeSelect().

Parameters
where_valuesarray of bound objects used to filter the results
statement_tagprepared statement being executed
Returns
a collection of hosts containing one or more hosts

Definition at line 1953 of file cql_host_data_source.cc.

References isc::db::CqlExchange::executeSelect(), and mergeHosts().

Referenced by getAll(), getAll4(), getAllHosts(), and getHost().

+ Here is the call graph for this function:

◆ getName()

std::string isc::dhcp::CqlHostDataSourceImpl::getName ( ) const
virtual

Implementation of CqlHostDataSource::getName()

Definition at line 1845 of file cql_host_data_source.cc.

References isc::db::DatabaseConnection::getParameter().

Referenced by isc::dhcp::CqlHostDataSource::getName().

+ Here is the call graph for this function:

◆ getVersion()

VersionPair isc::dhcp::CqlHostDataSourceImpl::getVersion ( ) const
virtual

Implementation of CqlHostDataSource::getVersion()

Definition at line 1856 of file cql_host_data_source.cc.

References isc::db::CqlVersionExchange::retrieveVersion().

Referenced by CqlHostDataSourceImpl(), and isc::dhcp::CqlHostDataSource::getVersion().

+ Here is the call graph for this function:

◆ insertOrDelete()

bool isc::dhcp::CqlHostDataSourceImpl::insertOrDelete ( const HostPtr host,
bool  insert 
)
virtual

Implementation of CqlHostDataSource::add() and del()

See CqlHostDataSource::add() for parameter details.

Parameters
hosthost to be added or deleted
insertinsert (true) or delete (false) the host

Definition at line 1623 of file cql_host_data_source.cc.

References insertOrDeleteHostWithReservations().

Referenced by isc::dhcp::CqlHostDataSource::add(), isc::dhcp::CqlHostDataSource::del(), isc::dhcp::CqlHostDataSource::del4(), and isc::dhcp::CqlHostDataSource::del6().

+ Here is the call graph for this function:

◆ insertOrDeleteHost()

bool isc::dhcp::CqlHostDataSourceImpl::insertOrDeleteHost ( bool  insert,
const HostPtr host,
const OptionalValue< SubnetID > &  subnet_id = OptionalValue<SubnetID>(),
const IPv6Resrv *const  reservation = NULL,
const std::string &  option_space = NULL_OPTION_SPACE,
const OptionDescriptor option_descriptor = OptionDescriptor(false) 
)
protectedvirtual

Inserts or deletes a single host.

All information is available here. Calls db::CqlExchange::executeMutation().

Parameters
insertinsert or delete a host
hostHost object from which options are retrieved and inserted/deleted into/from the Cassandra database
subnet_ididentifier of the subnet to which the host belongs
reservationreservation for the current denormalized table entry
option_spaceoption space for the current denormalized table entry's option
option_descriptoroption descriptor containing information for the current denormalized table entry's option

Definition at line 1991 of file cql_host_data_source.cc.

References isc::dhcp::CqlHostExchange::createBindForDelete(), isc::dhcp::CqlHostExchange::createBindForMutation(), isc::dhcp::CqlHostExchange::DELETE_HOST, isc::db::CqlExchange::executeMutation(), isc::dhcp::CqlHostExchange::INSERT_HOST, isc_throw, and isc::Exception::what().

Referenced by insertOrDeleteHostWithOptions().

+ Here is the call graph for this function:

◆ insertOrDeleteHostWithOptions()

bool isc::dhcp::CqlHostDataSourceImpl::insertOrDeleteHostWithOptions ( bool  insert,
const HostPtr host,
const IPv6Resrv *const  reservation = NULL,
const std::list< std::string > &  option_spaces = std::list<std::string>(),
const ConstCfgOptionPtr  cfg_option = ConstCfgOptionPtr() 
)
protectedvirtual

Adds/deletes any options found in the Host object to/from a separate table entry.

Parameters
insertinsert or delete a host with options
hostHost object from which options are retrieved and inserted/deleted into/from the Cassandra database
reservationreservation for the current denormalized table entry
option_spaceslist of option spaces to search for
cfg_optionoption configuration used to match option spaces in order to obtain actual options
Todo:
: Assign actual value to subnet id.

Definition at line 1862 of file cql_host_data_source.cc.

References insertOrDeleteHost().

Referenced by insertOrDeleteHostWithReservations().

+ Here is the call graph for this function:

◆ insertOrDeleteHostWithReservations()

bool isc::dhcp::CqlHostDataSourceImpl::insertOrDeleteHostWithReservations ( bool  insert,
const HostPtr host,
const IPv6Resrv *const  reservation,
const std::list< std::string > &  option_spaces4,
const ConstCfgOptionPtr  cfg_option4,
const std::list< std::string > &  option_spaces6,
const ConstCfgOptionPtr  cfg_option6 
)
protectedvirtual

Adds/deletes any reservations found in the Host object to/from a separate table entry.

Parameters
insertinsert or deletes a host with reservations
hostHost object from which reservations are retrieved and inserted/deleted into/from the Cassandra database
reservationreservation for the current denormalized table entry
option_spaces4list of option spaces for universe Option::V4 to search in
cfg_option4option configuration for universe Option::V4 used to match option spaces in order to obtain actual options
option_spaces6list of option spaces for universe Option::V6 to search in
cfg_option6option configuration for universe Option::V6 used to match option spaces in order to obtain actual options

Definition at line 1903 of file cql_host_data_source.cc.

References insertOrDeleteHostWithOptions().

Referenced by insertOrDelete().

+ Here is the call graph for this function:

◆ mergeHosts()

void isc::dhcp::CqlHostDataSourceImpl::mergeHosts ( const ConstHostPtr source_host,
HostPtr target_host 
) const
protectedvirtual

Merge denormalized table entries that belong to the same host into a single host, one by one.

Parameters
target_hosthost which can contain multiple reservations and options to which other distinct reservations and options are added.
source_hosthost that is being search for new reservations and options that will be merged into the old host.

Definition at line 2031 of file cql_host_data_source.cc.

Referenced by getHostCollection().


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