// Only recount the stats if we have subnets.
if (subnets_.begin() != subnets_.end()) {
- LeaseMgrFactory::instance().recountAddressStats4();
+ //LeaseMgrFactory::instance().recountAddressStats4();
+ LeaseMgrFactory::instance().recountLeaseStats4();
}
}
// Only recount the stats if we have subnets.
if (subnets_.begin() != subnets_.end()) {
- LeaseMgrFactory::instance().recountAddressStats6();
+ LeaseMgrFactory::instance().recountLeaseStats6();
}
}
}
void
-LeaseMgr::recountAddressStats4() {
+LeaseMgr::recountLeaseStats4() {
using namespace stats;
StatsMgr& stats_mgr = StatsMgr::instance();
- AddressStatsQuery4Ptr query = startAddressStatsQuery4();
+ LeaseStatsQueryPtr query = startLeaseStatsQuery4();
if (!query) {
/// NULL means not backend does not support recounting.
return;
// Get counts per state per subnet. Iterate over the result set
// updating the subnet and global values.
- AddressStatsRow4 row;
+ LeaseStatsRow row;
while (query->getNextRow(row)) {
if (row.lease_state_ == Lease::STATE_DEFAULT) {
// Set subnet level value.
}
}
-AddressStatsQuery4Ptr
-LeaseMgr::startAddressStatsQuery4() {
- return(AddressStatsQuery4Ptr());
+LeaseStatsQueryPtr
+LeaseMgr::startLeaseStatsQuery4() {
+ return(LeaseStatsQueryPtr());
}
bool
-AddressStatsQuery4::getNextRow(AddressStatsRow4& /*row*/) {
+LeaseStatsQuery::getNextRow(LeaseStatsRow& /*row*/) {
return (false);
}
void
-LeaseMgr::recountAddressStats6() {
+LeaseMgr::recountLeaseStats6() {
using namespace stats;
StatsMgr& stats_mgr = StatsMgr::instance();
- AddressStatsQuery6Ptr query = startAddressStatsQuery6();
+ LeaseStatsQueryPtr query = startLeaseStatsQuery6();
if (!query) {
/// NULL means not backend does not support recounting.
return;
// Get counts per state per subnet. Iterate over the result set
// updating the subnet and global values.
- AddressStatsRow6 row;
+ LeaseStatsRow row;
while (query->getNextRow(row)) {
switch(row.lease_type_) {
case Lease::TYPE_NA:
}
}
-AddressStatsQuery6Ptr
-LeaseMgr::startAddressStatsQuery6() {
- return(AddressStatsQuery6Ptr());
-}
-
-bool
-AddressStatsQuery6::getNextRow(AddressStatsRow6& /*row*/) {
- return (false);
+LeaseStatsQueryPtr
+LeaseMgr::startLeaseStatsQuery6() {
+ return(LeaseStatsQueryPtr());
}
std::string
ExchangeColumnInfoContainer parameters_; ///< Column names and types
};
-/// @brief Contains a single row of IPv4 lease statistical data
+/// @brief Contains a single row of 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 AddressStatsRow4 {
+/// The contents of the row consist of a subnet ID, a lease
+/// type, a lease state, and the number of leases in that state
+/// for that type for that subnet ID.
+struct LeaseStatsRow {
/// @brief Default constructor
- AddressStatsRow4() :
- subnet_id_(0), lease_state_(Lease::STATE_DEFAULT), state_count_(0) {
+ LeaseStatsRow() :
+ subnet_id_(0), lease_type_(Lease::TYPE_NA),
+ lease_state_(Lease::STATE_DEFAULT), state_count_(0) {
}
/// @brief Constructor
///
+ /// Constructor which defaults the type to TYPE_NA.
+ ///
/// @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
- AddressStatsRow4(const SubnetID& subnet_id,
- const uint32_t 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_;
- /// @brief state_count The count of leases in the lease state
- int64_t state_count_;
-};
-
-/// @brief Base class for fulfilling IPv4 statistical lease data query
-///
-/// LeaseMgr derivations implement this class such that it provides
-/// upto date IPv4 statistical lease data organized as rows of
-/// AddressStatsRow4 instances. The rows must be accessible in
-/// ascending order by subnet id.
-class AddressStatsQuery4 {
-public:
- /// @brief Default constructor
- AddressStatsQuery4() {};
-
- /// @brief virtual destructor
- virtual ~AddressStatsQuery4() {};
-
- /// @brief Executes the query
- ///
- /// 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() {};
-
- /// @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(AddressStatsRow4& row);
-};
-
-/// @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) {
+ LeaseStatsRow(const SubnetID& subnet_id, const uint32_t lease_state,
+ const int64_t state_count)
+ : subnet_id_(subnet_id), lease_type_(Lease::TYPE_NA),
+ lease_state_(lease_state), state_count_(state_count) {
}
/// @brief Constructor
/// @param lease_type The lease type for this state count
/// @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 uint32_t lease_state,
- const int64_t state_count)
+ LeaseStatsRow(const SubnetID& subnet_id, const Lease::Type& lease_type,
+ const uint32_t lease_state, const int64_t state_count)
: subnet_id_(subnet_id), lease_type_(lease_type),
lease_state_(lease_state), state_count_(state_count) {
}
int64_t state_count_;
};
-/// @brief Base class for fulfilling IPv6 statistical lease data query
+/// @brief Base class for fulfilling a 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 {
+/// upto date statistical lease data organized as rows of LeaseStatsRow
+/// instances. The rows must be accessible in ascending order by subnet id.
+class LeaseStatsQuery {
public:
/// @brief Default constructor
- AddressStatsQuery6() {};
+ LeaseStatsQuery() {};
/// @brief virtual destructor
- virtual ~AddressStatsQuery6() {};
+ virtual ~LeaseStatsQuery() {};
/// @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.
+ /// calculate the lease statistical data by examining the
+ /// lease data and making that results available row by row.
virtual void start() {};
/// @brief Fetches the next row of data
///
/// @return True if a row was fetched, false if there are no
/// more rows.
- virtual bool getNextRow(AddressStatsRow6& row);
+ virtual bool getNextRow(LeaseStatsRow& row);
};
-/// @brief Defines a pointer to an AddressStatsQuery6.
-typedef boost::shared_ptr<AddressStatsQuery6> AddressStatsQuery6Ptr;
+/// @brief Defines a pointer to an LeaseStatsQuery.
+typedef boost::shared_ptr<LeaseStatsQuery> LeaseStatsQueryPtr;
/// @brief Abstract Lease Manager
///
/// - declined-addresses
/// - declined-reclaimed-addresses (reset to zero)
///
- /// It invokes the virtual method, startAddressStatsQuery4(), which
- /// 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
+ /// It invokes the virtual method, startLeaseStatsQuery4(), which
+ /// returns an instance of an LeaseStatsQuery. The query
+ /// query contains a "result set" where each row is an LeaseStatRow
+ /// that contains a subnet id, a lease type (currently always TYPE_NA),
+ /// a lease state, and the number of leases of that type, 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 recountAddressStats4();
+ void recountLeaseStats4();
/// @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
+ /// returns an instance of an LeaseStatsQuery 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.
+ /// result set is an LeaseStatRow which ordered ascending by subnet ID.
///
- /// @return A populated AddressStatsQuery4
- virtual AddressStatsQuery4Ptr startAddressStatsQuery4();
+ /// @return A populated LeaseStatsQuery
+ virtual LeaseStatsQueryPtr startLeaseStatsQuery4();
/// @brief Recalculates per-subnet and global stats for IPv6 leases
///
/// - 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();
+ /// It invokes the virtual method, startLeaseStatsQuery6(), which
+ /// returns an instance of an LeaseStatsQuery. The query contains
+ /// a "result set" where each row is an LeaseStatRow that contains
+ /// a subnet id, a lease type, a lease state, and the number of leases
+ /// of that type, 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 recountLeaseStats6();
/// @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
+ /// returns an instance of an LeaseStatsQuery 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.
+ /// result set is an LeaseStatRow which ordered ascending by subnet ID.
///
- /// @return A populated AddressStatsQuery6
- virtual AddressStatsQuery6Ptr startAddressStatsQuery6();
+ /// @return A populated LeaseStatsQuery
+ virtual LeaseStatsQueryPtr startLeaseStatsQuery6();
/// @brief Return backend type
///
}
+/// @brief Base Memfile derivation of the statistical lease data query
+///
+/// This class provides the functionality such as results storgae and row
+/// fetching common to fulfilling the statistical lease data query.
+///
+class MemfileLeaseStatsQuery : public LeaseStatsQuery {
+public:
+ /// @brief Constructor
+ ///
+ MemfileLeaseStatsQuery()
+ : rows_(0), next_pos_(rows_.end()) {
+ };
+
+ /// @brief Destructor
+ virtual ~MemfileLeaseStatsQuery() {};
+
+ /// @brief 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.
+ /// @param row Storage for the fetched row
+ ///
+ /// @return True if the fetch succeeded, false if there are no more
+ /// rows to fetch.
+ virtual bool getNextRow(LeaseStatsRow& row) {
+ if (next_pos_ == rows_.end()) {
+ return (false);
+ }
+
+ row = *next_pos_;
+ ++next_pos_;
+ return (true);
+ }
+
+ /// @brief Returns the number of rows in the result set
+ int getRowCount() const {
+ return (rows_.size());
+ }
+
+protected:
+ /// @brief A vector containing the "result set"
+ std::vector<LeaseStatsRow> rows_;
+
+ /// @brief An iterator for accessing the next row within the result set
+ std::vector<LeaseStatsRow>::iterator next_pos_;
+};
+
/// @brief Memfile derivation of the IPv4 statistical lease data query
///
/// This class is used to recalculate IPv4 lease statistics for Memfile
/// The populated result set will contain one entry per monitored state
/// per subnet.
///
-class MemfileAddressStatsQuery4 : public AddressStatsQuery4 {
+class MemfileLeaseStatsQuery4 : public MemfileLeaseStatsQuery {
public:
/// @brief Constructor
///
/// @param storage4 A pointer to the v4 lease storage to be counted
- MemfileAddressStatsQuery4(Lease4Storage& storage4)
- : storage4_(storage4), rows_(0), next_pos_(rows_.end()) {
+ MemfileLeaseStatsQuery4(Lease4Storage& storage4)
+ : MemfileLeaseStatsQuery(), storage4_(storage4) {
};
/// @brief Destructor
- virtual ~MemfileAddressStatsQuery4() {};
+ virtual ~MemfileLeaseStatsQuery4() {};
/// @brief Creates the IPv4 lease statistical data result set
///
// and wipe the accumulators
if ((*lease)->subnet_id_ > cur_id) {
if (cur_id > 0) {
- rows_.push_back(AddressStatsRow4(cur_id,
- Lease::STATE_DEFAULT,
- assigned));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::STATE_DEFAULT,
+ assigned));
assigned = 0;
- rows_.push_back(AddressStatsRow4(cur_id,
- Lease::STATE_DECLINED,
- declined));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::STATE_DECLINED,
+ declined));
declined = 0;
}
// Make the rows for last subnet, unless there were no rows
if (idx.begin() != idx.end()) {
- rows_.push_back(AddressStatsRow4(cur_id, Lease::STATE_DEFAULT,
- assigned));
- rows_.push_back(AddressStatsRow4(cur_id, Lease::STATE_DECLINED,
- declined));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::STATE_DEFAULT,
+ assigned));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::STATE_DECLINED,
+ declined));
}
// Set the next row position to the beginning of the rows.
next_pos_ = rows_.begin();
}
- /// @brief 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.
- /// @param row Storage for the fetched row
- ///
- /// @return True if the fetch succeeded, false if there are no more
- /// rows to fetch.
- virtual bool getNextRow(AddressStatsRow4& row) {
- if (next_pos_ == rows_.end()) {
- return (false);
- }
-
- row = *next_pos_;
- ++next_pos_;
- return (true);
- }
-
- /// @brief Returns the number of rows in the result set
- int getRowCount() const {
- return (rows_.size());
- }
-
private:
/// @brief The Memfile storage containing the IPv4 leases to analyze
Lease4Storage& storage4_;
-
- /// @brief A vector containing the "result set"
- std::vector<AddressStatsRow4> rows_;
-
- /// @brief An iterator for accessing the next row within the result set
- std::vector<AddressStatsRow4>::iterator next_pos_;
};
/// The populated result set will contain one entry per monitored state
/// per subnet.
///
-class MemfileAddressStatsQuery6 : public AddressStatsQuery6 {
+class MemfileLeaseStatsQuery6 : public MemfileLeaseStatsQuery {
public:
/// @brief Constructor
///
/// @param storage6 A pointer to the v6 lease storage to be counted
- MemfileAddressStatsQuery6(Lease6Storage& storage6)
- : storage6_(storage6), rows_(0), next_pos_(rows_.end()) {
+ MemfileLeaseStatsQuery6(Lease6Storage& storage6)
+ : MemfileLeaseStatsQuery(), storage6_(storage6) {
};
/// @brief Destructor
- virtual ~MemfileAddressStatsQuery6() {};
+ virtual ~MemfileLeaseStatsQuery6() {};
/// @brief Creates the IPv6 lease statistical data result set
///
// and wipe the accumulators
if ((*lease)->subnet_id_ > cur_id) {
if (cur_id > 0) {
- rows_.push_back(AddressStatsRow6(cur_id, Lease::TYPE_NA,
- Lease::STATE_DEFAULT,
- assigned));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::TYPE_NA,
+ Lease::STATE_DEFAULT,
+ assigned));
assigned = 0;
- rows_.push_back(AddressStatsRow6(cur_id, Lease::TYPE_NA,
- Lease::STATE_DECLINED,
- declined));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::TYPE_NA,
+ Lease::STATE_DECLINED,
+ declined));
declined = 0;
- rows_.push_back(AddressStatsRow6(cur_id, Lease::TYPE_PD,
- Lease::STATE_DEFAULT,
- assigned_pds));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::TYPE_PD,
+ Lease::STATE_DEFAULT,
+ assigned_pds));
assigned_pds = 0;
}
// Make the rows for last subnet, unless there were no rows
if (idx.begin() != idx.end()) {
- rows_.push_back(AddressStatsRow6(cur_id, Lease::TYPE_NA,
- Lease::STATE_DEFAULT,
- assigned));
- rows_.push_back(AddressStatsRow6(cur_id, Lease::TYPE_NA,
- Lease::STATE_DECLINED,
- declined));
- rows_.push_back(AddressStatsRow6(cur_id, Lease::TYPE_PD,
- Lease::STATE_DEFAULT,
- assigned_pds));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::TYPE_NA,
+ Lease::STATE_DEFAULT,
+ assigned));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::TYPE_NA,
+ Lease::STATE_DECLINED,
+ declined));
+ rows_.push_back(LeaseStatsRow(cur_id, Lease::TYPE_PD,
+ Lease::STATE_DEFAULT,
+ assigned_pds));
}
// Set the next row position to the beginning of the rows.
next_pos_ = rows_.begin();
}
- /// @brief 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.
- /// @param row Storage for the fetched row
- ///
- /// @return True if the fetch succeeded, false if there are no more
- /// rows to fetch.
- virtual bool getNextRow(AddressStatsRow6& row) {
- if (next_pos_ == rows_.end()) {
- return (false);
- }
-
- row = *next_pos_;
- ++next_pos_;
- return (true);
- }
-
- /// @brief Returns the number of rows in the result set
- int getRowCount() {
- return (rows_.size());
- }
-
private:
/// @brief The Memfile storage containing the IPv6 leases to analyze
Lease6Storage& storage6_;
-
- /// @brief A vector containing the "result set"
- std::vector<AddressStatsRow6> rows_;
-
- /// @brief An iterator for accessing the next row within the result set
- std::vector<AddressStatsRow6>::iterator next_pos_;
};
// Explicit definition of class static constants. Values are given in the
}
}
-AddressStatsQuery4Ptr
-Memfile_LeaseMgr::startAddressStatsQuery4() {
- AddressStatsQuery4Ptr query(new MemfileAddressStatsQuery4(storage4_));
+LeaseStatsQueryPtr
+Memfile_LeaseMgr::startLeaseStatsQuery4() {
+ LeaseStatsQueryPtr query(new MemfileLeaseStatsQuery4(storage4_));
query->start();
return(query);
}
-AddressStatsQuery6Ptr
-Memfile_LeaseMgr::startAddressStatsQuery6() {
- AddressStatsQuery6Ptr query(new MemfileAddressStatsQuery6(storage6_));
+LeaseStatsQueryPtr
+Memfile_LeaseMgr::startLeaseStatsQuery6() {
+ LeaseStatsQueryPtr query(new MemfileLeaseStatsQuery6(storage6_));
query->start();
return(query);
}
int getLFCExitStatus() const;
//@}
- /// @brief Creates and runs the IPv4 lease stats query
+ /// @brief Creates and runs the IPv4 lease stats query
///
- /// It creates an instance of a MemfileAddressStatsQuery4 and then
- /// invokes it's start method in which the query constructs its
+ /// It creates an instance of a MemfileLeaseStatsQuery4 and then
+ /// invokes it's start method in which the query constructs its
/// statistical data result set. The query object is then returned.
- ///
- /// @return The populated query as a pointer to an AddressStatsQuery4
- virtual AddressStatsQuery4Ptr startAddressStatsQuery4();
+ ///
+ /// @return The populated query as a pointer to an LeaseStatsQuery
+ virtual LeaseStatsQueryPtr startLeaseStatsQuery4();
- /// @brief Creates and runs the IPv6 lease stats query
+ /// @brief Creates and runs the IPv6 lease stats query
///
- /// It creates an instance of a MemfileAddressStatsQuery6 and then
- /// invokes it's start method in which the query constructs its
+ /// It creates an instance of a MemfileLeaseStatsQuery6 and then
+ /// invokes it's start method in which the query constructs its
/// statistical data result set. The query object is then returned.
- ///
- /// @return The populated query as a pointer to an AddressStatsQuery6
- virtual AddressStatsQuery6Ptr startAddressStatsQuery6();
+ ///
+ /// @return The populated query as a pointer to an LeaseStatsQuery.
+ virtual LeaseStatsQueryPtr startLeaseStatsQuery6();
/// @name Protected methods used for %Lease File Cleanup.
/// The following methods are protected so as they can be accessed and
}
void
-GenericLeaseMgrTest::checkAddressStats(const StatValMapList& expectedStats) {
+GenericLeaseMgrTest::checkLeaseStats(const StatValMapList& expectedStats) {
// Global accumulators
int64_t declined_addresses = 0;
int64_t declined_reclaimed_addresses = 0;
ASSERT_TRUE(lmptr_->addLease(lease));
}
-
void
-GenericLeaseMgrTest::testRecountAddressStats4() {
+GenericLeaseMgrTest::testRecountLeaseStats4() {
using namespace stats;
StatsMgr::instance().removeAll();
}
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
// Recount stats. We should have the same results.
- ASSERT_NO_THROW(lmptr_->recountAddressStats4());
+ ASSERT_NO_THROW(lmptr_->recountLeaseStats4());
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
// Now let's insert some leases into subnet 1.
int subnet_id = 1;
expectedStats[subnet_id - 1]["declined-addresses"] = 1;
// Now Recount the stats.
- ASSERT_NO_THROW(lmptr_->recountAddressStats4());
+ ASSERT_NO_THROW(lmptr_->recountLeaseStats4());
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
// Delete some leases from subnet, and update the expected stats.
EXPECT_TRUE(lmptr_->deleteLease(IOAddress("192.0.1.1")));
expectedStats[0]["declined-addresses"] = 0;
// Recount the stats.
- ASSERT_NO_THROW(lmptr_->recountAddressStats4());
+ ASSERT_NO_THROW(lmptr_->recountLeaseStats4());
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
}
+
void
-GenericLeaseMgrTest::testRecountAddressStats6() {
+GenericLeaseMgrTest::testRecountLeaseStats6() {
using namespace stats;
StatsMgr::instance().removeAll();
}
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
// Recount stats. We should have the same results.
- ASSERT_NO_THROW(lmptr_->recountAddressStats4());
+ ASSERT_NO_THROW(lmptr_->recountLeaseStats4());
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
// Now let's insert some leases into subnet 1.
subnet_id = 1;
expectedStats[subnet_id - 1]["declined-addresses"] = 1;
// Now Recount the stats.
- ASSERT_NO_THROW(lmptr_->recountAddressStats6());
+ ASSERT_NO_THROW(lmptr_->recountLeaseStats6());
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
// Delete some leases and update the expected stats.
EXPECT_TRUE(lmptr_->deleteLease(IOAddress("3001:1::2")));
expectedStats[1]["declined-addresses"] = 0;
// Recount the stats.
- ASSERT_NO_THROW(lmptr_->recountAddressStats6());
+ ASSERT_NO_THROW(lmptr_->recountLeaseStats6());
// Make sure stats are as expected.
- ASSERT_NO_FATAL_FAILURE(checkAddressStats(expectedStats));
+ ASSERT_NO_FATAL_FAILURE(checkLeaseStats(expectedStats));
}
/// do not match.
///
/// @param expected_stats Map of expected static names and values.
- void checkAddressStats(const StatValMapList& expected_stats);
+ void checkLeaseStats(const StatValMapList& expected_stats);
/// @brief Constructs a minimal IPv4 lease and adds it to the lease storage
///
/// This test creates two subnets and several leases associated with
/// them, then verifies that lease statistics are recalculated correctly
/// after altering the lease states in various ways.
- void testRecountAddressStats4();
+ void testRecountLeaseStats4();
/// @brief Check that the IPv6 lease statistics can be recounted
///
/// This test creates two subnets and several leases associated with
/// them, then verifies that lease statistics are recalculated correctly
/// after altering the lease states in various ways.
- void testRecountAddressStats6();
+ void testRecountLeaseStats6();
/// @brief String forms of IPv4 addresses
std::vector<std::string> straddress4_;
}
// Verifies that IPv4 lease statistics can be recalculated.
-TEST_F(MemfileLeaseMgrTest, recountAddressStats4) {
+TEST_F(MemfileLeaseMgrTest, recountLeaseStats4) {
startBackend(V4);
- testRecountAddressStats4();
+ testRecountLeaseStats4();
}
// Verifies that IPv6 lease statistics can be recalculated.
-TEST_F(MemfileLeaseMgrTest, recountAddressStats6) {
+TEST_F(MemfileLeaseMgrTest, recountLeaseStats6) {
startBackend(V6);
- testRecountAddressStats6();
+ testRecountLeaseStats6();
}
}; // end of anonymous namespace