![]() |
Kea
1.5.0
|
Common database connection class. More...
#include <database_connection.h>
Inheritance diagram for isc::db::DatabaseConnection:Public Types | |
| 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... | |
Public Member Functions | |
| DatabaseConnection (const ParameterMap ¶meters) | |
| 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 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... | |
Static Public Attributes | |
| 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... | |
Common database connection class.
This class provides functions that are common for establishing connection with different types of databases; enables operations on access parameters strings. In particular, it provides a way to parse parameters in key=value format. This class is expected to be a base class for all isc::dhcp::LeaseMgr and possibly isc::dhcp::BaseHostDataSource derived classes.
Definition at line 140 of file database_connection.h.
| typedef boost::function<bool (ReconnectCtlPtr db_retry)> isc::db::DatabaseConnection::DbLostCallback |
Defines a callback prototype for propogating events upward.
Definition at line 206 of file database_connection.h.
| typedef std::map<std::string, std::string> isc::db::DatabaseConnection::ParameterMap |
Database configuration parameter map.
Definition at line 152 of file database_connection.h.
|
inline |
Constructor.
| parameters | A data structure relating keywords and values concerned with the database. |
Definition at line 158 of file database_connection.h.
|
inlinevirtual |
Destructor.
Definition at line 163 of file database_connection.h.
| bool isc::db::DatabaseConnection::configuredReadOnly | ( | ) | const |
Convenience method checking if database should be opened with read only access.
Definition at line 95 of file database_connection.cc.
References isc_throw.
Referenced by isc::dhcp::MySqlHostDataSourceImpl::MySqlHostDataSourceImpl(), and isc::dhcp::PgSqlHostDataSourceImpl::PgSqlHostDataSourceImpl().
| std::string isc::db::DatabaseConnection::getParameter | ( | const std::string & | name | ) | const |
Returns value of a connection parameter.
| name | Name of the parameter which value should be returned. |
| BadValue | if parameter is not found |
Definition at line 28 of file database_connection.cc.
References isc_throw.
Referenced by isc::dhcp::MySqlHostDataSource::getName(), isc::dhcp::PgSqlHostDataSource::getName(), isc::dhcp::PgSqlLeaseMgr::getName(), isc::dhcp::MySqlLeaseMgr::getName(), isc::dhcp::CqlLeaseMgr::getName(), isc::dhcp::CqlHostDataSourceImpl::getName(), isc::dhcp::Memfile_LeaseMgr::Memfile_LeaseMgr(), isc::db::CqlConnection::openDatabase(), isc::db::MySqlConnection::openDatabase(), and isc::db::PgSqlConnection::openDatabase().
| bool isc::db::DatabaseConnection::invokeDbLostCallback | ( | ) | const |
Invokes the connection's lost connectivity callback.
This function may be called by derivations when the connectivity to their data server is lost. If connectivity callback was specified, this function will instantiate a ReconnectCtl and pass it to the callback.
Definition at line 147 of file database_connection.cc.
Referenced by isc::db::MySqlConnection::checkError(), and isc::db::PgSqlConnection::checkStatementError().
|
virtual |
Instantiates a ReconnectCtl based on the connection's reconnect parameters.
Definition at line 114 of file database_connection.cc.
|
static |
Parse database access string.
Parses the string of "keyword=value" pairs and separates them out into the map.
| dbaccess | Database access string. |
Definition at line 37 of file database_connection.cc.
References isc::db::DB_INVALID_ACCESS, DB_LOG_ERROR, isc_throw, and isc::util::str::tokens().
Referenced by isc::dhcp::HostDataSourceFactory::add(), isc::cb::BaseConfigBackendMgr< ConfigBackendPoolDHCPv4 >::addBackend(), isc::dhcp::LeaseMgrFactory::create(), and isc::process::ConfigDbInfo::setAccessString().
Here is the call graph for this function:
|
static |
Redact database access string.
Takes the database parameters and returns a database access string passwords replaced by asterisks. This string is used in log messages.
| parameters | Database access parameters (output of "parse"). |
Definition at line 66 of file database_connection.cc.
Referenced by isc::dhcp::LeaseMgrFactory::create(), and isc::process::ConfigDbInfo::redactedAccessString().
|
static |
Unparse a parameter map.
| params | the parameter map to unparse |
Definition at line 157 of file database_connection.cc.
References isc::data::Element::create(), isc::data::Element::createMap(), isc::db::database_logger, and LOG_ERROR.
Here is the call graph for this function:
|
static |
Unparse an access string.
| dbaccess | the database access string |
Definition at line 211 of file database_connection.cc.
Referenced by isc::process::ConfigDbInfo::toElement(), isc::dhcp::CfgLeaseDbAccess::toElement(), and isc::dhcp::CfgHostDbAccess::toElement().
|
static |
Optional call back function to invoke if a successfully open connection subsequently fails.
Definition at line 233 of file database_connection.h.
|
static |
Defines maximum value for time that can be reliably stored.
If I'm still alive I'll be too old to care. You fix it.
Definition at line 149 of file database_connection.h.
Referenced by isc::db::CqlExchange::convertToDatabaseTime(), and isc::db::PgSqlExchange::convertToDatabaseTime().