|
@@ -153,7 +153,7 @@ public:
|
|
|
/// and the number of leases in that state for that subnet ID.
|
|
|
struct AddressStatsRow4 {
|
|
|
/// @brief Default constructor
|
|
|
- AddressStatsRow4() :
|
|
|
+ AddressStatsRow4() :
|
|
|
subnet_id_(0), lease_state_(Lease::STATE_DEFAULT), state_count_(0) {
|
|
|
}
|
|
|
|
|
@@ -164,15 +164,15 @@ struct AddressStatsRow4 {
|
|
|
/// @param state_count The count of leases in the lease state
|
|
|
AddressStatsRow4(const SubnetID& subnet_id,
|
|
|
const Lease::LeaseState& lease_state,
|
|
|
- const int64_t state_count)
|
|
|
- : subnet_id_(subnet_id), lease_state_(lease_state),
|
|
|
+ const int64_t state_count)
|
|
|
+ : subnet_id_(subnet_id), lease_state_(lease_state),
|
|
|
state_count_(state_count) {
|
|
|
}
|
|
|
|
|
|
/// @brief The subnet ID to which this data applies
|
|
|
SubnetID subnet_id_;
|
|
|
/// @brief The lease_state to which the count applies
|
|
|
- uint32_t lease_state_;
|
|
|
+ Lease::LeaseState lease_state_;
|
|
|
/// @brief state_count The count of leases in the lease state
|
|
|
int64_t state_count_;
|
|
|
};
|
|
@@ -188,12 +188,12 @@ public:
|
|
|
/// @brief Default constructor
|
|
|
AddressStatsQuery4() {};
|
|
|
|
|
|
- /// @brief virtual destructor
|
|
|
+ /// @brief virtual destructor
|
|
|
virtual ~AddressStatsQuery4() {};
|
|
|
|
|
|
/// @brief Executes the query
|
|
|
///
|
|
|
- /// This method should conduct whatever steps are required to
|
|
|
+ /// This method should conduct whatever steps are required to
|
|
|
/// calculate the IPv4 lease statistical data by examining the
|
|
|
/// IPv4 lease data and making that results available row by row.
|
|
|
virtual void start() {};
|
|
@@ -210,6 +210,72 @@ public:
|
|
|
/// @brief Defines a pointer to an AddressStatsQuery4.
|
|
|
typedef boost::shared_ptr<AddressStatsQuery4> AddressStatsQuery4Ptr;
|
|
|
|
|
|
+/// @brief Contains a single row of IPv6 lease statistical data
|
|
|
+///
|
|
|
+/// The contents of the row consist of a subnet ID, a lease state,
|
|
|
+/// and the number of leases in that state for that subnet ID.
|
|
|
+struct AddressStatsRow6 {
|
|
|
+ /// @brief Default constructor
|
|
|
+ AddressStatsRow6() :
|
|
|
+ subnet_id_(0), lease_type_(Lease::TYPE_NA),
|
|
|
+ lease_state_(Lease::STATE_DEFAULT), state_count_(0) {
|
|
|
+ }
|
|
|
+
|
|
|
+ /// @brief Constructor
|
|
|
+ ///
|
|
|
+ /// @param subnet_id The subnet id to which this data applies
|
|
|
+ /// @param lease_state The lease state counted
|
|
|
+ /// @param state_count The count of leases in the lease state
|
|
|
+ AddressStatsRow6(const SubnetID& subnet_id, const Lease::Type& lease_type,
|
|
|
+ const Lease::LeaseState& lease_state,
|
|
|
+ const int64_t state_count)
|
|
|
+ : subnet_id_(subnet_id), lease_state_(lease_state),
|
|
|
+ state_count_(state_count) {
|
|
|
+ }
|
|
|
+
|
|
|
+ /// @brief The subnet ID to which this data applies
|
|
|
+ SubnetID subnet_id_;
|
|
|
+ /// @brief The lease_state to which the count applies
|
|
|
+ Lease::Type lease_type_;
|
|
|
+ /// @brief The lease_state to which the count applies
|
|
|
+ uint32_t lease_state_;
|
|
|
+ /// @brief state_count The count of leases in the lease state
|
|
|
+ int64_t state_count_;
|
|
|
+};
|
|
|
+
|
|
|
+/// @brief Base class for fulfilling IPv6 statistical lease data query
|
|
|
+///
|
|
|
+/// LeaseMgr derivations implement this class such that it provides
|
|
|
+/// upto date IPv6 statistical lease data organized as rows of
|
|
|
+/// AddressStatsRow6 instances. The rows must be accessible in
|
|
|
+/// ascending order by subnet id.
|
|
|
+class AddressStatsQuery6 {
|
|
|
+public:
|
|
|
+ /// @brief Default constructor
|
|
|
+ AddressStatsQuery6() {};
|
|
|
+
|
|
|
+ /// @brief virtual destructor
|
|
|
+ virtual ~AddressStatsQuery6() {};
|
|
|
+
|
|
|
+ /// @brief Executes the query
|
|
|
+ ///
|
|
|
+ /// This method should conduct whatever steps are required to
|
|
|
+ /// calculate the IPv6 lease statistical data by examining the
|
|
|
+ /// IPv6 lease data and making that results available row by row.
|
|
|
+ virtual void start() {};
|
|
|
+
|
|
|
+ /// @brief Fetches the next row of data
|
|
|
+ ///
|
|
|
+ /// @param[out] row Storage into which the row is fetched
|
|
|
+ ///
|
|
|
+ /// @return True if a row was fetched, false if there are no
|
|
|
+ /// more rows.
|
|
|
+ virtual bool getNextRow(AddressStatsRow6& row) { return (false); };
|
|
|
+};
|
|
|
+
|
|
|
+/// @brief Defines a pointer to an AddressStatsQuery6.
|
|
|
+typedef boost::shared_ptr<AddressStatsQuery6> AddressStatsQuery6Ptr;
|
|
|
+
|
|
|
/// @brief Abstract Lease Manager
|
|
|
///
|
|
|
/// This is an abstract API for lease database backends. It provides unified
|
|
@@ -463,7 +529,7 @@ public:
|
|
|
|
|
|
/// @brief Recalculates per-subnet and global stats for IPv4 leases
|
|
|
///
|
|
|
- /// This method recalculates the following statistics:
|
|
|
+ /// This method recalculates the following statistics:
|
|
|
/// per-subnet:
|
|
|
/// - assigned-addresses
|
|
|
/// - declined-addresses
|
|
@@ -476,21 +542,52 @@ public:
|
|
|
/// returns an instance of an AddressStats4Qry. The query
|
|
|
/// query contains a "result set" where each row is an AddressStatRow4
|
|
|
/// that contains a subnet id, a lease state, the number of leases in that
|
|
|
- /// state and is ordered by subnet id. The method iterates over the
|
|
|
+ /// state and is ordered by subnet id. The method iterates over the
|
|
|
/// result set rows, setting the appropriate statistic per subnet and
|
|
|
- /// adding to the approporate global statistic.
|
|
|
+ /// adding to the approporate global statistic.
|
|
|
void recountAddressStats4();
|
|
|
|
|
|
- /// @brief Virtual method which creates and runs the IPv4 lease stats query
|
|
|
+ /// @brief Virtual method which creates and runs the IPv4 lease stats query
|
|
|
///
|
|
|
/// LeaseMgr derivations implement this method such that it creates and
|
|
|
- /// returns an instance of an AddressStatsQuery whose result set has been
|
|
|
- /// populated with upto date IPv4 lease statistical data. Each row of the
|
|
|
- /// result set is an AddressStatRow4 which ordered ascending by subnet ID.
|
|
|
+ /// returns an instance of an AddressStatsQuery whose result set has been
|
|
|
+ /// populated with upto date IPv4 lease statistical data. Each row of the
|
|
|
+ /// result set is an AddressStatRow4 which ordered ascending by subnet ID.
|
|
|
///
|
|
|
/// @return A populated AddressStatsQuery4
|
|
|
virtual AddressStatsQuery4Ptr startAddressStatsQuery4();
|
|
|
|
|
|
+ /// @brief Recalculates per-subnet and global stats for IPv6 leases
|
|
|
+ ///
|
|
|
+ /// This method recalculates the following statistics:
|
|
|
+ /// per-subnet:
|
|
|
+ /// - assigned-addresses
|
|
|
+ /// - declined-addresses
|
|
|
+ /// - declined-reclaimed-addresses (reset to zero)
|
|
|
+ /// - assigned-pds
|
|
|
+ /// global:
|
|
|
+ /// - declined-addresses
|
|
|
+ /// - declined-reclaimed-addresses (reset to zero)
|
|
|
+ ///
|
|
|
+ /// It invokes the virtual method, startAddressStatsQuery6(), which
|
|
|
+ /// returns an instance of an AddressStats6Qry. The query
|
|
|
+ /// query contains a "result set" where each row is an AddressStatRow6
|
|
|
+ /// that contains a subnet id, a lease state, the number of leases in that
|
|
|
+ /// state and is ordered by subnet id. The method iterates over the
|
|
|
+ /// result set rows, setting the appropriate statistic per subnet and
|
|
|
+ /// adding to the approporate global statistic.
|
|
|
+ void recountAddressStats6();
|
|
|
+
|
|
|
+ /// @brief Virtual method which creates and runs the IPv6 lease stats query
|
|
|
+ ///
|
|
|
+ /// LeaseMgr derivations implement this method such that it creates and
|
|
|
+ /// returns an instance of an AddressStatsQuery whose result set has been
|
|
|
+ /// populated with upto date IPv6 lease statistical data. Each row of the
|
|
|
+ /// result set is an AddressStatRow6 which ordered ascending by subnet ID.
|
|
|
+ ///
|
|
|
+ /// @return A populated AddressStatsQuery6
|
|
|
+ virtual AddressStatsQuery6Ptr startAddressStatsQuery6();
|
|
|
+
|
|
|
/// @brief Return backend type
|
|
|
///
|
|
|
/// Returns the type of the backend (e.g. "mysql", "memfile" etc.)
|