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_;
127 MySqlLeaseContextPtr createContext()
const;
154 static std::string getDBVersion();
165 virtual bool addLease(
const Lease4Ptr& lease);
176 virtual bool addLease(
const Lease6Ptr& lease);
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;
481 virtual void updateLease4(
const Lease4Ptr& lease4);
503 virtual void updateLease6(
const Lease6Ptr& lease6);
519 virtual bool deleteLease(
const Lease4Ptr& lease);
535 virtual bool deleteLease(
const Lease6Ptr& lease);
544 virtual uint64_t deleteExpiredReclaimedLeases4(
const uint32_t secs);
553 virtual uint64_t deleteExpiredReclaimedLeases6(
const uint32_t secs);
628 virtual size_t wipeLeases4(
const SubnetID& subnet_id);
639 virtual size_t wipeLeases6(
const SubnetID& subnet_id);
645 bool isJsonSupported()
const override;
653 return (std::string(
"mysql"));
661 virtual std::string getName()
const;
668 virtual std::string getDescription()
const;
677 virtual std::pair<uint32_t, uint32_t> getVersion()
const;
685 virtual void commit();
693 virtual void rollback();
757 bool addLeaseCommon(MySqlLeaseContextPtr& ctx,
781 template <
typename Exchange,
typename LeaseCollection>
782 void getLeaseCollection(MySqlLeaseContextPtr& ctx,
785 Exchange& exchange, LeaseCollection& result,
786 bool single =
false)
const;
805 void getLeaseCollection(MySqlLeaseContextPtr& ctx,
809 getLeaseCollection(ctx, stindex, bind, ctx->exchange4_, result);
828 void getLeaseCollection(MySqlLeaseContextPtr& ctx,
832 getLeaseCollection(ctx, stindex, bind, ctx->exchange6_, result);
845 void getLease(MySqlLeaseContextPtr& ctx,
860 void getLease(MySqlLeaseContextPtr& ctx,
879 template<
typename LeaseCollection>
880 void getExpiredLeasesCommon(LeaseCollection& expired_leases,
881 const size_t max_leases,
901 template <
typename LeasePtr>
902 void updateLeaseCommon(MySqlLeaseContextPtr& ctx,
934 uint64_t deleteExpiredReclaimedLeasesCommon(
const uint32_t secs,
988 void checkError(MySqlLeaseContextPtr& ctx,
990 const char* what)
const;
993 class MySqlLeaseContextAlloc {
1007 ~MySqlLeaseContextAlloc();
1010 MySqlLeaseContextPtr ctx_;
1026 MySqlLeaseContextPoolPtr pool_;
1029 std::string timer_name_;
1035 #endif // MYSQL_LEASE_MGR_H
std::function< bool(util::ReconnectCtlPtr db_reconnect_ctl)> DbCallback
Defines a callback prototype for propagating events upward.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
std::vector< MySqlLeaseContextPtr > pool_
The vector of available contexts.
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
MySQL Lease Context Pool.
An abstract API for lease database.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
Holds DUID (DHCPv6 Unique Identifier)
StatementIndex
Statement Tags.
boost::shared_ptr< MySqlLeaseContext > MySqlLeaseContextPtr
Type of pointers to contexts.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
boost::shared_ptr< const Element > ConstElementPtr
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
boost::scoped_ptr< MySqlLease6Exchange > exchange6_
Exchange object.
Defines the logger used by the top-level component of kea-lfc.
db::MySqlConnection conn_
MySQL connection.
Type
Type of lease or pool.
Holds Client identifier or client IPv4 address.
Hardware type that represents information from DHCPv4 packet.
Wraps value holding size of the page with leases.
virtual std::string getType() const
Return backend type.
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< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
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.
std::mutex mutex_
The mutex to protect pool access.
boost::shared_ptr< IOServiceAccessor > IOServiceAccessorPtr
Pointer to an instance of IOServiceAccessor.
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Common MySQL Connector Pool.