Kea  1.5.0
isc::db::CqlConnection Class Reference

Common CQL connector pool. More...

#include <cql_connection.h>

+ Inheritance diagram for isc::db::CqlConnection:

Public Member Functions

 CqlConnection (const ParameterMap &parameters)
 Constructor. More...
 
virtual ~CqlConnection ()
 Destructor. More...
 
virtual void commit ()
 Commit Transactions. More...
 
void openDatabase ()
 Open database. More...
 
void prepareStatements (StatementMap &statements)
 Prepare statements. More...
 
virtual void rollback ()
 Rollback Transactions. More...
 
void setConsistency (bool force, CassConsistency consistency)
 Set consistency. More...
 
void startTransaction ()
 Start transaction. More...
 
- Public Member Functions inherited from isc::db::DatabaseConnection
 DatabaseConnection (const ParameterMap &parameters)
 Constructor. More...
 
virtual ~DatabaseConnection ()
 Destructor. More...
 
bool configuredReadOnly () const
 Convenience method checking if database should be opened with read only access. More...
 
std::string getParameter (const std::string &name) const
 Returns value of a connection parameter. More...
 
bool invokeDbLostCallback () const
 Invokes the connection's lost connectivity callback. More...
 
virtual ReconnectCtlPtr makeReconnectCtl () const
 Instantiates a ReconnectCtl based on the connection's reconnect parameters. More...
 

Static Public Member Functions

static const std::string checkFutureError (const std::string &what, CassFuture *future, StatementTag statement_tag=NULL)
 Check for errors. More...
 
- Static Public Member Functions inherited from isc::db::DatabaseConnection
static ParameterMap parse (const std::string &dbaccess)
 Parse database access string. More...
 
static std::string redactedAccessString (const ParameterMap &parameters)
 Redact database access string. More...
 
static isc::data::ElementPtr toElement (const ParameterMap &params)
 Unparse a parameter map. More...
 
static isc::data::ElementPtr toElementDbAccessString (const std::string &dbaccess)
 Unparse an access string. More...
 

Public Attributes

CassCluster * cluster_
 CQL connection handle. More...
 
CassConsistency consistency_
 CQL consistency. More...
 
bool force_consistency_
 CQL consistency enabled. More...
 
const CassKeyspaceMeta * keyspace_meta_
 Keyspace meta information, used for UDTs. More...
 
const CassSchemaMeta * schema_meta_
 
CassSession * session_
 CQL session handle. More...
 
StatementMap statements_
 Pointer to external array of tagged statements containing statement name, array of names of bind parameters and text query. More...
 

Additional Inherited Members

- Public Types inherited from isc::db::DatabaseConnection
typedef boost::function< bool(ReconnectCtlPtr db_retry)> DbLostCallback
 Defines a callback prototype for propogating events upward. More...
 
typedef std::map< std::string, std::string > ParameterMap
 Database configuration parameter map. More...
 
- Static Public Attributes inherited from isc::db::DatabaseConnection
static DbLostCallback db_lost_callback = 0
 Optional call back function to invoke if a successfully open connection subsequently fails. More...
 
static const time_t MAX_DB_TIME = 2147483647
 Defines maximum value for time that can be reliably stored. More...
 

Detailed Description

Common CQL connector pool.

Provides common operations for the Cassandra database connection used by CqlLeaseMgr, CqlHostDataSource and CqlSrvConfigMgr. Manages the connection to the Cassandra database and preparing of compiled statements. Its fields are public because they are used (both set and retrieved) in classes that use instances of CqlConnection.

Definition at line 119 of file cql_connection.h.

Constructor & Destructor Documentation

◆ CqlConnection()

isc::db::CqlConnection::CqlConnection ( const ParameterMap parameters)
explicit

Constructor.

Initialize CqlConnection object with parameters needed for connection.

Parameters
parametersspecify the connection details (username, ip addresses etc.)

Definition at line 31 of file cql_connection.cc.

◆ ~CqlConnection()

isc::db::CqlConnection::~CqlConnection ( )
virtual

Destructor.

Definition at line 37 of file cql_connection.cc.

References checkFutureError(), cluster_, isc::db::CQL_DEALLOC_ERROR, DB_LOG_ERROR, isc::db::CqlTaggedStatement::prepared_statement_, schema_meta_, session_, and statements_.

+ Here is the call graph for this function:

Member Function Documentation

◆ checkFutureError()

const std::string isc::db::CqlConnection::checkFutureError ( const std::string &  what,
CassFuture *  future,
StatementTag  statement_tag = NULL 
)
static

Check for errors.

Check for errors on the current database operation and returns text description of what happened. In case of success, also returns some logging friendly text.

Parameters
whattext description of the operation
futurethe structure that holds the status of operation
statement_tagstatement that was used (optional)
Returns
text description of the error

