Kea 2.7.6
|
D2UpdateMgr creates and manages update transactions. More...
#include <d2_update_mgr.h>
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 | clearTransactionList () |
Immediately discards all entries in the transaction list. | |
TransactionList::iterator | findTransaction (const TransactionKey &key) |
Search the transaction list for the given key. | |
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 TransactionKey &key) |
Convenience method that checks transaction list for the given key. | |
void | removeTransaction (const TransactionKey &key) |
Removes the entry pointed to by key from the transaction list. | |
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. | |
TransactionList::iterator | transactionListBegin () |
Returns the transaction list beg position. | |
TransactionList::iterator | transactionListEnd () |
Returns the transaction list 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. | |
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.
isc::d2::D2UpdateMgr::D2UpdateMgr | ( | D2QueueMgrPtr & | queue_mgr, |
D2CfgMgrPtr & | cfg_mgr, | ||
asiolink::IOServicePtr & | io_service, | ||
const size_t | max_transactions = MAX_TRANSACTIONS_DEFAULT ) |
Constructor.
queue_mgr | reference to the queue manager receiving requests |
cfg_mgr | reference to the configuration manager |
io_service | IO service used by the upper layer(s) to manage IO events |
max_transactions | the maximum number of concurrent transactions |
D2UpdateMgrError | if either the queue manager or configuration managers are NULL, or max transactions is less than one. |
Definition at line 28 of file d2_update_mgr.cc.
References isc_throw, and setMaxTransactions().
|
virtual |
Destructor.
Definition at line 49 of file d2_update_mgr.cc.
|
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 78 of file d2_update_mgr.cc.
Referenced by sweep().
void isc::d2::D2UpdateMgr::clearTransactionList | ( | ) |
Immediately discards all entries in the transaction list.
Definition at line 301 of file d2_update_mgr.cc.
TransactionList::iterator isc::d2::D2UpdateMgr::findTransaction | ( | const TransactionKey & | key | ) |
Search the transaction list for the given key.
key | the transaction key value for which to search. |
Definition at line 273 of file d2_update_mgr.cc.
Referenced by hasTransaction(), makeTransaction(), and removeTransaction().
|
inline |
Gets the D2UpdateMgr's IOService.
Definition at line 162 of file d2_update_mgr.h.
|
inline |
Returns the maximum number of concurrent transactions.
Definition at line 167 of file d2_update_mgr.h.
Referenced by sweep().
size_t isc::d2::D2UpdateMgr::getQueueCount | ( | ) | const |
Convenience method that returns the number of requests queued.
Definition at line 326 of file d2_update_mgr.cc.
Referenced by pickNextJob(), and sweep().
size_t isc::d2::D2UpdateMgr::getTransactionCount | ( | ) | const |
Returns the current number of transactions.
Definition at line 331 of file d2_update_mgr.cc.
Referenced by pickNextJob(), setMaxTransactions(), and sweep().
bool isc::d2::D2UpdateMgr::hasTransaction | ( | const TransactionKey & | key | ) |
Convenience method that checks transaction list for the given key.
key | the transaction key value for which to search. |
Definition at line 278 of file d2_update_mgr.cc.
References findTransaction(), and transactionListEnd().
Referenced by pickNextJob().
|
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.
ncr | the NameChangeRequest for which to create a transaction. |
D2UpdateMgrError | if a transaction for this DHCID already exists. Note this would be programmatic error. |
Definition at line 134 of file d2_update_mgr.cc.
References 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, findTransaction(), isc_throw, LOG_DEBUG, LOG_ERROR, isc::dhcp_ddns::NO_CHECK_WITHOUT_DHCID, isc::dhcp_ddns::D2Dhcid::toStr(), and transactionListEnd().
Referenced by 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 100 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().
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.
key | of the transaction to remove |
Definition at line 283 of file d2_update_mgr.cc.
References findTransaction(), and transactionListEnd().
void isc::d2::D2UpdateMgr::setMaxTransactions | ( | const size_t | max_transactions | ) |
Sets the maximum number of entries allowed in the queue.
max_transactions | is the new maximum number of transactions |
Throws | D2QueueMgrError 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 308 of file d2_update_mgr.cc.
References getTransactionCount(), and isc_throw.
Referenced by D2UpdateMgr().
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:
Definition at line 53 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().
TransactionList::iterator isc::d2::D2UpdateMgr::transactionListBegin | ( | ) |
Returns the transaction list beg position.
Definition at line 291 of file d2_update_mgr.cc.
TransactionList::iterator isc::d2::D2UpdateMgr::transactionListEnd | ( | ) |
Returns the transaction list end position.
Definition at line 296 of file d2_update_mgr.cc.
Referenced by hasTransaction(), makeTransaction(), and removeTransaction().
|
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.