 |
Kea
1.5.0
|
Go to the documentation of this file.
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
static isc::data::ElementPtr toElementDbAccessString(const std::string &dbaccess)
Unparse an access string.
unsigned int retryInterval()
Returns the amount of time to wait between reconnect attempts.
DatabaseConnection(const ParameterMap ¶meters)
Constructor.
DbOperationError(const char *file, size_t line, const char *what)
static std::string redactedAccessString(const ParameterMap ¶meters)
Redact database access string.
Exception thrown if name of database is not specified.
bool configuredReadOnly() const
Convenience method checking if database should be opened with read only access.
bool checkRetries()
Decrements the number of retries remaining.
unsigned int retriesLeft()
Returns the number for retries remaining.
DbInvalidReadOnly(const char *file, size_t line, const char *what)
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.
std::string getParameter(const std::string &name) const
Returns value of a connection parameter.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
std::string backendType() const
Returns the type of the caller backend.
Exception thrown on failure to execute a database function.
InvalidType(const char *file, size_t line, const char *what)
unsigned int maxRetries()
Returns the maximum number for retries allowed.
Invalid 'readonly' value specification.
Warehouses DB reconnect control values.
DbInvalidTimeout(const char *file, size_t line, const char *what)
static ParameterMap parse(const std::string &dbaccess)
Parse database access string.
NoDatabaseName(const char *file, size_t line, const char *what)
virtual ReconnectCtlPtr makeReconnectCtl() const
Instantiates a ReconnectCtl based on the connection's reconnect parameters.
static DbLostCallback db_lost_callback
Optional call back function to invoke if a successfully open connection subsequently fails.
bool invokeDbLostCallback() const
Invokes the connection's lost connectivity callback.
Common database connection class.
boost::function< bool(ReconnectCtlPtr db_retry)> DbLostCallback
Defines a callback prototype for propogating events upward.
ReconnectCtl(const std::string &backend_type, unsigned int max_retries, unsigned int retry_interval)
Constructor.
boost::shared_ptr< Element > ElementPtr
static const time_t MAX_DB_TIME
Defines maximum value for time that can be reliably stored.
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
Exception thrown on failure to open database.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
virtual ~DatabaseConnection()
Destructor.
DbOpenError(const char *file, size_t line, const char *what)
static isc::data::ElementPtr toElement(const ParameterMap ¶ms)
Unparse a parameter map.