![]() |
Kea 2.7.3
|
Lease Manager Factory. More...
#include <lease_mgr_factory.h>
Static Public Member Functions | |
static void | create (const std::string &dbaccess) |
Create an instance of a lease manager. | |
static void | destroy () |
Destroy lease manager. | |
static bool | haveInstance () |
Indicates if the lease manager has been instantiated. | |
static TrackingLeaseMgr & | instance () |
Return current lease manager. | |
static void | recreate (const std::string &dbaccess, bool preserve_callbacks=true) |
Recreate an instance of a lease manager with optionally preserving registered callbacks. | |
Lease Manager Factory.
This class comprises nothing but static methods used to create a lease manager. It analyzes the database information passed to the creation function and instantiates an appropriate lease manager based on the type requested.
Strictly speaking these functions could be stand-alone functions. However, it is convenient to encapsulate them in a class for naming purposes.
Definition at line 44 of file lease_mgr_factory.h.
|
static |
Create an instance of a lease manager.
Each database backend has its own lease manager type. This static method sets the "current" lease manager to be a manager of the appropriate type. The actual lease manager is returned by the "instance" method.
dbaccess is a generic way of passing parameters. Parameters are passed in the "name=value" format, separated by spaces. The data MUST include a keyword/value pair of the form "type=dbtype" giving the database type, e.q. "mysql" or "sqlite3".
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. |
isc::InvalidParameter | dbaccess string does not contain the "type" keyword. |
isc::dhcp::InvalidType | The "type" keyword in dbaccess does not identify a supported backend. |
Definition at line 41 of file lease_mgr_factory.cc.
References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MEMFILE_DB, isc::dhcp::DHCPSRV_MYSQL_DB, isc::dhcp::DHCPSRV_NOTYPE_DB, isc::dhcp::DHCPSRV_PGSQL_DB, isc::dhcp::DHCPSRV_UNKNOWN_DB, isc_throw, LOG_ERROR, LOG_INFO, isc::db::DatabaseConnection::parse(), and isc::db::DatabaseConnection::redactedAccessString().
Referenced by recreate().
|
static |
Destroy lease manager.
Destroys the current lease manager object. This should have the effect of closing the database connection. The method is a no-op if no lease manager is available.
Definition at line 92 of file lease_mgr_factory.cc.
References isc::dhcp::DHCPSRV_CLOSE_DB, isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, and LOG_DEBUG.
Referenced by isc::dhcp::ControlledDhcpv4Srv::~ControlledDhcpv4Srv(), isc::dhcp::ControlledDhcpv6Srv::~ControlledDhcpv6Srv(), isc::dhcp::Dhcpv4Srv::~Dhcpv4Srv(), isc::dhcp::Dhcpv6Srv::~Dhcpv6Srv(), and recreate().
|
static |
Indicates if the lease manager has been instantiated.
Definition at line 122 of file lease_mgr_factory.cc.
Referenced by isc::dhcp::Allocator::~Allocator(), recreate(), and isc::dhcp::SrvConfig::updateStatistics().
|
static |
Return current lease manager.
Returns an instance of the "current" lease manager. An exception will be thrown if none is available.
isc::dhcp::NoLeaseManager | No lease manager is available: use create() to create one before calling this method. |
Definition at line 127 of file lease_mgr_factory.cc.
References isc_throw.
Referenced by isc::dhcp::Allocator::~Allocator(), isc::lease_cmds::LeaseCmdsImpl::addOrUpdate4(), isc::lease_cmds::LeaseCmdsImpl::addOrUpdate6(), isc::dhcp::AllocEngine::allocateLeases6(), isc::dhcp::Dhcpv4Srv::assignLease(), isc::dhcp::Dhcpv6Srv::checkDynamicSubnetChange(), isc::dhcp::Dhcpv6Srv::declineIA(), isc::dhcp::Dhcpv4Srv::declineLease(), isc::dhcp::Dhcpv6Srv::declineLease(), isc::dhcp::AllocEngine::deleteExpiredReclaimedLeases4(), isc::dhcp::AllocEngine::deleteExpiredReclaimedLeases6(), isc::lease_cmds::LeaseCmdsImpl::getIPv6LeaseForDelete(), isc::lease_cmds::LeaseCmdsImpl::lease4DelHandler(), isc::lease_cmds::LeaseCmdsImpl::lease4ResendDdnsHandler(), isc::lease_cmds::LeaseCmdsImpl::lease4WipeHandler(), isc::lease_cmds::LeaseCmdsImpl::lease6BulkApplyHandler(), isc::lease_cmds::LeaseCmdsImpl::lease6DelHandler(), isc::lease_cmds::LeaseCmdsImpl::lease6ResendDdnsHandler(), isc::lease_cmds::LeaseCmdsImpl::lease6WipeHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseAddHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetAllHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByClientIdHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByDuidHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByHostnameHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetByHwAddressHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseGetPageHandler(), isc::lease_cmds::LeaseCmdsImpl::leaseWriteHandler(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet4(), isc::stat_cmds::LeaseStatCmdsImpl::makeResultSet6(), isc::dhcp::Dhcpv4Srv::postAllocateNameUpdate(), isc::dhcp::Dhcpv4Srv::processDecline(), isc::dhcp::Dhcpv4Srv::processRelease(), isc::dhcp::AllocEngine::reclaimExpiredLeases4Internal(), isc::dhcp::AllocEngine::reclaimExpiredLeases6Internal(), isc::dhcp::Dhcpv4Srv::recoverStashedAgentOption(), recreate(), isc::dhcp::Dhcpv6Srv::releaseIA_NA(), isc::dhcp::Dhcpv6Srv::releaseIA_PD(), isc::dhcp::AllocEngine::renewLeases6(), isc::dhcp::Dhcpv4Srv::serverDecline(), isc::dhcp::CfgSubnets4::updateStatistics(), and isc::dhcp::CfgSubnets6::updateStatistics().
|
static |
Recreate an instance of a lease manager with optionally preserving registered callbacks.
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. |
preserve_callbacks | a boolean flag indicating if all registered TrackingLeaseMgr callbacks should be copied to the new instance. |
Definition at line 103 of file lease_mgr_factory.cc.
References create(), destroy(), haveInstance(), and instance().
Referenced by isc::dhcp::CfgDbAccess::createManagers(), isc::dhcp::MySqlLeaseMgr::dbReconnect(), and isc::dhcp::PgSqlLeaseMgr::dbReconnect().