Kea  1.9.9-git
isc::dhcp::PgSqlLeaseStatsQuery Class Reference

Base PgSql derivation of the statistical lease data query. More...

+ Inheritance diagram for isc::dhcp::PgSqlLeaseStatsQuery:

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

PgSqlConnectionconn_
 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< PgSqlResultresult_set_
 The result set returned by Postgres. More...
 
PgSqlTaggedStatementstatement_
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

isc::dhcp::PgSqlLeaseStatsQuery::PgSqlLeaseStatsQuery ( PgSqlConnection conn,
PgSqlTaggedStatement statement,
const bool  fetch_type 
)
inline

Constructor to query for all subnets' stats.

The query created will return statistics for all subnets

Parameters
connA open connection to the database housing the lease data
statementThe lease data SQL prepared statement to execute
fetch_typeIndicates whether or not lease_type should be fetched from the result set

Definition at line 1007 of file pgsql_lease_mgr.cc.

isc::dhcp::PgSqlLeaseStatsQuery::PgSqlLeaseStatsQuery ( PgSqlConnection conn,
PgSqlTaggedStatement statement,
const bool  fetch_type,
const SubnetID subnet_id 
)
inline

Constructor to query for a single subnet's stats.

The query created will return statistics for a single subnet

Parameters
connA open connection to the database housing the lease data
statementThe lease data SQL prepared statement to execute
fetch_typeIndicates if query supplies lease type
subnet_idid of the subnet for which stats are desired

Definition at line 1021 of file pgsql_lease_mgr.cc.

isc::dhcp::PgSqlLeaseStatsQuery::PgSqlLeaseStatsQuery ( PgSqlConnection conn,
PgSqlTaggedStatement statement,
const bool  fetch_type,
const SubnetID first_subnet_id,
const SubnetID last_subnet_id 
)
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.

Parameters
connA open connection to the database housing the lease data
statementThe lease data SQL prepared statement to execute
fetch_typeIndicates if query supplies lease type
first_subnet_idfirst subnet in the range of subnets
last_subnet_idlast subnet in the range of subnets

Definition at line 1037 of file pgsql_lease_mgr.cc.

virtual isc::dhcp::PgSqlLeaseStatsQuery::~PgSqlLeaseStatsQuery ( )
inlinevirtual

Destructor.

Definition at line 1045 of file pgsql_lease_mgr.cc.

Member Function Documentation

bool isc::dhcp::PgSqlLeaseStatsQuery::getNextRow ( LeaseStatsRow row)
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.

Parameters
rowStorage for the fetched row
Returns
True if the fetch succeeded, false if there are no more rows to fetch.

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_.

void isc::dhcp::PgSqlLeaseStatsQuery::start ( )
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_.

+ Here is the call graph for this function:

Member Data Documentation

PgSqlConnection& isc::dhcp::PgSqlLeaseStatsQuery::conn_
protected

Database connection to use to execute the query.

Definition at line 1150 of file pgsql_lease_mgr.cc.

bool isc::dhcp::PgSqlLeaseStatsQuery::fetch_type_
protected

Indicates if query supplies lease type.

Definition at line 1162 of file pgsql_lease_mgr.cc.

bool isc::dhcp::PgSqlLeaseStatsQuery::negative_count_ = false
staticprotected

Received negative state count showing a problem.

Definition at line 1165 of file pgsql_lease_mgr.cc.

uint32_t isc::dhcp::PgSqlLeaseStatsQuery::next_row_
protected

Index of the next row to fetch.

Definition at line 1159 of file pgsql_lease_mgr.cc.

boost::shared_ptr<PgSqlResult> isc::dhcp::PgSqlLeaseStatsQuery::result_set_
protected

The result set returned by Postgres.

Definition at line 1156 of file pgsql_lease_mgr.cc.

PgSqlTaggedStatement& isc::dhcp::PgSqlLeaseStatsQuery::statement_
protected

The query's prepared statement.

Definition at line 1153 of file pgsql_lease_mgr.cc.


The documentation for this class was generated from the following file: