Kea  2.3.5-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. More...
 
virtual ~D2UpdateMgr ()
 Destructor. More...
 
void clearTransactionList ()
 Immediately discards all entries in the transaction list. More...
 
TransactionList::iterator findTransaction (const TransactionKey &key)
 Search the transaction list for the given key. More...
 
const asiolink::IOServicePtrgetIOService ()
 Gets the D2UpdateMgr's IOService. More...
 
size_t getMaxTransactions () const
 Returns the maximum number of concurrent transactions. More...
 
size_t getQueueCount () const
 Convenience method that returns the number of requests queued. More...
 
size_t getTransactionCount () const
 Returns the current number of transactions. More...
 
bool hasTransaction (const TransactionKey &key)
 Convenience method that checks transaction list for the given key. More...
 
void removeTransaction (const TransactionKey &key)
 Removes the entry pointed to by key from the transaction list. More...
 
void setMaxTransactions (const size_t max_transactions)
 Sets the maximum number of entries allowed in the queue. More...
 
void sweep ()
 Check current transactions; start transactions for new requests. More...
 
TransactionList::iterator transactionListBegin ()
 Returns the transaction list beg position. More...
 
TransactionList::iterator transactionListEnd ()
 Returns the transaction list end position. More...
 

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. More...
 

Protected Member Functions

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

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 65 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 24 of file d2_update_mgr.cc.

References isc_throw, and setMaxTransactions().

+ Here is the call graph for this function:

◆ ~D2UpdateMgr()

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

Destructor.

Definition at line 45 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 74 of file d2_update_mgr.cc.

Referenced by sweep().

◆ clearTransactionList()

void isc::d2::D2UpdateMgr::clearTransactionList ( )

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 259 of file d2_update_mgr.cc.

◆ findTransaction()

TransactionList::iterator isc::d2::D2UpdateMgr::findTransaction ( const TransactionKey key)

Search the transaction list for the given key.

Parameters
keythe transaction key 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 231 of file d2_update_mgr.cc.

Referenced by hasTransaction(), makeTransaction(), and removeTransaction().

◆ getIOService()

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

Gets the D2UpdateMgr's IOService.

Returns
returns a reference to the IOService

Definition at line 160 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 165 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 284 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 289 of file d2_update_mgr.cc.

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

◆ hasTransaction()

bool isc::d2::D2UpdateMgr::hasTransaction ( const TransactionKey key)

Convenience method that checks transaction list for the given key.

Parameters
keythe transaction key value for which to search.
Returns
Returns true if the key is found within the list, false otherwise.

Definition at line 236 of file d2_update_mgr.cc.

References findTransaction(), and transactionListEnd().

Referenced by pickNextJob().

+ Here is the call graph for this function:

◆ makeTransaction()

void 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.
Exceptions
D2UpdateMgrErrorif a transaction for this DHCID already exists. Note this would be programmatic error.

Definition at line 121 of file d2_update_mgr.cc.

References 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, findTransaction(), isc_throw, LOG_DEBUG, LOG_ERROR, isc::dhcp_ddns::D2Dhcid::toStr(), and transactionListEnd().

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 DHCID there is no current transaction in progress.

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:

◆ removeTransaction()

void isc::d2::D2UpdateMgr::removeTransaction ( const TransactionKey key)

Removes the entry pointed to by key from the transaction list.

Removes the entry referred to by key if it exists. It has no effect if the entry is not found.

Parameters
keyof the transaction to remove

Definition at line 241 of file d2_update_mgr.cc.

References findTransaction(), and transactionListEnd().

+ 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 266 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 49 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:

◆ transactionListBegin()

TransactionList::iterator isc::d2::D2UpdateMgr::transactionListBegin ( )

Returns the transaction list beg position.

Definition at line 249 of file d2_update_mgr.cc.

◆ transactionListEnd()

TransactionList::iterator isc::d2::D2UpdateMgr::transactionListEnd ( )

Returns the transaction list end position.

Definition at line 254 of file d2_update_mgr.cc.

Referenced by hasTransaction(), makeTransaction(), and removeTransaction().

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 70 of file d2_update_mgr.h.


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