7#ifndef TRACKING_LEASE_MGR_H
8#define TRACKING_LEASE_MGR_H
12#include <boost/multi_index_container.hpp>
13#include <boost/multi_index/composite_key.hpp>
14#include <boost/multi_index/indexed_by.hpp>
15#include <boost/multi_index/member.hpp>
16#include <boost/multi_index/hashed_index.hpp>
17#include <boost/multi_index/ordered_index.hpp>
18#include <boost/multi_index/sequenced_index.hpp>
19#include <boost/shared_ptr.hpp>
22#include <unordered_set>
131 typedef boost::multi_index_container<
133 boost::multi_index::indexed_by<
134 boost::multi_index::ordered_non_unique<
135 boost::multi_index::composite_key<
137 boost::multi_index::member<Callback, CallbackType, &Callback::type>,
138 boost::multi_index::member<Callback, SubnetID, &Callback::subnet_id>,
139 boost::multi_index::member<Callback, Lease::Type, &Callback::lease_type>
142 boost::multi_index::ordered_non_unique<
143 boost::multi_index::composite_key<
145 boost::multi_index::member<Callback, SubnetID, &Callback::subnet_id>,
146 boost::multi_index::member<Callback, Lease::Type, &Callback::lease_type>
302 std::unordered_set<asiolink::IOAddress, asiolink::IOAddress::Hash>
locked_leases_;
Introduces callbacks into the LeaseMgr.
CallbackType
An enumeration differentiating between lease write operations.
bool isLocked(const LeasePtr &lease)
Checks if the lease is locked.
void trackAddLease(const LeasePtr &lease)
Invokes the callbacks when a new lease is added.
void unlock(const LeasePtr &lease)
Attempts to unlock a lease.
void trackUpdateLease(const LeasePtr &lease)
Invokes the callbacks when a lease is updated.
void runCallbacks(CallbackType type, const LeasePtr &lease)
Runs registered callbacks of the particular type.
boost::multi_index_container< Callback, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::composite_key< Callback, boost::multi_index::member< Callback, CallbackType, &Callback::type >, boost::multi_index::member< Callback, SubnetID, &Callback::subnet_id >, boost::multi_index::member< Callback, Lease::Type, &Callback::lease_type > > >, boost::multi_index::ordered_non_unique< boost::multi_index::composite_key< Callback, boost::multi_index::member< Callback, SubnetID, &Callback::subnet_id >, boost::multi_index::member< Callback, Lease::Type, &Callback::lease_type > > > > > CallbackContainer
A multi-index container holding registered callbacks.
void trackDeleteLease(const LeasePtr &lease)
Invokes the callbacks when a lease is deleted.
void unregisterCallbacks(SubnetID subnet_id, Lease::Type lease_type)
Unregisters all callbacks for a given subnet identifier.
static std::string callbackTypeToString(CallbackType type)
Converts callback type to string for logging purposes.
void registerCallback(CallbackType type, std::string owner, SubnetID subnet_id, Lease::Type lease_type, CallbackFn callback_fn)
Registers a callback function for a subnet.
std::function< void(LeasePtr)> CallbackFn
Type of a callback function invoked upon a lease insertion, update or deletion.
bool tryLock(const LeasePtr &lease)
Attempts to lock a lease.
std::unordered_set< asiolink::IOAddress, asiolink::IOAddress::Hash > locked_leases_
A set of locked leases.
TrackingLeaseMgr()
Constructor.
void runCallbacksForSubnetID(CallbackType type, SubnetID subnet_id, const LeasePtr &lease)
Runs registered callbacks of the particular type for a subnet id.
CallbackContainerPtr callbacks_
The multi-index container holding registered callbacks.
void unregisterAllCallbacks()
Unregisters all callbacks.
boost::shared_ptr< CallbackContainer > CallbackContainerPtr
Pointer to the callback container.
bool hasCallbacks() const
Checks if any callbacks have been registered.
An abstract API for lease database.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
std::unique_ptr< TrackingLeaseMgr > TrackingLeaseMgrPtr
TrackingLeaseMgr pointer.
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
A structure representing a registered callback.
CallbackFn fn
Callback function.
std::string owner
An entity owning callback registration (e.g., FLQ allocator).
SubnetID subnet_id
Subnet identifier associated with the callback.
Lease::Type lease_type
Lease types for which the callback should be invoked.
CallbackType type
Callback type (i.e., lease add, update, delete).