![]() |
Kea 3.2.1-git
|
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 | 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. | |
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.
| 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 30 of file d2_update_mgr.cc.
References isc_throw, and setMaxTransactions().
Referenced by isc::d2::D2Process::D2Process().
|
virtual |
Destructor.
Definition at line 51 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 80 of file d2_update_mgr.cc.
Referenced by sweep().
| void isc::d2::D2UpdateMgr::clearTransactions | ( | ) |
Immediately discards all entries in the transaction list.
Definition at line 287 of file d2_update_mgr.cc.
| TransactionAddressIndex::iterator isc::d2::D2UpdateMgr::findTransactionByAddress | ( | const asiolink::IOAddress & | address | ) | const |
Search the transaction store for a given address.
| address | the transaction address value for which to search. |
Definition at line 347 of file d2_update_mgr.cc.
| TransactionFqdnIndex::iterator isc::d2::D2UpdateMgr::findTransactionByFqdn | ( | const std::string & | fqdn | ) | const |
Search the transaction store for an FQDN.
| fqdn | transaction fqdn value for which to search. |
Definition at line 332 of file d2_update_mgr.cc.
|
inline |
Gets the D2UpdateMgr's IOService.
Definition at line 211 of file d2_update_mgr.h.
|
inline |
Returns the maximum number of concurrent transactions.
Definition at line 216 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 312 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 317 of file d2_update_mgr.cc.
Referenced by pickNextJob(), setMaxTransactions(), and sweep().
| 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.
| ncr | NameChangeRequest to search with |
Definition at line 263 of file d2_update_mgr.cc.
References isc_throw.
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 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().
|
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().
| 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 294 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 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().
| 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.
| 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.
| 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.
| 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.
| TransactionSequenceIndex::iterator isc::d2::D2UpdateMgr::transactionSequenceBegin | ( | ) |
Returns the transaction store sequence begin position.
Definition at line 322 of file d2_update_mgr.cc.
| TransactionSequenceIndex::iterator isc::d2::D2UpdateMgr::transactionSequenceEnd | ( | ) |
Returns the transaction store sequence end position.
Definition at line 327 of file d2_update_mgr.cc.
|
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.