Kea
1.9.9-git
|
Base PgSql derivation of the statistical lease data query. More...
Public Member Functions | |
PgSqlLeaseStatsQuery (PgSqlConnection &conn, PgSqlTaggedStatement &statement, const bool fetch_type) | |
Constructor to query for all subnets' stats. More... | |
PgSqlLeaseStatsQuery (PgSqlConnection &conn, PgSqlTaggedStatement &statement, const bool fetch_type, const SubnetID &subnet_id) | |
Constructor to query for a single subnet's stats. More... | |
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. More... | |
virtual | ~PgSqlLeaseStatsQuery () |
Destructor. More... | |
bool | getNextRow (LeaseStatsRow &row) |
Fetches the next row in the result set. More... | |
void | start () |
Creates the lease statistical data result set. More... | |
Public Member Functions inherited from isc::dhcp::LeaseStatsQuery | |
LeaseStatsQuery () | |
Default constructor The query created will return statistics for all subnets. More... | |
LeaseStatsQuery (const SubnetID &subnet_id) | |
Constructor to query for a single subnet's stats. More... | |
LeaseStatsQuery (const SubnetID &first_subnet_id, const SubnetID &last_subnet_id) | |
Constructor to query for the stats for a range of subnets. 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... | |
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... | |
Protected Attributes | |
PgSqlConnection & | conn_ |
Database connection to use to execute the query. More... | |
bool | fetch_type_ |
Indicates if query supplies lease type. More... | |
uint32_t | next_row_ |
Index of the next row to fetch. More... | |
boost::shared_ptr< PgSqlResult > | result_set_ |
The result set returned by Postgres. More... | |
PgSqlTaggedStatement & | statement_ |
The query's prepared statement. More... | |
Protected Attributes inherited from isc::dhcp::LeaseStatsQuery | |
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... | |
Static Protected Attributes | |
static bool | negative_count_ = false |
Received negative state count showing a problem. More... | |
Additional Inherited Members | |
Public Types inherited from isc::dhcp::LeaseStatsQuery | |
enum | SelectMode { ALL_SUBNETS, SINGLE_SUBNET, SUBNET_RANGE } |
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 996 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 |
Definition at line 1007 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 1021 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 1037 of file pgsql_lease_mgr.cc.
|
inlinevirtual |
Destructor.
Definition at line 1045 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 1100 of file pgsql_lease_mgr.cc.
References isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_PGSQL_NEGATIVE_LEASES_STAT, isc::dhcp::LeaseStatsRow::lease_state_, isc::dhcp::LeaseStatsRow::lease_type_, LOG_WARN, isc::dhcp::LeaseStatsRow::state_count_, and isc::dhcp::LeaseStatsRow::subnet_id_.
|
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 1056 of file pgsql_lease_mgr.cc.
References isc::db::PsqlBindArray::add(), isc::db::PsqlBindArray::formats_, isc::db::PsqlBindArray::lengths_, isc::db::PsqlBindArray::size(), and isc::db::PsqlBindArray::values_.
|
protected |
Database connection to use to execute the query.
Definition at line 1150 of file pgsql_lease_mgr.cc.
|
protected |
Indicates if query supplies lease type.
Definition at line 1162 of file pgsql_lease_mgr.cc.
|
staticprotected |
Received negative state count showing a problem.
Definition at line 1165 of file pgsql_lease_mgr.cc.
|
protected |
Index of the next row to fetch.
Definition at line 1159 of file pgsql_lease_mgr.cc.
|
protected |
The result set returned by Postgres.
Definition at line 1156 of file pgsql_lease_mgr.cc.
|
protected |
The query's prepared statement.
Definition at line 1153 of file pgsql_lease_mgr.cc.