Kea 2.7.3
|
MySql derivation of the statistical lease data query. More...
Public Member Functions | |
MySqlLeaseStatsQuery (MySqlConnection &conn, const size_t statement_index, const bool fetch_type, const bool fetch_pool=false) | |
Constructor to query for all subnets' stats. | |
MySqlLeaseStatsQuery (MySqlConnection &conn, const size_t statement_index, const bool fetch_type, const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) | |
Constructor to query for the stats for a range of subnets. | |
MySqlLeaseStatsQuery (MySqlConnection &conn, const size_t statement_index, const bool fetch_type, const SubnetID &subnet_id) | |
Constructor to query for a single subnet's stats. | |
virtual | ~MySqlLeaseStatsQuery () |
Destructor. | |
bool | getNextRow (LeaseStatsRow &row) override |
Fetches the next row in the result set. | |
void | start () override |
Creates the IPv4 lease statistical data result set. | |
Public Member Functions inherited from isc::dhcp::LeaseStatsQuery | |
LeaseStatsQuery (const SelectMode &select_mode=ALL_SUBNETS) | |
Constructor to query statistics for all subnets. | |
LeaseStatsQuery (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) | |
Constructor to query for the stats for a range of subnets. | |
LeaseStatsQuery (const SubnetID &subnet_id) | |
Constructor to query for a single subnet's stats. | |
virtual | ~LeaseStatsQuery () |
virtual destructor | |
SubnetID | getFirstSubnetID () const |
Returns the value of first subnet ID specified (or zero) | |
SubnetID | getLastSubnetID () const |
Returns the value of last subnet ID specified (or zero) | |
SelectMode | getSelectMode () const |
Returns the selection criteria mode The value returned is based upon the constructor variant used and it indicates which query variant will be executed. | |
Additional Inherited Members | |
Public Types inherited from isc::dhcp::LeaseStatsQuery | |
enum | SelectMode { ALL_SUBNETS , SINGLE_SUBNET , SUBNET_RANGE , ALL_SUBNET_POOLS } |
Defines the types of selection criteria supported. More... | |
Protected Attributes inherited from isc::dhcp::LeaseStatsQuery | |
SubnetID | first_subnet_id_ |
First (or only) subnet_id in the selection criteria. | |
SubnetID | last_subnet_id_ |
Last subnet_id in the selection criteria when a range is given. | |
MySql derivation of the statistical lease data query.
This class is used to recalculate lease statistics for MySQL lease storage. It does so by executing a query which returns a result containing one row per monitored state per lease type per subnet, ordered by subnet id in ascending order.
Definition at line 1832 of file mysql_lease_mgr.cc.
|
inline |
Constructor to query for all subnets' stats.
The query created will return statistics for all subnets
conn | An open connection to the database housing the lease data |
statement_index | Index of the query's prepared statement |
fetch_type | Indicates if query supplies lease type |
fetch_pool | Indicates if query requires pool data |
if | statement index is invalid. |
Definition at line 1844 of file mysql_lease_mgr.cc.
|
inline |
Constructor to query for a single subnet's stats.
The query created will return statistics for a single subnet
conn | An open connection to the database housing the lease data |
statement_index | Index of the query's prepared statement |
fetch_type | Indicates if query supplies lease type |
subnet_id | id of the subnet for which stats are desired |
BadValue | if subnet_id given is 0 or if statement index is invalid. |
Definition at line 1865 of file mysql_lease_mgr.cc.
|
inline |
Constructor to query for the stats for a range of subnets.
The query created will return statistics for the inclusive range of subnets described by first and last subnet IDs.
conn | An open connection to the database housing the lease data |
statement_index | Index of the query's prepared statement |
fetch_type | Indicates if query supplies lease type |
first_subnet_id | first subnet in the range of subnets |
last_subnet_id | last subnet in the range of subnets |
BadValue | if either subnet ID is 0 or if last <= first or if statement index is invalid. |
Definition at line 1889 of file mysql_lease_mgr.cc.
|
inlinevirtual |
Destructor.
Definition at line 1904 of file mysql_lease_mgr.cc.
|
inlineoverridevirtual |
Fetches the next row in the result set.
Once the internal result set has been populated by invoking the the start() method, this method is used to iterate over the result set rows. Once the last row has been fetched, subsequent calls will return false.
Checks against negative values for the state count and logs once a warning message. Unfortunately not getting the message is not a proof that detailed counters are correct.
row | Storage for the fetched row |
Reimplemented from isc::dhcp::LeaseStatsQuery.
Definition at line 2006 of file mysql_lease_mgr.cc.
References isc::db::MySqlConnection::checkError(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT, LOG_WARN, and isc::db::MLM_MYSQL_FETCH_SUCCESS.
|
inlineoverridevirtual |
Creates the IPv4 lease statistical data result set.
The result set is populated by executing a SQL query against the lease(4/6) table which sums the leases per lease state per lease type (v6 only) per subnet id. This method binds the statement to the output bind array and then executes the statement, and fetches entire result set.
Reimplemented from isc::dhcp::LeaseStatsQuery.
Definition at line 1915 of file mysql_lease_mgr.cc.
References isc::dhcp::LeaseStatsQuery::ALL_SUBNET_POOLS, isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, isc::db::MySqlConnection::checkError(), isc::dhcp::LeaseStatsQuery::first_subnet_id_, isc::dhcp::LeaseStatsQuery::getSelectMode(), isc::dhcp::LeaseStatsQuery::last_subnet_id_, isc::db::MLM_TRUE, isc::db::MysqlExecuteStatement(), isc::dhcp::LeaseStatsQuery::SUBNET_RANGE, and isc::dhcp::Lease::TYPE_NA.