7 #ifndef PGSQL_LEASE_MGR_H
8 #define PGSQL_LEASE_MGR_H
17 #include <boost/scoped_ptr.hpp>
18 #include <boost/utility.hpp>
28 class PgSqlLease4Exchange;
29 class PgSqlLease6Exchange;
76 std::vector<PgSqlLeaseContextPtr>
pool_;
338 uint32_t iaid)
const;
354 uint32_t iaid,
SubnetID subnet_id)
const;
421 const size_t max_leases)
const;
434 const size_t max_leases)
const;
622 return (std::string(
"postgresql"));
630 virtual std::string
getName()
const;
646 virtual std::pair<uint32_t, uint32_t>
getVersion()
const;
723 bool addLeaseCommon(PgSqlLeaseContextPtr& ctx,
748 template <
typename Exchange,
typename LeaseCollection>
749 void getLeaseCollection(PgSqlLeaseContextPtr& ctx,
752 Exchange& exchange, LeaseCollection& result,
753 bool single =
false)
const;
772 void getLeaseCollection(PgSqlLeaseContextPtr& ctx,
776 getLeaseCollection(ctx, stindex, bind_array, ctx->exchange4_, result);
795 void getLeaseCollection(PgSqlLeaseContextPtr& ctx,
799 getLeaseCollection(ctx, stindex, bind_array, ctx->exchange6_, result);
812 void getLease(PgSqlLeaseContextPtr& ctx,
814 db::PsqlBindArray& bind_array,
827 void getLease(PgSqlLeaseContextPtr& ctx,
829 db::PsqlBindArray& bind_array,
846 template<
typename LeaseCollection>
847 void getExpiredLeasesCommon(LeaseCollection& expired_leases,
848 const size_t max_leases,
867 template <
typename LeasePtr>
868 void updateLeaseCommon(PgSqlLeaseContextPtr& ctx,
870 db::PsqlBindArray& bind_array,
888 db::PsqlBindArray& bind_array);
899 uint64_t deleteExpiredReclaimedLeasesCommon(
const uint32_t secs,
903 class PgSqlLeaseContextAlloc {
917 ~PgSqlLeaseContextAlloc();
920 PgSqlLeaseContextPtr ctx_;
936 PgSqlLeaseContextPoolPtr pool_;
939 std::string timer_name_;
945 #endif // PGSQL_LEASE_MGR_H
virtual ~PgSqlLeaseMgr()
Destructor (closes database)
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress &addr) const
Returns an IPv4 lease for specified IPv4 address.
boost::shared_ptr< LeaseStatsQuery > LeaseStatsQueryPtr
Defines a pointer to a LeaseStatsQuery.
PostgreSQL Lease Context.
virtual Lease6Ptr getLease6(Lease::Type type, const isc::asiolink::IOAddress &addr) const
Returns existing IPv6 lease for a given IPv6 address.
virtual std::string getName() const
Returns backend name.
PostgreSQL Lease Manager.
virtual Lease6Collection getLeases6() const
Returns all IPv6 leases.
An abstract API for lease database.
virtual Lease4Collection getLeases4() const
Returns all IPv4 leases.
virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID &subnet_id)
Creates and runs the IPv6 lease stats query for a single subnet.
PgSqlLeaseContextPtr createContext() const
Create a new context.
std::vector< Lease4Ptr > Lease4Collection
A collection of IPv4 leases.
virtual uint64_t deleteExpiredReclaimedLeases6(const uint32_t secs)
Deletes all expired-reclaimed DHCPv6 leases.
PgSqlLeaseContext(const db::DatabaseConnection::ParameterMap ¶meters, db::IOServiceAccessorPtr io_service_accessor, db::DbCallback db_reconnect_callback)
Constructor.
boost::scoped_ptr< PgSqlLease4Exchange > exchange4_
The exchange objects are used for transfer of data to/from the database.
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.
std::mutex mutex_
The mutex to protect pool access.
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
std::vector< PgSqlLeaseContextPtr > pool_
The vector of available contexts.
virtual void getExpiredLeases6(Lease6Collection &expired_leases, const size_t max_leases) const
Returns a collection of expired DHCPv6 leases.
Holds DUID (DHCPv6 Unique Identifier)
virtual std::string getDescription() const
Returns description of the backend.
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 startSubnetLeaseStatsQuery4(const SubnetID &subnet_id)
Creates and runs the IPv4 lease stats query for a single subnet.
PostgreSQL Lease Context Pool.
virtual void updateLease4(const Lease4Ptr &lease4)
Updates IPv4 lease.
boost::scoped_ptr< PgSqlLease6Exchange > exchange6_
Exchange object.
boost::shared_ptr< Lease4 > Lease4Ptr
Pointer to a Lease4 structure.
db::PgSqlConnection conn_
PostgreSQL connection.
static std::string getDBVersion()
Local version of getDBVersion() class method.
virtual void updateLease6(const Lease6Ptr &lease6)
Updates IPv6 lease.
virtual uint64_t deleteExpiredReclaimedLeases4(const uint32_t secs)
Deletes all expired-reclaimed DHCPv4 leases.
virtual size_t wipeLeases6(const SubnetID &subnet_id)
Removed specified IPv6 leases.
virtual LeaseStatsQueryPtr startLeaseStatsQuery4()
Creates and runs the IPv4 lease stats query.
virtual void rollback()
Rollback Transactions.
Common PgSql Connector Pool.
std::vector< Lease6Ptr > Lease6Collection
A collection of IPv6 leases.
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.
boost::shared_ptr< PgSqlLeaseContext > PgSqlLeaseContextPtr
Type of pointers to contexts.
virtual std::string getType() const
Return backend type.
Type
Type of lease or pool.
Holds Client identifier or client IPv4 address.
static bool dbReconnect(db::ReconnectCtlPtr db_reconnect_ctl)
Attempts to reconnect the server to the lease DB backend manager.
StatementIndex
Statement Tags.
Hardware type that represents information from DHCPv4 packet.
virtual bool addLease(const Lease4Ptr &lease)
Adds an IPv4 lease.
virtual std::pair< uint32_t, uint32_t > getVersion() const
Returns backend version.
Wraps value holding size of the page with leases.
virtual void commit()
Commit Transactions.
virtual bool deleteLease(const Lease4Ptr &lease)
Deletes an IPv4 lease.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
The IOAddress class represents an IP addresses (version agnostic)
virtual size_t wipeLeases4(const SubnetID &subnet_id)
Removes specified IPv4 leases.
boost::shared_ptr< ReconnectCtl > ReconnectCtlPtr
Pointer to an instance of ReconnectCtl.
boost::shared_ptr< PgSqlLeaseContextPool > PgSqlLeaseContextPoolPtr
Type of pointers to context pools.
boost::shared_ptr< Lease6 > Lease6Ptr
Pointer to a Lease6 structure.
virtual LeaseStatsQueryPtr startLeaseStatsQuery6()
Creates and runs the IPv6 lease stats query.
boost::shared_ptr< IOServiceAccessor > IOServiceAccessorPtr
Pointer to an instance of IOServiceAccessor.
uint32_t SubnetID
Unique identifier for a subnet (both v4 and v6)
PgSqlLeaseMgr(const db::DatabaseConnection::ParameterMap ¶meters)
Constructor.