![]() |
Kea 2.5.5
|
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. More... | |
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. More... | |
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. More... | |
virtual | ~MySqlLeaseStatsQuery () |
Destructor. More... | |
bool | getNextRow (LeaseStatsRow &row) |
Fetches the next row in the result set. More... | |
void | start () |
Creates the IPv4 lease statistical data result set. More... | |
![]() | |
LeaseStatsQuery (const SelectMode &select_mode=ALL_SUBNETS) | |
Constructor to query statistics for all subnets. More... | |
LeaseStatsQuery (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) | |
Constructor to query for the stats for a range of subnets. More... | |
LeaseStatsQuery (const SubnetID &subnet_id) | |
Constructor to query for a single subnet's stats. More... | |
virtual | ~LeaseStatsQuery () |
virtual destructor More... | |
SubnetID | getFirstSubnetID () const |
Returns the value of first subnet ID specified (or zero) More... | |
SubnetID | getLastSubnetID () const |
Returns the value of last subnet ID specified (or zero) More... | |
virtual bool | getNextRow (LeaseStatsRow &row) |
Fetches the next row of data. More... | |
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. More... | |
virtual void | start () |
Executes the query. More... | |
Additional Inherited Members | |
![]() | |
enum | SelectMode { ALL_SUBNETS , SINGLE_SUBNET , SUBNET_RANGE , ALL_SUBNET_POOLS } |
Defines the types of selection criteria supported. More... | |
![]() | |
SubnetID | first_subnet_id_ |
First (or only) subnet_id in the selection criteria. More... | |
SubnetID | last_subnet_id_ |
Last subnet_id in the selection criteria when a range is given. More... | |
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 1874 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 1886 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 1907 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 1931 of file mysql_lease_mgr.cc.
|
inlinevirtual |
Destructor.
Definition at line 1946 of file mysql_lease_mgr.cc.
|
inlinevirtual |
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 2048 of file mysql_lease_mgr.cc.
References isc::db::MySqlConnection::checkError(), isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MYSQL_NEGATIVE_LEASES_STAT, isc::dhcp::LeaseStatsRow::lease_state_, isc::dhcp::LeaseStatsRow::lease_type_, LOG_WARN, isc::db::MLM_MYSQL_FETCH_SUCCESS, isc::dhcp::LeaseStatsRow::pool_id_, isc::dhcp::LeaseStatsRow::state_count_, and isc::dhcp::LeaseStatsRow::subnet_id_.
|
inlinevirtual |
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 1957 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.