Kea  1.5.0
isc::dhcp::CqlLease4Exchange Class Reference

Exchange Lease4 information between Kea and CQL. More...

+ Inheritance diagram for isc::dhcp::CqlLease4Exchange:

Public Member Functions

 CqlLease4Exchange (const CqlConnection &connection)
 Constructor. More...
 
void createBindForDelete (const IOAddress &address, AnyArray &data, StatementTag statement_tag=NULL)
 Create CQL_BIND objects for Lease4 Pointer. More...
 
void createBindForInsert (const Lease4Ptr &lease, AnyArray &data)
 Create CQL_BIND objects for Lease4 Pointer. More...
 
virtual void createBindForSelect (AnyArray &data, StatementTag statement_tag=NULL) override
 Create BIND array to receive data. More...
 
void createBindForUpdate (const Lease4Ptr &lease, AnyArray &data, StatementTag statement_tag=NULL)
 Create CQL_BIND objects for Lease4 Pointer. More...
 
void getExpiredLeases (const size_t &max_leases, Lease4Collection &expired_leases)
 Returns expired leases. More...
 
void getLease (StatementTag &statement_tag, AnyArray &data, Lease4Ptr &result)
 Retrieves one IPv4 lease. More...
 
void getLeaseCollection (StatementTag &statement_tag, AnyArray &data, Lease4Collection &result)
 Retrieves zero or more IPv4 leases. More...
 
virtual boost::any retrieve () override
 Retrieves the Lease4 object in Kea format. More...
 
- Public Member Functions inherited from isc::dhcp::CqlLeaseExchange
 CqlLeaseExchange (const CqlConnection &connection)
 Constructor. 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_LEASE4 = "INSERT_LEASE4"
 Statement tags definitions. More...
 
static constexpr StatementTag UPDATE_LEASE4 = "UPDATE_LEASE4"
 
static constexpr StatementTag DELETE_LEASE4 = "DELETE_LEASE4"
 
static constexpr StatementTag GET_LEASE4_EXPIRE = "GET_LEASE4_EXPIRE"
 
static constexpr StatementTag GET_LEASE4 = "GET_LEASE4"
 
static constexpr StatementTag GET_LEASE4_ADDR = "GET_LEASE4_ADDR"
 
static constexpr StatementTag GET_LEASE4_CLIENTID = "GET_LEASE4_CLIENTID"
 
static constexpr StatementTag GET_LEASE4_CLIENTID_SUBID = "GET_LEASE4_CLIENTID_SUBID"
 
static constexpr StatementTag GET_LEASE4_HWADDR = "GET_LEASE4_HWADDR"
 
static constexpr StatementTag GET_LEASE4_HWADDR_SUBID = "GET_LEASE4_HWADDR_SUBID"
 
static constexpr StatementTag GET_LEASE4_LIMIT = "GET_LEASE4_LIMIT"
 
static constexpr StatementTag GET_LEASE4_PAGE = "GET_LEASE4_PAGE"
 
static constexpr StatementTag GET_LEASE4_SUBID = "GET_LEASE4_SUBID"
 

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...
 
- Protected Attributes inherited from isc::dhcp::CqlLeaseExchange
const CqlConnectionconnection_
 Database connection. More...
 
cass_int64_t expire_
 Lease expiry time. More...
 
cass_bool_t fqdn_fwd_
 Has forward DNS update been performed? More...
 
cass_bool_t fqdn_rev_
 Has reverse DNS update been performed? More...
 
std::string hostname_
 Client hostname. More...
 
CassBlob hwaddr_
 Hardware address. More...
 
cass_int32_t state_
 Lease state. More...
 
cass_int32_t subnet_id_
 Subnet identifier. More...
 
std::string user_context_
 User context. More...
 
cass_int64_t valid_lifetime_
 Lease timer. More...
 

Detailed Description

Exchange Lease4 information between Kea and CQL.

On any CQL operation, arrays of CQL BIND structures must be built to describe the parameters in the prepared statements. Where information is inserted or retrieved - INSERT, UPDATE, SELECT - a large amount of that structure is identical. This class handles the creation of that array.

Owing to the CQL API, the process requires some intermediate variables to hold things like data length etc. This object holds those variables.

Note
There are no unit tests for this class. It is tested indirectly in all CqlLeaseMgr::xxx4() calls where it is used.

