Kea 2.5.8
|
Base PgSql derivation of the statistical lease data query. More...
Public Member Functions | |
PgSqlLeaseStatsQuery (PgSqlConnection &conn, PgSqlTaggedStatement &statement, const bool fetch_type, const bool fetch_pool=false) | |
Constructor to query for all subnets' stats. | |
PgSqlLeaseStatsQuery (PgSqlConnection &conn, PgSqlTaggedStatement &statement, 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. | |
PgSqlLeaseStatsQuery (PgSqlConnection &conn, PgSqlTaggedStatement &statement, const bool fetch_type, const SubnetID &subnet_id) | |
Constructor to query for a single subnet's stats. | |
virtual | ~PgSqlLeaseStatsQuery () |
Destructor. | |
bool | getNextRow (LeaseStatsRow &row) |
Fetches the next row in the result set. | |
void | start () |
Creates the 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) | |
virtual bool | getNextRow (LeaseStatsRow &row) |
Fetches the next row of data. | |
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. | |
virtual void | start () |
Executes the query. | |
Protected Attributes | |
PgSqlConnection & | conn_ |
Database connection to use to execute the query. | |
bool | fetch_pool_ |
Indicates if query requires pool data. | |
bool | fetch_type_ |
Indicates if query supplies lease type. | |
uint32_t | next_row_ |
Index of the next row to fetch. | |
boost::shared_ptr< PgSqlResult > | result_set_ |
The result set returned by Postgres. | |
PgSqlTaggedStatement & | statement_ |
The query's prepared statement. | |
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. | |
Static Protected Attributes | |
static bool | negative_count_ = false |
Received negative state count showing a problem. | |
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... | |
Base PgSql derivation of the statistical lease data query.
This class provides the functionality such as results storage and row fetching common to fulfilling the statistical lease data query.
Definition at line 1342 of file pgsql_lease_mgr.cc.
|
inline |
Constructor to query for all subnets' stats.
The query created will return statistics for all subnets
conn | A open connection to the database housing the lease data |
statement | The lease data SQL prepared statement to execute |
fetch_type | Indicates whether or not lease_type should be fetched from the result set |
fetch_pool | Indicates if query requires pool data |
Definition at line 1354 of file pgsql_lease_mgr.cc.
|
inline |
Constructor to query for a single subnet's stats.
The query created will return statistics for a single subnet
conn | A open connection to the database housing the lease data |
statement | The lease data SQL prepared statement to execute |
fetch_type | Indicates if query supplies lease type |
subnet_id | id of the subnet for which stats are desired |
Definition at line 1368 of file pgsql_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 | A open connection to the database housing the lease data |
statement | The lease data SQL prepared statement to execute |
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 |
Definition at line 1384 of file pgsql_lease_mgr.cc.
|
inlinevirtual |
Destructor.
Definition at line 1392 of file pgsql_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.
row | Storage for the fetched row |
Reimplemented from isc::dhcp::LeaseStatsQuery.
Definition at line 1445 of file pgsql_lease_mgr.cc.
References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT, fetch_pool_, fetch_type_, isc::db::PgSqlExchange::getColumnValue(), isc::dhcp::LeaseStatsRow::lease_state_, isc::dhcp::LeaseStatsRow::lease_type_, LOG_WARN, negative_count_, next_row_, isc::dhcp::LeaseStatsRow::pool_id_, result_set_, isc::dhcp::LeaseStatsRow::state_count_, isc::dhcp::LeaseStatsRow::subnet_id_, and isc::dhcp::Lease::TYPE_NA.
|
inlinevirtual |
Creates the lease statistical data result set.
The result set is populated by executing a prepared SQL query against the database fetches the lease count per lease state per (per least type - v6 only) per subnet id.
Depending upon the selection mode, the query will have either no parameters (for all subnets), a subnet id for a single subnet, or a first and last subnet id for a subnet range.
Reimplemented from isc::dhcp::LeaseStatsQuery.
Definition at line 1403 of file pgsql_lease_mgr.cc.
References isc::db::PsqlBindArray::addTempString(), isc::dhcp::LeaseStatsQuery::ALL_SUBNET_POOLS, isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, isc::db::PgSqlConnection::checkStatementError(), conn_, isc::db::PsqlBindArray::formats_, isc::dhcp::LeaseStatsQuery::getFirstSubnetID(), isc::dhcp::LeaseStatsQuery::getLastSubnetID(), isc::dhcp::LeaseStatsQuery::getSelectMode(), isc::db::PsqlBindArray::lengths_, isc::db::PgSqlTaggedStatement::name, result_set_, isc::db::PsqlBindArray::size(), statement_, isc::dhcp::LeaseStatsQuery::SUBNET_RANGE, and isc::db::PsqlBindArray::values_.
|
protected |
Database connection to use to execute the query.
Definition at line 1502 of file pgsql_lease_mgr.cc.
Referenced by start().
|
protected |
Indicates if query requires pool data.
Definition at line 1517 of file pgsql_lease_mgr.cc.
Referenced by getNextRow().
|
protected |
Indicates if query supplies lease type.
Definition at line 1514 of file pgsql_lease_mgr.cc.
Referenced by getNextRow().
|
staticprotected |
Received negative state count showing a problem.
Definition at line 1520 of file pgsql_lease_mgr.cc.
Referenced by getNextRow().
|
protected |
Index of the next row to fetch.
Definition at line 1511 of file pgsql_lease_mgr.cc.
Referenced by getNextRow().
|
protected |
The result set returned by Postgres.
Definition at line 1508 of file pgsql_lease_mgr.cc.
Referenced by getNextRow(), and start().
|
protected |
The query's prepared statement.
Definition at line 1505 of file pgsql_lease_mgr.cc.
Referenced by start().