Kea  1.9.9-git
d2_update_mgr.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2020 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 <exceptions/exceptions.h>
14 #include <d2/d2_log.h>
15 #include <d2/d2_queue_mgr.h>
16 #include <d2/d2_cfg_mgr.h>
17 #include <d2/nc_trans.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 
72  // @todo This structure is not yet used. It is here in anticipation of
73  // enabled statistics capture.
74  struct Stats {
75  uint64_t start_time_;
76  uint64_t stop_time_;
77  uint64_t update_count_;
78  uint64_t min_update_time_;
79  uint64_t max_update_time_;
80  uint64_t server_rejects_;
81  uint64_t server_timeouts_;
82  };
83 
94  D2UpdateMgr(D2QueueMgrPtr& queue_mgr, D2CfgMgrPtr& cfg_mgr,
95  asiolink::IOServicePtr& io_service,
96  const size_t max_transactions = MAX_TRANSACTIONS_DEFAULT);
97 
99  virtual ~D2UpdateMgr();
100 
115  void sweep();
116 
117 protected:
124 
138  void pickNextJob();
139 
167 
168 public:
173  return (io_service_);
174  }
175 
177  size_t getMaxTransactions() const {
178  return (max_transactions_);
179  }
180 
188  void setMaxTransactions(const size_t max_transactions);
189 
196  TransactionList::iterator findTransaction(const TransactionKey& key);
197 
199  TransactionList::iterator transactionListEnd();
200 
202  TransactionList::iterator transactionListBegin();
203 
210  bool hasTransaction(const TransactionKey& key);
211 
218  void removeTransaction(const TransactionKey& key);
219 
224  void clearTransactionList();
225 
227  size_t getQueueCount() const;
228 
230  size_t getTransactionCount() const;
231 
232 private:
234  D2QueueMgrPtr queue_mgr_;
235 
237  D2CfgMgrPtr cfg_mgr_;
238 
245  asiolink::IOServicePtr io_service_;
246 
248  size_t max_transactions_;
249 
251  TransactionList transaction_list_;
252 };
253 
255 typedef boost::shared_ptr<D2UpdateMgr> D2UpdateMgrPtr;
256 
257 
258 } // namespace isc::d2
259 } // namespace isc
260 #endif
This file defines the class NameChangeTransaction.
void clearTransactionList()
Immediately discards all entries in the transaction list.
const asiolink::IOServicePtr & getIOService()
Gets the D2UpdateMgr's IOService.
virtual ~D2UpdateMgr()
Destructor.
void makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr &ncr)
Create a new transaction for the given request.
D2UpdateMgr creates and manages update transactions.
Definition: d2_update_mgr.h:65
void sweep()
Check current transactions; start transactions for new requests.
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.
size_t getQueueCount() const
Convenience method that returns the number of requests queued.
TransactionList::iterator transactionListBegin()
Returns the transaction list beg position.
boost::shared_ptr< NameChangeRequest > NameChangeRequestPtr
Defines a pointer to a NameChangeRequest.
Definition: ncr_msg.h:212
void removeTransaction(const TransactionKey &key)
Removes the entry pointed to by key from the transaction list.
void pickNextJob()
Starts a transaction for the next eligible request in the queue.
D2UpdateMgr(D2QueueMgrPtr &queue_mgr, D2CfgMgrPtr &cfg_mgr, asiolink::IOServicePtr &io_service, const size_t max_transactions=MAX_TRANSACTIONS_DEFAULT)
Constructor.
boost::shared_ptr< D2QueueMgr > D2QueueMgrPtr
Defines a pointer for manager instances.
Definition: d2_queue_mgr.h:343
size_t getTransactionCount() const
Returns the current number of transactions.
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
size_t getMaxTransactions() const
Returns the maximum number of concurrent transactions.
TransactionList::iterator transactionListEnd()
Returns the transaction list end position.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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-dhcp-ddns.
void checkFinishedTransactions()
Performs post-completion cleanup on completed transactions.
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.
void setMaxTransactions(const size_t max_transactions)
Sets the maximum number of entries allowed 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 ...
Definition: d2_update_mgr.h:70