Kea 3.2.1-git
isc::d2::D2UpdateMgr Class Reference

D2UpdateMgr creates and manages update transactions. More...

#include <d2_update_mgr.h>

Inheritance diagram for isc::d2::D2UpdateMgr:

Public Member Functions

 D2UpdateMgr (D2QueueMgrPtr &queue_mgr, D2CfgMgrPtr &cfg_mgr, asiolink::IOServicePtr &io_service, const size_t max_transactions=MAX_TRANSACTIONS_DEFAULT)
 Constructor.
virtual ~D2UpdateMgr ()
 Destructor.
void clearTransactions ()
 Immediately discards all entries in the transaction list.
TransactionAddressIndex::iterator findTransactionByAddress (const asiolink::IOAddress &address) const
 Search the transaction store for a given address.
TransactionFqdnIndex::iterator findTransactionByFqdn (const std::string &fqdn) const
 Search the transaction store for an FQDN.
const asiolink::IOServicePtr & getIOService ()
 Gets the D2UpdateMgr's IOService.
size_t getMaxTransactions () const
 Returns the maximum number of concurrent transactions.
size_t getQueueCount () const
 Convenience method that returns the number of requests queued.
size_t getTransactionCount () const
 Returns the current number of transactions.
bool hasTransaction (const dhcp_ddns::NameChangeRequestPtr &ncr) const
 Checks if there is an active transaction matching the FQDN or ip address of an NCR.
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 transactionAddressBegin ()
 Returns the transaction store begin iterator, ordered by address.
TransactionAddressIndex::iterator transactionAddressEnd ()
 Returns the transaction store end iterator, ordered by address.
TransactionFqdnIndex::iterator transactionFqdnBegin ()
 Returns the transaction store begin iterator, ordered by FQDN.
TransactionFqdnIndex::iterator transactionFqdnEnd ()
 Returns the transaction store end iterator, ordered by FQDN.
TransactionSequenceIndex::iterator transactionSequenceBegin ()
 Returns the transaction store sequence begin position.
TransactionSequenceIndex::iterator transactionSequenceEnd ()
 Returns the transaction store sequence end position.

Static Public Attributes

static const size_t MAX_TRANSACTIONS_DEFAULT = 32
 Maximum number of concurrent transactions NOTE that 32 is an arbitrary choice picked for the initial implementation.

Protected Member Functions

void checkFinishedTransactions ()
 Performs post-completion cleanup on completed transactions.
bool makeTransaction (isc::dhcp_ddns::NameChangeRequestPtr &ncr)
 Create a new transaction for the given request.
void pickNextJob ()
 Starts a transaction for the next eligible request in the queue.

Detailed Description

D2UpdateMgr creates and manages update transactions.

D2UpdateMgr is the DHCP_DDNS task master, instantiating and then supervising transactions that execute the DNS updates needed to fulfill the requests (NameChangeRequests) received from DHCP_DDNS clients (e.g. DHCP servers).

D2UpdateMgr uses the services of D2QueueMgr to monitor the queue of NameChangeRequests and select and dequeue requests for processing. When a request is dequeued for processing it is removed from the queue and wrapped in NameChangeTransaction and added to the D2UpdateMgr's list of transactions.

As part of the process of forming transactions, D2UpdateMgr matches each request with the appropriate list of DNS servers. This matching is based upon request attributes, primarily the FQDN and update direction (forward or reverse). D2UpdateMgr uses the services of D2CfgMgr to match requests to DNS server lists.

Once created, each transaction is responsible for carrying out the steps required to fulfill its specific request. These steps typically consist of one or more DNS packet exchanges with the appropriate DNS server. As transactions complete, D2UpdateMgr removes them from the transaction list, replacing them with new transactions.

D2UpdateMgr carries out each of the above steps, with a method called sweep(). This method is intended to be called as IO events complete. The upper layer(s) are responsible for calling sweep in a timely and cyclic manner.

Definition at line 112 of file d2_update_mgr.h.

Constructor & Destructor Documentation

◆ D2UpdateMgr()

isc::d2::D2UpdateMgr::D2UpdateMgr ( D2QueueMgrPtr & queue_mgr,
D2CfgMgrPtr & cfg_mgr,
asiolink::IOServicePtr & io_service,
const size_t max_transactions = MAX_TRANSACTIONS_DEFAULT )

Constructor.

Parameters
queue_mgrreference to the queue manager receiving requests
cfg_mgrreference to the configuration manager
io_serviceIO service used by the upper layer(s) to manage IO events
max_transactionsthe maximum number of concurrent transactions
Exceptions
D2UpdateMgrErrorif either the queue manager or configuration managers are NULL, or max transactions is less than one.

Definition at line 30 of file d2_update_mgr.cc.

References isc_throw, and setMaxTransactions().

Referenced by isc::d2::D2Process::D2Process().

Here is the call graph for this function:

◆ ~D2UpdateMgr()

isc::d2::D2UpdateMgr::~D2UpdateMgr ( )
virtual

Destructor.

Definition at line 51 of file d2_update_mgr.cc.

Member Function Documentation

◆ checkFinishedTransactions()

