Kea 2.7.5
d2_update_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2013-2024 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>
18
19#include <boost/noncopyable.hpp>
20#include <boost/shared_ptr.hpp>
21#include <map>
22
23namespace isc {
24namespace d2 {
25
28public:
29 D2UpdateMgrError(const char* file, size_t line, const char* what) :
30 isc::Exception(file, line, what) { }
31};
32
34typedef std::map<TransactionKey, NameChangeTransactionPtr> TransactionList;
35
65class 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:
112
126 void pickNextJob();
127
157
158public:
163 return (io_service_);
164 }
165
167 size_t getMaxTransactions() const {
168 return (max_transactions_);
169 }
170
178 void setMaxTransactions(const size_t max_transactions);
179
186 TransactionList::iterator findTransaction(const TransactionKey& key);
187
189 TransactionList::iterator transactionListEnd();
190
192 TransactionList::iterator transactionListBegin();
193
200 bool hasTransaction(const TransactionKey& key);
201
208 void removeTransaction(const TransactionKey& key);
209
215
217 size_t getQueueCount() const;
218
220 size_t getTransactionCount() const;
221
222private:
224 D2QueueMgrPtr queue_mgr_;
225
227 D2CfgMgrPtr cfg_mgr_;
228
235 asiolink::IOServicePtr io_service_;
236
238 size_t max_transactions_;
239
241 TransactionList transaction_list_;
242};
243
245typedef boost::shared_ptr<D2UpdateMgr> D2UpdateMgrPtr;
246
247
248} // namespace isc::d2
249} // namespace isc
250#endif
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Thrown if the update manager encounters a general error.
D2UpdateMgrError(const char *file, size_t line, const char *what)
D2UpdateMgr creates and manages update transactions.
TransactionList::iterator transactionListEnd()
Returns the transaction list end position.
bool hasTransaction(const TransactionKey &key)
Convenience method that checks transaction list for the given key.
TransactionList::iterator findTransaction(const TransactionKey &key)
Search the transaction list for the given key.
virtual ~D2UpdateMgr()
Destructor.
void removeTransaction(const TransactionKey &key)
Removes the entry pointed to by key from the transaction list.
const asiolink::IOServicePtr & getIOService()
Gets the D2UpdateMgr's IOService.
bool makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr &ncr)
Create a new transaction for the given request.
void checkFinishedTransactions()
Performs post-completion cleanup on completed transactions.
void setMaxTransactions(const size_t max_transactions)
Sets the maximum number of entries allowed in the queue.
TransactionList::iterator transactionListBegin()
Returns the transaction list beg position.
void clearTransactionList()
Immediately discards all entries in the transaction list.
void sweep()
Check current transactions; start transactions for new requests.
size_t getMaxTransactions() const
Returns the maximum number of concurrent transactions.
size_t getQueueCount() const
Convenience method that returns the number of requests queued.
D2UpdateMgr(D2QueueMgrPtr &queue_mgr, D2CfgMgrPtr &cfg_mgr, asiolink::IOServicePtr &io_service, const size_t max_transactions=MAX_TRANSACTIONS_DEFAULT)
Constructor.
size_t getTransactionCount() const
Returns the current number of transactions.
void pickNextJob()
Starts a transaction for the next eligible request in the queue.
static const size_t MAX_TRANSACTIONS_DEFAULT
Maximum number of concurrent transactions NOTE that 32 is an arbitrary choice picked for the initial ...
Container class for handling the DHCID value within a NameChangeRequest.
Definition ncr_msg.h:113
This file defines the class D2QueueMgr.
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition d2_cfg_mgr.h:367
boost::shared_ptr< D2UpdateMgr > D2UpdateMgrPtr
Defines a pointer to a D2UpdateMgr instance.
boost::shared_ptr< D2QueueMgr > D2QueueMgrPtr
Defines a pointer for manager instances.
std::map< TransactionKey, NameChangeTransactionPtr > TransactionList
Defines a list of transactions.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition ncr_msg.h:241
Defines the logger used by the top-level component of kea-lfc.
This file defines the class NameChangeTransaction.