Kea
1.9.9-git
|
Base CQL derivation of the statistical lease data query. More...
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... | |
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.
|
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 | The lease data SQL prepared statement tag to execute |
fetch_type | Indicates 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.
|
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 | The lease data SQL prepared statement tag to execute |
fetch_type | Indicates whether or not lease_type should be fetched from the result set (should be true for v6) |
subnet_id | id of the subnet for which stats are desired |
Definition at line 1722 of file cql_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 | The lease data SQL prepared statement tag to execute |
fetch_type | Indicates whether or not lease_type should be fetched from the result set (should be true for v6) |
first_subnet_id | first subnet in the range of subnets |
last_subnet_id | last subnet in the range of subnets |
Definition at line 1741 of file cql_lease_mgr.cc.
|
inlinevirtual |
Destructor.
Definition at line 1751 of file cql_lease_mgr.cc.
|
virtual |
Create BIND array to receive C++ data.
Used in executeSelect() to retrieve from database
data | array of bound objects representing data to be retrieved |
statement_tag | prepared 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().
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.
connection | connection used to communicate with the Cassandra database |
data | array of bound objects used to filter the results |
statement_tag | prepared statement being executed |
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().
|
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.
row | Storage for the fetched row |
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_.
|
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.
|
static |
Statement tags definitions.
Definition at line 1816 of file cql_lease_mgr.cc.
|
static |
Definition at line 1823 of file cql_lease_mgr.cc.
|
static |
Return lease4 lease statistics for a single subnet.
Definition at line 1818 of file cql_lease_mgr.cc.
|
static |
Return lease6 lease statistics for a single subnet.
Definition at line 1825 of file cql_lease_mgr.cc.
|
static |
Return lease4 lease statistics for a range of subnets.
Definition at line 1820 of file cql_lease_mgr.cc.
|
static |
Return lease6 lease statistics for a range of subnets.
Definition at line 1827 of file cql_lease_mgr.cc.
|
static |
Cassandra statements.
Definition at line 1831 of file cql_lease_mgr.cc.
Referenced by isc::dhcp::CqlLeaseMgr::CqlLeaseMgr().