Kea: d2_update_mgr.h Source File

| Kea 2.2.0

d2_update_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2013-2021 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef D2_UPDATE_MGR_H
8#define D2_UPDATE_MGR_H
9
11
12#include <asiolink/io_service.h>
13#include <d2/d2_queue_mgr.h>
14#include <d2srv/nc_trans.h>
15#include <d2srv/d2_cfg_mgr.h>
16#include <d2srv/d2_log.h>
17#include <exceptions/exceptions.h>
18
19#include <boost/noncopyable.hpp>
20#include <boost/shared_ptr.hpp>
21#include <map>
22
23namespace isc {
24namespace d2 {
25
27 class D2UpdateMgrError : public isc::Exception {
28public:
29 D2UpdateMgrError(const char* file, size_t line, const char* what) :
30 isc::Exception(file, line, what) { };
31};
32
34 typedef std::map<TransactionKey, NameChangeTransactionPtr> TransactionList;
35
65 class D2UpdateMgr : public boost::noncopyable {
66public:
70 static const size_t MAX_TRANSACTIONS_DEFAULT = 32;
71
82 D2UpdateMgr(D2QueueMgrPtr& queue_mgr, D2CfgMgrPtr& cfg_mgr,
83 asiolink::IOServicePtr& io_service,
84 const size_t max_transactions = MAX_TRANSACTIONS_DEFAULT);
85
87 virtual ~D2UpdateMgr();
88
103 void sweep();
104
105protected:
111 void checkFinishedTransactions();
112
126 void pickNextJob();
127
154 void makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr& ncr);
155
156public:
160 const asiolink::IOServicePtr& getIOService() {
161 return (io_service_);
162 }
163
165 size_t getMaxTransactions() const {
166 return (max_transactions_);
167 }
168
176 void setMaxTransactions(const size_t max_transactions);
177
184 TransactionList::iterator findTransaction(const TransactionKey& key);
185
187 TransactionList::iterator transactionListEnd();
188
190 TransactionList::iterator transactionListBegin();
191
198 bool hasTransaction(const TransactionKey& key);
199
206 void removeTransaction(const TransactionKey& key);
207
212 void clearTransactionList();
213
215 size_t getQueueCount() const;
216
218 size_t getTransactionCount() const;
219
220private:
222 D2QueueMgrPtr queue_mgr_;
223
225 D2CfgMgrPtr cfg_mgr_;
226
233 asiolink::IOServicePtr io_service_;
234
236 size_t max_transactions_;
237
239 TransactionList transaction_list_;
240};
241
243 typedef boost::shared_ptr<D2UpdateMgr> D2UpdateMgrPtr;
244
245
246} // namespace isc::d2
247} // namespace isc
248#endif
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
isc::d2::D2UpdateMgrError
Thrown if the update manager encounters a general error.
Definition: d2_update_mgr.h:27
isc::d2::D2UpdateMgrError::D2UpdateMgrError
D2UpdateMgrError(const char *file, size_t line, const char *what)
Definition: d2_update_mgr.h:29
isc::d2::D2UpdateMgr
D2UpdateMgr creates and manages update transactions.
Definition: d2_update_mgr.h:65
isc::d2::D2UpdateMgr::transactionListEnd
TransactionList::iterator transactionListEnd()
Returns the transaction list end position.
Definition: d2_update_mgr.cc:254
isc::d2::D2UpdateMgr::hasTransaction
bool hasTransaction(const TransactionKey &key)
Convenience method that checks transaction list for the given key.
Definition: d2_update_mgr.cc:236
isc::d2::D2UpdateMgr::findTransaction
TransactionList::iterator findTransaction(const TransactionKey &key)
Search the transaction list for the given key.
Definition: d2_update_mgr.cc:231
isc::d2::D2UpdateMgr::~D2UpdateMgr
virtual ~D2UpdateMgr()
Destructor.
Definition: d2_update_mgr.cc:45
isc::d2::D2UpdateMgr::removeTransaction
void removeTransaction(const TransactionKey &key)
Removes the entry pointed to by key from the transaction list.
Definition: d2_update_mgr.cc:241
isc::d2::D2UpdateMgr::getIOService
const asiolink::IOServicePtr & getIOService()
Gets the D2UpdateMgr's IOService.
Definition: d2_update_mgr.h:160
isc::d2::D2UpdateMgr::makeTransaction
void makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr &ncr)
Create a new transaction for the given request.
Definition: d2_update_mgr.cc:121
isc::d2::D2UpdateMgr::checkFinishedTransactions
void checkFinishedTransactions()
Performs post-completion cleanup on completed transactions.
Definition: d2_update_mgr.cc:74
isc::d2::D2UpdateMgr::setMaxTransactions
void setMaxTransactions(const size_t max_transactions)
Sets the maximum number of entries allowed in the queue.
Definition: d2_update_mgr.cc:266
isc::d2::D2UpdateMgr::transactionListBegin
TransactionList::iterator transactionListBegin()
Returns the transaction list beg position.
Definition: d2_update_mgr.cc:249
isc::d2::D2UpdateMgr::clearTransactionList
void clearTransactionList()
Immediately discards all entries in the transaction list.
Definition: d2_update_mgr.cc:259
isc::d2::D2UpdateMgr::sweep
void sweep()
Check current transactions; start transactions for new requests.
Definition: d2_update_mgr.cc:49
isc::d2::D2UpdateMgr::getMaxTransactions
size_t getMaxTransactions() const
Returns the maximum number of concurrent transactions.
Definition: d2_update_mgr.h:165
isc::d2::D2UpdateMgr::getQueueCount
size_t getQueueCount() const
Convenience method that returns the number of requests queued.
Definition: d2_update_mgr.cc:284
isc::d2::D2UpdateMgr::D2UpdateMgr
D2UpdateMgr(D2QueueMgrPtr &queue_mgr, D2CfgMgrPtr &cfg_mgr, asiolink::IOServicePtr &io_service, const size_t max_transactions=MAX_TRANSACTIONS_DEFAULT)
Constructor.
Definition: d2_update_mgr.cc:24
isc::d2::D2UpdateMgr::getTransactionCount
size_t getTransactionCount() const
Returns the current number of transactions.
Definition: d2_update_mgr.cc:289
isc::d2::D2UpdateMgr::pickNextJob
void pickNextJob()
Starts a transaction for the next eligible request in the queue.
Definition: d2_update_mgr.cc:96
isc::d2::D2UpdateMgr::MAX_TRANSACTIONS_DEFAULT
static const size_t MAX_TRANSACTIONS_DEFAULT
Maximum number of concurrent transactions NOTE that 32 is an arbitrary choice picked for the initial ...
Definition: d2_update_mgr.h:70
isc::dhcp_ddns::D2Dhcid
Container class for handling the DHCID value within a NameChangeRequest.
Definition: ncr_msg.h:86
isc::dns::Exception
Definition: dns/exceptions.h:25
d2_cfg_mgr.h
d2_log.h
d2_queue_mgr.h
This file defines the class D2QueueMgr.
exceptions.h
io_service.h
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition: io_service.h:110
isc::d2::D2CfgMgrPtr
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition: d2_cfg_mgr.h:334
isc::d2::D2UpdateMgrPtr
boost::shared_ptr< D2UpdateMgr > D2UpdateMgrPtr
Defines a pointer to a D2UpdateMgr instance.
Definition: d2_update_mgr.h:243
isc::d2::D2QueueMgrPtr
boost::shared_ptr< D2QueueMgr > D2QueueMgrPtr
Defines a pointer for manager instances.
Definition: d2_queue_mgr.h:343
isc::d2::TransactionList
std::map< TransactionKey, NameChangeTransactionPtr > TransactionList
Defines a list of transactions.
Definition: d2_update_mgr.h:34
isc::dhcp_ddns::NameChangeRequestPtr
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition: ncr_msg.h:212
isc
Defines the logger used by the top-level component of kea-lfc.
Definition: agent_parser.cc:143
nc_trans.h
This file defines the class NameChangeTransaction.