Kea  1.5.0
isc::dhcp::CqlHostExchange Class Reference

Provides mechanisms for sending and retrieving data from the host_reservations table. More...

+ Inheritance diagram for isc::dhcp::CqlHostExchange:

Public Member Functions

 CqlHostExchange ()
 Constructor. More...
 
virtual ~CqlHostExchange ()
 Virtual destructor. More...
 
void createBindForDelete (const HostPtr &host, const OptionalValue< SubnetID > &subnet_id, const IPv6Resrv *const reservation, const std::string &option_space, const OptionDescriptor &option_descriptor, StatementTag statement_tag, AnyArray &data)
 Binds Host to data array to send data to the Cassandra database. More...
 
void createBindForMutation (const HostPtr &host, const OptionalValue< SubnetID > &subnet_id, const IPv6Resrv *const reservation, const std::string &option_space, const OptionDescriptor &option_descriptor, StatementTag statement_tag, AnyArray &data)
 Binds Host to data array to send data to the Cassandra database. More...
 
cass_int64_t hashIntoId () const
 Create unique hash for storage in table id. More...
 
void prepareExchange (const HostPtr &host, const OptionalValue< SubnetID > &subnet_id, const IPv6Resrv *const reservation, const std::string &option_space, const OptionDescriptor &option_descriptor)
 Sets the exchange members with data of Host. More...
 
virtual boost::any retrieve () override
 Copy received data into Host object. More...
 
const OptionWrapper retrieveOption () const
 Retrieves option from members. More...
 
const IPv6Resrv retrieveReservation () const
 Creates IPv6 reservation from the data contained in the currently processed row. More...
 
virtual void createBindForSelect (AnyArray &data, StatementTag statement_tag=NULL) override
 Binds member variables to data array to receive Host data. More...
 
- Public Member Functions inherited from isc::db::CqlExchange
 CqlExchange ()
 Constructor. More...
 
virtual ~CqlExchange ()
 Destructor. More...
 
void executeMutation (const CqlConnection &connection, const AnyArray &assigned_values, StatementTag statement_tag)
 Executes INSERT, UPDATE or DELETE statements. More...
 
AnyArray executeSelect (const CqlConnection &connection, const AnyArray &where_values, StatementTag statement_tag, const bool &single=false)
 Executes SELECT statements. More...
 
bool statementApplied (CassFuture *future, size_t *row_count=NULL, size_t *column_count=NULL)
 Check if CQL statement has been applied. More...
 
- Public Member Functions inherited from isc::db::SqlExchange
 SqlExchange ()
 Constructor. More...
 
virtual ~SqlExchange ()
 Destructor. More...
 

Static Public Attributes

static StatementMap tagged_statements_
 Cassandra statements. More...
 
static constexpr StatementTag INSERT_HOST
 Statement tags definitions. More...
 
static constexpr StatementTag GET_HOST
 
static constexpr StatementTag GET_HOST_BY_HOST_ID
 
static constexpr StatementTag GET_HOST_BY_IPV4_ADDRESS
 
static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID
 
static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID
 
static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS
 
static constexpr StatementTag GET_HOST_BY_IPV6_PREFIX
 
static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS
 
static constexpr StatementTag DELETE_HOST
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::db::CqlExchange
static void convertToDatabaseTime (const time_t &cltt, const uint32_t &valid_lifetime, cass_int64_t &expire)
 
static void convertFromDatabaseTime (const cass_int64_t &expire, const cass_int64_t &valid_lifetime, time_t &cltt)
 Converts time from Cassandra format. More...
 

Detailed Description

Provides mechanisms for sending and retrieving data from the host_reservations table.

Definition at line 144 of file cql_host_data_source.cc.

Constructor & Destructor Documentation

◆ CqlHostExchange()

isc::dhcp::CqlHostExchange::CqlHostExchange ( )

Constructor.

Specifies table columns.

Definition at line 768 of file cql_host_data_source.cc.

◆ ~CqlHostExchange()

isc::dhcp::CqlHostExchange::~CqlHostExchange ( )
virtual

Virtual destructor.

Definition at line 785 of file cql_host_data_source.cc.

Member Function Documentation

◆ createBindForDelete()

void isc::dhcp::CqlHostExchange::createBindForDelete ( const HostPtr host,
const OptionalValue< SubnetID > &  subnet_id,
const IPv6Resrv *const  reservation,
const std::string &  option_space,
const OptionDescriptor option_descriptor,
StatementTag  statement_tag,
AnyArray data 
)

Binds Host to data array to send data to the Cassandra database.

Fills in the bind array for sending data stored in the Host object to the database.

Parameters
hostHost object being deleted from the Cassandra database
subnet_ididentifier of the subnet to which the host belongs
reservationIPv6 reservation belonging to the host
option_spaceoption space
option_descriptorstructure used to hold option information
statement_tagtag of the statement being executed
dataarray being filled with data from to the Host object