Definition at line 121 of file cql_lease_mgr.cc.

Constructor & Destructor Documentation

◆ CqlLease4Exchange()

isc::dhcp::CqlLease4Exchange::CqlLease4Exchange ( const CqlConnection connection)
explicit

Constructor.

The initialization of the variables here is only to satisfy cppcheck - all variables are initialized/set in the methods before they are used.

Parameters
connectionconnection used for this query

Definition at line 399 of file cql_lease_mgr.cc.

Member Function Documentation

◆ createBindForDelete()

void isc::dhcp::CqlLease4Exchange::createBindForDelete ( const IOAddress address,
AnyArray data,
StatementTag  statement_tag = NULL 
)

Create CQL_BIND objects for Lease4 Pointer.

Fills in the CQL_BIND array for sending data in the Lease4 object to the database. Used for DELETE statements.

Parameters
addressaddress of the lease to be deleted
datalease info in CQL format will be stored here
statement_tagtag identifying the query (optional)

Definition at line 610 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc_throw, isc::asiolink::IOAddress::toUint32(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ createBindForInsert()

void isc::dhcp::CqlLease4Exchange::createBindForInsert ( const Lease4Ptr lease,
AnyArray data 
)

Create CQL_BIND objects for Lease4 Pointer.

Fills in the CQL_BIND array for sending data in the Lease4 object to the database. Used for INSERT statements.

Parameters
leaseThe lease information to be inserted
dataLease info will be stored here in CQL format

(cltt_)

Definition at line 404 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlLeaseExchange::expire_, isc::dhcp::CqlLeaseExchange::fqdn_fwd_, isc::dhcp::CqlLeaseExchange::fqdn_rev_, isc::dhcp::CqlLeaseExchange::hostname_, isc::dhcp::CqlLeaseExchange::hwaddr_, isc_throw, isc::dhcp::HWAddr::MAX_HWADDR_LEN, isc::dhcp::CqlLeaseExchange::state_, isc::dhcp::CqlLeaseExchange::subnet_id_, isc::dhcp::CqlLeaseExchange::user_context_, isc::dhcp::CqlLeaseExchange::valid_lifetime_, and isc::Exception::what().

+ Here is the call graph for this function:

◆ createBindForSelect()

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

Create BIND array to receive data.

Creates a CQL_BIND array to receive Lease4 data from the database.

Parameters
datainfo returned by CQL will be stored here
statement_tagtag identifying the query (optional)

Implements isc::dhcp::CqlLeaseExchange.

Definition at line 632 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlLeaseExchange::expire_, isc::dhcp::CqlLeaseExchange::fqdn_fwd_, isc::dhcp::CqlLeaseExchange::fqdn_rev_, isc::dhcp::CqlLeaseExchange::hostname_, isc::dhcp::CqlLeaseExchange::hwaddr_, isc::dhcp::CqlLeaseExchange::state_, isc::dhcp::CqlLeaseExchange::subnet_id_, isc::dhcp::CqlLeaseExchange::user_context_, and isc::dhcp::CqlLeaseExchange::valid_lifetime_.

+ Here is the call graph for this function:

◆ createBindForUpdate()

void isc::dhcp::CqlLease4Exchange::createBindForUpdate ( const Lease4Ptr lease,
AnyArray data,
StatementTag  statement_tag = NULL 
)

Create CQL_BIND objects for Lease4 Pointer.

Fills in the CQL_BIND array for sending data in the Lease4 object to the database. Used for UPDATE statements.

Parameters
leaseUpdated lease information.
datalease info in CQL format will be stored here
statement_tagtag identifying the query (optional)

(cltt_)

Definition at line 506 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::CqlLeaseExchange::expire_, isc::dhcp::CqlLeaseExchange::fqdn_fwd_, isc::dhcp::CqlLeaseExchange::fqdn_rev_, isc::dhcp::CqlLeaseExchange::hostname_, isc::dhcp::CqlLeaseExchange::hwaddr_, isc_throw, isc::dhcp::HWAddr::MAX_HWADDR_LEN, isc::dhcp::CqlLeaseExchange::state_, isc::dhcp::CqlLeaseExchange::subnet_id_, isc::dhcp::CqlLeaseExchange::user_context_, isc::dhcp::CqlLeaseExchange::valid_lifetime_, and isc::Exception::what().

+ Here is the call graph for this function:

◆ getExpiredLeases()

void isc::dhcp::CqlLease4Exchange::getExpiredLeases ( const size_t &  max_leases,
Lease4Collection expired_leases 
)

Returns expired leases.

This method returns up to specified number (see max_leases) of expired leases.

Parameters
max_leasesat most this number of leases will be returned
expired_leasesexpired leases will be stored here

Definition at line 768 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), GET_LEASE4_EXPIRE, getLeaseCollection(), isc::dhcp::Lease::STATE_DEFAULT, and isc::dhcp::Lease::STATE_EXPIRED_RECLAIMED.

