7#ifndef MYSQL_LEASE_MGR_H
8#define MYSQL_LEASE_MGR_H
16#include <boost/scoped_ptr.hpp>
17#include <boost/utility.hpp>
29class MySqlLease4Exchange;
30class MySqlLease6Exchange;
77 std::vector<MySqlLeaseContextPtr>
pool_;
360 uint32_t iaid)
const;
379 uint32_t iaid,
SubnetID subnet_id)
const;
446 const size_t max_leases)
const;
459 const size_t max_leases)
const;
647 return (std::string(
"mysql"));
655 virtual std::string
getName()
const;
671 virtual std::pair<uint32_t, uint32_t>
getVersion()
const;
772 template <
typename Exchange,
typename LeaseCollection>
776 Exchange& exchange, LeaseCollection& result,
777 bool single =
false)
const;
800 getLeaseCollection(ctx, stindex, bind, ctx->exchange4_, result);
823 getLeaseCollection(ctx, stindex, bind, ctx->exchange6_, result);
870 template<
typename LeaseCollection>
871 void getExpiredLeasesCommon(LeaseCollection& expired_leases,
872 const size_t max_leases,
892 template <
typename LeasePtr>
925 uint64_t deleteExpiredReclaimedLeasesCommon(
const uint32_t secs,
941 const char* what)
const;
944 class MySqlLeaseContextAlloc {
958 ~MySqlLeaseContextAlloc();
980 std::string timer_name_;
The IOAddress class represents an IP addresses (version agnostic)
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Common MySQL Connector Pool.
Holds Client identifier or client IPv4 address.
Holds DUID (DHCPv6 Unique Identifier)
Wraps value holding size of the page with leases.
MySQL Lease Context Pool.
std::mutex mutex_
The mutex to protect pool access.
std::vector< MySqlLeaseContextPtr > pool_
The vector of available contexts.
boost::scoped_ptr< MySqlLease6Exchange > exchange6_
Exchange object.
boost::scoped_ptr< MySqlLease4Exchange > exchange4_
The exchange objects are used for transfer of data to/from the database.
MySqlLeaseContext(const db::DatabaseConnection::ParameterMap ¶meters, db::IOServiceAccessorPtr io_service_accessor, db::DbCallback db_reconnect_callback)
Constructor.
db::MySqlConnection conn_
MySQL connection.
virtual std::string getName() const
Returns backend name.
virtual std::string getType() const
Return backend type.
virtual void rollback()
Rollback Transactions.
virtual size_t wipeLeases4(const SubnetID &subnet_id)
Removes specified IPv4 leases.
static std::string getDBVersion()
Local version of getDBVersion() class method.
virtual std::string getDescription() const
Returns description of the backend.
virtual void commit()
Commit Transactions.
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const
Returns a collection of expired DHCPv6 leases.
virtual std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
virtual Lease6Collection getLeases6() const
Returns all IPv6 leases.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
virtual bool addLease(const Lease4Ptr &lease)
Adds an IPv4 lease.
virtual size_t wipeLeases6(const SubnetID &subnet_id)
Removed specified IPv6 leases.
MySqlLeaseContextPtr createContext() const
Create a new context.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const
Returns existing IPv6 lease for a given IPv6 address.
virtual bool deleteLease(const Lease4Ptr &lease)
Deletes an IPv4 lease.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs)
Deletes all expired-reclaimed DHCPv6 leases.
virtual void updateLease6(const Lease6Ptr &lease6)
Updates IPv6 lease.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
MySqlLeaseMgr(const db::DatabaseConnection::ParameterMap ¶meters)
Constructor.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query.
virtual void updateLease4(const Lease4Ptr &lease4)
Updates IPv4 lease.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes all expired-reclaimed DHCPv4 leases.
StatementIndex
Statement Tags.
@ SUBNET_RANGE_LEASE6_STATS
@ GET_LEASE6_DUID_IAID_SUBID
@ SUBNET_RANGE_LEASE4_STATS
@ GET_LEASE4_HWADDR_SUBID
@ DELETE_LEASE4_STATE_EXPIRED
@ GET_LEASE4_CLIENTID_SUBID
@ DELETE_LEASE6_STATE_EXPIRED
virtual void getExpiredLeases4(Lease4Collection &expired_leases, const size_t max_leases) const
Returns a collection of expired DHCPv4 leases.
virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID &first_subnet_id, const SubnetID &last_subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query.
virtual Lease4Collection getLeases4() const
Returns all IPv4 leases.
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const
Returns an IPv4 lease for specified IPv4 address.
virtual ~MySqlLeaseMgr()
Destructor (closes database)
static bool dbReconnect(db::ReconnectCtlPtr db_reconnect_ctl)
Attempts to reconnect the server to the lease DB backend manager.
An abstract API for lease database.
std::function< bool(ReconnectCtlPtr db_reconnect_ctl)> DbCallback
Defines a callback prototype for propagating events upward.
boost::shared_ptr< IOServiceAccessor > IOServiceAccessorPtr
Pointer to an instance of IOServiceAccessor.
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
boost::shared_ptr< MySqlLeaseContextPool > MySqlLeaseContextPoolPtr
Type of pointers to context pools.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< MySqlLeaseContext > MySqlLeaseContextPtr
Type of pointers to contexts.
Defines the logger used by the top-level component of kea-lfc.
Hardware type that represents information from DHCPv4 packet.
Type
Type of lease or pool.