Definition at line 1105 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), DELETE_HOST, isc_throw, prepareExchange(), and isc::Exception::what().

Referenced by isc::dhcp::CqlHostDataSourceImpl::insertOrDeleteHost().

+ Here is the call graph for this function:

◆ createBindForMutation()

void isc::dhcp::CqlHostExchange::createBindForMutation ( const HostPtr host,
const OptionalValue< SubnetID > &  subnet_id,
const IPv6Resrv *const  reservation,
const std::string &  option_space,
const OptionDescriptor option_descriptor,
StatementTag  statement_tag,
AnyArray data 
)

Binds Host to data array to send data to the Cassandra database.

Fills in the bind array for sending data stored in the Host object to the database.

Parameters
hostHost object being added to the Cassandra database
subnet_ididentifier of the subnet to which the host belongs
reservationIPv6 reservation belonging to the host
option_spaceoption space
option_descriptorstructure used to hold option information
statement_tagtag of the statement being executed
dataarray being filled with data from to the Host object

Definition at line 1049 of file cql_host_data_source.cc.

References isc::db::AnyArray::add(), INSERT_HOST, isc_throw, prepareExchange(), and isc::Exception::what().

Referenced by isc::dhcp::CqlHostDataSourceImpl::insertOrDeleteHost().

+ Here is the call graph for this function:

◆ createBindForSelect()

void isc::dhcp::CqlHostExchange::createBindForSelect ( AnyArray data,
StatementTag  statement_tag = NULL 
)
overridevirtual

Binds member variables to data array to receive Host data.

Creates a bind array to receive Host data from the Cassandra database. After data is successfully received, retrieve() can be called to retrieve the Host object. Called in db::CqlExchange::executeSelect().

Parameters
dataarray of objects representing data being retrieved
statement_tagprepared statement being executed; defaults to an invalid statement

Denormalized reservation columns

Implements isc::db::CqlExchange.

Definition at line 789 of file cql_host_data_source.cc.

References isc::db::AnyArray::add().

+ Here is the call graph for this function:

◆ hashIntoId()

cass_int64_t isc::dhcp::CqlHostExchange::hashIntoId ( ) const

Create unique hash for storage in table id.

Hash function used for creating a pseudo-unique hash from member values which uniquely determine an entry in the table. Uses FNV-1a on 64 bits.

The primary key aggregates: host_ipv4_subnet_id, host_ipv6_subnet_id, host_ipv4_address, reserved_ipv6_prefix_address, reserved_ipv6_prefix_length, option_code, option_space.

Definition at line 1130 of file cql_host_data_source.cc.

References isc::dhcp::DUID::MAX_DUID_LEN, and isc::dhcp::DUID::toText().

Referenced by prepareExchange().

+ Here is the call graph for this function:

◆ prepareExchange()

void isc::dhcp::CqlHostExchange::prepareExchange ( const HostPtr host,
const OptionalValue< SubnetID > &  subnet_id,
const IPv6Resrv *const  reservation,
const std::string &  option_space,
const OptionDescriptor option_descriptor 
)

Sets the exchange members with data of Host.

Fills in the members of the exchange with data from Host object.

Parameters
hostHost object being modified in the Cassandra database
subnet_ididentifier of the subnet to which the host belongs
reservationIPv6 reservation belonging to the host
option_spaceoption space
option_descriptorstructure used to hold option information
Todo:
: We don't support iaid in the IPv6Resrv yet.
Todo:
Assign actual value to client class string. See #5503.

Definition at line 858 of file cql_host_data_source.cc.

References isc::dhcp::OptionDescriptor::formatted_value_, isc::data::UserContext::getContext(), isc::dhcp::IPv6Resrv::getPrefix(), isc::dhcp::IPv6Resrv::getPrefixLen(), isc::dhcp::IPv6Resrv::getType(), hashIntoId(), isc_throw, isc::util::OptionalValue< T >::isSpecified(), isc::dhcp::DUID::MAX_DUID_LEN, isc::dhcp::OptionDescriptor::option_, isc::dhcp::OptionDescriptor::persistent_, isc::asiolink::IOAddress::toText(), isc::dhcp::IPv6Resrv::TYPE_NA, and isc::Exception::what().

Referenced by createBindForDelete(), and createBindForMutation().

+ Here is the call graph for this function:

◆ retrieve()

boost::any isc::dhcp::CqlHostExchange::retrieve ( )
overridevirtual

Copy received data into Host object.

Copies information about the host into a newly created Host object Called in executeSelect after createBindForSelect().

Returns
Host Pointer to a HostPtr object holding a pointer to the Host object returned.

Implements isc::db::CqlExchange.

