diff options
-rw-r--r-- | fastos/src/vespa/fastos/timestamp.cpp | 2 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricmanager.cpp | 8 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricmanager.h | 1 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/state_api_adapter.cpp | 4 | ||||
-rw-r--r-- | storage/src/vespa/storage/config/distributorconfiguration.cpp | 3 |
5 files changed, 7 insertions, 11 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp index b671aa15b71..bc865448e5a 100644 --- a/fastos/src/vespa/fastos/timestamp.cpp +++ b/fastos/src/vespa/fastos/timestamp.cpp @@ -43,7 +43,7 @@ int64_t ClockSystem::now() } time_t time() { - return duration_cast<seconds>(system_clock::now().time_since_epoch()).count(); + return system_clock::to_time_t(system_clock::now()); } } diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp index db2e5affa03..40622b8c786 100644 --- a/metrics/src/vespa/metrics/metricmanager.cpp +++ b/metrics/src/vespa/metrics/metricmanager.cpp @@ -10,6 +10,7 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/stllike/hashtable.hpp> +#include <vespa/fastos/timestamp.h> #include <sstream> #include <algorithm> @@ -24,13 +25,8 @@ MetricManager::ConsumerSpec::ConsumerSpec() = default; MetricManager::ConsumerSpec::~ConsumerSpec() = default; time_t -MetricManager::Timer::secondsSinceEpoch() { - return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count(); -} - -time_t MetricManager::Timer::getTime() const { - return secondsSinceEpoch(); + return fastos::time(); } void diff --git a/metrics/src/vespa/metrics/metricmanager.h b/metrics/src/vespa/metrics/metricmanager.h index 2edf39d67f1..f2b2926873f 100644 --- a/metrics/src/vespa/metrics/metricmanager.h +++ b/metrics/src/vespa/metrics/metricmanager.h @@ -70,7 +70,6 @@ public: struct Timer { virtual ~Timer() {} - static time_t secondsSinceEpoch(); virtual time_t getTime() const; virtual time_t getTimeInMilliSecs() const { return getTime() * 1000; } }; diff --git a/metrics/src/vespa/metrics/state_api_adapter.cpp b/metrics/src/vespa/metrics/state_api_adapter.cpp index 20421ebdbb2..f2e5108872e 100644 --- a/metrics/src/vespa/metrics/state_api_adapter.cpp +++ b/metrics/src/vespa/metrics/state_api_adapter.cpp @@ -3,7 +3,7 @@ #include "state_api_adapter.h" #include "metricmanager.h" #include <vespa/vespalib/stllike/asciistream.h> - +#include <vespa/fastos/timestamp.h> namespace metrics { @@ -30,7 +30,7 @@ StateApiAdapter::getTotalMetrics(const vespalib::string &consumer) _manager.updateMetrics(true); metrics::MetricLockGuard guard(_manager.getMetricLock()); _manager.checkMetricsAltered(guard); - time_t currentTime = MetricManager::Timer::secondsSinceEpoch(); + time_t currentTime = fastos::time(); auto generated = std::make_unique<metrics::MetricSnapshot>( "Total metrics from start until current time", 0, _manager.getTotalMetricSnapshot(guard).getMetrics(), diff --git a/storage/src/vespa/storage/config/distributorconfiguration.cpp b/storage/src/vespa/storage/config/distributorconfiguration.cpp index e6d9ce05d3e..d2dd74693c8 100644 --- a/storage/src/vespa/storage/config/distributorconfiguration.cpp +++ b/storage/src/vespa/storage/config/distributorconfiguration.cpp @@ -3,6 +3,7 @@ #include <vespa/document/select/parser.h> #include <vespa/document/select/traversingvisitor.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/fastos/timestamp.h> #include <sstream> #include <vespa/log/log.h> @@ -124,7 +125,7 @@ DistributorConfiguration::configure(const vespa::config::content::core::StorDist // Always changes. _lastGarbageCollectionChange = 1; } else if (_garbageCollectionSelection != config.garbagecollection.selectiontoremove) { - _lastGarbageCollectionChange = duration_cast<seconds>(system_clock::now().time_since_epoch()).count(); + _lastGarbageCollectionChange = fastos::time(); } _garbageCollectionSelection = config.garbagecollection.selectiontoremove; |