void isc::d2::D2UpdateMgr::checkFinishedTransactions ( )
protected

Performs post-completion cleanup on completed transactions.

Iterates through the list of transactions and removes any that have reached completion. This method may expand in complexity or even disappear altogether as the implementation matures.

Definition at line 80 of file d2_update_mgr.cc.

Referenced by sweep().

◆ clearTransactions()

void isc::d2::D2UpdateMgr::clearTransactions ( )

Immediately discards all entries in the transaction list.

Todo
For now this just wipes them out. We might need something more elegant, that allows a cancel first.

Definition at line 287 of file d2_update_mgr.cc.

◆ findTransactionByAddress()

TransactionAddressIndex::iterator isc::d2::D2UpdateMgr::findTransactionByAddress ( const asiolink::IOAddress & address) const

Search the transaction store for a given address.

Parameters
addressthe transaction address value for which to search.
Returns
Iterator pointing to the entry found. If no entry is it will point to the list end position.

Definition at line 347 of file d2_update_mgr.cc.

◆ findTransactionByFqdn()

TransactionFqdnIndex::iterator isc::d2::D2UpdateMgr::findTransactionByFqdn ( const std::string & fqdn) const

Search the transaction store for an FQDN.

Parameters
fqdntransaction fqdn value for which to search.
Returns
Iterator pointing to the entry found. If no entry is it will point to the list end position.

Definition at line 332 of file d2_update_mgr.cc.

◆ getIOService()

const asiolink::IOServicePtr & isc::d2::D2UpdateMgr::getIOService ( )
inline

Gets the D2UpdateMgr's IOService.

Returns
returns a reference to the IOService

Definition at line 211 of file d2_update_mgr.h.

◆ getMaxTransactions()

size_t isc::d2::D2UpdateMgr::getMaxTransactions ( ) const
inline

Returns the maximum number of concurrent transactions.

Definition at line 216 of file d2_update_mgr.h.

Referenced by sweep().

◆ getQueueCount()

size_t isc::d2::D2UpdateMgr::getQueueCount ( ) const

Convenience method that returns the number of requests queued.

Definition at line 312 of file d2_update_mgr.cc.

Referenced by pickNextJob(), and sweep().

◆ getTransactionCount()

size_t isc::d2::D2UpdateMgr::getTransactionCount ( ) const

Returns the current number of transactions.

Definition at line 317 of file d2_update_mgr.cc.

Referenced by pickNextJob(), setMaxTransactions(), and sweep().

◆ hasTransaction()

bool isc::d2::D2UpdateMgr::hasTransaction ( const dhcp_ddns::NameChangeRequestPtr & ncr) const

Checks if there is an active transaction matching the FQDN or ip address of an NCR.

Parameters
ncrNameChangeRequest to search with
Returns
True if a matching transaction exists

Definition at line 263 of file d2_update_mgr.cc.

References isc_throw.

Referenced by pickNextJob().

◆ makeTransaction()

bool isc::d2::D2UpdateMgr::makeTransaction ( isc::dhcp_ddns::NameChangeRequestPtr & ncr)
protected

Create a new transaction for the given request.

This method will attempt to match the request to suitable DNS servers. If matching servers are found, it will instantiate a transaction for the requests, add the transaction to the transaction list, and start the transaction.

If updates in a given direction are disabled requests for updates in that direction will be ignored. For example: If a request is received which asks for updates in both directions but only forward updates are enabled; only the forward update will be attempted. Effectively, the request will be treated as if it only asked for forward updates.

If updates in a given direction are enabled, and a request asks for updates in that direction, failing to match the request to a list of servers is an error which will be logged and the request will be discarded.

Finally, If conflict resolution is enabled, it will instantiate either a NameAddTransaction or a NameRemoveTransaction. If disabled it will instantiate either a SimpleAddTransaction or a SimpleRemoveTransaction.

Parameters
ncrthe NameChangeRequest for which to create a transaction.
Returns
True if a transaction was added, false otherwise.
Exceptions
D2UpdateMgrErrorif a transaction for this DHCID already exists. Note this would be programmatic error.

Definition at line 129 of file d2_update_mgr.cc.

References isc::d2::CheckExistsAddTransaction::CheckExistsAddTransaction(), isc::d2::CheckExistsRemoveTransaction::CheckExistsRemoveTransaction(), isc::d2::NameAddTransaction::NameAddTransaction(), isc::d2::NameRemoveTransaction::NameRemoveTransaction(), isc::d2::SimpleAddTransaction::SimpleAddTransaction(), isc::d2::SimpleAddWithoutDHCIDTransaction::SimpleAddWithoutDHCIDTransaction(), isc::d2::SimpleRemoveTransaction::SimpleRemoveTransaction(), isc::d2::SimpleRemoveWithoutDHCIDTransaction::SimpleRemoveWithoutDHCIDTransaction(), isc::dhcp_ddns::CHECK_EXISTS_WITH_DHCID, isc::dhcp_ddns::CHECK_WITH_DHCID, isc::dhcp_ddns::CHG_ADD, isc::log::DBGLVL_TRACE_DETAIL_DATA, isc::d2::DHCP_DDNS_FWD_REQUEST_IGNORED, isc::d2::DHCP_DDNS_NO_FWD_MATCH_ERROR, isc::d2::DHCP_DDNS_NO_REV_MATCH_ERROR, isc::d2::DHCP_DDNS_REQUEST_DROPPED, isc::d2::DHCP_DDNS_REV_REQUEST_IGNORED, isc::d2::dhcp_to_d2_logger, isc_throw, LOG_DEBUG, LOG_ERROR, and isc::dhcp_ddns::NO_CHECK_WITHOUT_DHCID.

