7 #ifndef DATABASE_CONNECTION_H 8 #define DATABASE_CONNECTION_H 11 #include <boost/noncopyable.hpp> 12 #include <boost/function.hpp> 13 #include <boost/shared_ptr.hpp> 82 ReconnectCtl(
const std::string& backend_type,
unsigned int max_retries,
83 unsigned int retry_interval)
84 : backend_type_(backend_type), max_retries_(max_retries),
85 retries_left_(max_retries), retry_interval_(retry_interval) {}
89 return (backend_type_);
97 return (retries_left_ ? --retries_left_ :
false);
102 return (max_retries_);
107 return (retries_left_);
112 return (retry_interval_);
117 const std::string backend_type_;
120 unsigned int max_retries_;
123 unsigned int retries_left_;
126 unsigned int retry_interval_;
159 :parameters_(parameters) {
175 std::string
getParameter(
const std::string& name)
const;
249 #endif // DATABASE_CONNECTION_H virtual ReconnectCtlPtr makeReconnectCtl() const
Instantiates a ReconnectCtl based on the connection's reconnect parameters.
DbOpenError(const char *file, size_t line, const char *what)
bool checkRetries()
Decrements the number of retries remaining.
Warehouses DB reconnect control values.
unsigned int retriesLeft()
Returns the number for retries remaining.
NoDatabaseName(const char *file, size_t line, const char *what)
bool invokeDbLostCallback() const
Invokes the connection's lost connectivity callback.
static isc::data::ElementPtr toElement(const ParameterMap ¶ms)
Unparse a parameter map.
boost::shared_ptr< Element > ElementPtr
static ParameterMap parse(const std::string &dbaccess)
Parse database access string.
unsigned int maxRetries()
Returns the maximum number for retries allowed.
Common database connection class.
DbOperationError(const char *file, size_t line, const char *what)
static const time_t MAX_DB_TIME
Defines maximum value for time that can be reliably stored.
DbInvalidTimeout(const char *file, size_t line, const char *what)
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception thrown on failure to open database.
std::string backendType() const
Returns the type of the caller backend.
static isc::data::ElementPtr toElementDbAccessString(const std::string &dbaccess)
Unparse an access string.
Exception thrown if name of database is not specified.
virtual ~DatabaseConnection()
Destructor.
std::string getParameter(const std::string &name) const
Returns value of a connection parameter.
bool configuredReadOnly() const
Convenience method checking if database should be opened with read only access.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
static DbLostCallback db_lost_callback
Optional call back function to invoke if a successfully open connection subsequently fails.
boost::function< bool(ReconnectCtlPtr db_retry)> DbLostCallback
Defines a callback prototype for propogating events upward.
unsigned int retryInterval()
Returns the amount of time to wait between reconnect attempts.
DbInvalidReadOnly(const char *file, size_t line, const char *what)
Invalid 'readonly' value specification.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
DatabaseConnection(const ParameterMap ¶meters)
Constructor.
InvalidType(const char *file, size_t line, const char *what)
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
static std::string redactedAccessString(const ParameterMap ¶meters)
Redact database access string.
Exception thrown on failure to execute a database function.
ReconnectCtl(const std::string &backend_type, unsigned int max_retries, unsigned int retry_interval)
Constructor.