Definition at line 1164 of file cql_host_data_source.cc.

References isc::dhcp::Host::addReservation(), isc::dhcp::Host::getCfgOption4(), isc::dhcp::Host::getCfgOption6(), isc::dhcp::Host::hasReservation(), isc_throw, retrieveOption(), retrieveReservation(), isc::data::UserContext::setContext(), isc::dhcp::Host::setHostId(), isc::dhcp::Option::V4, isc::dhcp::Option::V6, and isc::Exception::what().

+ Here is the call graph for this function:

◆ retrieveOption()

const OptionWrapper isc::dhcp::CqlHostExchange::retrieveOption ( ) const

Retrieves option from members.

Called after createBindForSelect().

Returns
OptionDescriptorPtr object (containing the option from the database)

Definition at line 1254 of file cql_host_data_source.cc.

References DHCP4_OPTION_SPACE, DHCP6_OPTION_SPACE, isc::dhcp::LibDHCP::getOptionDef(), isc::dhcp::LibDHCP::getRuntimeOptionDef(), isc::dhcp::LibDHCP::getVendorOptionDef(), isc_throw, isc::dhcp::LibDHCP::optionSpaceToVendorId(), and isc::Exception::what().

Referenced by retrieve().

+ Here is the call graph for this function:

◆ retrieveReservation()

const IPv6Resrv isc::dhcp::CqlHostExchange::retrieveReservation ( ) const

Creates IPv6 reservation from the data contained in the currently processed row.

Called after createBindForSelect().

Returns
IPv6Resrv object (containing IPv6 address or prefix reservation)

Definition at line 1231 of file cql_host_data_source.cc.

References isc_throw, isc::dhcp::IPv6Resrv::TYPE_NA, and isc::dhcp::IPv6Resrv::TYPE_PD.

Referenced by retrieve().

Member Data Documentation

◆ DELETE_HOST

constexpr StatementTag isc::dhcp::CqlHostExchange::DELETE_HOST
static
Initial value:
=
"DELETE_HOST"

Definition at line 312 of file cql_host_data_source.cc.

Referenced by createBindForDelete(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDeleteHost().

◆ GET_HOST

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST
static
Initial value:
=
"GET_HOST"

Definition at line 268 of file cql_host_data_source.cc.

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

◆ GET_HOST_BY_HOST_ID

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_BY_HOST_ID
static
Initial value:
=
"GET_HOST_BY_HOST_ID"

Definition at line 273 of file cql_host_data_source.cc.

Referenced by isc::dhcp::CqlHostDataSourceImpl::getAll().

◆ GET_HOST_BY_IPV4_ADDRESS

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV4_ADDRESS
static
Initial value:
=
"GET_HOST_BY_IPV4_ADDRESS"

Definition at line 278 of file cql_host_data_source.cc.

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

◆ GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS
static
Initial value:
=
"GET_HOST_BY_IPV4_SUBNET_ID_AND_ADDRESS"

Definition at line 294 of file cql_host_data_source.cc.

Referenced by isc::dhcp::CqlHostDataSourceImpl::get4().

◆ GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID
static
Initial value:
=
"GET_HOST_BY_IPV4_SUBNET_ID_AND_HOST_ID"

Definition at line 283 of file cql_host_data_source.cc.

Referenced by isc::dhcp::CqlHostDataSourceImpl::get4().

◆ GET_HOST_BY_IPV6_PREFIX

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV6_PREFIX
static
Initial value:
=
"GET_HOST_BY_IPV6_PREFIX"

Definition at line 303 of file cql_host_data_source.cc.

Referenced by isc::dhcp::CqlHostDataSourceImpl::get6().

◆ GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS
static
Initial value:
=
"GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS"

Definition at line 308 of file cql_host_data_source.cc.

Referenced by isc::dhcp::CqlHostDataSourceImpl::get6().

◆ GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID
static
Initial value:
=
"GET_HOST_BY_IPV6_SUBNET_ID_AND_HOST_ID"

Definition at line 289 of file cql_host_data_source.cc.

Referenced by isc::dhcp::CqlHostDataSourceImpl::get6().

◆ INSERT_HOST

constexpr StatementTag isc::dhcp::CqlHostExchange::INSERT_HOST
static
Initial value:
=
"INSERT_HOST"

Statement tags definitions.

Definition at line 263 of file cql_host_data_source.cc.

Referenced by createBindForMutation(), and isc::dhcp::CqlHostDataSourceImpl::insertOrDeleteHost().

◆ tagged_statements_

StatementMap isc::dhcp::CqlHostExchange::tagged_statements_
static

Cassandra statements.

Definition at line 317 of file cql_host_data_source.cc.

Referenced by isc::dhcp::CqlHostDataSourceImpl::CqlHostDataSourceImpl().


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