summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-05 19:25:21 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-02-05 19:27:05 +0000
commitd1374ccd3ea7df17db98373bb53ef2a4e6dcd14a (patch)
tree2587e552a7934d6cd384a4e4486615999a165ff6 /storage
parent2f017158e13648f8e1068cabc8d5492af8f77437 (diff)
Use steady_time
Diffstat (limited to 'storage')
-rw-r--r--storage/src/vespa/storage/distributor/pendingclusterstate.cpp9
-rw-r--r--storage/src/vespa/storage/distributor/pendingclusterstate.h5
-rw-r--r--storage/src/vespa/storage/distributor/stripe_bucket_db_updater.cpp8
-rw-r--r--storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h2
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.cpp32
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.h6
6 files changed, 26 insertions, 36 deletions
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/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp
index 124655f6eaf..647cba52bfc 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.cpp
+++ b/storage/src/vespa/storage/storageserver/statemanager.cpp
@@ -134,7 +134,7 @@ StateManager::reportHtmlStatus(std::ostream& out,
<< "<table border=\"1\"><tr>"
<< "<th>Received at time</th><th>State</th></tr>\n";
for (const auto & it : std::ranges::reverse_view(_systemStateHistory)) {
- out << "<tr><td>" << it.first << "</td><td>"
+ out << "<tr><td>" << vespalib::to_string(vespalib::to_utc(it.first)) << "</td><td>"
<< xml_content_escaped(it.second->getBaselineClusterState()->toString()) << "</td></tr>\n";
}
out << "</table>\n";
@@ -296,7 +296,7 @@ StateManager::enableNextClusterState()
_reported_host_info_cluster_state_version = _systemState->getVersion();
} // else: reported version updated upon explicit activation edge
_nextSystemState.reset();
- _systemStateHistory.emplace_back(_component.getClock().getTimeInMillis(), _systemState);
+ _systemStateHistory.emplace_back(_component.getClock().getMonotonicTime(), _systemState);
}
namespace {
@@ -390,8 +390,7 @@ StateManager::onGetNodeState(const api::GetNodeStateCommand::SP& cmd)
{
bool sentReply = false;
if (cmd->getSourceIndex() != 0xffff) {
- sentReply = sendGetNodeStateReplies(framework::MilliSecTime(0),
- cmd->getSourceIndex());
+ sentReply = sendGetNodeStateReplies(vespalib::steady_time::max(), cmd->getSourceIndex());
}
std::shared_ptr<api::GetNodeStateReply> reply;
{
@@ -402,16 +401,13 @@ StateManager::onGetNodeState(const api::GetNodeStateCommand::SP& cmd)
&& (*cmd->getExpectedState() == *_nodeState || sentReply)
&& is_up_to_date)
{
- int64_t msTimeout = vespalib::count_ms(cmd->getTimeout());
+ vespalib::duration timeout = cmd->getTimeout();
LOG(debug, "Received get node state request with timeout of "
- "%" PRId64 " milliseconds. Scheduling to be answered in "
- "%" PRId64 " milliseconds unless a node state change "
+ "%f seconds. Scheduling to be answered in "
+ "%f seconds unless a node state change "
"happens before that time.",
- msTimeout, msTimeout * 800 / 1000);
- TimeStateCmdPair pair(
- _component.getClock().getTimeInMillis()
- + framework::MilliSecTime(msTimeout * 800 / 1000),
- cmd);
+ vespalib::to_s(timeout), vespalib::to_s(timeout)*0.8);
+ TimeStateCmdPair pair(_component.getClock().getMonotonicTime() + timeout, cmd);
_queuedStateRequests.emplace_back(std::move(pair));
} else {
LOG(debug, "Answered get node state request right away since it "
@@ -495,13 +491,14 @@ StateManager::tick() {
bool almost_immediate_replies = _requested_almost_immediate_node_state_replies.load(std::memory_order_relaxed);
if (almost_immediate_replies) {
_requested_almost_immediate_node_state_replies.store(false, std::memory_order_relaxed);
+ sendGetNodeStateReplies();
+ } else {
+ sendGetNodeStateReplies(_component.getClock().getMonotonicTime());
}
- framework::MilliSecTime time(almost_immediate_replies ? framework::MilliSecTime(0) : _component.getClock().getTimeInMillis());
- sendGetNodeStateReplies(time);
}
bool
-StateManager::sendGetNodeStateReplies(framework::MilliSecTime olderThanTime, uint16_t node)
+StateManager::sendGetNodeStateReplies(vespalib::steady_time olderThanTime, uint16_t node)
{
std::vector<std::shared_ptr<api::GetNodeStateReply>> replies;
{
@@ -509,9 +506,8 @@ StateManager::sendGetNodeStateReplies(framework::MilliSecTime olderThanTime, uin
for (auto it = _queuedStateRequests.begin(); it != _queuedStateRequests.end();) {
if (node != 0xffff && node != it->second->getSourceIndex()) {
++it;
- } else if (!olderThanTime.isSet() || it->first < olderThanTime) {
- LOG(debug, "Sending reply to msg with id %" PRIu64,
- it->second->getMsgId());
+ } else if (it->first < olderThanTime) {
+ LOG(debug, "Sending reply to msg with id %" PRIu64, it->second->getMsgId());
replies.emplace_back(std::make_shared<api::GetNodeStateReply>(*it->second, *_nodeState));
auto eraseIt = it++;
diff --git a/storage/src/vespa/storage/storageserver/statemanager.h b/storage/src/vespa/storage/storageserver/statemanager.h
index 74b59875ff8..3605a0b1605 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.h
+++ b/storage/src/vespa/storage/storageserver/statemanager.h
@@ -42,8 +42,8 @@ class StateManager : public NodeStateUpdater,
private vespalib::JsonStreamTypes
{
using ClusterStateBundle = lib::ClusterStateBundle;
- using TimeStateCmdPair = std::pair<framework::MilliSecTime, api::GetNodeStateCommand::SP>;
- using TimeSysStatePair = std::pair<framework::MilliSecTime, std::shared_ptr<const ClusterStateBundle>>;
+ using TimeStateCmdPair = std::pair<vespalib::steady_time, api::GetNodeStateCommand::SP>;
+ using TimeSysStatePair = std::pair<vespalib::steady_time, std::shared_ptr<const ClusterStateBundle>>;
struct StateManagerMetrics;
@@ -109,7 +109,7 @@ private:
void notifyStateListeners();
bool sendGetNodeStateReplies(
- framework::MilliSecTime olderThanTime = framework::MilliSecTime(0),
+ vespalib::steady_time olderThanTime = vespalib::steady_time::max(),
uint16_t index = 0xffff);
void mark_controller_as_having_observed_explicit_node_state(const std::unique_lock<std::mutex> &, uint16_t controller_index);