summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/database/database_connection.cc17
-rw-r--r--src/lib/database/database_connection.h41
-rw-r--r--src/lib/mysql/mysql_connection.h7
-rw-r--r--src/lib/pgsql/pgsql_connection.h7
4 files changed, 51 insertions, 21 deletions
diff --git a/src/lib/database/database_connection.cc b/src/lib/database/database_connection.cc
index 38ca41b25f..840a7d8a13 100644
--- a/src/lib/database/database_connection.cc
+++ b/src/lib/database/database_connection.cc
@@ -183,8 +183,23 @@ DatabaseConnection::makeReconnectCtl(const std::string& timer_name) {
// Wasn't specified so we'll use default of true;
}
+ bool connection_recovery = true;
+ try {
+ parm_str = getParameter("enable-connection-recovery");
+ connection_recovery = boost::lexical_cast<bool>(parm_str);
+ } catch (...) {
+ // Wasn't specified so we'll use default of true;
+ }
+
+ // If "enable-connection-recovery" is 'false' the recovery mechanism must
+ // be disabled
+ if (!connection_recovery) {
+ callback_ = DbCallback();
+ }
+
reconnect_ctl_ = boost::make_shared<ReconnectCtl>(type, timer_name, retries,
- interval, disable_dhcp);
+ interval, connection_recovery,
+ disable_dhcp);
}
bool
diff --git a/src/lib/database/database_connection.h b/src/lib/database/database_connection.h
index 3d69895e95..a21ff75722 100644
--- a/src/lib/database/database_connection.h
+++ b/src/lib/database/database_connection.h
@@ -93,10 +93,12 @@ public:
/// @param retry_interval amount of time to between reconnect attempts
ReconnectCtl(const std::string& backend_type, const std::string& timer_name,
unsigned int max_retries, unsigned int retry_interval,
- bool disable_dhcp) : backend_type_(backend_type),
- timer_name_(timer_name), max_retries_(max_retries),
- retries_left_(max_retries), retry_interval_(retry_interval),
- disable_dhcp_(disable_dhcp) {}
+ bool connection_recovery, bool alter_dhcp_state) :
+ backend_type_(backend_type), timer_name_(timer_name),
+ max_retries_(max_retries), retries_left_(max_retries),
+ retry_interval_(retry_interval),
+ connection_recovery_(connection_recovery),
+ alter_dhcp_state_(alter_dhcp_state) {}
/// @brief Returns the type of the caller backend.
std::string backendType() const {
@@ -140,8 +142,14 @@ public:
/// @brief Return the flag which indicates if the connection loss should
/// disable the dhcp service.
- bool disableDHCP() {
- return (disable_dhcp_);
+ bool alterDHCPState() {
+ return (alter_dhcp_state_);
+ }
+
+ /// @brief Return the flag which indicates if the connection recovery
+ /// mechanism is enabled.
+ bool connectionRecovery() {
+ return (connection_recovery_);
}
private:
@@ -161,9 +169,13 @@ private:
/// @brief The amount of time to wait between reconnect attempts
unsigned int retry_interval_;
- /// @brief Flag which indicates if the connection loss should disable the
+ /// @brief Flag which indicates if the connection recovery mechanism is
+ /// enabled.
+ bool connection_recovery_;
+
+ /// @brief Flag which indicates if the connection loss should affect the
/// dhcp service.
- bool disable_dhcp_;
+ bool alter_dhcp_state_;
};
/// @brief Pointer to an instance of ReconnectCtl
@@ -210,8 +222,10 @@ public:
///
/// @param parameters A data structure relating keywords and values
/// concerned with the database.
- DatabaseConnection(const ParameterMap& parameters)
- : parameters_(parameters), unusable_(false) {
+ /// @param callback The connection recovery callback.
+ DatabaseConnection(const ParameterMap& parameters,
+ DbCallback callback = DbCallback())
+ : parameters_(parameters), callback_(callback), unusable_(false) {
}
/// @brief Destructor
@@ -336,6 +350,13 @@ private:
/// intended to keep any DHCP-related parameters.
ParameterMap parameters_;
+protected:
+
+ /// @brief The callback used to recover the connection.
+ DbCallback callback_;
+
+private:
+
/// @brief Indicates if the connection can no longer be used for normal
/// operations. Typically a connection is marked unusable after an unrecoverable
/// DB error. There may be a time when the connection exists, after
diff --git a/src/lib/mysql/mysql_connection.h b/src/lib/mysql/mysql_connection.h
index dff65e9d3b..8d51554411 100644
--- a/src/lib/mysql/mysql_connection.h
+++ b/src/lib/mysql/mysql_connection.h
@@ -246,8 +246,8 @@ public:
MySqlConnection(const ParameterMap& parameters,
IOServiceAccessorPtr io_accessor = IOServiceAccessorPtr(),
DbCallback callback = DbCallback())
- : DatabaseConnection(parameters), io_service_accessor_(io_accessor),
- io_service_(), callback_(callback) {
+ : DatabaseConnection(parameters, callback),
+ io_service_accessor_(io_accessor), io_service_() {
}
/// @brief Destructor
@@ -698,9 +698,6 @@ public:
/// @brief IOService object, used for all ASIO operations.
isc::asiolink::IOServicePtr io_service_;
-
- /// @brief The callback used to recover the connection.
- DbCallback callback_;
};
} // end of isc::db namespace
diff --git a/src/lib/pgsql/pgsql_connection.h b/src/lib/pgsql/pgsql_connection.h
index e338446e12..c4b8e49d19 100644
--- a/src/lib/pgsql/pgsql_connection.h
+++ b/src/lib/pgsql/pgsql_connection.h
@@ -312,8 +312,8 @@ public:
PgSqlConnection(const ParameterMap& parameters,
IOServiceAccessorPtr io_accessor = IOServiceAccessorPtr(),
DbCallback callback = DbCallback())
- : DatabaseConnection(parameters), io_service_accessor_(io_accessor),
- io_service_(), callback_(callback) {
+ : DatabaseConnection(parameters, callback),
+ io_service_accessor_(io_accessor), io_service_() {
}
/// @brief Destructor
@@ -469,9 +469,6 @@ public:
/// @brief IOService object, used for all ASIO operations.
isc::asiolink::IOServicePtr io_service_;
-
- /// @brief The callback used to recover the connection.
- DbCallback callback_;
};
} // end of isc::db namespace