32 const size_t max_transactions)
33 :queue_mgr_(queue_mgr), cfg_mgr_(cfg_mgr), io_service_(io_service) {
40 "D2UpdateMgr configuration manager cannot be null");
52 transaction_store_.clear();
86 auto siter = sidx.begin();
87 while (siter != sidx.end()) {
88 if ((*siter)->isModelDone()) {
89 siter = transaction_store_.get<
SequenceTag>().erase(siter);
104 for (
size_t index = 0; index < queue_count; ) {
111 queue_mgr_->dequeueAt(index);
130 int direction_count = 0;
133 if (next_ncr->isForwardChange()) {
134 if (!cfg_mgr_->forwardUpdatesEnabled()) {
135 next_ncr->setForwardChange(
false);
138 .arg(next_ncr->getRequestId())
139 .arg(next_ncr->toText());
141 bool matched = cfg_mgr_->matchForward(next_ncr->getFqdn(),
148 .arg(next_ncr->getRequestId())
149 .arg(next_ncr->toText());
159 if (next_ncr->isReverseChange()) {
160 if (!cfg_mgr_->reverseUpdatesEnabled()) {
161 next_ncr->setReverseChange(
false);
164 .arg(next_ncr->getRequestId())
165 .arg(next_ncr->toText());
167 bool matched = cfg_mgr_->matchReverse(next_ncr->getIpAddress(),
174 .arg(next_ncr->getRequestId())
175 .arg(next_ncr->toText());
185 if (!direction_count) {
188 .arg(next_ncr->getRequestId())
189 .arg(next_ncr->toText());
199 if (next_ncr->getChangeType() ==
CHG_ADD) {
200 switch(next_ncr->getConflictResolutionMode()) {
203 forward_domain, reverse_domain,
208 forward_domain, reverse_domain,
213 forward_domain, reverse_domain,
219 forward_domain, reverse_domain,
224 switch(next_ncr->getConflictResolutionMode()) {
227 forward_domain, reverse_domain,
232 forward_domain, reverse_domain,
237 forward_domain, reverse_domain,
243 forward_domain, reverse_domain,
250 auto ret = transaction_store_.push_back(trans);
251 if (ret.second ==
false) {
254 << trans->getFqdn() <<
" or address " << trans->getIOAddress());
258 trans->startTransaction();
266 "D2UpdateMgr::hasTransaction() ncr cannot be null");
270 auto& fidx = transaction_store_.get<
FqdnTag>();
271 auto fiter = fidx.find(ncr->getFqdnLower());
272 if (fiter != fidx.end()) {
277 auto& aidx = transaction_store_.get<
AddressTag>();
278 auto aiter = aidx.find(ncr->getIOAddress());
279 if (aiter != aidx.end()) {
290 transaction_store_.clear();
296 if (new_trans_max < 1) {
298 " maximum transactions limit must be greater than zero");
304 "cannot be less than the current transaction count :"
308 max_transactions_ = new_trans_max;
313 return (queue_mgr_->getQueueSize());
318 return (transaction_store_.size());
321TransactionSequenceIndex::iterator
323 return (transaction_store_.get<
SequenceTag>().begin());
326TransactionSequenceIndex::iterator
328 return (transaction_store_.get<
SequenceTag>().end());
331TransactionFqdnIndex::iterator
333 return (transaction_store_.get<
FqdnTag>().find(fqdn));
336TransactionFqdnIndex::iterator
338 return (transaction_store_.get<
FqdnTag>().begin());
341TransactionFqdnIndex::iterator
343 return (transaction_store_.get<
FqdnTag>().end());
346TransactionAddressIndex::iterator
348 return (transaction_store_.get<
AddressTag>().find(address));
351TransactionAddressIndex::iterator
353 return (transaction_store_.get<
AddressTag>().begin());
356TransactionAddressIndex::iterator
358 return (transaction_store_.get<
AddressTag>().end());
This file defines the class CheckExistsAddTransaction.
This file defines the class CheckExistsRemoveTransaction.
The IOAddress class represents an IP addresses (version agnostic).
CheckExistsAddTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
CheckExistsRemoveTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Event sent when replace attempt to fails with address not in use.
Thrown if the update manager encounters a general error.
TransactionFqdnIndex::iterator transactionFqdnBegin()
Returns the transaction store begin iterator, ordered by FQDN.
TransactionAddressIndex::iterator transactionAddressEnd()
Returns the transaction store end iterator, ordered by address.
virtual ~D2UpdateMgr()
Destructor.
bool makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr &ncr)
Create a new transaction for the given request.
TransactionFqdnIndex::iterator transactionFqdnEnd()
Returns the transaction store end iterator, ordered by FQDN.
TransactionAddressIndex::iterator transactionAddressBegin()
Returns the transaction store begin iterator, ordered by address.
TransactionSequenceIndex::iterator transactionSequenceEnd()
Returns the transaction store sequence end position.
void checkFinishedTransactions()
Performs post-completion cleanup on completed transactions.
void setMaxTransactions(const size_t max_transactions)
Sets the maximum number of entries allowed in the queue.
void sweep()
Check current transactions; start transactions for new requests.
TransactionAddressIndex::iterator findTransactionByAddress(const asiolink::IOAddress &address) const
Search the transaction store for a given address.
size_t getMaxTransactions() const
Returns the maximum number of concurrent transactions.
size_t getQueueCount() const
Convenience method that returns the number of requests queued.
bool hasTransaction(const dhcp_ddns::NameChangeRequestPtr &ncr) const
Checks if there is an active transaction matching the FQDN or ip address of an NCR.
D2UpdateMgr(D2QueueMgrPtr &queue_mgr, D2CfgMgrPtr &cfg_mgr, asiolink::IOServicePtr &io_service, const size_t max_transactions=MAX_TRANSACTIONS_DEFAULT)
Constructor.
size_t getTransactionCount() const
Returns the current number of transactions.
void pickNextJob()
Starts a transaction for the next eligible request in the queue.
void clearTransactions()
Immediately discards all entries in the transaction list.
TransactionFqdnIndex::iterator findTransactionByFqdn(const std::string &fqdn) const
Search the transaction store for an FQDN.
static const size_t MAX_TRANSACTIONS_DEFAULT
Maximum number of concurrent transactions NOTE that 32 is an arbitrary choice picked for the initial ...
TransactionSequenceIndex::iterator transactionSequenceBegin()
Returns the transaction store sequence begin position.
NameAddTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
NameRemoveTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Event sent when replace attempt to fails with address not in use.
SimpleAddTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
SimpleAddWithoutDHCIDTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Constructor.
SimpleRemoveTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Event sent when replace attempt to fails with address not in use.
SimpleRemoveWithoutDHCIDTransaction(asiolink::IOServicePtr &io_service, dhcp_ddns::NameChangeRequestPtr &ncr, DdnsDomainPtr &forward_domain, DdnsDomainPtr &reverse_domain, D2CfgMgrPtr &cfg_mgr)
Event sent when replace attempt to fails with address not in use.
This file defines the class D2UpdateMgr.
#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_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
const isc::log::MessageID DHCP_DDNS_REQUEST_DROPPED
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
const isc::log::MessageID DHCP_DDNS_NO_REV_MATCH_ERROR
const isc::log::MessageID DHCP_DDNS_FWD_REQUEST_IGNORED
const isc::log::MessageID DHCP_DDNS_REV_REQUEST_IGNORED
isc::log::Logger dhcp_to_d2_logger("dhcp-to-d2")
const isc::log::MessageID DHCP_DDNS_AT_MAX_TRANSACTIONS
boost::shared_ptr< NameChangeTransaction > NameChangeTransactionPtr
Defines a pointer to a NameChangeTransaction.
boost::shared_ptr< D2QueueMgr > D2QueueMgrPtr
Defines a pointer for manager instances.
const isc::log::MessageID DHCP_DDNS_NO_ELIGIBLE_JOBS
const isc::log::MessageID DHCP_DDNS_NO_FWD_MATCH_ERROR
@ CHECK_EXISTS_WITH_DHCID
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
const int DBGLVL_TRACE_DETAIL_DATA
Trace data associated with detailed operations.
Defines the logger used by the top-level component of kea-lfc.
This file defines the class NameAddTransaction.
This file defines the class NameRemoveTransaction.
This file defines the class SimpleAddWithoutDHCIDTransaction.
This file defines the class SimpleRemoveWithoutDHCIDTransaction.
Tag for index by ip-address.
Tag for insertion order index.