16#include <boost/foreach.hpp>
17#include <boost/date_time/posix_time/posix_time.hpp>
18#include <boost/date_time/gregorian/gregorian.hpp>
81template<
typename ConfigBackendMgrType>
140 if (!config_ctl || config_ctl->getConfigDatabases().empty()) {
146 for (
auto const& db : config_ctl->getConfigDatabases()) {
147 const std::string& redacted = db.redactedAccessString();
151 getMgr().addBackend(db.getAccessString());
154 .arg(redacted).arg(err.what());
164 getMgr().delAllBackends();
196 std::string server_tag = srv_cfg->getServerTag();
217 audit_entries =
getMgr().getPool()->getRecentAuditEntries(backend_selector,
219 lb_modification_time,
228 audit_entries.clear();
238 lb_modification_time, audit_entries);
271 const std::string& object_type)
const {
274 auto range = index.equal_range(object_type);
275 BOOST_FOREACH(
auto const& it, range) {
313 const boost::posix_time::ptime& lb_modification_time,
321 return (ConfigBackendMgrType::instance());
329 static boost::posix_time::ptime
330 initial_time(boost::gregorian::date(2000, boost::gregorian::Jan, 1));
331 return (initial_time);
344 if (audit_entries.empty()) {
373 const uint64_t& object_id) {
375 return (object_id_idx.count(object_id) > 0);
Exception thrown on failure to open database but permit retries.
Server selector for associating objects in a database with specific servers.
static ServerSelector ALL()
Factory returning "all servers" selector.
static ServerSelector ONE(const std::string &server_tag)
Factory returning selector of one server.
Base class for implementing server specific mechanisms to control the use of the Configuration Backen...
FetchMode
Fetch mode used in invocations to databaseConfigFetch.
db::AuditEntryCollection fetchConfigElement(const db::AuditEntryCollection &audit_entries, const std::string &object_type) const
Returns audit entries for new or updated configuration elements of specific type to be fetched from t...
bool databaseConfigConnect(const ConfigPtr &srv_cfg)
(Re)connects to the specified configuration backends.
uint64_t last_audit_revision_id_
Stores the most recent audit revision identifier.
virtual void databaseConfigApply(const db::BackendSelector &backend_selector, const db::ServerSelector &server_selector, const boost::posix_time::ptime &lb_modification_time, const db::AuditEntryCollection &audit_entries)=0
Server specific method to fetch and apply back end configuration into the local configuration.
virtual void databaseConfigFetch(const ConfigPtr &srv_cfg, const FetchMode &fetch_mode=FetchMode::FETCH_ALL)
Fetches the entire or partial configuration from the database.
CBControlBase()
Constructor.
virtual ~CBControlBase()
Virtual destructor.
boost::posix_time::ptime last_audit_revision_time_
Stores the most recent audit revision timestamp.
void reset()
Resets the state of this object.
void databaseConfigDisconnect()
Disconnects from the configuration backends.
void updateLastAuditRevisionTimeId(const db::AuditEntryCollection &audit_entries)
Updates timestamp of the most recent audit entry fetched from the database.
static boost::posix_time::ptime getInitialAuditRevisionTime()
Convenience method returning initial timestamp to set the last_audit_revision_time_ to.
ConfigBackendMgrType & getMgr() const
Returns the instance of the Config Backend Manager used by this object.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
boost::multi_index_container< AuditEntryPtr, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::tag< AuditEntryObjectTypeTag >, boost::multi_index::composite_key< AuditEntry, boost::multi_index::const_mem_fun< AuditEntry, std::string, &AuditEntry::getObjectType >, boost::multi_index::const_mem_fun< AuditEntry, AuditEntry::ModificationType, &AuditEntry::getModificationType > > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< AuditEntryModificationTimeIdTag >, boost::multi_index::composite_key< AuditEntry, boost::multi_index::const_mem_fun< AuditEntry, boost::posix_time::ptime, &AuditEntry::getModificationTime >, boost::multi_index::const_mem_fun< AuditEntry, uint64_t, &AuditEntry::getRevisionId > > >, boost::multi_index::hashed_non_unique< boost::multi_index::tag< AuditEntryObjectIdTag >, boost::multi_index::const_mem_fun< AuditEntry, uint64_t, &AuditEntry::getObjectId > > > > AuditEntryCollection
Multi index container holding AuditEntry instances.
isc::log::Logger dctl_logger("dctl")
Defines the logger used within libkea-process library.
bool hasObjectId(const db::AuditEntryCollection &audit_entries, const uint64_t &object_id)
Checks if an object is in a collection od audit entries.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
const isc::log::MessageID DCTL_OPEN_CONFIG_DB
const isc::log::MessageID DCTL_CONFIG_FETCH
boost::shared_ptr< const ConfigControlInfo > ConstConfigControlInfoPtr
Defines a pointer to a const ConfigControlInfo.
const isc::log::MessageID DCTL_DB_OPEN_CONNECTION_WITH_RETRY_FAILED
Defines the logger used by the top-level component of kea-lfc.
Tag used to access index by modification time.
Tag used to access index by object id.
Tag used to access index by object type.