// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef ASIOLINK_IO_SERVICE_H
-#define ASIOLINK_IO_SERVICE_H 1
+#define ASIOLINK_IO_SERVICE_H
#include <boost/version.hpp>
#include <boost/shared_ptr.hpp>
#define BASE_HOST_DATA_SOURCE_H
#include <asiolink/io_address.h>
+#include <database/database_connection.h>
#include <dhcpsrv/host.h>
#include <exceptions/exceptions.h>
#include <boost/shared_ptr.hpp>
/// @return Type of the backend.
virtual std::string getType() const = 0;
+ /// @brief Return backend parameters
+ ///
+ /// Returns the backend parameters
+ ///
+ /// @return Parameters of the backend.
+ virtual isc::db::DatabaseConnection::ParameterMap getParameters() const {
+ return (isc::db::DatabaseConnection::ParameterMap());
+ };
+
/// @brief Commit Transactions
///
/// Commits all pending database operations. On databases that don't
/// This constructor opens database connection and initializes
/// prepared statements used in the queries.
/// @param parameters parameters passed to the CQL connection.
- explicit CqlHostDataSourceImpl(const CqlConnection::ParameterMap& parameters);
+ explicit CqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters);
/// @brief Destructor.
virtual ~CqlHostDataSourceImpl();
std::get<IPv4_RESERVATION>(key1) == std::get<IPv4_RESERVATION>(key2));
}
-CqlHostDataSourceImpl::CqlHostDataSourceImpl(const CqlConnection::ParameterMap& parameters)
+CqlHostDataSourceImpl::CqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters)
: parameters_(parameters), dbconn_(parameters) {
// Validate the schema version first.
std::pair<uint32_t, uint32_t> code_version(CQL_SCHEMA_VERSION_MAJOR,
source_host->getCfgOption6()->mergeTo(*target_host->getCfgOption6());
}
-CqlHostDataSource::CqlHostDataSource(const CqlConnection::ParameterMap& parameters)
+CqlHostDataSource::CqlHostDataSource(const DatabaseConnection::ParameterMap& parameters)
: impl_(new CqlHostDataSourceImpl(parameters)) {
}
bool
HostDataSourceFactory::del(HostDataSourceList& sources,
const string& db_type) {
+ bool result = false;
for (auto it = sources.begin(); it != sources.end(); ++it) {
if ((*it)->getType() != db_type) {
continue;
LOG_DEBUG(hosts_logger, DHCPSRV_DBG_TRACE, HOSTS_CFG_CLOSE_HOST_DATA_SOURCE)
.arg(db_type);
sources.erase(it);
- return (true);
+ result = true;
+ }
+ return (result);
+}
+
+bool
+HostDataSourceFactory::del(HostDataSourceList& sources,
+ const string& db_type,
+ const string& dbaccess) {
+ DatabaseConnection::ParameterMap parameters =
+ DatabaseConnection::parse(dbaccess);
+ bool result = false;
+ for (auto it = sources.begin(); it != sources.end(); ++it) {
+ if ((*it)->getType() != db_type || (*it)->getParameters() != parameters) {
+ continue;
+ }
+ LOG_DEBUG(hosts_logger, DHCPSRV_DBG_TRACE, HOSTS_CFG_CLOSE_HOST_DATA_SOURCE)
+ .arg((*it)->getType());
+ sources.erase(it);
+ result = true;
}
- return (false);
+ return (result);
}
bool
/// @brief Delete a host data source.
///
- /// Delete the first instance of a host data source of the given type.
+ /// Delete all instances of a host data source of the given type.
/// This should have the effect of closing the database connection.
///
/// @param sources host data source list.
/// @return true when found and removed, false when not found.
static bool del(HostDataSourceList& sources, const std::string& db_type);
+ /// @brief Delete a host data source.
+ ///
+ /// Delete instance of a host data source which matches specific parameters.
+ /// This should have the effect of closing the database connection.
+ ///
+ /// @param sources host data source list.
+ /// @param db_type database backend type.
+ /// @param dbaccess Database access parameters. These are in the form of
+ /// "keyword=value" pairs, separated by spaces. They are backend-
+ /// -end specific, although must include the "type" keyword which
+ /// gives the backend in use.
+ /// @return true when found and removed, false when not found.
+ static bool del(HostDataSourceList& sources, const std::string& db_type,
+ const std::string& dbaccess);
+
/// @brief Type of host data source factory
///
/// A factory takes a parameter map and returns a pointer to a host
namespace dhcp {
using namespace isc::asiolink;
+using namespace isc::db;
IOServicePtr HostMgr::io_service_ = IOServicePtr();
return (HostDataSourceFactory::del(getHostMgrPtr()->alternate_sources_, db_type));
}
+bool
+HostMgr::delBackend(const std::string& db_type, const std::string& access) {
+ return (HostDataSourceFactory::del(getHostMgrPtr()->alternate_sources_, db_type, access));
+}
+
void
HostMgr::delAllBackends() {
getHostMgrPtr()->alternate_sources_.clear();
/// @return true when found and removed, false when not found.
static bool delBackend(const std::string& db_type);
+ /// @brief Delete an alternate host backend (aka host data source).
+ ///
+ /// @param db_type database backend type.
+ /// @param access Host backend access parameters for the alternate
+ /// host backend. It holds "keyword=value" pairs, separated by spaces.
+ /// @return true when found and removed, false when not found.
+ static bool delBackend(const std::string& db_type, const std::string& access);
+
/// @brief Delete all alternate backends.
static void delAllBackends();
#include <config.h>
+#include <asiolink/io_service.h>
#include <database/db_exceptions.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option.h>
#include <dhcp/option_definition.h>
#include <dhcp/option_space.h>
+#include <dhcpsrv/cfg_db_access.h>
#include <dhcpsrv/cfg_option.h>
+#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_log.h>
+#include <dhcpsrv/host_mgr.h>
#include <dhcpsrv/mysql_host_data_source.h>
+#include <dhcpsrv/timer_mgr.h>
#include <util/buffer.h>
#include <util/multi_threading_mgr.h>
#include <util/optional.h>
/// @brief Constructor
///
/// @param parameters See MySqlHostMgr constructor.
- MySqlHostContext(const DatabaseConnection::ParameterMap& parameters);
+ MySqlHostContext(const DatabaseConnection::ParameterMap& parameters,
+ const isc::asiolink::IOServicePtr& io_service,
+ db::DbCallback callback);
/// The exchange objects are used for transfer of data to/from the database.
/// They are pointed-to objects as the contents may change in "const" calls,
///
/// This constructor opens database connection and initializes prepared
/// statements used in the queries.
- MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters);
+ MySqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters);
/// @brief Destructor.
~MySqlHostDataSourceImpl();
+ /// @brief Attempts to reconnect the server to the host DB backend manager.
+ ///
+ /// This is a self-rescheduling function that attempts to reconnect to the
+ /// server's host DB backends after connectivity to one or more have been
+ /// lost. Upon entry it will attempt to reconnect via
+ /// @ref HostDataSourceFactory::add.
+ /// If this is successful, DHCP servicing is re-enabled and server returns
+ /// to normal operation.
+ ///
+ /// If reconnection fails and the maximum number of retries has not been
+ /// exhausted, it will schedule a call to itself to occur at the
+ /// configured retry interval. DHCP service remains disabled.
+ ///
+ /// If the maximum number of retries has been exhausted an error is logged
+ /// and the server shuts down.
+ ///
+ /// @param db_reconnect_ctl pointer to the ReconnectCtl containing the
+ /// configured reconnect parameters.
+ /// @return true if connection has been recovered, false otherwise.
+ static bool dbReconnect(ReconnectCtlPtr db_reconnect_ctl);
+
/// @brief Create a new context.
///
/// The database is opened with all the SQL commands pre-compiled.
// MySqlHostContext Constructor
-MySqlHostContext::MySqlHostContext(const DatabaseConnection::ParameterMap& parameters)
- : conn_(parameters), is_readonly_(true) {
+MySqlHostContext::MySqlHostContext(const DatabaseConnection::ParameterMap& parameters,
+ const isc::asiolink::IOServicePtr& io_service,
+ db::DbCallback callback)
+ : conn_(parameters, io_service, callback), is_readonly_(true) {
}
// MySqlHostContextAlloc Constructor and Destructor
// If running in single-threaded mode, there's nothing to do here.
}
-MySqlHostDataSourceImpl::MySqlHostDataSourceImpl(const MySqlConnection::ParameterMap& parameters)
+MySqlHostDataSourceImpl::MySqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters)
: parameters_(parameters), ip_reservations_unique_(true) {
// Validate the schema version first.
// Create an initial context.
pool_.reset(new MySqlHostContextPool());
pool_->pool_.push_back(createContext());
+
+ auto db_reconnect_ctl = pool_->pool_[0]->conn_.reconnectCtl();
+
+ std::string manager = "MySqlLeaseMgr[";
+ manager += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
+ std::string timer_name = manager + "]DbReconnectTimer";
+
+ TimerMgr::instance()->registerTimer(timer_name,
+ std::bind(&MySqlHostDataSourceImpl::dbReconnect, db_reconnect_ctl),
+ db_reconnect_ctl->retryInterval(),
+ asiolink::IntervalTimer::ONE_SHOT);
}
// Create context.
MySqlHostContextPtr
MySqlHostDataSourceImpl::createContext() const {
- MySqlHostContextPtr ctx(new MySqlHostContext(parameters_));
+ MySqlHostContextPtr ctx(new MySqlHostContext(parameters_,
+ HostMgr::getIOService(),
+ &MySqlHostDataSourceImpl::dbReconnect));
// Open the database.
ctx->conn_.openDatabase();
ctx->host_ipv6_reservation_exchange_.reset(new MySqlIPv6ReservationExchange());
ctx->host_option_exchange_.reset(new MySqlOptionExchange());
+ std::string manager = "MySqlHostMgr[";
+ manager += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
+ std::string timer_name = manager + "]DbReconnectTimer";
+
+ ctx->conn_.makeReconnectCtl(timer_name);
+
return (ctx);
}
MySqlHostDataSourceImpl::~MySqlHostDataSourceImpl() {
+ std::string manager = "MySqlHostMgr[";
+ manager += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
+ std::string timer_name = manager + "]DbReconnectTimer";
+
+ TimerMgr::instance()->unregisterTimer(timer_name);
+}
+
+bool
+MySqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
+ MultiThreadingCriticalSection cs;
+
+ DatabaseConnection::invokeDbLostCallback(db_reconnect_ctl);
+
+ bool reopened = false;
+
+ // At least one connection was lost.
+ try {
+ CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess();
+ std::list<std::string> host_db_access_list = cfg_db->getHostDbAccessStringList();
+ for (std::string& hds : host_db_access_list) {
+ auto parameters = DatabaseConnection::parse(hds);
+ if (HostMgr::delBackend("mysql", hds)) {
+ HostMgr::addBackend(hds);
+ }
+ }
+
+ reopened = true;
+ } catch (const std::exception& ex) {
+ //LOG_ERROR(dhcpsrv_logger, DHCPSRV_MYSQL_DB_RECONNECT_ATTEMPT_FAILED)
+ // .arg(ex.what());
+ }
+
+ if (reopened) {
+ // Cancel the timer.
+ const std::string& timer_name = db_reconnect_ctl->timerName();
+ TimerMgr::instance()->cancel(timer_name);
+
+ DatabaseConnection::invokeDbRecoveredCallback(db_reconnect_ctl);
+ } else {
+ if (!db_reconnect_ctl->checkRetries()) {
+ // We're out of retries, log it and initiate shutdown.
+ //LOG_ERROR(dhcpsrv_logger, DHCPSRV_MYSQL_DB_RECONNECT_RETRIES_EXHAUSTED)
+ // .arg(db_reconnect_ctl->maxRetries());
+
+ DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl);
+
+ return (false);
+ }
+
+ //LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB_RECONNECT_ATTEMPT_SCHEDULE)
+ // .arg(db_reconnect_ctl->maxRetries() - db_reconnect_ctl->retriesLeft() + 1)
+ // .arg(db_reconnect_ctl->maxRetries())
+ // .arg(db_reconnect_ctl->retryInterval());
+
+ TimerMgr::instance()->setup(db_reconnect_ctl->timerName());
+ }
+
+ return (true);
}
std::pair<uint32_t, uint32_t>
}
}
-MySqlHostDataSource::MySqlHostDataSource(const MySqlConnection::ParameterMap& parameters)
+MySqlHostDataSource::MySqlHostDataSource(const DatabaseConnection::ParameterMap& parameters)
: impl_(new MySqlHostDataSourceImpl(parameters)) {
}
MySqlHostDataSource::~MySqlHostDataSource() {
}
+DatabaseConnection::ParameterMap
+MySqlHostDataSource::getParameters() const {
+ return impl_->parameters_;
+}
+
void
MySqlHostDataSource::add(const HostPtr& host) {
// Get a context
#ifndef MYSQL_HOST_DATA_SOURCE_H
#define MYSQL_HOST_DATA_SOURCE_H
+#include <database/database_connection.h>
#include <database/db_exceptions.h>
#include <dhcpsrv/base_host_data_source.h>
#include <mysql/mysql_connection.h>
/// Releases prepared MySQL statements used by the backend.
virtual ~MySqlHostDataSource();
+ /// @brief Return backend parameters
+ ///
+ /// Returns the backend parameters
+ ///
+ /// @return Parameters of the backend.
+ virtual isc::db::DatabaseConnection::ParameterMap getParameters() const;
+
/// @brief Adds a new host to the collection.
///
/// The implementations of this method should guard against duplicate
// MySqlLeaseContext Constructor
-MySqlLeaseContext::MySqlLeaseContext(const MySqlConnection::ParameterMap& parameters,
+MySqlLeaseContext::MySqlLeaseContext(const DatabaseConnection::ParameterMap& parameters,
const isc::asiolink::IOServicePtr& io_service,
DbCallback callback)
: conn_(parameters, io_service, callback) {
// MySqlLeaseMgr Constructor and Destructor
-MySqlLeaseMgr::MySqlLeaseMgr(const MySqlConnection::ParameterMap& parameters)
+MySqlLeaseMgr::MySqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters)
: parameters_(parameters) {
// Validate schema version first.
#include <config.h>
+#include <asiolink/io_service.h>
#include <database/db_exceptions.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option.h>
#include <dhcp/option_definition.h>
#include <dhcp/option_space.h>
+#include <dhcpsrv/cfg_db_access.h>
#include <dhcpsrv/cfg_option.h>
+#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_log.h>
+#include <dhcpsrv/host_mgr.h>
#include <dhcpsrv/pgsql_host_data_source.h>
+#include <dhcpsrv/timer_mgr.h>
#include <util/buffer.h>
#include <util/multi_threading_mgr.h>
#include <util/optional.h>
/// @brief Constructor
///
/// @param parameters See PgSqlHostMgr constructor.
- PgSqlHostContext(const DatabaseConnection::ParameterMap& parameters);
+ PgSqlHostContext(const DatabaseConnection::ParameterMap& parameters,
+ const isc::asiolink::IOServicePtr& io_service,
+ db::DbCallback callback);
/// The exchange objects are used for transfer of data to/from the database.
/// They are pointed-to objects as the contents may change in "const" calls,
///
/// This constructor opens database connection and initializes prepared
/// statements used in the queries.
- PgSqlHostDataSourceImpl(const PgSqlConnection::ParameterMap& parameters);
+ PgSqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters);
/// @brief Destructor.
~PgSqlHostDataSourceImpl();
+ /// @brief Attempts to reconnect the server to the host DB backend manager.
+ ///
+ /// This is a self-rescheduling function that attempts to reconnect to the
+ /// server's host DB backends after connectivity to one or more have been
+ /// lost. Upon entry it will attempt to reconnect via
+ /// @ref HostDataSourceFactory::add.
+ /// If this is successful, DHCP servicing is re-enabled and server returns
+ /// to normal operation.
+ ///
+ /// If reconnection fails and the maximum number of retries has not been
+ /// exhausted, it will schedule a call to itself to occur at the
+ /// configured retry interval. DHCP service remains disabled.
+ ///
+ /// If the maximum number of retries has been exhausted an error is logged
+ /// and the server shuts down.
+ ///
+ /// @param db_reconnect_ctl pointer to the ReconnectCtl containing the
+ /// configured reconnect parameters.
+ /// @return true if connection has been recovered, false otherwise.
+ static bool dbReconnect(ReconnectCtlPtr db_reconnect_ctl);
+
/// @brief Create a new context.
///
/// The database is opened with all the SQL commands pre-compiled.
std::pair<uint32_t, uint32_t> getVersion() const;
/// @brief The parameters
- PgSqlConnection::ParameterMap parameters_;
+ DatabaseConnection::ParameterMap parameters_;
/// @brief Holds the setting whether the IP reservations must be unique or
/// may be non-unique.
// PgSqlHostContext Constructor
-PgSqlHostContext::PgSqlHostContext(const DatabaseConnection::ParameterMap& parameters)
- : conn_(parameters), is_readonly_(true) {
+PgSqlHostContext::PgSqlHostContext(const DatabaseConnection::ParameterMap& parameters,
+ const isc::asiolink::IOServicePtr& io_service,
+ db::DbCallback callback)
+ : conn_(parameters, io_service, callback), is_readonly_(true) {
}
// PgSqlHostContextAlloc Constructor and Destructor
// If running in single-threaded mode, there's nothing to do here.
}
-PgSqlHostDataSourceImpl::PgSqlHostDataSourceImpl(const PgSqlConnection::ParameterMap& parameters)
+PgSqlHostDataSourceImpl::PgSqlHostDataSourceImpl(const DatabaseConnection::ParameterMap& parameters)
: parameters_(parameters), ip_reservations_unique_(true) {
// Validate the schema version first.
// Create an initial context.
pool_.reset(new PgSqlHostContextPool());
pool_->pool_.push_back(createContext());
+
+ auto db_reconnect_ctl = pool_->pool_[0]->conn_.reconnectCtl();
+
+ std::string manager = "PgSqlLeaseMgr[";
+ manager += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
+ std::string timer_name = manager + "]DbReconnectTimer";
+
+ TimerMgr::instance()->registerTimer(timer_name,
+ std::bind(&PgSqlHostDataSourceImpl::dbReconnect, db_reconnect_ctl),
+ db_reconnect_ctl->retryInterval(),
+ asiolink::IntervalTimer::ONE_SHOT);
}
// Create context.
PgSqlHostContextPtr
PgSqlHostDataSourceImpl::createContext() const {
- PgSqlHostContextPtr ctx(new PgSqlHostContext(parameters_));
+ PgSqlHostContextPtr ctx(new PgSqlHostContext(parameters_,
+ HostMgr::getIOService(),
+ &PgSqlHostDataSourceImpl::dbReconnect));
// Open the database.
ctx->conn_.openDatabase();
ctx->host_ipv6_reservation_exchange_.reset(new PgSqlIPv6ReservationExchange());
ctx->host_option_exchange_.reset(new PgSqlOptionExchange());
+ std::string manager = "PgSqlHostMgr[";
+ manager += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
+ std::string timer_name = manager + "]DbReconnectTimer";
+
+ ctx->conn_.makeReconnectCtl(timer_name);
+
return (ctx);
}
PgSqlHostDataSourceImpl::~PgSqlHostDataSourceImpl() {
+ std::string manager = "PgSqlHostMgr[";
+ manager += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
+ std::string timer_name = manager + "]DbReconnectTimer";
+
+ TimerMgr::instance()->unregisterTimer(timer_name);
+}
+
+bool
+PgSqlHostDataSourceImpl::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
+ MultiThreadingCriticalSection cs;
+
+ DatabaseConnection::invokeDbLostCallback(db_reconnect_ctl);
+
+ bool reopened = false;
+
+ // At least one connection was lost.
+ try {
+ CfgDbAccessPtr cfg_db = CfgMgr::instance().getCurrentCfg()->getCfgDbAccess();
+ std::list<std::string> host_db_access_list = cfg_db->getHostDbAccessStringList();
+ for (std::string& hds : host_db_access_list) {
+ auto parameters = DatabaseConnection::parse(hds);
+ if (HostMgr::delBackend("postgresql", hds)) {
+ HostMgr::addBackend(hds);
+ }
+ }
+
+ reopened = true;
+ } catch (const std::exception& ex) {
+ //LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_DB_RECONNECT_ATTEMPT_FAILED)
+ // .arg(ex.what());
+ }
+
+ if (reopened) {
+ // Cancel the timer.
+ const std::string& timer_name = db_reconnect_ctl->timerName();
+ TimerMgr::instance()->cancel(timer_name);
+
+ DatabaseConnection::invokeDbRecoveredCallback(db_reconnect_ctl);
+ } else {
+ if (!db_reconnect_ctl->checkRetries()) {
+ // We're out of retries, log it and initiate shutdown.
+ //LOG_ERROR(dhcpsrv_logger, DHCPSRV_PGSQL_DB_RECONNECT_RETRIES_EXHAUSTED)
+ // .arg(db_reconnect_ctl->maxRetries());
+
+ DatabaseConnection::invokeDbFailedCallback(db_reconnect_ctl);
+
+ return (false);
+ }
+
+ //LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_DB_RECONNECT_ATTEMPT_SCHEDULE)
+ // .arg(db_reconnect_ctl->maxRetries() - db_reconnect_ctl->retriesLeft() + 1)
+ // .arg(db_reconnect_ctl->maxRetries())
+ // .arg(db_reconnect_ctl->retryInterval());
+
+ TimerMgr::instance()->setup(db_reconnect_ctl->timerName());
+ }
+
+ return (true);
}
uint64_t
/*********** PgSqlHostDataSource *********************/
-PgSqlHostDataSource::PgSqlHostDataSource(const PgSqlConnection::ParameterMap& parameters)
+PgSqlHostDataSource::PgSqlHostDataSource(const DatabaseConnection::ParameterMap& parameters)
: impl_(new PgSqlHostDataSourceImpl(parameters)) {
}
PgSqlHostDataSource::~PgSqlHostDataSource() {
}
+DatabaseConnection::ParameterMap
+PgSqlHostDataSource::getParameters() const {
+ return impl_->parameters_;
+}
+
void
PgSqlHostDataSource::add(const HostPtr& host) {
// Get a context
#ifndef PGSQL_HOST_DATA_SOURCE_H
#define PGSQL_HOST_DATA_SOURCE_H
+#include <database/database_connection.h>
#include <dhcpsrv/base_host_data_source.h>
#include <pgsql/pgsql_connection.h>
#include <pgsql/pgsql_exchange.h>
/// the destruction of member impl_.
virtual ~PgSqlHostDataSource();
+ /// @brief Return backend parameters
+ ///
+ /// Returns the backend parameters
+ ///
+ /// @return Parameters of the backend.
+ virtual isc::db::DatabaseConnection::ParameterMap getParameters() const;
+
/// @brief Adds a new host to the collection.
///
/// The method will insert the given host and all of its children (v4
// PgSqlLeaseContext Constructor
-PgSqlLeaseContext::PgSqlLeaseContext(const PgSqlConnection::ParameterMap& parameters,
+PgSqlLeaseContext::PgSqlLeaseContext(const DatabaseConnection::ParameterMap& parameters,
const isc::asiolink::IOServicePtr& io_service,
DbCallback callback)
: conn_(parameters, io_service, callback) {
// PgSqlLeaseMgr Constructor and Destructor
-PgSqlLeaseMgr::PgSqlLeaseMgr(const PgSqlConnection::ParameterMap& parameters)
+PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters)
: parameters_(parameters) {
// Validate schema version first.
int countRowsInTable(const std::string& table) {
string query = "SELECT * FROM " + table;
- MySqlConnection::ParameterMap params;
+ DatabaseConnection::ParameterMap params;
params["name"] = "keatest";
params["user"] = "keatest";
params["password"] = "keatest";
// when inserting reservations or options. The simplest way to
// achieve that is to simply drop one of the tables. To do so, we
// connect to the database and issue a DROP query.
- MySqlConnection::ParameterMap params;
+ DatabaseConnection::ParameterMap params;
params["name"] = "keatest";
params["user"] = "keatest";
params["password"] = "keatest";
// when inserting reservations or options. The simplest way to
// achieve that is to simply drop one of the tables. To do so, we
// connect to the database and issue a DROP query.
- MySqlConnection::ParameterMap params;
+ DatabaseConnection::ParameterMap params;
params["name"] = "keatest";
params["user"] = "keatest";
params["password"] = "keatest";
int countRowsInTable(const std::string& table) {
string query = "SELECT * FROM " + table;
- PgSqlConnection::ParameterMap params;
+ DatabaseConnection::ParameterMap params;
params["name"] = "keatest";
params["user"] = "keatest";
params["password"] = "keatest";
createPgSQLSchema();
callback_called = false;
- DatabaseConnection::db_lost_callback = db_lost_callback;
+ DatabaseConnection::db_lost_callback_ = db_lost_callback;
HostMgr::create();
EXPECT_THROW(HostMgr::addBackend(connectionString(
PGSQL_VALID_TYPE, VALID_NAME, INVALID_HOST, VALID_USER, VALID_PASSWORD)),
createPgSQLSchema();
callback_called = false;
- DatabaseConnection::db_lost_callback = db_lost_callback;
+ DatabaseConnection::db_lost_callback_ = db_lost_callback;
HostMgr::create();
EXPECT_THROW(HostMgr::addBackend(connectionString(
PGSQL_VALID_TYPE, VALID_NAME, INVALID_HOST, VALID_USER, VALID_PASSWORD)),
// when inserting reservations or options. The simplest way to
// achieve that is to simply drop one of the tables. To do so, we
// connect to the database and issue a DROP query.
- PgSqlConnection::ParameterMap params;
+ DatabaseConnection::ParameterMap params;
params["name"] = "keatest";
params["user"] = "keatest";
params["password"] = "keatest";
// when inserting reservations or options. The simplest way to
// achieve that is to simply drop one of the tables. To do so, we
// connect to the database and issue a DROP query.
- PgSqlConnection::ParameterMap params;
+ DatabaseConnection::ParameterMap params;
params["name"] = "keatest";
params["user"] = "keatest";
params["password"] = "keatest";
/// the table (if present) and then recreates it.
PgSqlBasicsTest() : expectedColNames_(NUM_BASIC_COLS) {
// Create database connection parameter list
- PgSqlConnection::ParameterMap params;
+ DatabaseConnection::ParameterMap params;
params["name"] = "keatest";
params["user"] = "keatest";
params["password"] = "keatest";