of free address leases for the given subnet. It can take a considerable amount
of time, depending on the size of the address pools.
-% DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_ADDRESS_LEASES_DONE populating free address leases for the FLQ allocator in subnet %1 completed
+% DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_ADDRESS_LEASES_DONE populating free address leases for the FLQ allocator in subnet %1 completed in %2
This informational message is issued when the server ends building a queue
-of free address leases for a given subnet.
+of free address leases for a given subnet. The second argument logs the
+duration.
% DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES populating free prefix leases for the FLQ allocator in subnet %1; it can take a while!
This informational message is issued when the server begins building a queue
of free leases for the given subnet. It can take a considerable amount of
time, depending on the size of the delegated prefix pools.
-% DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES_DONE populating free prefix leases for the FLQ allocator in subnet %1 completed
+% DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES_DONE populating free prefix leases for the FLQ allocator in subnet %1 completed in %2
This informational message is issued when the server ends building a queue
-of free prefix leases for a given subnet.
+of free prefix leases for a given subnet. The second argument logs the
+duration.
% DHCPSRV_CFGMGR_IPV4_RESERVATIONS_NON_UNIQUE_IGNORED ignoring "ip-reservations-unique" setting because at least one of the host database backends does not support non-unique IP reservations in a subnet
This warning message is issued when the server failed to use the new setting
#include <dhcpsrv/ip_range_permutation.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/subnet.h>
+#include <util/stopwatch.h>
#include <unordered_set>
using namespace isc::asiolink;
LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_ADDRESS_LEASES)
.arg(subnet->toText());
+ Stopwatch stopwatch;
+
// Let's iterate over the lease queue and index them with the
// unordered_set. Also, elminate the expired leases and those
// in the expired-reclaimed state.
}
}
}
+
+ stopwatch.stop();
+
LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_ADDRESS_LEASES_DONE)
- .arg(subnet->toText());
+ .arg(subnet->toText())
+ .arg(stopwatch.logFormatLastDuration());
}
void
LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES)
.arg(subnet->toText());
+ Stopwatch stopwatch;
+
// Let's iterate over the lease queue and index them with the
// unordered_set. Also, elminate the expired leases and those
// in the expired-reclaimed state.
}
}
}
+
+ stopwatch.stop();
+
LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_FLQ_POPULATE_FREE_PREFIX_LEASES_DONE)
- .arg(subnet->toText());
+ .arg(subnet->toText())
+ .arg(stopwatch.logFormatLastDuration());
}
SubnetFreeLeaseQueueAllocationStatePtr
#include <boost/shared_ptr.hpp>
-#include <map>
+#include <unordered_map>
#include <random>
namespace isc {
/// Keeps the current permutation state. The state associates the
/// swapped IP addresses or delegated prefixes with their positions in
/// the permutation.
- std::map<uint64_t, asiolink::IOAddress> state_;
+ std::unordered_map<uint64_t, asiolink::IOAddress> state_;
/// Indicates if the addresses or delegated prefixes are exhausted.
bool done_;
std::string
StopwatchImpl::logFormat(const boost::posix_time::time_duration& duration) {
std::ostringstream s;
- s << duration.total_milliseconds() << ".";
- s << std::setfill('0') << std::setw(3) << (duration.total_microseconds() % 1000)
- << " ms";
+ if (duration.total_seconds() > 0) {
+ s << duration.total_seconds() << "."
+ << std::setfill('0') << std::setw(2) << (duration.total_milliseconds()/10 % 100)
+ << " s";
+ } else {
+ s << duration.total_milliseconds() << ".";
+ s << std::setfill('0') << std::setw(3) << (duration.total_microseconds() % 1000)
+ << " ms";
+ }
return (s.str());
}
/// @brief Returns the duration in the textual format which can be
/// directly used in log messages.
///
- /// @todo Currently this function returns the duration as fractional
- /// milliseconds. We may come up with something more sophisticated
- /// in the future.
- ///
/// @param duration Duration to be converted to the textual format.
///
/// @return Converted value which can be used to log duration.
duration = microseconds(2000);
EXPECT_EQ("2.000 ms", StopwatchImpl::logFormat(duration));
+
+ duration = milliseconds(2100);
+ EXPECT_EQ("2.10 s", StopwatchImpl::logFormat(duration));
+
+ duration = milliseconds(3123);
+ EXPECT_EQ("3.12 s", StopwatchImpl::logFormat(duration));
}
} // end of anonymous namespace