Referenced by pickNextJob().

Here is the call graph for this function:

◆ pickNextJob()

void isc::d2::D2UpdateMgr::pickNextJob ( )
protected

Starts a transaction for the next eligible request in the queue.

This method will scan the request queue for the next request to dequeue. The current implementation starts at the front of the queue and looks for the first request for whose FQDN and ip address there is no current transaction in progress. If request is a duplicate (same client, FQDN, address, and flags) for an active transaction, the request is discarded. If the request is partial match it is skipped but left in place on the queue to be checked on a subsequent call. If a request is selected, it is removed from the queue and transaction is constructed for it.

It is possible that no such request exists, though this is likely to be rather rare unless a system is frequently seeing requests for the same clients in quick succession.

Definition at line 96 of file d2_update_mgr.cc.

References isc::log::DBGLVL_TRACE_DETAIL_DATA, isc::d2::DHCP_DDNS_NO_ELIGIBLE_JOBS, isc::d2::dhcp_to_d2_logger, getQueueCount(), getTransactionCount(), hasTransaction(), LOG_DEBUG, and makeTransaction().

Referenced by sweep().

Here is the call graph for this function:

◆ setMaxTransactions()

void isc::d2::D2UpdateMgr::setMaxTransactions ( const size_t max_transactions)

Sets the maximum number of entries allowed in the queue.

Parameters
max_transactionsis the new maximum number of transactions
Exceptions
ThrowsD2QueueMgrError if the new value is less than one or if the new value is less than the number of entries currently in the queue.

Definition at line 294 of file d2_update_mgr.cc.

References getTransactionCount(), and isc_throw.

Referenced by D2UpdateMgr().

Here is the call graph for this function:

◆ sweep()

void isc::d2::D2UpdateMgr::sweep ( )

Check current transactions; start transactions for new requests.

This method is the primary public interface used by the upper layer. It should be called as IO events complete. During each invocation it does the following:

  • Removes all completed transactions from the transaction list.
  • If the request queue is not empty and the number of transactions in the transaction list has not reached maximum allowed, then select a request from the queue.
  • If a request was selected, start a new transaction for it and add the transaction to the list of transactions.

Definition at line 55 of file d2_update_mgr.cc.

References checkFinishedTransactions(), isc::log::DBGLVL_TRACE_DETAIL_DATA, isc::d2::DHCP_DDNS_AT_MAX_TRANSACTIONS, isc::d2::dhcp_to_d2_logger, getMaxTransactions(), getQueueCount(), getTransactionCount(), LOG_DEBUG, and pickNextJob().

Here is the call graph for this function:

◆ transactionAddressBegin()

TransactionAddressIndex::iterator isc::d2::D2UpdateMgr::transactionAddressBegin ( )

Returns the transaction store begin iterator, ordered by address.

Definition at line 352 of file d2_update_mgr.cc.

◆ transactionAddressEnd()

TransactionAddressIndex::iterator isc::d2::D2UpdateMgr::transactionAddressEnd ( )

Returns the transaction store end iterator, ordered by address.

Definition at line 357 of file d2_update_mgr.cc.

◆ transactionFqdnBegin()

TransactionFqdnIndex::iterator isc::d2::D2UpdateMgr::transactionFqdnBegin ( )

Returns the transaction store begin iterator, ordered by FQDN.

Definition at line 337 of file d2_update_mgr.cc.

◆ transactionFqdnEnd()

TransactionFqdnIndex::iterator isc::d2::D2UpdateMgr::transactionFqdnEnd ( )

Returns the transaction store end iterator, ordered by FQDN.

Definition at line 342 of file d2_update_mgr.cc.

◆ transactionSequenceBegin()

TransactionSequenceIndex::iterator isc::d2::D2UpdateMgr::transactionSequenceBegin ( )

Returns the transaction store sequence begin position.

Definition at line 322 of file d2_update_mgr.cc.

◆ transactionSequenceEnd()

TransactionSequenceIndex::iterator isc::d2::D2UpdateMgr::transactionSequenceEnd ( )

Returns the transaction store sequence end position.

Definition at line 327 of file d2_update_mgr.cc.

Member Data Documentation

◆ MAX_TRANSACTIONS_DEFAULT

const size_t isc::d2::D2UpdateMgr::MAX_TRANSACTIONS_DEFAULT = 32
static

Maximum number of concurrent transactions NOTE that 32 is an arbitrary choice picked for the initial implementation.

Definition at line 117 of file d2_update_mgr.h.


The documentation for this class was generated from the following files: