summaryrefslogtreecommitdiffstats
path: root/vdslib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-07 22:25:18 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-02-07 22:25:18 +0000
commitfc56636315ca68ba4955dd8057c4c9399f15a659 (patch)
treef379a180d9df72b8eeb8da32ad52d8b45bc55435 /vdslib
parented4288e9df281b1d85e9316a3a93de00a95a2534 (diff)
Timestamp used in NodeState must have well defined resolution in order to compare for exactness.
Revert back to using an uint64_t for representing it as seconds since epoch.
Diffstat (limited to 'vdslib')
-rw-r--r--vdslib/src/tests/state/nodestatetest.cpp2
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.cpp22
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.h12
3 files changed, 16 insertions, 20 deletions
diff --git a/vdslib/src/tests/state/nodestatetest.cpp b/vdslib/src/tests/state/nodestatetest.cpp
index c854adf3915..39a4e09c7ba 100644
--- a/vdslib/src/tests/state/nodestatetest.cpp
+++ b/vdslib/src/tests/state/nodestatetest.cpp
@@ -20,7 +20,7 @@ TEST(NodeStateTest, test_parsing)
{
NodeState ns = NodeState("t:4");
EXPECT_EQ(std::string("s:u t:4"), ns.toString());
- EXPECT_EQ(4s, ns.getStartTimestamp().time_since_epoch());
+ EXPECT_EQ(4u, ns.getStartTimestamp());
}
{
NodeState ns = NodeState("s:u c:2.4 b:12");
diff --git a/vdslib/src/vespa/vdslib/state/nodestate.cpp b/vdslib/src/vespa/vdslib/state/nodestate.cpp
index 3fc33862e6f..90a61d34664 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.cpp
+++ b/vdslib/src/vespa/vdslib/state/nodestate.cpp
@@ -29,7 +29,7 @@ NodeState::NodeState()
_capacity(1.0),
_initProgress(0.0),
_minUsedBits(16),
- _startTimestamp()
+ _startTimestamp(0)
{
setState(State::UP);
}
@@ -42,7 +42,7 @@ NodeState::NodeState(const NodeType& type, const State& state,
_capacity(1.0),
_initProgress(0.0),
_minUsedBits(16),
- _startTimestamp()
+ _startTimestamp(0)
{
setState(state);
if (type == NodeType::STORAGE) {
@@ -57,7 +57,7 @@ NodeState::NodeState(vespalib::stringref serialized, const NodeType* type)
_capacity(1.0),
_initProgress(0.0),
_minUsedBits(16),
- _startTimestamp()
+ _startTimestamp(0)
{
vespalib::StringTokenizer st(serialized, " \t\f\r\n");
@@ -106,7 +106,7 @@ NodeState::NodeState(vespalib::stringref serialized, const NodeType* type)
case 't':
if (key.size() > 1) break;
try {
- setStartTimestamp(vespalib::system_time(std::chrono::seconds(boost::lexical_cast<uint64_t>(value))));
+ setStartTimestamp(boost::lexical_cast<uint64_t>(value));
} catch (...) {
throw IllegalArgumentException("Illegal start timestamp '" + value + "'. Start timestamp must be"
" 0 or positive long.", VESPA_STRLOC);
@@ -167,8 +167,8 @@ NodeState::serialize(vespalib::asciistream & out, vespalib::stringref prefix,
if (*_state == State::INITIALIZING) {
out << sep << prefix << "i:" << _initProgress;
}
- if (_startTimestamp != vespalib::system_time()) {
- out << sep << prefix << "t:" << vespalib::count_s(_startTimestamp.time_since_epoch());
+ if (_startTimestamp != 0u) {
+ out << sep << prefix << "t:" << _startTimestamp;
}
if (includeDescription && ! _description.empty()) {
out << sep << prefix << "m:"
@@ -229,7 +229,7 @@ NodeState::setInitProgress(vespalib::Double initProgress)
}
void
-NodeState::setStartTimestamp(vespalib::system_time startTimestamp)
+NodeState::setStartTimestamp(uint64_t startTimestamp)
{
_startTimestamp = startTimestamp;
}
@@ -253,8 +253,8 @@ NodeState::print(std::ostream& out, bool verbose, const std::string& indent) con
if (*_state == State::INITIALIZING) {
out << ", init progress " << _initProgress;
}
- if (_startTimestamp != vespalib::system_time()) {
- out << ", start timestamp " << vespalib::to_string(_startTimestamp);
+ if (_startTimestamp != 0) {
+ out << ", start timestamp " << _startTimestamp;
}
if (!_description.empty()) {
out << ": " << _description;
@@ -334,8 +334,8 @@ NodeState::getTextualDifference(const NodeState& other) const {
}
}
if (_startTimestamp != other._startTimestamp) {
- source << ", start timestamp " << vespalib::to_string(_startTimestamp);
- target << ", start timestamp " << vespalib::to_string(other._startTimestamp);
+ source << ", start timestamp " << _startTimestamp;
+ target << ", start timestamp " << other._startTimestamp;
}
if (source.str().length() < 2 || target.str().length() < 2) {
diff --git a/vdslib/src/vespa/vdslib/state/nodestate.h b/vdslib/src/vespa/vdslib/state/nodestate.h
index 4fb035b6dcd..fd114828820 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.h
+++ b/vdslib/src/vespa/vdslib/state/nodestate.h
@@ -13,7 +13,6 @@
#include "state.h"
#include <vespa/document/util/printable.h>
#include <vespa/vespalib/objects/floatingpointtype.h>
-#include <vespa/vespalib/util/time.h>
#include <memory>
namespace storage::lib {
@@ -26,7 +25,7 @@ class NodeState : public document::Printable
vespalib::Double _capacity;
vespalib::Double _initProgress;
uint32_t _minUsedBits;
- vespalib::system_time _startTimestamp;
+ uint64_t _startTimestamp;
public:
using CSP = std::shared_ptr<const NodeState>;
@@ -60,17 +59,16 @@ public:
[[nodiscard]] uint32_t getMinUsedBits() const { return _minUsedBits; }
[[nodiscard]] vespalib::Double getInitProgress() const { return _initProgress; }
[[nodiscard]] const vespalib::string& getDescription() const { return _description; }
- [[nodiscard]] vespalib::system_time getStartTimestamp() const { return _startTimestamp; }
+ [[nodiscard]] uint64_t getStartTimestamp() const { return _startTimestamp; }
void setState(const State& state);
void setCapacity(vespalib::Double capacity);
void setMinUsedBits(uint32_t usedBits);
void setInitProgress(vespalib::Double initProgress);
- void setStartTimestamp(vespalib::system_time startTimestamp);
+ void setStartTimestamp(uint64_t startTimestamp);
void setDescription(vespalib::stringref desc) { _description = desc; }
- void print(std::ostream& out, bool verbose,
- const std::string& indent) const override;
+ void print(std::ostream& out, bool verbose, const std::string& indent) const override;
bool operator==(const NodeState& other) const;
bool operator!=(const NodeState& other) const {
return !(operator==(other));
@@ -84,9 +82,7 @@ public:
* @throws vespalib::IllegalStateException if not fitting.
*/
void verifySupportForNodeType(const NodeType& type) const;
-
std::string getTextualDifference(const NodeState& other) const;
-
};
}