Kea  1.9.9-git
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, CassConsistency serial_consistency)
 Set consistency. More...
 
void startTransaction ()
 Start transaction. More...
 
- Public Member Functions inherited from isc::db::DatabaseConnection
 DatabaseConnection (const ParameterMap &parameters, DbCallback callback=DbCallback())
 Constructor. More...
 
virtual ~DatabaseConnection ()
 Destructor. More...
 
void checkUnusable ()
 Throws an exception if the connection is not usable. 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 isUnusable ()
 Flag which indicates if connection is unusable. More...
 
virtual void makeReconnectCtl (const std::string &timer_name)
 Instantiates a ReconnectCtl based on the connection's reconnect parameters. More...
 
ReconnectCtlPtr reconnectCtl ()
 The reconnect settings. 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 std::pair< uint32_t, uint32_t > getVersion (const ParameterMap &parameters)
 Get the schema version. More...
 
static CassConsistency parseConsistency (std::string value)
 parse Consistency value More...
 
- Static Public Member Functions inherited from isc::db::DatabaseConnection
static bool invokeDbFailedCallback (const ReconnectCtlPtr &db_reconnect_ctl)
 Invokes the connection's restore failed connectivity callback. More...
 
static bool invokeDbLostCallback (const ReconnectCtlPtr &db_reconnect_ctl)
 Invokes the connection's lost connectivity callback. More...
 
static bool invokeDbRecoveredCallback (const ReconnectCtlPtr &db_reconnect_ctl)
 Invokes the connection's restored connectivity callback. More...
 
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_
 
CassConsistency serial_consistency_
 CQL serial consistency. More...
 
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 std::map< std::string, std::string > ParameterMap
 Database configuration parameter map. More...
 
- Static Public Attributes inherited from isc::db::DatabaseConnection
static DbCallback db_failed_callback_ = 0
 Optional callback function to invoke if an opened connection recovery failed. More...
 
static DbCallback db_lost_callback_ = 0
 Optional callback function to invoke if an opened connection is lost. More...
 
static DbCallback db_recovered_callback_ = 0
 Optional callback function to invoke if an opened connection recovery succeeded. More...
 
static const time_t MAX_DB_TIME = 2147483647
 Defines maximum value for time that can be reliably stored. More...
 
- Protected Member Functions inherited from isc::db::DatabaseConnection
void markUnusable ()
 Sets the unusable flag to true. More...
 
- Protected Attributes inherited from isc::db::DatabaseConnection
DbCallback callback_
 The callback used to recover the connection. 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

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.

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

Member Function Documentation

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 442 of file cql_connection.cc.

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

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

Commit Transactions.

Definition at line 432 of file cql_connection.cc.

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

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

std::pair< uint32_t, uint32_t > isc::db::CqlConnection::getVersion ( const ParameterMap parameters)
static

Get the schema version.

Parameters
parametersA data structure relating keywords and values concerned with the database.
Returns
Version number as a pair of unsigned integers. "first" is the major version number, "second" the minor number.
Exceptions
isc::db::DbOperationErrorAn operation on the open database has failed.

Definition at line 79 of file cql_connection.cc.

References openDatabase(), prepareStatements(), and isc::db::CqlVersionExchange::tagged_statements_.

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

+ Here is the call graph for this function:

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)
  • consistency: consistency level (quorum)
  • serial-consistency: serial consistency level (serial)
  • port: The TCP port to use (9042)
  • user - credentials to use when connecting (no username)
  • password - credentials 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 114 of file cql_connection.cc.

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

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

+ Here is the call graph for this function:

CassConsistency isc::db::CqlConnection::parseConsistency ( std::string  value)
static

parse Consistency value

Definition at line 93 of file cql_connection.cc.

Referenced by openDatabase().

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 387 of file cql_connection.cc.

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

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

+ Here is the call graph for this function:

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

Rollback Transactions.

Definition at line 437 of file cql_connection.cc.

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

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

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

Set consistency.

Definition at line 418 of file cql_connection.cc.

References consistency_, force_consistency_, and serial_consistency_.

Referenced by openDatabase().

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

Start transaction.

Definition at line 427 of file cql_connection.cc.

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

Member Data Documentation

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

CQL connection handle.

Definition at line 214 of file cql_connection.h.

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

CassConsistency isc::db::CqlConnection::consistency_
bool isc::db::CqlConnection::force_consistency_
const CassKeyspaceMeta* isc::db::CqlConnection::keyspace_meta_

Keyspace meta information, used for UDTs.

Definition at line 229 of file cql_connection.h.

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

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

Definition at line 226 of file cql_connection.h.

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

CassConsistency isc::db::CqlConnection::serial_consistency_
CassSession* isc::db::CqlConnection::session_
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 211 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: