Kea  1.9.9-git
isc::db::CqlExchange Class Referenceabstract

Cassandra Exchange. More...

#include <cql_exchange.h>

+ Inheritance diagram for isc::db::CqlExchange:

Public Member Functions

 CqlExchange ()
 Constructor. More...
 
virtual ~CqlExchange ()
 Destructor. More...
 
virtual void createBindForSelect (AnyArray &data, StatementTag statement_tag=NULL)=0
 Create BIND array to receive C++ data. 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...
 
virtual boost::any retrieve ()=0
 Copy received data into the derived class' object. 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 Member Functions

Time conversion:

Converts time to Cassandra format

Parameters
cltttimestamp of last client transmission time to be converted
valid_lifetimelifetime of a lease
expireexpiration time (result will be stored here)
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

Cassandra Exchange.

Used to convert between Cassandra CQL and C++ data types. A different exchange is made for every distinct set of columns. Multiple tables may use the same exchange if they have the same columns.

Definition at line 142 of file cql_exchange.h.

Constructor & Destructor Documentation

isc::db::CqlExchange::CqlExchange ( )

Constructor.

Empty body. Derived constructors specify table columns.

Definition at line 736 of file cql_exchange.cc.

isc::db::CqlExchange::~CqlExchange ( )
virtual

Destructor.

Definition at line 739 of file cql_exchange.cc.

Member Function Documentation

void isc::db::CqlExchange::convertFromDatabaseTime ( const cass_int64_t &  expire,
const cass_int64_t &  valid_lifetime,
time_t &  cltt 
)
static

Converts time from Cassandra format.

Parameters
expireexpiration time in Cassandra format
valid_lifetimelifetime of a lease
clttclient last transmission time (result will be stored here)

Definition at line 754 of file cql_exchange.cc.

Referenced by isc::dhcp::CqlLease4Exchange::retrieve(), and isc::dhcp::CqlLease6Exchange::retrieve().

virtual void isc::db::CqlExchange::createBindForSelect ( AnyArray data,
StatementTag  statement_tag = NULL 
)
pure virtual

Create BIND array to receive C++ data.

Used in executeSelect() to retrieve from database

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

Implemented in isc::dhcp::CqlLease6Exchange, isc::db::CqlVersionExchange, isc::dhcp::CqlLease4Exchange, isc::dhcp::CqlHostExchange, and isc::dhcp::CqlLeaseExchange.

Referenced by executeSelect().

void isc::db::CqlExchange::executeMutation ( const CqlConnection connection,
const AnyArray assigned_values,
StatementTag  statement_tag 
)

Executes INSERT, UPDATE or DELETE statements.

Parameters
connectionconnection used to communicate with the Cassandra database
assigned_valuesarray of bound objects to be used when inserting values
statement_tagprepared statement being executed applied, could be different for commit than it is for rollback

Definition at line 874 of file cql_exchange.cc.

References isc::db::CqlCommon::bindData(), isc::db::CqlConnection::checkFutureError(), isc::db::CqlConnection::consistency_, isc::db::error, isc::db::CqlConnection::force_consistency_, isc_throw, isc::db::CqlTaggedStatement::name_, isc::db::CqlTaggedStatement::prepared_statement_, isc::db::CqlConnection::serial_consistency_, isc::db::CqlConnection::session_, statementApplied(), and isc::db::CqlConnection::statements_.

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

+ Here is the call graph for this function:

AnyArray isc::db::CqlExchange::executeSelect ( const CqlConnection connection,
const AnyArray where_values,
StatementTag  statement_tag,
const bool &  single = false 
)

Executes SELECT statements.

Parameters
connectionconnection used to communicate with the Cassandra database
where_valuesarray of bound objects used to filter the results
statement_tagprepared statement being executed
singletrue if a single row should be returned; by default, multiple rows are allowed
Returns
collection of boost::any objects
Exceptions
DbOperationError
MultipleRecords

Definition at line 762 of file cql_exchange.cc.

References isc::db::AnyArray::add(), isc::db::CqlCommon::bindData(), isc::db::CqlConnection::checkFutureError(), isc::db::CqlConnection::consistency_, createBindForSelect(), isc::db::error, isc::db::CqlConnection::force_consistency_, isc::db::CqlCommon::getData(), isc::db::CqlTaggedStatement::is_raw_, isc_throw, isc::db::CqlTaggedStatement::name_, isc::db::CqlTaggedStatement::prepared_statement_, retrieve(), isc::db::CqlConnection::serial_consistency_, isc::db::CqlConnection::session_, and isc::db::CqlConnection::statements_.

Referenced by isc::dhcp::CqlHostDataSourceImpl::getHostCollection(), isc::dhcp::CqlHostDataSourceImpl::getHostKey(), isc::dhcp::CqlHostDataSourceImpl::getHostKey4(), isc::dhcp::CqlHostDataSourceImpl::getHostKey6(), isc::dhcp::CqlLease4Exchange::getLeaseCollection(), isc::dhcp::CqlLease6Exchange::getLeaseCollection(), isc::dhcp::CqlHostDataSourceImpl::getNextHostKey(), isc::dhcp::CqlHostDataSourceImpl::getNextHostKey4(), isc::dhcp::CqlHostDataSourceImpl::getNextHostKey6(), and isc::db::CqlVersionExchange::retrieveVersion().

+ Here is the call graph for this function:

virtual boost::any isc::db::CqlExchange::retrieve ( )
pure virtual

Copy received data into the derived class' object.

Copies information about the entity to be retrieved into a holistic object. Called in executeSelect(). Not implemented for base class CqlExchange. To be implemented in derived classes.

Returns
a pointer to the object retrieved.

Implemented in isc::dhcp::CqlLease6Exchange, isc::db::CqlVersionExchange, isc::dhcp::CqlHostExchange, isc::dhcp::CqlLease4Exchange, and isc::dhcp::CqlLeaseExchange.

Referenced by executeSelect().

bool isc::db::CqlExchange::statementApplied ( CassFuture *  future,
size_t *  row_count = NULL,
size_t *  column_count = NULL 
)

Check if CQL statement has been applied.

Parameters
futurestructure used to wait on statement executions
row_countnumber of rows returned
column_countnumber of columns queried

On insert, a false [applied] means there is a duplicate entry with the same primary key.

Returns
true if statement has been successfully applied, false otherwise

Definition at line 953 of file cql_exchange.cc.

References isc::db::AnyArray::add(), isc::db::CqlCommon::getData(), and isc_throw.

Referenced by executeMutation().

+ Here is the call graph for this function:


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