Kea  2.3.5-git
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 
23 namespace isc {
24 namespace d2 {
25 
28 public:
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 {
66 public:
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 
105 protected:
111  void checkFinishedTransactions();
112 
126  void pickNextJob();
127 
154  void makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr& ncr);
155 
156 public:
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 
220 private:
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
size_t getMaxTransactions() const
Returns the maximum number of concurrent transactions.
This file defines the class NameChangeTransaction.
const asiolink::IOServicePtr & getIOService()
Gets the D2UpdateMgr&#39;s IOService.
D2UpdateMgr creates and manages update transactions.
Definition: d2_update_mgr.h:65
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition: ncr_msg.h:212
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
boost::shared_ptr< D2QueueMgr > D2QueueMgrPtr
Defines a pointer for manager instances.
Definition: d2_queue_mgr.h:343
std::map< TransactionKey, NameChangeTransactionPtr > TransactionList
Defines a list of transactions.
Definition: d2_update_mgr.h:34
D2UpdateMgrError(const char *file, size_t line, const char *what)
Definition: d2_update_mgr.h:29
boost::shared_ptr< D2CfgMgr > D2CfgMgrPtr
Defines a shared pointer to D2CfgMgr.
Definition: d2_cfg_mgr.h:334
boost::shared_ptr< D2UpdateMgr > D2UpdateMgrPtr
Defines a pointer to a D2UpdateMgr instance.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
Container class for handling the DHCID value within a NameChangeRequest.
Definition: ncr_msg.h:86
Thrown if the update manager encounters a general error.
Definition: d2_update_mgr.h:27
This file defines the class D2QueueMgr.