Kea
1.9.9-git
|
Common CQL connector pool. More...
#include <cql_connection.h>
Public Member Functions | |
CqlConnection (const ParameterMap ¶meters) | |
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 ¶meters, 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 ¶meters) |
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 ¶meters) |
Redact database access string. More... | |
static isc::data::ElementPtr | toElement (const ParameterMap ¶ms) |
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... | |
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.
|
explicit |
Constructor.
Initialize CqlConnection object with parameters needed for connection.
parameters | specify the connection details (username, ip addresses etc.) |
Definition at line 31 of file cql_connection.cc.
|
virtual |
Destructor.
Definition at line 38 of file cql_connection.cc.
References isc::db::DB_LOG< log_type >::arg(), checkFutureError(), cluster_, isc::db::CQL_DEALLOC_ERROR, isc::db::error, isc::db::CqlTaggedStatement::prepared_statement_, schema_meta_, session_, and statements_.
|
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.
what | text description of the operation |
future | the structure that holds the status of operation |
statement_tag | statement that was used (optional) |
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().
|
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().
|
static |
Get the schema version.
parameters | A data structure relating keywords and values concerned with the database. |
isc::db::DbOperationError | An 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().
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):
DbOpenError | error 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().
|
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.
statements | statements to be prepared |
isc::db::DbOperationError | if an operation on the open database has failed |
isc::InvalidParameter | if 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().
|
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.
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_ |
CQL consistency.
Definition at line 220 of file cql_connection.h.
Referenced by isc::db::CqlExchange::executeMutation(), isc::db::CqlExchange::executeSelect(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), and setConsistency().
bool isc::db::CqlConnection::force_consistency_ |
CQL consistency enabled.
Definition at line 232 of file cql_connection.h.
Referenced by isc::db::CqlExchange::executeMutation(), isc::db::CqlExchange::executeSelect(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), and setConsistency().
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_ |
CQL serial consistency.
Definition at line 223 of file cql_connection.h.
Referenced by isc::db::CqlExchange::executeMutation(), isc::db::CqlExchange::executeSelect(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), and setConsistency().
CassSession* isc::db::CqlConnection::session_ |
CQL session handle.
Definition at line 217 of file cql_connection.h.
Referenced by isc::db::CqlExchange::executeMutation(), isc::db::CqlExchange::executeSelect(), isc::dhcp::CqlLeaseStatsQuery::executeSelect(), openDatabase(), prepareStatements(), and ~CqlConnection().
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().