return (t == time_point::min());
}
+ static time_point zero() {
+ return time_point::min();
+ }
+
// Allow conversion to/from any clock with the same interface as
// std::chrono::system_clock)
template<typename Clock, typename Duration>
return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
}
+ static bool is_zero(const time_point& t) {
+ return (t == time_point::min());
+ }
+
+ static time_point zero() {
+ return time_point::min();
+ }
+
// A monotonic clock's timepoints are only meaningful to the
// computer on which they were generated. Thus having an
// optional skew is meaningless.
dirfrag_load_vec_t pop_auth_subtree;
dirfrag_load_vec_t pop_auth_subtree_nested;
- utime_t last_popularity_sample;
+ mono_time last_popularity_sample;
load_spread_t pop_spread;
#include <map>
using std::map;
using std::vector;
+using std::chrono::duration_cast;
#include "common/config.h"
#include "common/errno.h"
void MDBalancer::tick()
{
static int num_bal_times = g_conf->mds_bal_max;
- static utime_t first = ceph_clock_now();
- utime_t now = ceph_clock_now();
- utime_t elapsed = now;
- elapsed -= first;
+ static mono_time first = mono_clock::now();
+ mono_time now = mono_clock::now();
+ ceph::timespan elapsed = now - first;
if (g_conf->mds_bal_export_pin) {
handle_export_pins();
}
// sample?
- if ((double)now - (double)last_sample > g_conf->mds_bal_sample_interval) {
+ if (chrono::duration<double> (now - last_sample).count() >
+ g_conf->mds_bal_sample_interval) {
dout(15) << "tick last_sample now " << now << dendl;
last_sample = now;
}
+ // We can use duration_cast below, although the result is an int,
+ // because the values from g_conf are also integers.
// balance?
- if (last_heartbeat == utime_t())
+ if (mono_clock::is_zero(last_heartbeat))
last_heartbeat = now;
if (mds->get_nodeid() == 0 &&
g_conf->mds_bal_interval > 0 &&
(num_bal_times ||
(g_conf->mds_bal_max_until >= 0 &&
- elapsed.sec() > g_conf->mds_bal_max_until)) &&
+ duration_cast<chrono::seconds>(elapsed).count() >
+ g_conf->mds_bal_max_until)) &&
mds->is_active() &&
- now.sec() - last_heartbeat.sec() >= g_conf->mds_bal_interval) {
+ duration_cast<chrono::seconds>(now - last_heartbeat).count() >=
+ g_conf->mds_bal_interval) {
last_heartbeat = now;
send_heartbeat();
num_bal_times--;
string bal_code;
string bal_version;
- utime_t last_heartbeat;
- utime_t last_sample;
+ mono_time last_heartbeat = mono_clock::zero();
+ mono_time last_sample = mono_clock::zero();
utime_t rebalance_time; //ensure a consistent view of load for rebalance
// Dirfrags which are marked to be passed on to MDCache::[split|merge]_dir