26#include <boost/algorithm/string.hpp>
27#include <boost/foreach.hpp>
28#include <boost/scoped_ptr.hpp>
43map<string, HostDataSourceFactory::Factory> HostDataSourceFactory::map_;
47 const string& dbaccess) {
53 DatabaseConnection::ParameterMap::iterator it = parameters.find(
"type");
54 if (it == parameters.end()) {
56 "contain the 'type' keyword");
59 string db_type = it->second;
60 auto index = map_.find(db_type);
63 if (index == map_.end()) {
65 db_type <<
"' is not currently supported");
69 sources.push_back(boost::shared_ptr<BaseHostDataSource>(index->second(parameters)));
72 if (!sources.back()) {
75 " factory returned NULL");
81 const string& db_type) {
82 for (
auto it = sources.begin(); it != sources.end(); ++it) {
83 if ((*it)->getType() != db_type) {
98 if (map_.count(db_type)) {
101 map_.insert(pair<string, Factory>(db_type, factory));
116 auto index = map_.find(db_type);
117 if (index != map_.end()) {
121 HOSTS_BACKEND_DEREGISTER)
132 auto index = map_.find(db_type);
133 return (index != map_.end());
138 std::stringstream txt;
140 for (
auto x : map_) {
141 txt << x.first <<
" ";
159struct MySqlHostDataSourceInit {
161 MySqlHostDataSourceInit() {
166 ~MySqlHostDataSourceInit() {
180MySqlHostDataSourceInit mysql_init_;
184struct PgSqlHostDataSourceInit {
186 PgSqlHostDataSourceInit() {
191 ~PgSqlHostDataSourceInit() {
205PgSqlHostDataSourceInit pgsql_init_;
209struct CqlHostDataSourceInit {
211 CqlHostDataSourceInit() {
216 ~CqlHostDataSourceInit() {
230CqlHostDataSourceInit cql_init_;
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.
Cassandra host data source.
boost::function< HostDataSourcePtr(const db::DatabaseConnection::ParameterMap &)> Factory
Type of host data source factory.
static bool deregisterFactory(const std::string &db_type, bool no_log=false)
Deregister a host data source factory.
static void add(HostDataSourceList &sources, const std::string &dbaccess)
Create and add an instance of a host data source.
static void printRegistered()
Prints out all registered backends.
static bool registerFactory(const std::string &db_type, const Factory &factory, bool no_log=false)
Register a host data source factory.
static bool del(HostDataSourceList &sources, const std::string &db_type)
Delete a host data source.
static bool registeredFactory(const std::string &db_type)
Check if a host data source factory was registered.
PostgreSQL Host Data Source.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Logging initialization functions.
#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.
boost::shared_ptr< BaseHostDataSource > HostDataSourcePtr
HostDataSource pointer.
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
isc::log::Logger hosts_logger("hosts")
Logger for the HostMgr and the code it calls.
std::vector< HostDataSourcePtr > HostDataSourceList
HostDataSource list.
const int DHCPSRV_DBG_TRACE
DHCP server library logging levels.
Defines the logger used by the top-level component of kea-dhcp-ddns.