summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-07 11:07:57 +0100
committerGitHub <noreply@github.com>2023-02-07 11:07:57 +0100
commit2e9c4005b24c90a42167d2fdf197a855c5a11fee (patch)
tree943d30fccfa195299e2e44abfa48f8c41f83ede0 /storage
parent0e2842965370836f66c505c61a3c2f4ebac7c6ad (diff)
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, 28 insertions, 22 deletions
diff --git a/storage/src/vespa/storage/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp
index 647cba52bfc..81961370ed3 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.cpp
+++ b/storage/src/vespa/storage/storageserver/statemanager.cpp
@@ -9,14 +9,16 @@
#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 <ranges>
+#include <unistd.h>
#include <vespa/log/log.h>
LOG_SETUP(".state.manager");
@@ -69,7 +71,7 @@ StateManager::StateManager(StorageComponentRegister& compReg,
_requested_almost_immediate_node_state_replies(false)
{
_nodeState->setMinUsedBits(58);
- _nodeState->setStartTimestamp(_component.getClock().getSystemTime());
+ _nodeState->setStartTimestamp(_component.getClock().getTimeInSeconds().getTime());
_component.registerStatusPage(*this);
_component.registerMetric(*_metrics);
}
@@ -133,9 +135,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 (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";
+ 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";
}
out << "</table>\n";
}
@@ -144,7 +146,7 @@ StateManager::reportHtmlStatus(std::ostream& out,
lib::Node
StateManager::thisNode() const
{
- return { _component.getNodeType(), _component.getIndex() };
+ return lib::Node(_component.getNodeType(), _component.getIndex());
}
lib::NodeState::CSP
@@ -296,7 +298,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().getMonotonicTime(), _systemState);
+ _systemStateHistory.emplace_back(_component.getClock().getTimeInMillis(), _systemState);
}
namespace {
@@ -390,7 +392,8 @@ StateManager::onGetNodeState(const api::GetNodeStateCommand::SP& cmd)
{
bool sentReply = false;
if (cmd->getSourceIndex() != 0xffff) {
- sentReply = sendGetNodeStateReplies(vespalib::steady_time::max(), cmd->getSourceIndex());
+ sentReply = sendGetNodeStateReplies(framework::MilliSecTime(0),
+ cmd->getSourceIndex());
}
std::shared_ptr<api::GetNodeStateReply> reply;
{
@@ -401,13 +404,16 @@ StateManager::onGetNodeState(const api::GetNodeStateCommand::SP& cmd)
&& (*cmd->getExpectedState() == *_nodeState || sentReply)
&& is_up_to_date)
{
- vespalib::duration timeout = cmd->getTimeout();
+ int64_t msTimeout = vespalib::count_ms(cmd->getTimeout());
LOG(debug, "Received get node state request with timeout of "
- "%f seconds. Scheduling to be answered in "
- "%f seconds unless a node state change "
+ "%" PRId64 " milliseconds. Scheduling to be answered in "
+ "%" PRId64 " milliseconds unless a node state change "
"happens before that time.",
- vespalib::to_s(timeout), vespalib::to_s(timeout)*0.8);
- TimeStateCmdPair pair(_component.getClock().getMonotonicTime() + timeout, cmd);
+ msTimeout, msTimeout * 800 / 1000);
+ TimeStateCmdPair pair(
+ _component.getClock().getTimeInMillis()
+ + framework::MilliSecTime(msTimeout * 800 / 1000),
+ cmd);
_queuedStateRequests.emplace_back(std::move(pair));
} else {
LOG(debug, "Answered get node state request right away since it "
@@ -491,14 +497,13 @@ 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(vespalib::steady_time olderThanTime, uint16_t node)
+StateManager::sendGetNodeStateReplies(framework::MilliSecTime olderThanTime, uint16_t node)
{
std::vector<std::shared_ptr<api::GetNodeStateReply>> replies;
{
@@ -506,8 +511,9 @@ StateManager::sendGetNodeStateReplies(vespalib::steady_time olderThanTime, uint1
for (auto it = _queuedStateRequests.begin(); it != _queuedStateRequests.end();) {
if (node != 0xffff && node != it->second->getSourceIndex()) {
++it;
- } else if (it->first < olderThanTime) {
- LOG(debug, "Sending reply to msg with id %" PRIu64, it->second->getMsgId());
+ } else if (!olderThanTime.isSet() || 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 3605a0b1605..74b59875ff8 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<vespalib::steady_time, api::GetNodeStateCommand::SP>;
- using TimeSysStatePair = std::pair<vespalib::steady_time, std::shared_ptr<const ClusterStateBundle>>;
+ using TimeStateCmdPair = std::pair<framework::MilliSecTime, api::GetNodeStateCommand::SP>;
+ using TimeSysStatePair = std::pair<framework::MilliSecTime, std::shared_ptr<const ClusterStateBundle>>;
struct StateManagerMetrics;
@@ -109,7 +109,7 @@ private:
void notifyStateListeners();
bool sendGetNodeStateReplies(
- vespalib::steady_time olderThanTime = vespalib::steady_time::max(),
+ framework::MilliSecTime olderThanTime = framework::MilliSecTime(0),
uint16_t index = 0xffff);
void mark_controller_as_having_observed_explicit_node_state(const std::unique_lock<std::mutex> &, uint16_t controller_index);