+ Here is the call graph for this function:

◆ getLease()

void isc::dhcp::CqlLease4Exchange::getLease ( StatementTag statement_tag,
AnyArray data,
Lease4Ptr result 
)

Retrieves one IPv4 lease.

Parameters
statement_tagquery to be executed
dataparameters for the query
resultpointer to the lease being returned (or null)

Definition at line 746 of file cql_lease_mgr.cc.

References getLeaseCollection(), and isc_throw.

+ Here is the call graph for this function:

◆ getLeaseCollection()

void isc::dhcp::CqlLease4Exchange::getLeaseCollection ( StatementTag statement_tag,
AnyArray data,
Lease4Collection result 
)

Retrieves zero or more IPv4 leases.

Parameters
statement_tagquery to be executed
dataparameters for the query
resultthis lease collection will be updated

Definition at line 735 of file cql_lease_mgr.cc.

References isc::dhcp::CqlLeaseExchange::connection_, and isc::db::CqlExchange::executeSelect().

Referenced by getExpiredLeases(), and getLease().

+ Here is the call graph for this function:

◆ retrieve()

Member Data Documentation

◆ DELETE_LEASE4

constexpr StatementTag isc::dhcp::CqlLease4Exchange::DELETE_LEASE4 = "DELETE_LEASE4"
static

Definition at line 213 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::deleteLease().

◆ GET_LEASE4

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4 = "GET_LEASE4"
static

Definition at line 217 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLeases4().

◆ GET_LEASE4_ADDR

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_ADDR = "GET_LEASE4_ADDR"
static

Definition at line 219 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLease4().

◆ GET_LEASE4_CLIENTID

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_CLIENTID = "GET_LEASE4_CLIENTID"
static

Definition at line 221 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLease4().

◆ GET_LEASE4_CLIENTID_SUBID

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_CLIENTID_SUBID = "GET_LEASE4_CLIENTID_SUBID"
static

Definition at line 223 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLease4().

◆ GET_LEASE4_EXPIRE

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_EXPIRE = "GET_LEASE4_EXPIRE"
static

◆ GET_LEASE4_HWADDR

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_HWADDR = "GET_LEASE4_HWADDR"
static

Definition at line 225 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLease4().

◆ GET_LEASE4_HWADDR_SUBID

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_HWADDR_SUBID = "GET_LEASE4_HWADDR_SUBID"
static

Definition at line 227 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLease4().

◆ GET_LEASE4_LIMIT

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_LIMIT = "GET_LEASE4_LIMIT"
static

Definition at line 229 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLeases4().

◆ GET_LEASE4_PAGE

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_PAGE = "GET_LEASE4_PAGE"
static

Definition at line 231 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLeases4().

◆ GET_LEASE4_SUBID

constexpr StatementTag isc::dhcp::CqlLease4Exchange::GET_LEASE4_SUBID = "GET_LEASE4_SUBID"
static

Definition at line 233 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::getLeases4().

◆ INSERT_LEASE4

constexpr StatementTag isc::dhcp::CqlLease4Exchange::INSERT_LEASE4 = "INSERT_LEASE4"
static

Statement tags definitions.

Definition at line 209 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::addLease().

◆ tagged_statements_

StatementMap isc::dhcp::CqlLease4Exchange::tagged_statements_
static

Cassandra statements.

Definition at line 204 of file cql_lease_mgr.cc.

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

◆ UPDATE_LEASE4

constexpr StatementTag isc::dhcp::CqlLease4Exchange::UPDATE_LEASE4 = "UPDATE_LEASE4"
static

Definition at line 211 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::updateLease4().


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