12#include <boost/algorithm/string.hpp> 
   27map<string, pair<LeaseMgrFactory::Factory, LeaseMgrFactory::DBVersion>> LeaseMgrFactory::map_;
 
   32isc::dhcp::MemfileLeaseMgrInit memfile_init;
 
   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");
 
   58    string db_type = it->second;
 
   59    auto index = map_.find(db_type);
 
   62    if (index == map_.end()) {
 
   63        if ((db_type == 
"mysql") || (db_type == 
"postgresql")) {
 
   65            string libdhcp(db_type == 
"postgresql" ? 
"pgsql" : db_type);
 
   67                      "support for lease database type: " << db_type
 
   68                      << 
". Did you forget to use -D " 
   69                      << db_type << 
"=enabled during setup or to load libdhcp_" 
   70                      << libdhcp << 
" hook library?");
 
   75                  "not specify a supported database backend: " << parameters[type]);
 
   79    getLeaseMgrPtr() = index->second.first(parameters);
 
   82    if (!getLeaseMgrPtr()) {
 
   84                  " factory returned null");
 
 
   92    if (getLeaseMgrPtr()) {
 
   94            .arg(getLeaseMgrPtr()->getType());
 
   95        getLeaseMgrPtr().reset();
 
 
  120    return (!!getLeaseMgrPtr());
 
 
  137    if (map_.count(db_type)) {
 
  141    static auto default_db_version = []() -> std::string {
 
  142        return (std::string());
 
  146        db_version = default_db_version;
 
  149    map_.insert(pair<
string, pair<Factory, DBVersion>>(db_type, pair<Factory, DBVersion>(factory, db_version)));
 
 
  164    auto index = map_.find(db_type);
 
  165    if (index != map_.end()) {
 
 
  180    auto index = map_.find(db_type);
 
  181    return (index != map_.end());
 
 
  186    std::stringstream txt;
 
  188    for (
auto const& x : map_) {
 
  189        if (!txt.str().empty()) {
 
 
  199std::list<std::string>
 
  201    std::list<std::string> result;
 
  202    for (
auto const& x : map_) {
 
  203        auto version = x.second.second();
 
 
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 bool registerFactory(const std::string &db_type, const Factory &factory, bool no_log=false, DBVersion db_version=DBVersion())
Register a lease mgr factory.
static std::list< std::string > getDBVersions()
Return extended version info for registered backends.
std::function< TrackingLeaseMgrPtr(const db::DatabaseConnection::ParameterMap &)> Factory
Type of lease mgr factory.
static void destroy()
Destroy lease manager.
static bool registeredFactory(const std::string &db_type)
Check if a lease mgr factory was registered.
std::function< std::string()> DBVersion
Type of lease mgr version.
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.
No lease manager exception.
Introduces callbacks into the LeaseMgr.
boost::shared_ptr< CallbackContainer > CallbackContainerPtr
Pointer to the callback container.
CallbackContainerPtr callbacks_
The multi-index container holding registered callbacks.
int version()
returns Kea hooks version.
#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_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.
Defines the logger used by the top-level component of kea-lfc.