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