2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-05 08:25:16 +00:00

[3966] Implemented deletion of the reclaimed leases in MySQL.

This commit is contained in:
Marcin Siodelski
2015-09-07 13:58:22 +02:00
parent 54a90126ec
commit f127bed4fb
2 changed files with 72 additions and 31 deletions

View File

@@ -512,24 +512,26 @@ public:
///
/// The contents of the enum are indexes into the list of SQL statements
enum StatementIndex {
DELETE_LEASE4, // Delete from lease4 by address
DELETE_LEASE6, // Delete from lease6 by address
GET_LEASE4_ADDR, // Get lease4 by address
GET_LEASE4_CLIENTID, // Get lease4 by client ID
GET_LEASE4_CLIENTID_SUBID, // Get lease4 by client ID & subnet ID
GET_LEASE4_HWADDR, // Get lease4 by HW address
GET_LEASE4_HWADDR_SUBID, // Get lease4 by HW address & subnet ID
GET_LEASE4_EXPIRE, // Get lease4 by expiration.
GET_LEASE6_ADDR, // Get lease6 by address
GET_LEASE6_DUID_IAID, // Get lease6 by DUID and IAID
GET_LEASE6_DUID_IAID_SUBID, // Get lease6 by DUID, IAID and subnet ID
GET_LEASE6_EXPIRE, // Get lease6 by expiration.
GET_VERSION, // Obtain version number
INSERT_LEASE4, // Add entry to lease4 table
INSERT_LEASE6, // Add entry to lease6 table
UPDATE_LEASE4, // Update a Lease4 entry
UPDATE_LEASE6, // Update a Lease6 entry
NUM_STATEMENTS // Number of statements
DELETE_LEASE4, // Delete from lease4 by address
DELETE_LEASE4_STATE_EXPIRED, // Delete expired lease4 in a given state
DELETE_LEASE6, // Delete from lease6 by address
DELETE_LEASE6_STATE_EXPIRED, // Delete expired lease6 in a given state
GET_LEASE4_ADDR, // Get lease4 by address
GET_LEASE4_CLIENTID, // Get lease4 by client ID
GET_LEASE4_CLIENTID_SUBID, // Get lease4 by client ID & subnet ID
GET_LEASE4_HWADDR, // Get lease4 by HW address
GET_LEASE4_HWADDR_SUBID, // Get lease4 by HW address & subnet ID
GET_LEASE4_EXPIRE, // Get lease4 by expiration.
GET_LEASE6_ADDR, // Get lease6 by address
GET_LEASE6_DUID_IAID, // Get lease6 by DUID and IAID
GET_LEASE6_DUID_IAID_SUBID, // Get lease6 by DUID, IAID and subnet ID
GET_LEASE6_EXPIRE, // Get lease6 by expiration.
GET_VERSION, // Obtain version number
INSERT_LEASE4, // Add entry to lease4 table
INSERT_LEASE6, // Add entry to lease6 table
UPDATE_LEASE4, // Update a Lease4 entry
UPDATE_LEASE6, // Update a Lease6 entry
NUM_STATEMENTS // Number of statements
};
private:
@@ -726,12 +728,24 @@ private:
/// (Note that the number is determined by the number of parameters
/// in the statement.)
///
/// @return true if one or more rows were deleted, false if none were
/// deleted.
/// @return Number of deleted leases.
///
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
bool deleteLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind);
uint64_t deleteLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind);
/// @brief Delete expired-reclaimed leases.
///
/// @param secs Number of seconds since expiration of leases before
/// they can be removed. Leases which have expired later than this
/// time will not be deleted.
/// @param statement_index One of the @c DELETE_LEASE4_STATE_EXPIRED or
/// @c DELETE_LEASE6_STATE_EXPIRED.
///
/// @return Number of leases deleted.
uint64_t deleteExpiredReclaimedLeasesCommon(const uint32_t secs,
StatementIndex statement_index);
/// @brief Check Error and Throw Exception
///