Definition at line 367 of file cql_connection.cc.

Referenced by isc::db::CqlExchange::executeMutation(), isc::db::CqlExchange::executeSelect(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), openDatabase(), prepareStatements(), and ~CqlConnection().

◆ commit()

void isc::db::CqlConnection::commit ( )
virtual

Commit Transactions.

Definition at line 357 of file cql_connection.cc.

References isc::db::CQL_CONNECTION_COMMIT, isc::db::DB_DBG_TRACE_DETAIL, and DB_LOG_DEBUG.

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

◆ openDatabase()

void isc::db::CqlConnection::openDatabase ( )

Open database.

Opens the database using the information supplied in the parameters passed to the constructor. If no parameters are supplied, the default values will be used. The parameters supported as as follows (default values specified in parentheses):

  • keyspace: name of the database to which to connect (keatest)
  • contact-points: IP addresses of the nodes to connect to (127.0.0.1)
  • port: The TCP port to use (9042)
  • user - credentials to use when connecting (no username)
  • password - credentails to use when connecting (no password)
  • reconnect-wait-time 2000
  • connect-timeout 5000
  • request-timeout 12000
  • tcp-keepalive no
  • tcp-nodelay no
Exceptions
DbOpenErrorerror opening the database

Definition at line 78 of file cql_connection.cc.

References checkFutureError(), cluster_, isc::db::DatabaseConnection::getParameter(), isc_throw, keyspace_meta_, schema_meta_, session_, and isc::Exception::what().

Referenced by isc::dhcp::CqlHostDataSourceImpl::CqlHostDataSourceImpl(), and isc::dhcp::CqlLeaseMgr::CqlLeaseMgr().

+ Here is the call graph for this function:

◆ prepareStatements()

void isc::db::CqlConnection::prepareStatements ( StatementMap statements)

Prepare statements.

Creates the prepared statements for all of the CQL statements used by the CQL backend.

Parameters
statementsstatements to be prepared
Exceptions
isc::db::DbOperationErrorif an operation on the open database has failed
isc::InvalidParameterif there is an invalid access in the vector. This represents an internal error within the code.

Definition at line 315 of file cql_connection.cc.

References checkFutureError(), isc_throw, isc::db::CqlTaggedStatement::name_, isc::db::CqlTaggedStatement::prepared_statement_, session_, statements_, and isc::db::CqlTaggedStatement::text_.

Referenced by isc::dhcp::CqlHostDataSourceImpl::CqlHostDataSourceImpl(), and isc::dhcp::CqlLeaseMgr::CqlLeaseMgr().

+ Here is the call graph for this function:

◆ rollback()

void isc::db::CqlConnection::rollback ( )
virtual

Rollback Transactions.

Definition at line 362 of file cql_connection.cc.

References isc::db::CQL_CONNECTION_ROLLBACK, isc::db::DB_DBG_TRACE_DETAIL, and DB_LOG_DEBUG.

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

◆ setConsistency()

void isc::db::CqlConnection::setConsistency ( bool  force,
CassConsistency  consistency 
)

Set consistency.

Definition at line 346 of file cql_connection.cc.

References consistency_, and force_consistency_.

◆ startTransaction()

void isc::db::CqlConnection::startTransaction ( )

Start transaction.

Definition at line 352 of file cql_connection.cc.

References isc::db::CQL_CONNECTION_BEGIN_TRANSACTION, isc::db::DB_DBG_TRACE_DETAIL, and DB_LOG_DEBUG.

Member Data Documentation

◆ cluster_

CassCluster* isc::db::CqlConnection::cluster_

CQL connection handle.

Definition at line 194 of file cql_connection.h.

Referenced by openDatabase(), and ~CqlConnection().

◆ consistency_

CassConsistency isc::db::CqlConnection::consistency_

◆ force_consistency_

bool isc::db::CqlConnection::force_consistency_

◆ keyspace_meta_

const CassKeyspaceMeta* isc::db::CqlConnection::keyspace_meta_

Keyspace meta information, used for UDTs.

Definition at line 206 of file cql_connection.h.

Referenced by openDatabase(), and isc::db::Udt::Udt().

◆ schema_meta_

const CassSchemaMeta* isc::db::CqlConnection::schema_meta_

Definition at line 203 of file cql_connection.h.

Referenced by openDatabase(), and ~CqlConnection().

◆ session_

CassSession* isc::db::CqlConnection::session_

◆ statements_

StatementMap isc::db::CqlConnection::statements_

Pointer to external array of tagged statements containing statement name, array of names of bind parameters and text query.

Definition at line 191 of file cql_connection.h.

Referenced by isc::db::CqlExchange::executeMutation(), isc::db::CqlExchange::executeSelect(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), prepareStatements(), and ~CqlConnection().


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