Kea  1.9.9-git
isc::db::ReconnectCtl Class Reference

Warehouses DB reconnect control values. More...

#include <database_connection.h>

Public Member Functions

 ReconnectCtl (const std::string &backend_type, const std::string &timer_name, unsigned int max_retries, unsigned int retry_interval, OnFailAction action)
 Constructor. More...
 
bool alterServiceState ()
 Return true if the connection loss should affect the service, false otherwise. More...
 
std::string backendType () const
 Returns the type of the caller backend. More...
 
bool checkRetries ()
 Decrements the number of retries remaining. More...
 
bool exitOnFailure ()
 Return true if the connection recovery mechanism should shut down the server on failure, false otherwise. More...
 
unsigned int maxRetries ()
 Returns the maximum number of retries allowed. More...
 
void resetRetries ()
 Resets the retries count. More...
 
unsigned int retriesLeft ()
 Returns the number for retries remaining. More...
 
unsigned int retryInterval ()
 Returns the amount of time to wait between reconnect attempts. More...
 
std::string timerName () const
 Returns the associated timer name. More...
 

Static Public Member Functions

static OnFailAction onFailActionFromText (const std::string &text)
 Convert string to action. More...
 
static std::string onFailActionToText (OnFailAction action)
 Convert action to string. More...
 

Detailed Description

Warehouses DB reconnect control values.

When a DatabaseConnection loses connectivity to its backend, it creates an instance of this class based on its configuration parameters and passes the instance into connection's DB lost callback. This allows the layer(s) above the connection to know how to proceed.

Definition at line 93 of file database_connection.h.

Constructor & Destructor Documentation

isc::db::ReconnectCtl::ReconnectCtl ( const std::string &  backend_type,
const std::string &  timer_name,
unsigned int  max_retries,
unsigned int  retry_interval,
OnFailAction  action 
)
inline

Constructor.

Parameters
backend_typetype of the caller backend.
timer_nametimer associated to this object.
max_retriesmaximum number of reconnect attempts to make.
retry_intervalamount of time to between reconnect attempts.
actionwhich should be taken on connection loss.

Definition at line 102 of file database_connection.h.

Member Function Documentation

bool isc::db::ReconnectCtl::alterServiceState ( )
inline

Return true if the connection loss should affect the service, false otherwise.

Definition at line 151 of file database_connection.h.

References isc::db::STOP_RETRY_EXIT.

std::string isc::db::ReconnectCtl::backendType ( ) const
inline

Returns the type of the caller backend.

Definition at line 110 of file database_connection.h.

bool isc::db::ReconnectCtl::checkRetries ( )
inline

Decrements the number of retries remaining.

Each call decrements the number of retries by one until zero is reached.

Returns
true the number of retries remaining is greater than zero.

Definition at line 125 of file database_connection.h.

bool isc::db::ReconnectCtl::exitOnFailure ( )
inline

Return true if the connection recovery mechanism should shut down the server on failure, false otherwise.

Definition at line 157 of file database_connection.h.

References isc::db::SERVE_RETRY_EXIT, and isc::db::STOP_RETRY_EXIT.

unsigned int isc::db::ReconnectCtl::maxRetries ( )
inline

Returns the maximum number of retries allowed.

Definition at line 130 of file database_connection.h.

OnFailAction isc::db::ReconnectCtl::onFailActionFromText ( const std::string &  text)
static

Convert string to action.

Parameters
textThe text to be converted to action type.
Returns
The action type corresponding to the text representation.

Definition at line 293 of file database_connection.cc.

References isc_throw.

std::string isc::db::ReconnectCtl::onFailActionToText ( OnFailAction  action)
static

Convert action to string.

Parameters
actionThe action type to be converted to text.
Returns
The text representation of the action type.

Definition at line 280 of file database_connection.cc.

void isc::db::ReconnectCtl::resetRetries ( )
inline

Resets the retries count.

Definition at line 145 of file database_connection.h.

unsigned int isc::db::ReconnectCtl::retriesLeft ( )
inline

Returns the number for retries remaining.

Definition at line 135 of file database_connection.h.

unsigned int isc::db::ReconnectCtl::retryInterval ( )
inline

Returns the amount of time to wait between reconnect attempts.

Definition at line 140 of file database_connection.h.

std::string isc::db::ReconnectCtl::timerName ( ) const
inline

Returns the associated timer name.

Returns
the associated timer.

Definition at line 117 of file database_connection.h.


The documentation for this class was generated from the following files: