From a662ab45d9271c5892c0e499fb65385f47bc4639 Mon Sep 17 00:00:00 2001 From: Thomas Markwalder Date: Wed, 2 May 2018 13:36:02 -0400 Subject: [5586] MySQL shared leases stats implemented src/share/database/scripts/mysql/dhcpdb_create.mysql src/share/database/scripts/mysql/dhcpdb_drop.mysql src/share/database/scripts/mysql/upgrade_5.2_to_6.0.sh.in Added MySQL v4/6 stat tables and triggers src/lib/dhcpsrv/memfile_lease_mgr.cc Suppress output of of rows with count values of 0 src/lib/dhcpsrv/mysql_lease_mgr.* Added v4/v6 lease stat SQL statements MySqlLeaseStatsQuery - Added ctor variants that accomodate selection criteria - Modified start() to handle three variants of selection MySqlLeaseMgr - Added start***Query4/6 variants src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc Added tests: - TEST_F(MySqlLeaseMgrTest, leaseStatsQuery4) - TEST_F(MySqlLeaseMgrTest, leaseStatsQuery6) --- src/lib/dhcpsrv/mysql_lease_mgr.h | 56 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'src/lib/dhcpsrv/mysql_lease_mgr.h') diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h index db87cf812b..fb2a427659 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.h +++ b/src/lib/dhcpsrv/mysql_lease_mgr.h @@ -365,22 +365,66 @@ public: /// /// It creates an instance of a MySqlLeaseStatsQuery4 and then /// invokes its start method, which fetches its statistical data - /// result set by executing the RECOUNT_LEASE_STATS4 query. + /// result set by executing the ALL_LEASE_STATS4 query. /// The query object is then returned. /// /// @return The populated query as a pointer to an LeaseStatsQuery virtual LeaseStatsQueryPtr startLeaseStatsQuery4(); + /// @brief Creates and runs the IPv4 lease stats query for a single subnet + /// + /// It creates an instance of a MySqlLeaseStatsQuery4 for a single subnet + /// query and then invokes its start method in which the query constructs its + /// statistical data result set. The query object is then returned. + /// + /// @param subnet_id id of the subnet for which stats are desired + /// @return A populated LeaseStatsQuery + virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery4(const SubnetID& subnet_id); + + /// @brief Creates and runs the IPv4 lease stats query for a single subnet + /// + /// It creates an instance of a MySqlLeaseStatsQuery4 for a subnet range + /// query and then invokes its start method in which the query constructs its + /// statistical data result set. The query object is then returned. + /// + /// @param first_subnet_id first subnet in the range of subnets + /// @param last_subnet_id last subnet in the range of subnets + /// @return A populated LeaseStatsQuery + virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery4(const SubnetID& first_subnet_id, + const SubnetID& last_subnet_id); + /// @brief Creates and runs the IPv6 lease stats query /// /// It creates an instance of a MySqlLeaseStatsQuery6 and then /// invokes its start method, which fetches its statistical data - /// result set by executing the RECOUNT_LEASE_STATS6 query. + /// result set by executing the ALL_LEASE_STATS6 query. /// The query object is then returned. /// /// @return The populated query as a pointer to an LeaseStatsQuery virtual LeaseStatsQueryPtr startLeaseStatsQuery6(); + /// @brief Creates and runs the IPv6 lease stats query for a single subnet + /// + /// It creates an instance of a MySqlLeaseStatsQuery6 for a single subnet + /// query and then invokes its start method in which the query constructs its + /// statistical data result set. The query object is then returned. + /// + /// @param subnet_id id of the subnet for which stats are desired + /// @return A populated LeaseStatsQuery + virtual LeaseStatsQueryPtr startSubnetLeaseStatsQuery6(const SubnetID& subnet_id); + + /// @brief Creates and runs the IPv6 lease stats query for a single subnet + /// + /// It creates an instance of a MySqlLeaseStatsQuery6 for a subnet range + /// query and then invokes its start method in which the query constructs its + /// statistical data result set. The query object is then returned. + /// + /// @param first_subnet_id first subnet in the range of subnets + /// @param last_subnet_id last subnet in the range of subnets + /// @return A populated LeaseStatsQuery + virtual LeaseStatsQueryPtr startSubnetRangeLeaseStatsQuery6(const SubnetID& first_subnet_id, + const SubnetID& last_subnet_id); + /// @brief Removes specified IPv4 leases. /// /// This rather dangerous method is able to remove all leases from specified @@ -478,8 +522,12 @@ public: INSERT_LEASE6, // Add entry to lease6 table UPDATE_LEASE4, // Update a Lease4 entry UPDATE_LEASE6, // Update a Lease6 entry - RECOUNT_LEASE4_STATS, // Fetches IPv4 address statistics - RECOUNT_LEASE6_STATS, // Fetches IPv6 address statistics + ALL_LEASE4_STATS, // Fetches IPv4 lease statistics + SUBNET_LEASE4_STATS, // Fetched IPv4 lease stats for a single subnet. + SUBNET_RANGE_LEASE4_STATS, // Fetched IPv4 lease stats for a subnet range. + ALL_LEASE6_STATS, // Fetches IPv6 lease statistics + SUBNET_LEASE6_STATS, // Fetched IPv6 lease stats for a single subnet. + SUBNET_RANGE_LEASE6_STATS, // Fetched IPv6 lease stats for a subnet range. NUM_STATEMENTS // Number of statements }; -- cgit v1.2.3