diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-07 09:28:30 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-07 09:28:30 +0000 |
commit | a6a0567da7b98332a4b5d8aaff724e7ec108a5d7 (patch) | |
tree | 6846aa7d35479eb6d5636222d07bad3374c2045d /storage | |
parent | 0a44cf455dd74557f1dd769954f5e66e52089330 (diff) |
Use std::chrono for time tracking
Diffstat (limited to 'storage')
6 files changed, 11 insertions, 19 deletions
diff --git a/storage/src/vespa/storage/distributor/distributor_stripe.cpp b/storage/src/vespa/storage/distributor/distributor_stripe.cpp index cb1c935082e..2f150cf7250 100644 --- a/storage/src/vespa/storage/distributor/distributor_stripe.cpp +++ b/storage/src/vespa/storage/distributor/distributor_stripe.cpp @@ -2,7 +2,6 @@ #include "blockingoperationstarter.h" #include "distributor_bucket_space.h" -#include "distributor_status.h" #include "distributor_stripe.h" #include "distributormetricsset.h" #include "idealstatemetricsset.h" @@ -853,7 +852,7 @@ DistributorStripe::enable_cluster_state_bundle(const lib::ClusterStateBundle& ne // Note: this assumes that std::chrono::system_clock and the framework // system clock have the same epoch, which should be a reasonable // assumption. - const auto now = TimePoint(std::chrono::milliseconds(_component.getClock().getTimeInMillis().getTime())); + TimePoint now = _component.getClock().getSystemTime(); _externalOperationHandler.rejectFeedBeforeTimeReached(_ownershipSafeTimeCalc->safeTimePoint(now)); } _bucketDBUpdater.handle_activated_cluster_state_bundle(); // Triggers resending of queued requests diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp index c03b211d1aa..c86254cb69a 100644 --- a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp +++ b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp @@ -10,7 +10,6 @@ #include <vespa/vdslib/distribution/distribution.h> #include <vespa/vespalib/util/xmlstream.hpp> #include <vespa/vespalib/stllike/hash_map.hpp> -#include <climits> #include <vespa/log/bufferedlogger.h> LOG_SETUP(".pendingclusterstate"); @@ -250,9 +249,7 @@ PendingClusterState::onRequestBucketInfoReply(const std::shared_ptr<api::Request api::ReturnCode result(reply->getResult()); if (!result.success()) { - framework::MilliSecTime resendTime(_clock); - resendTime += framework::MilliSecTime(100); - _delayedRequests.emplace_back(resendTime, bucketSpaceAndNode); + _delayedRequests.emplace_back(_clock.getMonotonicTime() + 100ms, bucketSpaceAndNode); _sentMessages.erase(iter); update_reply_failure_statistics(result, bucketSpaceAndNode); return true; @@ -273,9 +270,9 @@ PendingClusterState::onRequestBucketInfoReply(const std::shared_ptr<api::Request void PendingClusterState::resendDelayedMessages() { if (_delayedRequests.empty()) return; // Don't fetch time if not needed - framework::MilliSecTime currentTime(_clock); + vespalib::steady_time currentTime = _clock.getMonotonicTime(); while (!_delayedRequests.empty() - && currentTime >= _delayedRequests.front().first) + && (currentTime >= _delayedRequests.front().first)) { requestNode(_delayedRequests.front().second); _delayedRequests.pop_front(); diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.h b/storage/src/vespa/storage/distributor/pendingclusterstate.h index 24b31e45cbb..8af08e1ba4d 100644 --- a/storage/src/vespa/storage/distributor/pendingclusterstate.h +++ b/storage/src/vespa/storage/distributor/pendingclusterstate.h @@ -193,8 +193,7 @@ private: struct BucketSpaceAndNode { document::BucketSpace bucketSpace; uint16_t node; - BucketSpaceAndNode(document::BucketSpace bucketSpace_, - uint16_t node_) + BucketSpaceAndNode(document::BucketSpace bucketSpace_, uint16_t node_) : bucketSpace(bucketSpace_), node(node_) { @@ -218,7 +217,7 @@ private: void update_node_supported_features_from_reply(uint16_t node, const api::RequestBucketInfoReply& reply); using SentMessages = std::map<uint64_t, BucketSpaceAndNode>; - using DelayedRequests = std::deque<std::pair<framework::MilliSecTime, BucketSpaceAndNode>>; + using DelayedRequests = std::deque<std::pair<vespalib::steady_time , BucketSpaceAndNode>>; using PendingTransitions = std::unordered_map<document::BucketSpace, std::unique_ptr<PendingBucketSpaceDbTransition>, document::BucketSpace::hash>; using NodeFeatures = vespalib::hash_map<uint16_t, NodeSupportedFeatures>; diff --git a/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.cpp b/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.cpp index 5a584f7c332..f69f9e3d427 100644 --- a/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.cpp +++ b/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.cpp @@ -440,9 +440,7 @@ StripeBucketDBUpdater::handleSingleBucketInfoFailure( req.targetNode, repl->getResult().toString().c_str()); if (req.bucket.getBucketId() != document::BucketId(0)) { - framework::MilliSecTime sendTime(_node_ctx.clock()); - sendTime += framework::MilliSecTime(100); - _delayedRequests.emplace_back(sendTime, req); + _delayedRequests.emplace_back(_node_ctx.clock().getMonotonicTime() + 100ms, req); } } @@ -452,7 +450,7 @@ StripeBucketDBUpdater::resendDelayedMessages() if (_delayedRequests.empty()) { return; // Don't fetch time if not needed } - framework::MilliSecTime currentTime(_node_ctx.clock()); + vespalib::steady_time currentTime(_node_ctx.clock().getMonotonicTime()); while (!_delayedRequests.empty() && currentTime >= _delayedRequests.front().first) { @@ -644,7 +642,7 @@ void StripeBucketDBUpdater::report_delayed_single_bucket_requests(vespalib::xml::XmlOutputStream& xos) const { for (const auto& entry : _delayedRequests) { - entry.second.print_xml_tag(xos, XmlAttribute("resendtimestamp", entry.first.getTime())); + entry.second.print_xml_tag(xos, XmlAttribute("resendtimestamp", vespalib::count_ms(vespalib::to_utc(entry.first).time_since_epoch()))); } } diff --git a/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h b/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h index 2f6e665be14..6339283f963 100644 --- a/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h +++ b/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h @@ -231,7 +231,7 @@ private: using DbGuards = std::unordered_map<document::BucketSpace, std::shared_ptr<BucketDatabase::ReadGuard>, document::BucketSpace::hash>; - using DelayedRequestsQueue = std::deque<std::pair<framework::MilliSecTime, BucketRequest>>; + using DelayedRequestsQueue = std::deque<std::pair<vespalib::steady_time, BucketRequest>>; const DistributorNodeContext& _node_ctx; DistributorStripeOperationContext& _op_ctx; diff --git a/storage/src/vespa/storage/distributor/top_level_distributor.cpp b/storage/src/vespa/storage/distributor/top_level_distributor.cpp index 54dedbebbfe..b0702ac7bf0 100644 --- a/storage/src/vespa/storage/distributor/top_level_distributor.cpp +++ b/storage/src/vespa/storage/distributor/top_level_distributor.cpp @@ -531,8 +531,7 @@ TopLevelDistributor::on_cluster_state_bundle_activated(const lib::ClusterStateBu } if (has_bucket_ownership_transfer && _maintenance_safe_time_delay.count() > 0) { OwnershipTransferSafeTimePointCalculator safe_time_calc(_maintenance_safe_time_delay); - using TimePoint = OwnershipTransferSafeTimePointCalculator::TimePoint; - const auto now = TimePoint(std::chrono::milliseconds(_component.getClock().getTimeInMillis().getTime())); + const auto now = _component.getClock().getSystemTime(); _maintenance_safe_time_point = safe_time_calc.safeTimePoint(now); // All stripes are in a waiting pattern and will observe this on their next tick. // Memory visibility enforced by all stripes being held under a mutex by our caller. |