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

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

+ Inheritance diagram for isc::dhcp::CqlLeaseStatsQuery:

Public Member Functions

 CqlLeaseStatsQuery (CqlConnection &conn, StatementTag &statement, const bool fetch_type)
 Constructor to query for all subnets' stats. More...
 
 CqlLeaseStatsQuery (CqlConnection &conn, StatementTag &statement, const bool fetch_type, const SubnetID &subnet_id)
 Constructor to query for a single subnet's stats. More...
 
 CqlLeaseStatsQuery (CqlConnection &conn, StatementTag &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 ~CqlLeaseStatsQuery ()
 Destructor. More...
 
virtual void createBindForSelect (AnyArray &data, StatementTag statement_tag=NULL)
 Create BIND array to receive C++ data. More...
 
void executeSelect (const CqlConnection &connection, const AnyArray &data, StatementTag statement_tag)
 Executes protocol specific lease query SELECT statement. 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...
 

Static Public Attributes

static StatementMap tagged_statements_
 Cassandra statements. More...
 
static constexpr StatementTag ALL_LEASE4_STATS = "ALL_LEASE4_STATS"
 Statement tags definitions. More...
 
static constexpr StatementTag SUBNET_LEASE4_STATS = "SUBNET_LEASE4_STATS"
 Return lease4 lease statistics for a single subnet. More...
 
static constexpr StatementTag SUBNET_RANGE_LEASE4_STATS = "SUBNET_RANGE_LEASE4_STATS"
 Return lease4 lease statistics for a range of subnets. More...
 
static constexpr StatementTag ALL_LEASE6_STATS = "ALL_LEASE6_STATS"
 
static constexpr StatementTag SUBNET_LEASE6_STATS = "SUBNET_LEASE6_STATS"
 Return lease6 lease statistics for a single subnet. More...
 
static constexpr StatementTag SUBNET_RANGE_LEASE6_STATS = "SUBNET_RANGE_LEASE6_STATS"
 Return lease6 lease statistics for a range of subnets. 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...
 
- 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...
 

Detailed Description

Base CQL 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 1695 of file cql_lease_mgr.cc.

Constructor & Destructor Documentation

isc::dhcp::CqlLeaseStatsQuery::CqlLeaseStatsQuery ( CqlConnection conn,
StatementTag statement,
const bool  fetch_type 
)
inline

Constructor to query for all subnets' stats.

The query created will return statistics for all subnets

Parameters
connAn open connection to the database housing the lease data
statementThe lease data SQL prepared statement tag to execute
fetch_typeIndicates whether or not lease_type should be fetched from the result set (should be true for v6)

Definition at line 1706 of file cql_lease_mgr.cc.

isc::dhcp::CqlLeaseStatsQuery::CqlLeaseStatsQuery ( CqlConnection conn,
StatementTag 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
connAn open connection to the database housing the lease data
statementThe lease data SQL prepared statement tag to execute
fetch_typeIndicates whether or not lease_type should be fetched from the result set (should be true for v6)
subnet_idid of the subnet for which stats are desired

Definition at line 1722 of file cql_lease_mgr.cc.

isc::dhcp::CqlLeaseStatsQuery::CqlLeaseStatsQuery ( CqlConnection conn,
StatementTag 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
connAn open connection to the database housing the lease data
statementThe lease data SQL prepared statement tag to execute
fetch_typeIndicates whether or not lease_type should be fetched from the result set (should be true for v6)
first_subnet_idfirst subnet in the range of subnets
last_subnet_idlast subnet in the range of subnets

Definition at line 1741 of file cql_lease_mgr.cc.

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

Destructor.

Definition at line 1751 of file cql_lease_mgr.cc.

Member Function Documentation

void isc::dhcp::CqlLeaseStatsQuery::createBindForSelect ( AnyArray data,
StatementTag  statement_tag = NULL 
)
virtual

Create BIND array to receive C++ data.

Used in executeSelect() to retrieve from database

Parameters
dataarray of bound objects representing data to be retrieved
statement_tagprepared statement being executed; defaults to an invalid index

Definition at line 1970 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add().

Referenced by executeSelect().

+ Here is the call graph for this function:

void isc::dhcp::CqlLeaseStatsQuery::executeSelect ( const CqlConnection connection,
const AnyArray data,
StatementTag  statement_tag 
)

Executes protocol specific lease query SELECT statement.

Currently we do not have a good way for Cassandra to roll up the lease counts per subnet, type, and state as we do the other back ends. This method executes the select statement which returns a result set containing a row of data for every lease: -v4 - subnet-id, lease-state -v6 - subnet-id, lease-type, lease-state

It then iterates over this result set, aggregating the data into a a map of LeaseStatRows.

If we didn't have to roll up the raw lease data first, we could have derived this class from CqlExchange and used it's executeSelect (from which this method borrows heavily). However, that would mean copying all the raw lease data into a collection returned by executeSelect and then aggregating that into cumulative rows. The way we are now we go turn the raw lease data directly into the cumulative row map.

Parameters
connectionconnection used to communicate with the Cassandra database
dataarray of bound objects used to filter the results
statement_tagprepared statement being executed
Exceptions
DbOperationError

Definition at line 1981 of file cql_lease_mgr.cc.

References isc::db::CqlCommon::bindData(), isc::db::CqlConnection::checkFutureError(), isc::db::CqlConnection::consistency_, createBindForSelect(), isc::db::error, isc::db::CqlConnection::force_consistency_, isc::db::CqlCommon::getData(), isc::db::CqlTaggedStatement::is_raw_, isc_throw, isc::db::CqlTaggedStatement::name_, isc::db::CqlTaggedStatement::prepared_statement_, isc::db::CqlConnection::serial_consistency_, isc::db::CqlConnection::session_, isc::dhcp::Lease::STATE_DECLINED, isc::dhcp::Lease::STATE_DEFAULT, isc::db::CqlConnection::statements_, and isc::dhcp::Lease::TYPE_NA.

Referenced by start().

+ Here is the call graph for this function:

bool isc::dhcp::CqlLeaseStatsQuery::getNextRow ( LeaseStatsRow row)
virtual

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.

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 1950 of file cql_lease_mgr.cc.

References isc::dhcp::LeaseStatsRow::lease_state_, isc::dhcp::LeaseStatsRow::lease_type_, isc::dhcp::LeaseStatsRow::state_count_, and isc::dhcp::LeaseStatsRow::subnet_id_.

void isc::dhcp::CqlLeaseStatsQuery::start ( )
virtual

Creates the lease statistical data result set.

The result set is populated by executing a prepared SQL query against the database which sums the leases per lease state per subnet id. Positions internal row tracking to point to the first row of the aggregate results.

Reimplemented from isc::dhcp::LeaseStatsQuery.

Definition at line 1925 of file cql_lease_mgr.cc.

References isc::db::AnyArray::add(), isc::dhcp::LeaseStatsQuery::ALL_SUBNETS, executeSelect(), isc::dhcp::LeaseStatsQuery::first_subnet_id_, isc::dhcp::LeaseStatsQuery::getSelectMode(), isc::dhcp::LeaseStatsQuery::last_subnet_id_, and isc::dhcp::LeaseStatsQuery::SUBNET_RANGE.

+ Here is the call graph for this function:

Member Data Documentation

constexpr StatementTag isc::dhcp::CqlLeaseStatsQuery::ALL_LEASE4_STATS = "ALL_LEASE4_STATS"
static

Statement tags definitions.

Definition at line 1816 of file cql_lease_mgr.cc.

constexpr StatementTag isc::dhcp::CqlLeaseStatsQuery::ALL_LEASE6_STATS = "ALL_LEASE6_STATS"
static

Definition at line 1823 of file cql_lease_mgr.cc.

constexpr StatementTag isc::dhcp::CqlLeaseStatsQuery::SUBNET_LEASE4_STATS = "SUBNET_LEASE4_STATS"
static

Return lease4 lease statistics for a single subnet.

Definition at line 1818 of file cql_lease_mgr.cc.

constexpr StatementTag isc::dhcp::CqlLeaseStatsQuery::SUBNET_LEASE6_STATS = "SUBNET_LEASE6_STATS"
static

Return lease6 lease statistics for a single subnet.

Definition at line 1825 of file cql_lease_mgr.cc.

constexpr StatementTag isc::dhcp::CqlLeaseStatsQuery::SUBNET_RANGE_LEASE4_STATS = "SUBNET_RANGE_LEASE4_STATS"
static

Return lease4 lease statistics for a range of subnets.

Definition at line 1820 of file cql_lease_mgr.cc.

constexpr StatementTag isc::dhcp::CqlLeaseStatsQuery::SUBNET_RANGE_LEASE6_STATS = "SUBNET_RANGE_LEASE6_STATS"
static

Return lease6 lease statistics for a range of subnets.

Definition at line 1827 of file cql_lease_mgr.cc.

StatementMap isc::dhcp::CqlLeaseStatsQuery::tagged_statements_
static

Cassandra statements.

Definition at line 1831 of file cql_lease_mgr.cc.

Referenced by isc::dhcp::CqlLeaseMgr::CqlLeaseMgr().


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