19#include <boost/algorithm/string.hpp>
34map<string, LeaseMgrFactory::Factory> LeaseMgrFactory::map_;
37LeaseMgrFactory::getLeaseMgrPtr() {
39 return (lease_mgr_ptr);
44 const std::string type =
"type";
51 DatabaseConnection::ParameterMap::iterator it = parameters.find(type);
52 if (it == parameters.end()) {
55 "contain the 'type' keyword");
88 string db_type = it->second;
89 auto index = map_.find(db_type);
92 if (index == map_.end()) {
93 if ((db_type ==
"mysql") || (db_type ==
"postgresql")) {
95 string with = (db_type ==
"postgresql" ?
"pgsql" : db_type);
97 "support for database type: " << db_type
98 <<
". Did you forget to use --with-"
99 << with <<
" during compilation?");
104 "not specify a supported database backend: " << parameters[type]);
108 getLeaseMgrPtr() = index->second(parameters);
111 if (!getLeaseMgrPtr()) {
113 " factory returned null");
121 if (getLeaseMgrPtr()) {
123 .arg(getLeaseMgrPtr()->getType());
125 getLeaseMgrPtr().reset();
158 return (!!getLeaseMgrPtr());
172 const Factory& factory,
174 if (map_.count(db_type)) {
177 map_.insert(pair<string, Factory>(db_type, factory));
192 auto index = map_.find(db_type);
193 if (index != map_.end()) {
208 auto index = map_.find(db_type);
209 return (index != map_.end());
214 std::stringstream txt;
216 for (
auto const& x : map_) {
217 if (!txt.str().empty()) {
A generic exception that is thrown if a parameter given to a method or function is considered invalid...
A generic exception that is thrown when an unexpected error condition occurs.
static std::string redactedAccessString(const ParameterMap ¶meters)
Redact database access string.
static ParameterMap parse(const std::string &dbaccess)
Parse database access string.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
static void create(const std::string &dbaccess)
Create an instance of a lease manager.
static TrackingLeaseMgr & instance()
Return current lease manager.
static void destroy()
Destroy lease manager.
static bool registeredFactory(const std::string &db_type)
Check if a lease mgr factory was registered.
static bool registerFactory(const std::string &db_type, const Factory &factory, bool no_log=false)
Register a lease mgr factory.
static bool haveInstance()
Indicates if the lease manager has been instantiated.
static bool deregisterFactory(const std::string &db_type, bool no_log=false)
Deregister a lease mgr factory.
static void logRegistered()
Logs out all registered backends.
static void recreate(const std::string &dbaccess, bool preserve_callbacks=true)
Recreate an instance of a lease manager with optionally preserving registered callbacks.
Concrete implementation of a lease database backend using flat file.
No lease manager exception.
PostgreSQL Lease Manager.
Introduces callbacks into the LeaseMgr.
boost::shared_ptr< CallbackContainer > CallbackContainerPtr
Pointer to the callback container.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
const isc::log::MessageID DHCPSRV_LEASE_MGR_BACKENDS_REGISTERED
const isc::log::MessageID DHCPSRV_MEMFILE_DB
const isc::log::MessageID DHCPSRV_PGSQL_DB
const isc::log::MessageID DHCPSRV_LEASE_MGR_BACKEND_DEREGISTER
const isc::log::MessageID DHCPSRV_CLOSE_DB
const isc::log::MessageID DHCPSRV_UNKNOWN_DB
const isc::log::MessageID DHCPSRV_LEASE_MGR_BACKEND_REGISTER
const isc::log::MessageID DHCPSRV_NOTYPE_DB
std::unique_ptr< TrackingLeaseMgr > TrackingLeaseMgrPtr
TrackingLeaseMgr pointer.
const int DHCPSRV_DBG_TRACE
DHCP server library logging levels.
const isc::log::MessageID DHCPSRV_MYSQL_DB
Defines the logger used by the top-level component of kea-lfc.