aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--metrics/src/tests/metricmanagertest.cpp8
-rw-r--r--metrics/src/tests/snapshottest.cpp4
-rw-r--r--metrics/src/vespa/metrics/metricmanager.cpp8
-rw-r--r--metrics/src/vespa/metrics/metricmanager.h4
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.cpp4
-rw-r--r--metrics/src/vespa/metrics/metricsnapshot.h10
-rw-r--r--metrics/src/vespa/metrics/updatehook.h8
-rw-r--r--storage/src/vespa/storage/storageserver/statereporter.cpp2
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp4
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h2
-rw-r--r--storage/src/vespa/storageframework/generic/component/component.cpp2
-rw-r--r--storage/src/vespa/storageframework/generic/component/component.h4
-rw-r--r--storage/src/vespa/storageframework/generic/metric/metricregistrator.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/time.h5
14 files changed, 34 insertions, 33 deletions
diff --git a/metrics/src/tests/metricmanagertest.cpp b/metrics/src/tests/metricmanagertest.cpp
index 52b17576c5c..9e6b0f40be3 100644
--- a/metrics/src/tests/metricmanagertest.cpp
+++ b/metrics/src/tests/metricmanagertest.cpp
@@ -29,7 +29,7 @@ struct MetricManagerTest : public ::testing::Test {
// MetricManager that aren't accessible to "freestanding" fixtures. So we
// get the test to do the necessary poking and prodding for us instead.
void takeSnapshots(MetricManager& mm, time_t timeToProcess) {
- mm.takeSnapshots(mm.getMetricLock(), system_time(vespalib::from_s(timeToProcess)));
+ mm.takeSnapshots(mm.getMetricLock(), system_time(vespalib::from_s<system_time::duration>(timeToProcess)));
}
};
@@ -364,7 +364,7 @@ class FakeTimer : public MetricManager::Timer {
std::atomic<time_t> _time;
public:
FakeTimer(time_t startTime = 0) : _time(startTime) {}
- time_point getTime() const override { return time_point(vespalib::from_s(load_relaxed(_time))); }
+ time_point getTime() const override { return time_point(vespalib::from_s<time_point::duration>(load_relaxed(_time))); }
void set_time(time_t t) noexcept { store_relaxed(_time, t); }
// Not safe for multiple writers, only expected to be called by test.
void add_time(time_t t) noexcept { set_time(load_relaxed(_time) + t); }
@@ -384,7 +384,7 @@ struct BriefValuePrinter : public MetricVisitor {
}
};
-bool waitForTimeProcessed(const MetricManager& mm, vespalib::duration processtime, uint32_t timeout = 120)
+bool waitForTimeProcessed(const MetricManager& mm, time_point::duration processtime, uint32_t timeout = 120)
{
uint32_t lastchance = time(0) + timeout;
while (time(0) < lastchance) {
@@ -945,7 +945,7 @@ namespace {
std::mutex& _output_mutex;
FakeTimer& _timer;
- MyUpdateHook(std::ostringstream& output, std::mutex& output_mutex, const char* name, vespalib::duration period, FakeTimer& timer)
+ MyUpdateHook(std::ostringstream& output, std::mutex& output_mutex, const char* name, vespalib::system_clock::duration period, FakeTimer& timer)
: UpdateHook(name, period),
_output(output),
_output_mutex(output_mutex),
diff --git a/metrics/src/tests/snapshottest.cpp b/metrics/src/tests/snapshottest.cpp
index 5561825e2ba..580769bbadb 100644
--- a/metrics/src/tests/snapshottest.cpp
+++ b/metrics/src/tests/snapshottest.cpp
@@ -148,7 +148,7 @@ TestMetricSet::incValues() {
struct FakeTimer : public MetricManager::Timer {
uint32_t _timeInSecs;
FakeTimer() : _timeInSecs(1) {}
- time_point getTime() const override { return time_point(vespalib::from_s(_timeInSecs)); }
+ time_point getTime() const override { return time_point(vespalib::from_s<time_point::duration>(_timeInSecs)); }
};
void ASSERT_VALUE(int32_t value, const MetricSnapshot & snapshot, const char *name) __attribute__((noinline));
@@ -166,7 +166,7 @@ void ASSERT_VALUE(int32_t value, const MetricSnapshot & snapshot, const char *na
struct SnapshotTest : public ::testing::Test {
void tick(MetricManager& mgr, time_t currentTime) {
- mgr.tick(mgr.getMetricLock(), time_point(vespalib::from_s(currentTime)));
+ mgr.tick(mgr.getMetricLock(), time_point(vespalib::from_s<time_point::duration>(currentTime)));
}
};
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp
index 606b97bda73..2f6fe4c6ba6 100644
--- a/metrics/src/vespa/metrics/metricmanager.cpp
+++ b/metrics/src/vespa/metrics/metricmanager.cpp
@@ -427,7 +427,7 @@ MetricManager::createSnapshotPeriods(const Config& config)
} else {
name << length << " seconds";
}
- result.emplace_back(vespalib::from_s(length), name.str());
+ result.emplace_back(vespalib::from_s<time_point::duration>(length), name.str());
}
for (uint32_t i=1; i<result.size(); ++i) {
if (result[i].first % result[i-1].first != vespalib::duration::zero()) {
@@ -473,7 +473,7 @@ MetricManager::configure(const MetricLockGuard & , std::unique_ptr<Config> confi
uint32_t nextCount = 1;
if (i + 1 < snapshotPeriods.size()) {
nextCount = snapshotPeriods[i + 1].first / snapshotPeriods[i].first;
- if ((snapshotPeriods[i + 1].first % snapshotPeriods[i].first) != vespalib::duration::zero()) {
+ if ((snapshotPeriods[i + 1].first % snapshotPeriods[i].first) != time_point::duration::zero()) {
throw IllegalStateException("Snapshot periods must be multiplum of each other",VESPA_STRLOC);
}
}
@@ -570,11 +570,11 @@ MetricManager::visit(const MetricLockGuard & guard, const MetricSnapshot& snapsh
visitor.doneVisiting();
}
-std::vector<vespalib::duration>
+std::vector<time_point::duration>
MetricManager::getSnapshotPeriods(const MetricLockGuard& l) const
{
assertMetricLockLocked(l);
- std::vector<vespalib::duration> result;
+ std::vector<time_point::duration> result;
result.reserve(_snapshots.size());
for (const auto & snapshot : _snapshots) {
result.emplace_back(snapshot->getPeriod());
diff --git a/metrics/src/vespa/metrics/metricmanager.h b/metrics/src/vespa/metrics/metricmanager.h
index 99fad4f2ad3..6f40e7961f4 100644
--- a/metrics/src/vespa/metrics/metricmanager.h
+++ b/metrics/src/vespa/metrics/metricmanager.h
@@ -243,7 +243,7 @@ public:
const MetricSnapshot& getMetricSnapshot( const MetricLockGuard&, vespalib::duration period, bool getInProgressSet) const;
const MetricSnapshotSet& getMetricSnapshotSet(const MetricLockGuard&, vespalib::duration period) const;
- std::vector<vespalib::duration> getSnapshotPeriods(const MetricLockGuard& l) const;
+ std::vector<time_point::duration> getSnapshotPeriods(const MetricLockGuard& l) const;
// Public only for testing. The returned pointer is only valid while holding the lock.
const ConsumerSpec * getConsumerSpec(const MetricLockGuard & guard, const Metric::String& consumer) const;
@@ -290,7 +290,7 @@ private:
void handleMetricsAltered(const MetricLockGuard & guard);
- using SnapSpec = std::pair<vespalib::duration, std::string>;
+ using SnapSpec = std::pair<time_point::duration, std::string>;
static std::vector<SnapSpec> createSnapshotPeriods( const MetricsmanagerConfig& config);
void assertMetricLockLocked(const MetricLockGuard& g) const;
};
diff --git a/metrics/src/vespa/metrics/metricsnapshot.cpp b/metrics/src/vespa/metrics/metricsnapshot.cpp
index cd06fb731c2..6bcdcc60995 100644
--- a/metrics/src/vespa/metrics/metricsnapshot.cpp
+++ b/metrics/src/vespa/metrics/metricsnapshot.cpp
@@ -24,7 +24,7 @@ MetricSnapshot::MetricSnapshot(const Metric::String& name)
{
}
-MetricSnapshot::MetricSnapshot(const Metric::String& name, vespalib::duration period, const MetricSet& source, bool copyUnset)
+MetricSnapshot::MetricSnapshot(const Metric::String& name, system_time::duration period, const MetricSet& source, bool copyUnset)
: _name(name),
_period(period),
_fromTime(system_time_epoch),
@@ -73,7 +73,7 @@ MetricSnapshot::addMemoryUsage(MemoryConsumption& mc) const
_snapshot->addMemoryUsage(mc);
}
-MetricSnapshotSet::MetricSnapshotSet(const Metric::String& name, vespalib::duration period, uint32_t count,
+MetricSnapshotSet::MetricSnapshotSet(const Metric::String& name, system_time::duration period, uint32_t count,
const MetricSet& source, bool snapshotUnsetMetrics)
: _count(count),
_builderCount(0),
diff --git a/metrics/src/vespa/metrics/metricsnapshot.h b/metrics/src/vespa/metrics/metricsnapshot.h
index 945f9dc7326..859ee4a4a97 100644
--- a/metrics/src/vespa/metrics/metricsnapshot.h
+++ b/metrics/src/vespa/metrics/metricsnapshot.h
@@ -23,7 +23,7 @@ class MetricSnapshot
{
Metric::String _name;
// Period length of this snapshot
- vespalib::duration _period;
+ system_time::duration _period;
// Time this snapshot was last updated.
system_time _fromTime;
// If set to 0, use _fromTime + _period.
@@ -37,7 +37,7 @@ public:
/** Create a fresh empty top level snapshot. */
MetricSnapshot(const Metric::String& name);
/** Create a snapshot of another metric source. */
- MetricSnapshot(const Metric::String& name, vespalib::duration period,
+ MetricSnapshot(const Metric::String& name, system_time::duration period,
const MetricSet& source, bool copyUnset);
~MetricSnapshot();
@@ -54,7 +54,7 @@ public:
void setToTime(system_time toTime) { _toTime = toTime; }
const Metric::String& getName() const { return _name; }
- vespalib::duration getPeriod() const { return _period; }
+ system_time::duration getPeriod() const { return _period; }
system_time getFromTime() const { return _fromTime; }
system_time getToTime() const { return _toTime; }
const MetricSet& getMetrics() const { return *_snapshot; }
@@ -78,11 +78,11 @@ class MetricSnapshotSet {
std::unique_ptr<MetricSnapshot> _current; // The last full period
std::unique_ptr<MetricSnapshot> _building; // The building period
public:
- MetricSnapshotSet(const Metric::String& name, vespalib::duration period, uint32_t count,
+ MetricSnapshotSet(const Metric::String& name, system_time::duration period, uint32_t count,
const MetricSet& source, bool snapshotUnsetMetrics);
const Metric::String& getName() const { return _current->getName(); }
- vespalib::duration getPeriod() const { return _current->getPeriod(); }
+ system_time::duration getPeriod() const { return _current->getPeriod(); }
system_time getFromTime() const { return _current->getFromTime(); }
system_time getToTime() const { return _current->getToTime(); }
system_time getNextWorkTime() const { return getToTime() + getPeriod(); }
diff --git a/metrics/src/vespa/metrics/updatehook.h b/metrics/src/vespa/metrics/updatehook.h
index 997bdf0b5a4..aced45b91c9 100644
--- a/metrics/src/vespa/metrics/updatehook.h
+++ b/metrics/src/vespa/metrics/updatehook.h
@@ -28,7 +28,7 @@ class MetricManager;
class UpdateHook {
public:
using MetricLockGuard = metrics::MetricLockGuard;
- UpdateHook(const char* name, vespalib::duration period)
+ UpdateHook(const char* name, time_point::duration period)
: _name(name),
_period(period),
_nextCall()
@@ -38,15 +38,15 @@ public:
const char* getName() const { return _name; }
void updateNextCall() { updateNextCall(_nextCall); }
void updateNextCall(time_point now) { setNextCall(now + _period); }
- bool is_periodic() const noexcept { return _period != vespalib::duration::zero(); }
+ bool is_periodic() const noexcept { return _period != time_point::duration::zero(); }
bool expired(time_point now) { return _nextCall <= now; }
bool has_valid_expiry() const noexcept { return _nextCall != time_point(); }
- vespalib::duration getPeriod() const noexcept { return _period; }
+ time_point::duration getPeriod() const noexcept { return _period; }
time_point getNextCall() const noexcept { return _nextCall; }
void setNextCall(time_point now) { _nextCall = now; }
private:
const char* _name;
- const vespalib::duration _period;
+ const time_point::duration _period;
time_point _nextCall;
};
diff --git a/storage/src/vespa/storage/storageserver/statereporter.cpp b/storage/src/vespa/storage/storageserver/statereporter.cpp
index d9e79d3b7b4..16de56fad22 100644
--- a/storage/src/vespa/storage/storageserver/statereporter.cpp
+++ b/storage/src/vespa/storage/storageserver/statereporter.cpp
@@ -73,7 +73,7 @@ StateReporter::getMetrics(const vespalib::string &consumer)
if (periods.empty()) {
return ""; // no configuration yet
}
- vespalib::duration interval = periods[0];
+ auto interval = periods[0];
// To get unset metrics, we have to copy active metrics, clear them
// and then assign the snapshot
diff --git a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
index 74d58244636..84b12d34e01 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
+++ b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
@@ -126,7 +126,7 @@ namespace {
struct MetricHookWrapper : public metrics::UpdateHook {
MetricUpdateHook& _hook;
- MetricHookWrapper(vespalib::stringref name, MetricUpdateHook& hook, vespalib::duration period)
+ MetricHookWrapper(vespalib::stringref name, MetricUpdateHook& hook, vespalib::system_time::duration period)
: metrics::UpdateHook(name.data(), period), // Expected to point to static name
_hook(hook)
{
@@ -139,7 +139,7 @@ namespace {
void
ComponentRegisterImpl::registerUpdateHook(vespalib::stringref name,
MetricUpdateHook& hook,
- vespalib::duration period)
+ vespalib::system_time::duration period)
{
std::lock_guard lock(_componentLock);
auto hookPtr = std::make_unique<MetricHookWrapper>(name, hook, period);
diff --git a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
index e569288ac64..43005575032 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
+++ b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.h
@@ -73,7 +73,7 @@ public:
std::vector<const StatusReporter*> getStatusReporters() override;
void registerMetric(metrics::Metric&) override;
- void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, vespalib::duration period) override;
+ void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, vespalib::system_time::duration period) override;
void registerShutdownListener(ShutdownListener&);
};
diff --git a/storage/src/vespa/storageframework/generic/component/component.cpp b/storage/src/vespa/storageframework/generic/component/component.cpp
index 0f08503852c..c69e59b8eba 100644
--- a/storage/src/vespa/storageframework/generic/component/component.cpp
+++ b/storage/src/vespa/storageframework/generic/component/component.cpp
@@ -52,7 +52,7 @@ Component::registerMetric(metrics::Metric& m)
}
void
-Component::registerMetricUpdateHook(MetricUpdateHook& hook, vespalib::duration period)
+Component::registerMetricUpdateHook(MetricUpdateHook& hook, vespalib::system_time::duration period)
{
assert(_metricUpdateHook.first == 0);
_metricUpdateHook = std::make_pair(&hook, period);
diff --git a/storage/src/vespa/storageframework/generic/component/component.h b/storage/src/vespa/storageframework/generic/component/component.h
index 47469cce05d..372559e133d 100644
--- a/storage/src/vespa/storageframework/generic/component/component.h
+++ b/storage/src/vespa/storageframework/generic/component/component.h
@@ -86,7 +86,7 @@ class Component : private ManagedComponent
metrics::Metric* _metric;
ThreadPool* _threadPool;
MetricRegistrator* _metricReg;
- std::pair<MetricUpdateHook*, vespalib::duration> _metricUpdateHook;
+ std::pair<MetricUpdateHook*, vespalib::system_time::duration> _metricUpdateHook;
const Clock* _clock;
// ManagedComponent implementation
@@ -124,7 +124,7 @@ public:
* update hook will only be called if there actually is a metric mananger
* component registered in the application.
*/
- void registerMetricUpdateHook(MetricUpdateHook&, vespalib::duration period);
+ void registerMetricUpdateHook(MetricUpdateHook&, vespalib::system_time::duration period);
/** Get the name of the component. Must be a unique name. */
[[nodiscard]] const vespalib::string& getName() const override { return _name; }
diff --git a/storage/src/vespa/storageframework/generic/metric/metricregistrator.h b/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
index 6daca1213a8..bea43fcfb6b 100644
--- a/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
+++ b/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
@@ -24,7 +24,7 @@ struct MetricRegistrator {
virtual ~MetricRegistrator() = default;
virtual void registerMetric(metrics::Metric&) = 0;
- virtual void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, vespalib::duration period) = 0;
+ virtual void registerUpdateHook(vespalib::stringref name, MetricUpdateHook& hook, vespalib::system_time::duration period) = 0;
};
}
diff --git a/vespalib/src/vespa/vespalib/util/time.h b/vespalib/src/vespa/vespalib/util/time.h
index 27f359071ae..2cb53df8ae2 100644
--- a/vespalib/src/vespa/vespalib/util/time.h
+++ b/vespalib/src/vespa/vespalib/util/time.h
@@ -43,8 +43,9 @@ constexpr double to_s(duration d) {
system_time to_utc(steady_time ts);
-constexpr duration from_s(double seconds) {
- return std::chrono::duration_cast<duration>(std::chrono::duration<double>(seconds));
+template <typename duration_type = duration>
+constexpr duration_type from_s(double seconds) {
+ return std::chrono::duration_cast<duration_type>(std::chrono::duration<double>(seconds));
}
constexpr int64_t count_s(duration d) {