Kea  1.9.9-git
isc::dhcp::CqlHostExchange Class Reference

Provides mechanisms for sending and retrieving data from the hosts 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 Optional< 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 Optional< 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...
 
virtual void createBindForSelect (AnyArray &data, StatementTag statement_tag=NULL) override
 Binds member variables to data array to receive Host data. More...
 
uint64_t hashIntoId () const
 Create unique hash for storage in table id. More...
 
uint64_t hashIntoKey () const
 Create unique key for storage in table key. More...
 
std::string hostKey () const
 Create unique key string for a host. More...
 
void prepareExchange (const HostPtr &host, const Optional< 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...
 
- 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 = "INSERT_HOST"
 Statement tags. More...
 
static constexpr StatementTag GET_HOST = "GET_HOST"
 
static constexpr StatementTag GET_HOST_BY_HOST_ID = "GET_HOST_BY_HOST_ID"
 
static constexpr StatementTag GET_HOST_BY_IPV4_ADDRESS = "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 = "GET_HOST_BY_IPV6_PREFIX"
 
static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_AND_ADDRESS
 
static constexpr StatementTag DELETE_HOST
 
static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID
 
static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID
 
static constexpr StatementTag GET_HOST_BY_HOST_NAME
 
static constexpr StatementTag GET_HOST_BY_HOST_NAME_AND_IPV4_SUBNET_ID
 
static constexpr StatementTag GET_HOST_BY_HOST_NAME_AND_IPV6_SUBNET_ID
 
static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_LIMIT
 
static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_NEXT_KEY
 
static constexpr StatementTag GET_HOST_BY_IPV4_SUBNET_ID_PAGE
 
static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_LIMIT
 
static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_NEXT_KEY
 
static constexpr StatementTag GET_HOST_BY_IPV6_SUBNET_ID_PAGE
 
static constexpr StatementTag GET_HOST_LIMIT = "GET_HOST_LIMIT"
 
static constexpr StatementTag GET_HOST_KEY = "GET_HOST_KEY"
 
static constexpr StatementTag GET_HOST_NEXT_KEY = "GET_HOST_NEXT_KEY"
 
static constexpr StatementTag GET_HOST_PAGE = "GET_HOST_PAGE"
 

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 hosts table.

Definition at line 126 of file cql_host_data_source.cc.

Constructor & Destructor Documentation

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

Constructor.

Specifies table columns.

Definition at line 1436 of file cql_host_data_source.cc.

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

Virtual destructor.

Definition at line 1453 of file cql_host_data_source.cc.

Member Function Documentation

void isc::dhcp::CqlHostExchange::createBindForDelete ( const HostPtr host,
const Optional< 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 1790 of file cql_host_data_source.cc.

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

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

+ Here is the call graph for this function:

void isc::dhcp::CqlHostExchange::createBindForMutation ( const HostPtr host,
const Optional< 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 1732 of file cql_host_data_source.cc.

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

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

+ Here is the call graph for this function:

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 1457 of file cql_host_data_source.cc.

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

+ Here is the call graph for this function:

uint64_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 clustering column aggregates: host_identifier, host_identifier_type, 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 1816 of file cql_host_data_source.cc.

References hostKey(), and isc::dhcp::OPTION_SPACE_MAX_LEN.

Referenced by prepareExchange().

+ Here is the call graph for this function:

uint64_t isc::dhcp::CqlHostExchange::hashIntoKey ( ) const

Create unique key for storage in table key.

The primary key partition key aggregates: host_identifier, host_identifier_type, host_ipv4_subnet_id, host_ipv6_subnet_id, host_ipv4_address

Definition at line 1836 of file cql_host_data_source.cc.

References hostKey().

Referenced by isc::dhcp::CqlHostDataSourceImpl::getHostKey(), isc::dhcp::CqlHostDataSourceImpl::getHostKey4(), isc::dhcp::CqlHostDataSourceImpl::getHostKey6(), isc::dhcp::CqlHostDataSourceImpl::getNextHostKey(), isc::dhcp::CqlHostDataSourceImpl::getNextHostKey4(), isc::dhcp::CqlHostDataSourceImpl::getNextHostKey6(), and prepareExchange().

+ Here is the call graph for this function:

std::string isc::dhcp::CqlHostExchange::hostKey ( ) const

Create unique key string for a host.

The primary key partition key aggregates: host_identifier, host_identifier_type, host_ipv4_subnet_id, host_ipv6_subnet_id, host_ipv4_address

Definition at line 1843 of file cql_host_data_source.cc.

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

Referenced by hashIntoId(), and hashIntoKey().

+ Here is the call graph for this function:

void isc::dhcp::CqlHostExchange::prepareExchange ( const HostPtr host,
const Optional< 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 1528 of file cql_host_data_source.cc.

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

Referenced by createBindForDelete(), and createBindForMutation().

+ Here is the call graph for this function:

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 1865 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:

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 1955 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:

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 1932 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

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

Definition at line 304 of file cql_host_data_source.cc.

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

Definition at line 264 of file cql_host_data_source.cc.

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

Definition at line 268 of file cql_host_data_source.cc.

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

Definition at line 319 of file cql_host_data_source.cc.

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

Definition at line 324 of file cql_host_data_source.cc.

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

Definition at line 329 of file cql_host_data_source.cc.

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

Definition at line 272 of file cql_host_data_source.cc.

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

Definition at line 309 of file cql_host_data_source.cc.

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 287 of file cql_host_data_source.cc.

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 276 of file cql_host_data_source.cc.

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

Definition at line 334 of file cql_host_data_source.cc.

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

Definition at line 339 of file cql_host_data_source.cc.

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

Definition at line 344 of file cql_host_data_source.cc.

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

Definition at line 296 of file cql_host_data_source.cc.

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

Definition at line 314 of file cql_host_data_source.cc.

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 300 of file cql_host_data_source.cc.

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 282 of file cql_host_data_source.cc.

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

Definition at line 349 of file cql_host_data_source.cc.

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

Definition at line 354 of file cql_host_data_source.cc.

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

Definition at line 360 of file cql_host_data_source.cc.

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_KEY = "GET_HOST_KEY"
static

Definition at line 369 of file cql_host_data_source.cc.

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_LIMIT = "GET_HOST_LIMIT"
static

Definition at line 365 of file cql_host_data_source.cc.

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_NEXT_KEY = "GET_HOST_NEXT_KEY"
static

Definition at line 373 of file cql_host_data_source.cc.

constexpr StatementTag isc::dhcp::CqlHostExchange::GET_HOST_PAGE = "GET_HOST_PAGE"
static

Definition at line 377 of file cql_host_data_source.cc.

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

Statement tags.

Definition at line 260 of file cql_host_data_source.cc.

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

Cassandra statements.

Definition at line 381 of file cql_host_data_source.cc.


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