summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-07 15:06:54 +0100
committerGitHub <noreply@github.com>2023-02-07 15:06:54 +0100
commitd907c83a12d78c8b4c0d96dc51320cf29f680728 (patch)
tree31a48c935ec3608610d24867cee55c81f9dad453 /storage
parent2c8c643e3fcd0aaaf8e47094e5059194239f1600 (diff)
Revert "Revert "Use steady_time for vdslib::NodeState MERGEOK""
Diffstat (limited to 'storage')
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.cpp44
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.h6
2 files changed, 22 insertions, 28 deletions
diff --git a/storage/src/vespa/storage/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp
index 81961370ed3..647cba52bfc 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.cpp
+++ b/storage/src/vespa/storage/storageserver/statemanager.cpp
@@ -9,16 +9,14 @@
#include <vespa/metrics/metricset.h>
#include <vespa/metrics/metrictimer.h>
#include <vespa/metrics/valuemetric.h>
-#include <vespa/storageapi/messageapi/storagemessage.h>
#include <vespa/vdslib/state/cluster_state_bundle.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/string_escape.h>
#include <vespa/vespalib/util/stringfmt.h>
-
#include <fstream>
-#include <unistd.h>
+#include <ranges>
#include <vespa/log/log.h>
LOG_SETUP(".state.manager");
@@ -71,7 +69,7 @@ StateManager::StateManager(StorageComponentRegister& compReg,
_requested_almost_immediate_node_state_replies(false)
{
_nodeState->setMinUsedBits(58);
- _nodeState->setStartTimestamp(_component.getClock().getTimeInSeconds().getTime());
+ _nodeState->setStartTimestamp(_component.getClock().getSystemTime());
_component.registerStatusPage(*this);
_component.registerMetric(*_metrics);
}
@@ -135,9 +133,9 @@ StateManager::reportHtmlStatus(std::ostream& out,
<< "<h1>System state history</h1>\n"
<< "<table border=\"1\"><tr>"
<< "<th>Received at time</th><th>State</th></tr>\n";
- for (auto it = _systemStateHistory.rbegin(); it != _systemStateHistory.rend(); ++it) {
- out << "<tr><td>" << it->first << "</td><td>"
- << xml_content_escaped(it->second->getBaselineClusterState()->toString()) << "</td></tr>\n";
+ for (const auto & it : std::ranges::reverse_view(_systemStateHistory)) {
+ 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";
}
@@ -146,7 +144,7 @@ StateManager::reportHtmlStatus(std::ostream& out,
lib::Node
StateManager::thisNode() const
{
- return lib::Node(_component.getNodeType(), _component.getIndex());
+ return { _component.getNodeType(), _component.getIndex() };
}
lib::NodeState::CSP
@@ -298,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 {
@@ -392,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;
{
@@ -404,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 "
@@ -497,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;
{
@@ -511,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);