aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-05 09:35:23 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-02-05 09:35:23 +0000
commit9813f9cb0bcd7dfa039c33aa0f3b4b600d6fd8a9 (patch)
treee0301af92c1c208200d886abbc03f59ec1f1172b
parent11b731d1a6b3a9e9bbf84bc94285a6c22d6910e1 (diff)
Øess use of getSeconds/getMicroSeconds/getMilliSeconds.
-rw-r--r--storage/src/tests/common/teststorageapp.cpp34
-rw-r--r--storage/src/tests/common/teststorageapp.h2
-rw-r--r--storage/src/tests/distributor/bucketstateoperationtest.cpp8
-rw-r--r--storage/src/tests/distributor/garbagecollectiontest.cpp24
-rw-r--r--storage/src/tests/distributor/getoperationtest.cpp3
-rw-r--r--storage/src/tests/distributor/joinbuckettest.cpp4
-rw-r--r--storage/src/tests/distributor/mergeoperationtest.cpp8
-rw-r--r--storage/src/tests/distributor/putoperationtest.cpp2
-rw-r--r--storage/src/tests/distributor/removebucketoperationtest.cpp9
-rw-r--r--storage/src/tests/distributor/removelocationtest.cpp2
-rw-r--r--storage/src/tests/distributor/removeoperationtest.cpp5
-rw-r--r--storage/src/tests/distributor/splitbuckettest.cpp6
-rw-r--r--storage/src/tests/distributor/statoperationtest.cpp4
-rw-r--r--storage/src/tests/distributor/twophaseupdateoperationtest.cpp86
-rw-r--r--storage/src/tests/distributor/updateoperationtest.cpp15
-rw-r--r--storage/src/tests/distributor/visitoroperationtest.cpp52
-rw-r--r--storage/src/tests/storageframework/clock/timetest.cpp11
-rw-r--r--storage/src/vespa/storage/common/statusmetricconsumer.cpp36
-rw-r--r--storage/src/vespa/storage/common/statusmetricconsumer.h16
-rw-r--r--storage/src/vespa/storage/distributor/distributor_stripe.cpp3
-rw-r--r--storage/src/vespa/storage/distributor/operationowner.cpp8
-rw-r--r--storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp9
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp58
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.h4
-rw-r--r--storage/src/vespa/storage/distributor/operations/operation.cpp14
-rw-r--r--storage/src/vespa/storage/distributor/operations/operation.h18
-rw-r--r--storage/src/vespa/storage/distributor/pendingmessagetracker.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/pendingmessagetracker.h2
-rw-r--r--storage/src/vespa/storage/distributor/throttlingoperationstarter.h21
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.cpp39
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.h7
-rw-r--r--storage/src/vespa/storage/storageserver/opslogger.cpp8
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.cpp14
-rw-r--r--storage/src/vespa/storage/storageserver/statereporter.cpp8
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.cpp10
-rw-r--r--storage/src/vespa/storage/storageserver/storagenode.h2
-rw-r--r--storage/src/vespa/storage/visiting/visitormanager.cpp12
-rw-r--r--storage/src/vespa/storage/visiting/visitormanager.h2
-rw-r--r--storage/src/vespa/storage/visiting/visitorthread.cpp23
-rw-r--r--storage/src/vespa/storage/visiting/visitorthread.h4
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/clock/fakeclock.h8
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/clock/realclock.cpp19
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/clock/realclock.h3
-rw-r--r--storage/src/vespa/storageframework/generic/clock/clock.h3
-rw-r--r--storage/src/vespa/storageframework/generic/clock/time.h30
-rw-r--r--vdslib/src/tests/state/nodestatetest.cpp2
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.cpp60
-rw-r--r--vdslib/src/vespa/vdslib/state/nodestate.h28
48 files changed, 332 insertions, 415 deletions
diff --git a/storage/src/tests/common/teststorageapp.cpp b/storage/src/tests/common/teststorageapp.cpp
index 91fdf5aa602..fae71f15bca 100644
--- a/storage/src/tests/common/teststorageapp.cpp
+++ b/storage/src/tests/common/teststorageapp.cpp
@@ -22,18 +22,6 @@ using storage::framework::defaultimplementation::ComponentRegisterImpl;
namespace storage {
-namespace {
- template<typename T>
- struct ConfigReader : public T::Subscriber,
- public T
- {
- ConfigReader(const std::string& configId) {
- T::subscribe(configId, *this);
- }
- void configure(const T& c) { dynamic_cast<T&>(*this) = c; }
- };
-}
-
TestStorageApp::TestStorageApp(StorageComponentRegisterImpl::UP compReg,
const lib::NodeType& type, NodeIndex index,
vespalib::stringref configId)
@@ -84,7 +72,7 @@ TestStorageApp::setDistribution(Redundancy redundancy, NodeCount nodeCount)
void
TestStorageApp::setTypeRepo(std::shared_ptr<const document::DocumentTypeRepo> repo)
{
- _compReg.setDocumentTypeRepo(repo);
+ _compReg.setDocumentTypeRepo(std::move(repo));
}
void
@@ -94,21 +82,19 @@ TestStorageApp::setClusterState(const lib::ClusterState& c)
}
void
-TestStorageApp::waitUntilInitialized(
- StorageBucketDBInitializer* initializer, framework::SecondTime timeout)
+TestStorageApp::waitUntilInitialized(StorageBucketDBInitializer* initializer, vespalib::duration timeout) const
{
// Always use real clock for wait timeouts. Component clock may be faked
// in tests
framework::defaultimplementation::RealClock clock;
- framework::MilliSecTime endTime(clock.getTimeInMillis() + timeout.getMillis());
+ vespalib::steady_time endTime(clock.getMonotonicTime() + timeout);
while (!isInitialized()) {
std::this_thread::sleep_for(1ms);
- framework::MilliSecTime currentTime(clock.getTimeInMillis());
+ vespalib::steady_time currentTime(clock.getMonotonicTime());
if (currentTime > endTime) {
std::ostringstream error;
- error << "Failed to initialize service layer within timeout of "
- << timeout << " seconds.";
- if (initializer != 0) {
+ error << "Failed to initialize service layer within timeout of " << timeout << " seconds.";
+ if (initializer != nullptr) {
error << " ";
LOG(error, "%s", error.str().c_str());
throw std::runtime_error(error.str());
@@ -174,7 +160,7 @@ TestServiceLayerApp::setPersistenceProvider(PersistenceProviderUP provider)
spi::PersistenceProvider&
TestServiceLayerApp::getPersistenceProvider()
{
- if (_persistenceProvider.get() == 0) {
+ if ( ! _persistenceProvider) {
throw vespalib::IllegalStateException("Persistence provider requested but not initialized.", VESPA_STRLOC);
}
return *_persistenceProvider;
@@ -182,7 +168,7 @@ TestServiceLayerApp::getPersistenceProvider()
namespace {
template<typename T>
- const T getConfig(vespalib::stringref configId) {
+ T getConfig(vespalib::stringref configId) {
config::ConfigUri uri(configId);
return *config::ConfigGetter<T>::getConfig(uri.getConfigId(), uri.getContext());
}
@@ -192,9 +178,9 @@ void
TestDistributorApp::configure(vespalib::stringref id)
{
if (id.empty()) return;
- DistributorConfig dc(getConfig<vespa::config::content::core::StorDistributormanagerConfig>(id));
+ auto dc(getConfig<vespa::config::content::core::StorDistributormanagerConfig>(id));
_compReg.setDistributorConfig(dc);
- VisitorConfig vc(getConfig<vespa::config::content::core::StorVisitordispatcherConfig>(id));
+ auto vc(getConfig<vespa::config::content::core::StorVisitordispatcherConfig>(id));
_compReg.setVisitorConfig(vc);
}
diff --git a/storage/src/tests/common/teststorageapp.h b/storage/src/tests/common/teststorageapp.h
index de1dc99bb6e..185fe50cbad 100644
--- a/storage/src/tests/common/teststorageapp.h
+++ b/storage/src/tests/common/teststorageapp.h
@@ -97,7 +97,7 @@ public:
bool isInitialized() const { return _initialized; }
void waitUntilInitialized(
StorageBucketDBInitializer* initializer = 0,
- framework::SecondTime timeout = framework::SecondTime(30));
+ vespalib::duration timeout = 30s) const;
private:
// Storage server interface implementation (until we can remove it)
diff --git a/storage/src/tests/distributor/bucketstateoperationtest.cpp b/storage/src/tests/distributor/bucketstateoperationtest.cpp
index 5d11f9653ea..42ee4675e26 100644
--- a/storage/src/tests/distributor/bucketstateoperationtest.cpp
+++ b/storage/src/tests/distributor/bucketstateoperationtest.cpp
@@ -43,7 +43,7 @@ TEST_F(BucketStateOperationTest, activate_single_node) {
SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ(1, _sender.commands().size());
@@ -79,7 +79,7 @@ TEST_F(BucketStateOperationTest, activate_and_deactivate_nodes) {
SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ(1, _sender.commands().size());
{
@@ -135,7 +135,7 @@ TEST_F(BucketStateOperationTest, do_not_deactivate_if_activate_fails) {
SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ(1, _sender.commands().size());
{
@@ -178,7 +178,7 @@ TEST_F(BucketStateOperationTest, bucket_db_not_updated_on_failure) {
SetBucketStateOperation op(dummy_cluster_context, bucketAndNodes, active);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ(1, _sender.commands().size());
diff --git a/storage/src/tests/distributor/garbagecollectiontest.cpp b/storage/src/tests/distributor/garbagecollectiontest.cpp
index 1a104727f43..c2f4836f4cb 100644
--- a/storage/src/tests/distributor/garbagecollectiontest.cpp
+++ b/storage/src/tests/distributor/garbagecollectiontest.cpp
@@ -139,7 +139,7 @@ struct GarbageCollectionOperationTest : Test, DistributorStripeTestUtil {
TEST_F(GarbageCollectionOperationTest, simple_legacy) {
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
EXPECT_FALSE(op->is_two_phase());
ASSERT_EQ(2, _sender.commands().size());
@@ -158,7 +158,7 @@ TEST_F(GarbageCollectionOperationTest, simple_legacy) {
TEST_F(GarbageCollectionOperationTest, replica_bucket_info_not_added_to_db_until_all_replies_received) {
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
EXPECT_EQ(0u, gc_removed_documents_metric());
@@ -175,7 +175,7 @@ TEST_F(GarbageCollectionOperationTest, replica_bucket_info_not_added_to_db_until
TEST_F(GarbageCollectionOperationTest, gc_bucket_info_does_not_overwrite_later_sequenced_bucket_info_writes) {
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
reply_to_nth_request(*op, 0, 1234, 0);
@@ -195,20 +195,20 @@ TEST_F(GarbageCollectionOperationTest, two_phase_gc_requires_config_enabling_and
// Config enabled, but only 1 node says it supports two-phase RemoveLocation
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
EXPECT_FALSE(op->is_two_phase());
// Node 0 suddenly upgraded...!
set_node_supported_features(0, with_two_phase);
op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
EXPECT_TRUE(op->is_two_phase());
// But doesn't matter if two-phase GC is config-disabled
config_enable_two_phase_gc(false);
op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
EXPECT_FALSE(op->is_two_phase());
}
@@ -216,7 +216,7 @@ TEST_F(GarbageCollectionOperationTest, first_phase_sends_enumerate_only_remove_l
enable_two_phase_gc();
auto op = create_op();
op->setPriority(getConfig().getMaintenancePriorities().garbageCollection);
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
for (int i : {0, 1}) {
@@ -229,7 +229,7 @@ TEST_F(GarbageCollectionOperationTest, first_phase_sends_enumerate_only_remove_l
TEST_F(GarbageCollectionOperationTest, second_phase_sends_highest_timestamped_union_of_returned_entries_with_feed_pri) {
enable_two_phase_gc();
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
auto r1 = make_remove_location_reply(*_sender.command(0));
@@ -256,7 +256,7 @@ TEST_F(GarbageCollectionOperationTest, second_phase_sends_highest_timestamped_un
TEST_F(GarbageCollectionOperationTest, no_second_phase_if_first_phase_has_no_results) {
enable_two_phase_gc();
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
auto r1 = make_remove_location_reply(*_sender.command(0));
@@ -272,7 +272,7 @@ TEST_F(GarbageCollectionOperationTest, no_second_phase_if_first_phase_has_no_res
TEST_F(GarbageCollectionOperationTest, db_metrics_and_timestamp_are_updated_on_second_phase_completion) {
enable_two_phase_gc();
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
auto r1 = make_remove_location_reply(*_sender.command(0));
@@ -314,7 +314,7 @@ struct GarbageCollectionOperationPhase1FailureTest : GarbageCollectionOperationT
enable_two_phase_gc();
_op = create_op();
- _op->start(_sender, framework::MilliSecTime(0));
+ _op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
_r1 = make_remove_location_reply(*_sender.command(0));
@@ -367,7 +367,7 @@ TEST_F(GarbageCollectionOperationPhase1FailureTest, no_second_phase_if_bucket_in
TEST_F(GarbageCollectionOperationTest, document_level_write_locks_are_checked_and_held_if_acquired) {
enable_two_phase_gc();
auto op = create_op();
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ(2, _sender.commands().size());
auto r1 = make_remove_location_reply(*_sender.command(0));
diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp
index 6b27af63fb7..8d188f6c005 100644
--- a/storage/src/tests/distributor/getoperationtest.cpp
+++ b/storage/src/tests/distributor/getoperationtest.cpp
@@ -4,7 +4,6 @@
#include <vespa/config/helper/configgetter.h>
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/document/config/documenttypes_config_fwd.h>
-#include <vespa/document/config/config-documenttypes.h>
#include <vespa/document/fieldset/fieldsets.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/fieldvalue/stringfieldvalue.h>
@@ -62,7 +61,7 @@ struct GetOperationTest : Test, DistributorStripeTestUtil {
getDistributorBucketSpace().getBucketDatabase().acquire_read_guard(),
msg, metrics().gets,
consistency);
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
}
static constexpr uint32_t LastCommand = UINT32_MAX;
diff --git a/storage/src/tests/distributor/joinbuckettest.cpp b/storage/src/tests/distributor/joinbuckettest.cpp
index bc87893b610..570fe24679e 100644
--- a/storage/src/tests/distributor/joinbuckettest.cpp
+++ b/storage/src/tests/distributor/joinbuckettest.cpp
@@ -46,7 +46,7 @@ TEST_F(JoinOperationTest, simple) {
document::BucketId(33, 0x100000001)));
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
checkSourceBucketsAndSendReply(op, 0, {{33, 1}, {33, 0x100000001}});
@@ -103,7 +103,7 @@ TEST_F(JoinOperationTest, send_sparse_joins_to_nodes_without_both_source_buckets
document::BucketId(33, 0x100000001)));
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_NO_FATAL_FAILURE(checkSourceBucketsAndSendReply(op, 0, {{33, 1}, {33, 0x100000001}}));
ASSERT_NO_FATAL_FAILURE(checkSourceBucketsAndSendReply(op, 1, {{33, 1}, {33, 1}}));
diff --git a/storage/src/tests/distributor/mergeoperationtest.cpp b/storage/src/tests/distributor/mergeoperationtest.cpp
index 9e0c89819a7..512c092d8ae 100644
--- a/storage/src/tests/distributor/mergeoperationtest.cpp
+++ b/storage/src/tests/distributor/mergeoperationtest.cpp
@@ -71,7 +71,7 @@ MergeOperationTest::setup_simple_merge_op(const std::vector<uint16_t>& nodes, Pr
auto op = std::make_shared<MergeOperation>(BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)), nodes));
op->setIdealStateManager(&getIdealStateManager());
op->setPriority(merge_pri);
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
return op;
}
@@ -291,7 +291,7 @@ TEST_F(MergeOperationTest, do_not_remove_copies_with_pending_messages) {
MergeOperation op(BucketAndNodes(makeDocumentBucket(bucket),
toVector<uint16_t>(0, 1, 2)));
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
std::string merge("MergeBucketCommand(BucketId(0x4000000000000001), to time 10000000, "
"cluster state version: 0, nodes: [0, 2, 1 (source only)], chain: [], "
@@ -352,7 +352,7 @@ TEST_F(MergeOperationTest, allow_deleting_active_source_only_replica) {
MergeOperation op(BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(0, 1, 2)));
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
std::string merge(
"MergeBucketCommand(BucketId(0x4000000000000001), to time "
@@ -501,7 +501,7 @@ TEST_F(MergeOperationTest, missing_replica_is_included_in_limited_node_list) {
const uint16_t max_merge_size = 2;
MergeOperation op(BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)), toVector<uint16_t>(0, 1, 2, 3)), max_merge_size);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
// Must include missing node 0 and not just 2 existing replicas
EXPECT_EQ("MergeBucketCommand(BucketId(0x4000000000000001), to time 10000000, "
diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp
index 53773a55826..735666e5c89 100644
--- a/storage/src/tests/distributor/putoperationtest.cpp
+++ b/storage/src/tests/distributor/putoperationtest.cpp
@@ -76,7 +76,7 @@ public:
getDistributorBucketSpace(),
msg,
metrics().puts);
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
}
const document::DocumentType& doc_type() const {
diff --git a/storage/src/tests/distributor/removebucketoperationtest.cpp b/storage/src/tests/distributor/removebucketoperationtest.cpp
index 971ff36c833..68d86884036 100644
--- a/storage/src/tests/distributor/removebucketoperationtest.cpp
+++ b/storage/src/tests/distributor/removebucketoperationtest.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "dummy_cluster_context.h"
-#include <tests/common/dummystoragelink.h>
#include <tests/distributor/distributor_stripe_test_util.h>
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/storage/distributor/top_level_distributor.h>
@@ -37,9 +36,9 @@ TEST_F(RemoveBucketOperationTest, simple) {
RemoveBucketOperation op(dummy_cluster_context,
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
- toVector<uint16_t>(1,2)));
+ toVector<uint16_t>(1,2)));
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ("Delete bucket => 1,"
@@ -71,7 +70,7 @@ TEST_F(RemoveBucketOperationTest, bucket_info_mismatch_failure) {
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(1)));
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ("Delete bucket => 1", _sender.getCommands(true));
ASSERT_EQ(1, _sender.commands().size());
@@ -106,7 +105,7 @@ TEST_F(RemoveBucketOperationTest, fail_with_invalid_bucket_info) {
BucketAndNodes(makeDocumentBucket(document::BucketId(16, 1)),
toVector<uint16_t>(1)));
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ("Delete bucket => 1", _sender.getCommands(true));
ASSERT_EQ(1, _sender.commands().size());
diff --git a/storage/src/tests/distributor/removelocationtest.cpp b/storage/src/tests/distributor/removelocationtest.cpp
index 889b5c833af..b19a448199b 100644
--- a/storage/src/tests/distributor/removelocationtest.cpp
+++ b/storage/src/tests/distributor/removelocationtest.cpp
@@ -35,7 +35,7 @@ struct RemoveLocationOperationTest : Test, DistributorStripeTestUtil {
msg,
metrics().removelocations);
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
}
};
diff --git a/storage/src/tests/distributor/removeoperationtest.cpp b/storage/src/tests/distributor/removeoperationtest.cpp
index b3104cae623..ed24b7271b8 100644
--- a/storage/src/tests/distributor/removeoperationtest.cpp
+++ b/storage/src/tests/distributor/removeoperationtest.cpp
@@ -1,6 +1,5 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <iomanip>
#include <tests/distributor/distributor_stripe_test_util.h>
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/storage/distributor/top_level_distributor.h>
@@ -41,7 +40,7 @@ struct RemoveOperationTest : Test, DistributorStripeTestUtil {
msg,
metrics().removes);
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
}
void replyToMessage(RemoveOperation& callback,
@@ -55,7 +54,7 @@ struct RemoveOperationTest : Test, DistributorStripeTestUtil {
std::shared_ptr<api::StorageMessage> msg2 = _sender.command(index);
auto* removec = dynamic_cast<api::RemoveCommand*>(msg2.get());
std::unique_ptr<api::StorageReply> reply(removec->makeReply());
- auto* removeR = static_cast<api::RemoveReply*>(reply.get());
+ auto* removeR = dynamic_cast<api::RemoveReply*>(reply.get());
removeR->setOldTimestamp(oldTimestamp);
callback.onReceive(_sender, std::shared_ptr<api::StorageReply>(reply.release()));
}
diff --git a/storage/src/tests/distributor/splitbuckettest.cpp b/storage/src/tests/distributor/splitbuckettest.cpp
index 1e951029994..edb392d9532 100644
--- a/storage/src/tests/distributor/splitbuckettest.cpp
+++ b/storage/src/tests/distributor/splitbuckettest.cpp
@@ -65,7 +65,7 @@ TEST_F(SplitOperationTest, simple) {
splitByteSize);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
{
ASSERT_EQ(1, _sender.commands().size());
@@ -134,7 +134,7 @@ TEST_F(SplitOperationTest, multi_node_failure) {
splitByteSize);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
{
ASSERT_EQ(2, _sender.commands().size());
@@ -218,7 +218,7 @@ TEST_F(SplitOperationTest, copy_trusted_status_not_carried_over_after_split) {
splitByteSize);
op.setIdealStateManager(&getIdealStateManager());
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ(3, _sender.commands().size());
diff --git a/storage/src/tests/distributor/statoperationtest.cpp b/storage/src/tests/distributor/statoperationtest.cpp
index e3323d601df..ec0165dde05 100644
--- a/storage/src/tests/distributor/statoperationtest.cpp
+++ b/storage/src/tests/distributor/statoperationtest.cpp
@@ -35,7 +35,7 @@ TEST_F(StatOperationTest, bucket_info) {
std::make_shared<api::StatBucketCommand>(
makeDocumentBucket(document::BucketId(16, 5)), ""));
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ("Statbucket => 0,Statbucket => 1", _sender.getCommands(true));
@@ -76,7 +76,7 @@ TEST_F(StatOperationTest, bucket_list) {
getIdealStateManager(),
node_context().node_index(),
msg);
- op.start(_sender, framework::MilliSecTime(0));
+ op.start(_sender);
ASSERT_EQ(1, _sender.replies().size());
diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
index 6eb15bf05e7..579fd156962 100644
--- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
+++ b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
@@ -154,7 +154,7 @@ struct TwoPhaseUpdateOperationTest : Test, DistributorStripeTestUtil {
cfg->set_enable_metadata_only_fetch_phase_for_inconsistent_updates(enable_3phase);
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
return cb;
}
@@ -342,7 +342,7 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState,
TEST_F(TwoPhaseUpdateOperationTest, simple) {
setup_stripe(1, 1, "storage:1 distributor:1");
auto cb = sendUpdate("0=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0", _sender.getCommands(true));
@@ -359,7 +359,7 @@ TEST_F(TwoPhaseUpdateOperationTest, simple) {
TEST_F(TwoPhaseUpdateOperationTest, non_existing) {
setup_stripe(1, 1, "storage:1 distributor:1");
auto cb = sendUpdate("");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
EXPECT_EQ("UpdateReply(id:ns:testdoctype1::1, BucketId(0x0000000000000000), "
"timestamp 0, timestamp of updated doc: 0) ReturnCode(NONE)",
@@ -371,7 +371,7 @@ TEST_F(TwoPhaseUpdateOperationTest, non_existing) {
TEST_F(TwoPhaseUpdateOperationTest, update_failed) {
setup_stripe(1, 1, "storage:1 distributor:1");
auto cb = sendUpdate("0=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0", _sender.getCommands(true));
@@ -386,7 +386,7 @@ TEST_F(TwoPhaseUpdateOperationTest, update_failed) {
TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0,Update => 1", _sender.getCommands(true));
@@ -413,7 +413,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps) {
TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_not_found) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0,Update => 1", _sender.getCommands(true));
@@ -434,7 +434,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_not_found)
TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_update_error) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0,Update => 1", _sender.getCommands(true));
@@ -451,7 +451,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_update_err
TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_get_error) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0,Update => 1", _sender.getCommands(true));
@@ -473,7 +473,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_get_error)
TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_put_error) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0,Update => 1", _sender.getCommands(true));
@@ -501,7 +501,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_put_error)
TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_put_not_started) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0,Update => 1", _sender.getCommands(true));
@@ -526,7 +526,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_put_not_st
TEST_F(TwoPhaseUpdateOperationTest, fast_path_inconsistent_timestamps_inconsistent_split) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3", UpdateOptions().makeInconsistentSplit(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
std::string wanted("Get(BucketId(0x400000000000cac4), id:ns:testdoctype1::1) => 0,"
"Get(BucketId(0x440000000000cac4), id:ns:testdoctype1::1) => 0");
@@ -567,7 +567,7 @@ TwoPhaseUpdateOperationTest::checkMessageSettingsPropagatedTo(
TEST_F(TwoPhaseUpdateOperationTest, fast_path_propagates_message_settings_to_update) {
setup_stripe(1, 1, "storage:1 distributor:1");
auto cb = sendUpdate("0=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0", _sender.getCommands(true));
@@ -578,7 +578,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_propagates_message_settings_to_upd
TEST_F(TwoPhaseUpdateOperationTest, n_of_m) {
setup_stripe(2, 2, "storage:2 distributor:1", 1);
auto cb = sendUpdate("0=1/2/3,1=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0,Update => 1", _sender.getCommands(true));
@@ -606,7 +606,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_updates_newest_received_document)
setup_stripe(3, 3, "storage:3 distributor:1");
// 0,1 in sync. 2 out of sync.
auto cb = sendUpdate("0=1/2/3,1=1/2/3,2=2/3/4");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get(BucketId(0x400000000000cac4), id:ns:testdoctype1::1) => 0,"
"Get(BucketId(0x400000000000cac4), id:ns:testdoctype1::1) => 2",
@@ -639,7 +639,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_updates_newest_received_document)
TEST_F(TwoPhaseUpdateOperationTest, create_if_non_existent_creates_document_if_all_empty_gets) {
setup_stripe(3, 3, "storage:3 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3,2=2/3/4", UpdateOptions().createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 2", _sender.getCommands(true));
replyToGet(*cb, _sender, 0, 0, false);
@@ -670,7 +670,7 @@ TEST_F(TwoPhaseUpdateOperationTest, create_if_non_existent_creates_document_if_a
TEST_F(TwoPhaseUpdateOperationTest, update_fails_if_safe_path_has_failed_put) {
setup_stripe(3, 3, "storage:3 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3,2=2/3/4", UpdateOptions().createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 2", _sender.getCommands(true));
replyToGet(*cb, _sender, 0, 0, false);
@@ -697,7 +697,7 @@ TEST_F(TwoPhaseUpdateOperationTest, update_fails_if_safe_path_has_failed_put) {
TEST_F(TwoPhaseUpdateOperationTest, update_fails_if_safe_path_gets_fail) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
replyToGet(*cb, _sender, 0, 0, false, api::ReturnCode::IO_FAILURE);
@@ -717,7 +717,7 @@ TEST_F(TwoPhaseUpdateOperationTest, update_fails_if_apply_throws_exception) {
setup_stripe(2, 2, "storage:2 distributor:1");
// Create update for wrong doctype which will fail the update.
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().withError());
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
replyToGet(*cb, _sender, 0, 50);
@@ -737,7 +737,7 @@ TEST_F(TwoPhaseUpdateOperationTest, non_existing_with_auto_create) {
setup_stripe(1, 1, "storage:1 distributor:1");
auto cb = sendUpdate("", UpdateOptions().createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("CreateBucketCommand(BucketId(0x400000000000cac4), active) "
"Reasons to start: => 0,"
@@ -766,7 +766,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_fails_update_when_mismatching_time
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().timestampToUpdate(1234));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
replyToGet(*cb, _sender, 0, 100);
@@ -786,7 +786,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_fails_update_when_mismatching_time
TEST_F(TwoPhaseUpdateOperationTest, safe_path_update_propagates_message_settings_to_gets_and_puts) {
setup_stripe(3, 3, "storage:3 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3,2=2/3/4");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 2", _sender.getCommands(true));
checkMessageSettingsPropagatedTo(_sender.command(0));
@@ -805,7 +805,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_update_propagates_message_settings
TEST_F(TwoPhaseUpdateOperationTest, safe_path_propagates_mbus_traces_from_replies) {
setup_stripe(3, 3, "storage:3 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=1/2/3,2=2/3/4");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 2", _sender.getCommands(true));
replyToGet(*cb, _sender, 0, 50, true, api::ReturnCode::OK, "hello earthlings");
@@ -832,7 +832,7 @@ void TwoPhaseUpdateOperationTest::do_test_ownership_changed_between_gets_and_sec
setup_stripe(2, 2, "storage:2 distributor:1");
// Update towards inconsistent bucket invokes safe path.
auto cb = sendUpdate("0=1/2/3,1=2/3/4");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
@@ -875,7 +875,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_condition_mismatch_fails_with_tas_
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().condition("testdoctype1.headerval==120"));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
// Newest doc has headerval==110, not 120.
replyToGet(*cb, _sender, 0, 100);
replyToGet(*cb, _sender, 1, 110);
@@ -894,7 +894,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_condition_match_sends_puts_with_up
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().condition("testdoctype1.headerval==110"));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
replyToGet(*cb, _sender, 0, 100);
replyToGet(*cb, _sender, 1, 110);
ASSERT_EQ("Put => 1,Put => 0", _sender.getCommands(true, false, 2));
@@ -904,7 +904,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_condition_parse_failure_fails_with
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().condition("testdoctype1.san==fran...cisco"));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
replyToGet(*cb, _sender, 0, 100);
replyToGet(*cb, _sender, 1, 110);
// NOTE: condition is currently not attempted parsed until Gets have been
@@ -924,7 +924,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_condition_unknown_doc_type_fails_w
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().condition("langbein.headerval=1234"));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
replyToGet(*cb, _sender, 0, 100);
replyToGet(*cb, _sender, 1, 110);
// NOTE: condition is currently not attempted parsed until Gets have been
@@ -943,7 +943,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_condition_with_missing_doc_and_no_
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().condition("testdoctype1.headerval==120"));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
// Both Gets return nothing at all, nothing at all.
replyToGet(*cb, _sender, 0, 100, false);
replyToGet(*cb, _sender, 1, 110, false);
@@ -964,7 +964,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_condition_with_missing_doc_and_aut
.condition("testdoctype1.headerval==120")
.createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
replyToGet(*cb, _sender, 0, 0, false);
replyToGet(*cb, _sender, 1, 0, false);
ASSERT_EQ("Put => 1,Put => 0", _sender.getCommands(true, false, 2));
@@ -999,7 +999,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_close_edge_sends_correct_reply) {
setup_stripe(1, 1, "storage:1 distributor:1");
// Only 1 replica; consistent with itself by definition.
auto cb = sendUpdate("0=1/2/3");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Update => 0", _sender.getCommands(true));
// Close the operation. This should generate a single reply that is
@@ -1017,7 +1017,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_close_edge_sends_correct_reply) {
setup_stripe(2, 2, "storage:2 distributor:1");
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
// Closing the operation should now only return an ABORTED reply for
@@ -1037,7 +1037,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_consistent_get_reply_timestamps_re
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
Timestamp old_timestamp = 500;
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
@@ -1065,7 +1065,7 @@ TEST_F(TwoPhaseUpdateOperationTest, safe_path_consistent_get_reply_timestamps_do
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
Timestamp old_timestamp = 500;
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
@@ -1086,7 +1086,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_not_restarted_if_replica_set_alter
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
// Replica set changes between time of Get requests sent and
// responses received. This may happen e.g. if concurrent mutations
@@ -1112,7 +1112,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_not_restarted_if_document_not_foun
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
replyToGet(*cb, _sender, 0, Timestamp(0), false);
@@ -1131,7 +1131,7 @@ TEST_F(TwoPhaseUpdateOperationTest, fast_path_not_restarted_if_no_initial_replic
// No replicas, technically consistent but cannot use fast path.
auto cb = sendUpdate("", UpdateOptions().createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Create bucket => 1,Create bucket => 0,Put => 1,Put => 0",
_sender.getCommands(true));
}
@@ -1146,7 +1146,7 @@ TEST_F(TwoPhaseUpdateOperationTest, update_gets_are_sent_with_strong_consistency
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
auto& get_cmd = dynamic_cast<const api::GetCommand&>(*_sender.command(0));
@@ -1156,7 +1156,7 @@ TEST_F(TwoPhaseUpdateOperationTest, update_gets_are_sent_with_strong_consistency
TEST_F(TwoPhaseUpdateOperationTest, operation_is_rejected_in_safe_path_if_feed_is_blocked) {
set_up_distributor_with_feed_blocked_state();
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas to trigger safe path
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
EXPECT_EQ("UpdateReply(id:ns:testdoctype1::1, BucketId(0x0000000000000000), "
"timestamp 0, timestamp of updated doc: 0) "
@@ -1275,7 +1275,7 @@ TEST_F(ThreePhaseUpdateTest, update_failed_with_transient_error_code_if_replica_
cfg->set_enable_metadata_only_fetch_phase_for_inconsistent_updates(true);
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // 2 replicas, room for 1 more.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
// Add new replica to deterministic test bucket after gets have been sent
BucketId bucket(0x400000000000cac4); // Always the same in the test.
addNodesToBucketDB(bucket, "0=1/2/3,1=2/3/4,2=3/3/3");
@@ -1299,7 +1299,7 @@ TEST_F(ThreePhaseUpdateTest, single_full_get_cannot_restart_in_fast_path) {
cfg->set_update_fast_path_restart_enabled(true);
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4"); // Inconsistent replicas.
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
reply_to_metadata_get(*cb, _sender, 0, 1000U);
@@ -1360,7 +1360,7 @@ TEST_F(ThreePhaseUpdateTest, safe_mode_is_implicitly_triggered_if_no_replicas_ex
cfg->set_enable_metadata_only_fetch_phase_for_inconsistent_updates(true);
configure_stripe(cfg);
auto cb = sendUpdate("", UpdateOptions().createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("CreateBucketCommand(BucketId(0x400000000000cac4), active) "
"Reasons to start: => 0,"
@@ -1419,7 +1419,7 @@ TEST_F(ThreePhaseUpdateTest, single_full_get_tombstone_is_no_op_without_auto_cre
cfg->set_update_fast_path_restart_enabled(true);
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4");
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
reply_to_metadata_get(*cb, _sender, 0, 1000U);
@@ -1443,7 +1443,7 @@ TEST_F(ThreePhaseUpdateTest, single_full_get_tombstone_sends_puts_with_auto_crea
cfg->set_update_fast_path_restart_enabled(true);
configure_stripe(cfg);
auto cb = sendUpdate("0=1/2/3,1=2/3/4", UpdateOptions().createIfNonExistent(true));
- cb->start(_sender, framework::MilliSecTime(0));
+ cb->start(_sender);
ASSERT_EQ("Get => 0,Get => 1", _sender.getCommands(true));
reply_to_metadata_get(*cb, _sender, 0, 1000U);
diff --git a/storage/src/tests/distributor/updateoperationtest.cpp b/storage/src/tests/distributor/updateoperationtest.cpp
index f0cb30368cb..d0ae31b9524 100644
--- a/storage/src/tests/distributor/updateoperationtest.cpp
+++ b/storage/src/tests/distributor/updateoperationtest.cpp
@@ -1,6 +1,5 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <tests/common/dummystoragelink.h>
#include <tests/distributor/distributor_stripe_test_util.h>
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/document/repo/documenttyperepo.h>
@@ -91,7 +90,7 @@ TEST_F(UpdateOperationTest, simple) {
std::shared_ptr<UpdateOperation> cb(sendUpdate("0=1/2/3"));
DistributorMessageSenderStub sender;
- cb->start(sender, framework::MilliSecTime(0));
+ cb->start(sender);
ASSERT_EQ("Update => 0", sender.getCommands(true));
@@ -110,7 +109,7 @@ TEST_F(UpdateOperationTest, not_found) {
std::shared_ptr<UpdateOperation> cb(sendUpdate("0=1/2/3"));
DistributorMessageSenderStub sender;
- cb->start(sender, framework::MilliSecTime(0));
+ cb->start(sender);
ASSERT_EQ("Update => 0", sender.getCommands(true));
@@ -125,7 +124,7 @@ TEST_F(UpdateOperationTest, multi_node) {
setup_stripe(2, 2, "distributor:1 storage:2");
std::shared_ptr<UpdateOperation> cb(sendUpdate("0=1/2/3,1=1/2/3"));
DistributorMessageSenderStub sender;
- cb->start(sender, framework::MilliSecTime(0));
+ cb->start(sender);
ASSERT_EQ("Update => 0,Update => 1", sender.getCommands(true));
@@ -149,7 +148,7 @@ TEST_F(UpdateOperationTest, multi_node_inconsistent_timestamp) {
setup_stripe(2, 2, "distributor:1 storage:2");
std::shared_ptr<UpdateOperation> cb(sendUpdate("0=1/2/3,1=1/2/3"));
DistributorMessageSenderStub sender;
- cb->start(sender, framework::MilliSecTime(0));
+ cb->start(sender);
ASSERT_EQ("Update => 0,Update => 1", sender.getCommands(true));
@@ -169,7 +168,7 @@ TEST_F(UpdateOperationTest, test_and_set_failures_increment_tas_metric) {
setup_stripe(2, 2, "distributor:1 storage:1");
std::shared_ptr<UpdateOperation> cb(sendUpdate("0=1/2/3"));
DistributorMessageSenderStub sender;
- cb->start(sender, framework::MilliSecTime(0));
+ cb->start(sender);
ASSERT_EQ("Update => 0", sender.getCommands(true));
api::ReturnCode result(api::ReturnCode::TEST_AND_SET_CONDITION_FAILED, "bork bork");
replyToMessage(*cb, sender, 0, 1234, api::BucketInfo(), result);
@@ -198,7 +197,7 @@ TEST_F(UpdateOperationTest, create_if_missing_update_sentinel_timestamp_is_treat
setup_stripe(2, 2, "distributor:1 storage:2");
std::shared_ptr<UpdateOperation> cb(sendUpdate("0=1/2/3,1=1/2/3", true));
DistributorMessageSenderStub sender;
- cb->start(sender, framework::MilliSecTime(0));
+ cb->start(sender);
ASSERT_EQ("Update => 0,Update => 1", sender.getCommands(true));
@@ -220,7 +219,7 @@ TEST_F(UpdateOperationTest, inconsistent_create_if_missing_updates_picks_largest
setup_stripe(2, 3, "distributor:1 storage:3");
std::shared_ptr<UpdateOperation> cb(sendUpdate("0=1/2/3,1=1/2/3,2=1/2/3", true));
DistributorMessageSenderStub sender;
- cb->start(sender, framework::MilliSecTime(0));
+ cb->start(sender);
ASSERT_EQ("Update => 0,Update => 1,Update => 2", sender.getCommands(true));
replyToMessage(*cb, sender, 0, 100); // Newly created
diff --git a/storage/src/tests/distributor/visitoroperationtest.cpp b/storage/src/tests/distributor/visitoroperationtest.cpp
index 6c597b620dd..ecfa7232def 100644
--- a/storage/src/tests/distributor/visitoroperationtest.cpp
+++ b/storage/src/tests/distributor/visitoroperationtest.cpp
@@ -41,7 +41,7 @@ struct VisitorOperationTest : Test, DistributorStripeTestUtil {
document::BucketId nullId;
VisitorOperation::Config defaultConfig;
- api::CreateVisitorCommand::SP
+ static api::CreateVisitorCommand::SP
createVisitorCommand(std::string instanceId,
document::BucketId superBucket,
document::BucketId lastBucket,
@@ -122,7 +122,7 @@ struct VisitorOperationTest : Test, DistributorStripeTestUtil {
*/
std::string runEmptyVisitor(api::CreateVisitorCommand::SP msg) {
auto op = createOpWithDefaultConfig(std::move(msg));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
return _sender.getLastReply();
}
@@ -178,7 +178,7 @@ VisitorOperationTest::doStandardVisitTest(const std::string& clusterState)
auto op = createOpWithDefaultConfig(std::move(msg));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -228,7 +228,7 @@ TEST_F(VisitorOperationTest, shutdown) {
auto op = createOpWithDefaultConfig(std::move(msg));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -296,7 +296,7 @@ TEST_F(VisitorOperationTest, no_resend_after_timeout_passed) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("lowtimeoutbusy", id, nullId, 8, 20ms));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -346,7 +346,7 @@ TEST_F(VisitorOperationTest, user_single_bucket) {
"dumpvisitor",
"true"));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true)) << _sender.getLastReply();
sendReply(*op);
@@ -371,7 +371,7 @@ VisitorOperationTest::runVisitor(document::BucketId id,
"dumpvisitor",
"true"));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
sendReply(*op);
@@ -437,7 +437,7 @@ TEST_F(VisitorOperationTest, bucket_removed_while_visitor_pending) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("removefrombucketdb", id, nullId));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -459,7 +459,7 @@ TEST_F(VisitorOperationTest, empty_buckets_visited_when_visiting_removes) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("emptybucket", id, nullId, 8, 500ms, false, true));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
// Since visitRemoves is true, the empty bucket will be visited
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -474,7 +474,7 @@ TEST_F(VisitorOperationTest, resend_to_other_storage_node_on_failure) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("emptyinconsistent", id, nullId));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -502,7 +502,7 @@ TEST_F(VisitorOperationTest, timeout_only_after_reply_from_all_storage_nodes) {
nullId,
8));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0,Visitor Create => 1",
_sender.getCommands(true));
@@ -539,7 +539,7 @@ TEST_F(VisitorOperationTest, timeout_does_not_override_critical_error) {
8,
500ms)); // ms timeout
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0,Visitor Create => 1",
_sender.getCommands(true));
@@ -614,7 +614,7 @@ TEST_F(VisitorOperationTest, bucket_high_bit_count) {
"dumpvisitor",
"true"));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
EXPECT_EQ("Visitor Create => 0", _sender.getCommands(true));
}
@@ -640,7 +640,7 @@ TEST_F(VisitorOperationTest, bucket_low_bit_count) {
"dumpvisitor",
"true"));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
EXPECT_EQ("CreateVisitorReply(last=BucketId(0x0000000000000000)) "
"ReturnCode(WRONG_DISTRIBUTION, distributor:1 storage:1)",
_sender.getLastReply());
@@ -661,7 +661,7 @@ TEST_F(VisitorOperationTest, parallel_visitors_to_one_storage_node) {
createVisitorCommand("multiplebuckets", id, nullId, 31),
VisitorOperation::Config(1, 4));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0,Visitor Create => 0,"
"Visitor Create => 0,Visitor Create => 0",
@@ -708,7 +708,7 @@ TEST_F(VisitorOperationTest, parallel_visitors_to_one_storage_node) {
createVisitorCommand("multiplebuckets", id, document::BucketId(0x54000000000f0001), 31),
VisitorOperation::Config(minBucketsPerVisitor, maxVisitorsPerNode));
- op2->start(_sender, framework::MilliSecTime(0));
+ op2->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -736,7 +736,7 @@ TEST_F(VisitorOperationTest, parallel_visitors_resend_only_failing) {
createVisitorCommand("multiplebuckets", id, nullId, 31),
VisitorOperation::Config(minBucketsPerVisitor, maxVisitorsPerNode));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0,Visitor Create => 0,"
"Visitor Create => 0,Visitor Create => 0",
@@ -775,7 +775,7 @@ TEST_F(VisitorOperationTest, parallel_visitors_to_one_storage_node_one_super_buc
createVisitorCommand("multiplebucketsonesuper", id, nullId),
VisitorOperation::Config(5, 4));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -833,7 +833,7 @@ TEST_F(VisitorOperationTest, inconsistency_handling) {
createVisitorCommand("multiplebucketsonesuper", id, nullId, 8, 500ms, true),
VisitorOperation::Config(5, 4));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 1", _sender.getCommands(true));
@@ -858,7 +858,7 @@ TEST_F(VisitorOperationTest, visit_ideal_node) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("multinode", id, nullId, 8));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -889,7 +889,7 @@ TEST_F(VisitorOperationTest, no_resending_on_critical_failure) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("multinodefailurecritical", id, nullId, 8));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -913,7 +913,7 @@ TEST_F(VisitorOperationTest, failure_on_all_nodes) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("multinodefailurecritical", id, nullId, 8));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
@@ -992,7 +992,7 @@ VisitorOperationTest::startOperationWith2StorageNodeVisitors(bool inconsistent)
500ms,
inconsistent));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
assert(_sender.getCommands(true) == "Visitor Create => 0,Visitor Create => 1");
return op;
@@ -1043,7 +1043,7 @@ TEST_F(VisitorOperationTest, queue_timeout_is_factor_of_total_timeout) {
auto op = createOpWithDefaultConfig(
createVisitorCommand("foo", id, nullId, 8, 10000ms));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
auto& cmd = dynamic_cast<CreateVisitorCommand&>(*_sender.command(0));
@@ -1061,7 +1061,7 @@ VisitorOperationTest::do_visitor_roundtrip_with_statistics(
auto op = createOpWithDefaultConfig(
createVisitorCommand("metricstats", id, nullId));
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
auto& cmd = dynamic_cast<CreateVisitorCommand&>(*_sender.command(0));
auto reply = cmd.makeReply();
@@ -1109,7 +1109,7 @@ TEST_F(VisitorOperationTest, assigning_put_lock_access_token_sets_special_visito
auto op = createOpWithDefaultConfig(createVisitorCommand("metricstats", id, nullId));
op->assign_put_lock_access_token("its-a me, mario");
- op->start(_sender, framework::MilliSecTime(0));
+ op->start(_sender);
ASSERT_EQ("Visitor Create => 0", _sender.getCommands(true));
auto cmd = std::dynamic_pointer_cast<api::CreateVisitorCommand>(_sender.command(0));
ASSERT_TRUE(cmd);
diff --git a/storage/src/tests/storageframework/clock/timetest.cpp b/storage/src/tests/storageframework/clock/timetest.cpp
index e1270156aa0..9dbcdd409d8 100644
--- a/storage/src/tests/storageframework/clock/timetest.cpp
+++ b/storage/src/tests/storageframework/clock/timetest.cpp
@@ -8,16 +8,12 @@ namespace storage::framework::defaultimplementation {
TEST(TimeTest, testBasics)
{
- SecondTime timeSec(1);
- MilliSecTime timeMillis = timeSec.getMillis();
+ MilliSecTime timeMillis(1000);
EXPECT_EQ(uint64_t(1000), timeMillis.getTime());
- EXPECT_EQ(timeSec, timeMillis.getSeconds());
- MicroSecTime timeMicros = timeSec.getMicros();
- EXPECT_EQ(timeSec.getMicros(), timeMillis.getMicros());
+ MicroSecTime timeMicros = timeMillis.getMicros();
EXPECT_EQ(timeMillis, timeMicros.getMillis());
- EXPECT_EQ(timeSec, timeMicros.getSeconds());
MicroSecTime timeMicros2 = timeMicros;
EXPECT_EQ(timeMicros2, timeMicros);
@@ -32,7 +28,6 @@ TEST(TimeTest, testBasics)
MilliSecTime timeMillis2 = timeMicros2.getMillis();
EXPECT_GT(timeMillis2, timeMillis);
EXPECT_EQ(uint64_t(1050), timeMillis2.getTime());
- EXPECT_EQ(timeSec, timeMillis2.getSeconds());
}
TEST(TimeTest, testCreatedFromClock)
@@ -40,7 +35,6 @@ TEST(TimeTest, testCreatedFromClock)
defaultimplementation::FakeClock clock;
clock.setAbsoluteTimeInSeconds(600);
- EXPECT_EQ(SecondTime(600), SecondTime(clock));
EXPECT_EQ(MilliSecTime(600 * 1000), MilliSecTime(clock));
EXPECT_EQ(MicroSecTime(600 * 1000 * 1000), MicroSecTime(clock));
}
@@ -51,7 +45,6 @@ TEST(TimeTest, canAssignMicrosecondResolutionTimeToFakeClock)
clock.setAbsoluteTimeInMicroSeconds(1234567); // 1.234567 seconds
// All non-microsec time points must necessarily be truncated.
- EXPECT_EQ(SecondTime(1), SecondTime(clock));
EXPECT_EQ(MilliSecTime(1234), MilliSecTime(clock));
EXPECT_EQ(MicroSecTime(1234567), MicroSecTime(clock));
}
diff --git a/storage/src/vespa/storage/common/statusmetricconsumer.cpp b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
index 9ffb044b0a5..e9360c35f3c 100644
--- a/storage/src/vespa/storage/common/statusmetricconsumer.cpp
+++ b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
@@ -15,32 +15,20 @@ LOG_SETUP(".status.metricreporter");
namespace storage {
-StatusMetricConsumer::StatusMetricConsumer(
- StorageComponentRegister& compReg, metrics::MetricManager& manager,
- const std::string& name)
+StatusMetricConsumer::StatusMetricConsumer(StorageComponentRegister& compReg, metrics::MetricManager& manager, const std::string& name)
: framework::StatusReporter("metrics", "Performance metrics"),
_manager(manager),
_component(compReg, "statusmetricsconsumer"),
_name(name),
- _lock(),
- _startTime(_component.getClock().getTimeInSeconds()),
- _processedTime(0)
+ _lock()
{
LOG(debug, "Started metrics consumer");
setlocale(LC_NUMERIC, "");
- _component.registerMetricUpdateHook(*this, 3600s);
_component.registerStatusPage(*this);
}
StatusMetricConsumer::~StatusMetricConsumer() = default;
-void
-StatusMetricConsumer::updateMetrics(const MetricLockGuard & guard)
-{
- metrics::MemoryConsumption::UP mc(_manager.getMemoryConsumption(guard));
- // TODO is this hook needed anymore?
-}
-
vespalib::string
StatusMetricConsumer::getReportContentType(const framework::HttpUrlPath& path) const
{
@@ -77,7 +65,7 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
} else {
LOG(debug, "Not calling update hooks as dontcallupdatehooks option has been given");
}
- framework::SecondTime currentTime(_component.getClock().getTimeInSeconds());
+ int64_t currentTimeS(vespalib::count_s(_component.getClock().getMonotonicTime().time_since_epoch()));
bool xml = (path.getAttribute("format") == "xml");
bool json = (path.getAttribute("format") == "json");
@@ -89,7 +77,7 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
if (path.hasAttribute("task") && path.getAttribute("task") == "reset") {
std::lock_guard guard(_lock);
- _manager.reset(currentTime.getTime());
+ _manager.reset(currentTimeS);
}
if (path.hasAttribute("interval")) {
@@ -100,7 +88,7 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
const metrics::MetricSnapshot* snapshot;
if (interval == -2) {
snapshot = &_manager.getActiveMetrics(metricLock);
- _manager.getActiveMetrics(metricLock).setToTime(currentTime.getTime());
+ _manager.getActiveMetrics(metricLock).setToTime(currentTimeS);
} else if (interval == -1) {
// "Prime" the metric structure by first fetching the set of active
// metrics (complete with structure) and resetting these. This
@@ -112,19 +100,17 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
_manager.getActiveMetrics(metricLock).getMetrics(),
copyUnset);
generated->reset(0);
- _manager.getTotalMetricSnapshot(metricLock).addToSnapshot(*generated, currentTime.getTime());
- _manager.getActiveMetrics(metricLock).addToSnapshot(*generated, currentTime.getTime());
+ _manager.getTotalMetricSnapshot(metricLock).addToSnapshot(*generated, currentTimeS);
+ _manager.getActiveMetrics(metricLock).addToSnapshot(*generated, currentTimeS);
generated->setFromTime(_manager.getTotalMetricSnapshot(metricLock).getFromTime());
snapshot = generated.get();
} else if (interval == 0) {
if (copyUnset) {
generated = std::make_unique<metrics::MetricSnapshot>(
- _manager.getTotalMetricSnapshot(metricLock).getName(),
- 0,
- _manager.getActiveMetrics(metricLock).getMetrics(),
- true);
+ _manager.getTotalMetricSnapshot(metricLock).getName(), 0,
+ _manager.getActiveMetrics(metricLock).getMetrics(), true);
generated->reset(0);
- _manager.getTotalMetricSnapshot(metricLock).addToSnapshot(*generated, currentTime.getTime());
+ _manager.getTotalMetricSnapshot(metricLock).addToSnapshot(*generated, currentTimeS);
snapshot = generated.get();
} else {
snapshot = &_manager.getTotalMetricSnapshot(metricLock);
@@ -136,7 +122,7 @@ StatusMetricConsumer::reportStatus(std::ostream& out,
_manager.getActiveMetrics(metricLock).getMetrics(), true);
generated->reset(0);
_manager.getMetricSnapshot(metricLock, interval, temporarySnap)
- .addToSnapshot(*generated, currentTime.getTime());
+ .addToSnapshot(*generated, currentTimeS);
snapshot = generated.get();
} else {
snapshot = &_manager.getMetricSnapshot(metricLock, interval, temporarySnap);
diff --git a/storage/src/vespa/storage/common/statusmetricconsumer.h b/storage/src/vespa/storage/common/statusmetricconsumer.h
index 337c3ea7ff0..b25c2d5db48 100644
--- a/storage/src/vespa/storage/common/statusmetricconsumer.h
+++ b/storage/src/vespa/storage/common/statusmetricconsumer.h
@@ -11,27 +11,18 @@
#include "storagecomponent.h"
#include <vespa/storageframework/generic/status/statusreporter.h>
-#include <vespa/storageframework/generic/metric/metricupdatehook.h>
-#include <vespa/vespalib/util/document_runnable.h>
-#include <vespa/metrics/metricmanager.h>
-#include <map>
+#include <vespa/vespalib/util/jsonstream.h>
namespace vespalib { class StringTokenizer; }
namespace metrics { class MetricManager; }
namespace storage {
-namespace framework { class MemoryToken; }
-
class StatusMetricConsumer : public framework::StatusReporter,
- private framework::MetricUpdateHook,
private vespalib::JsonStreamTypes
{
public:
- StatusMetricConsumer(
- StorageComponentRegister&,
- metrics::MetricManager&,
- const std::string& name = "status");
+ StatusMetricConsumer(StorageComponentRegister&, metrics::MetricManager&, const std::string& name = "status");
~StatusMetricConsumer() override;
// Metric reporting requires the "vespa.content.metrics_api" capability
@@ -40,14 +31,11 @@ public:
}
vespalib::string getReportContentType(const framework::HttpUrlPath&) const override;
bool reportStatus(std::ostream& out, const framework::HttpUrlPath&) const override;
- void updateMetrics(const MetricLockGuard & guard) override;
private:
metrics::MetricManager& _manager;
StorageComponent _component;
std::string _name;
mutable std::mutex _lock;
- framework::SecondTime _startTime;
- framework::SecondTime _processedTime;
};
} // storage
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/operationowner.cpp b/storage/src/vespa/storage/distributor/operationowner.cpp
index 81512393c5b..4cc9bfd3ca7 100644
--- a/storage/src/vespa/storage/distributor/operationowner.cpp
+++ b/storage/src/vespa/storage/distributor/operationowner.cpp
@@ -31,7 +31,7 @@ OperationOwner::handleReply(const std::shared_ptr<api::StorageReply>& reply)
{
std::shared_ptr<Operation> cb = _sentMessageMap.pop(reply->getMsgId());
- if (cb.get() != 0) {
+ if (cb.get() != nullptr) {
Sender sender(*this, _sender, cb);
cb->receive(sender, reply);
return true;
@@ -41,13 +41,11 @@ OperationOwner::handleReply(const std::shared_ptr<api::StorageReply>& reply)
}
bool
-OperationOwner::start(const std::shared_ptr<Operation>& operation,
- Priority priority)
+OperationOwner::start(const std::shared_ptr<Operation>& operation, Priority)
{
- (void) priority;
LOG(spam, "Starting operation %s", operation->toString().c_str());
Sender sender(*this, _sender, operation);
- operation->start(sender, _clock.getTimeInMillis());
+ operation->start(sender, _clock.getSystemTime());
return true;
}
diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
index 2acd6068e1a..55fe2e039e1 100644
--- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp
@@ -203,7 +203,7 @@ TwoPhaseUpdateOperation::startFastPathUpdate(DistributorStripeMessageSender& sen
(_node_ctx, _op_ctx, _bucketSpace, _updateCmd, std::move(entries), _updateMetric);
UpdateOperation & op = *updateOperation;
IntermediateMessageSender intermediate(_sentMessageMap, std::move(updateOperation), sender);
- op.start(intermediate, _node_ctx.clock().getTimeInMillis());
+ op.start(intermediate, _node_ctx.clock().getSystemTime());
transitionTo(SendState::UPDATES_SENT);
if (intermediate._reply.get()) {
@@ -223,7 +223,7 @@ TwoPhaseUpdateOperation::startSafePathUpdate(DistributorStripeMessageSender& sen
GetOperation& op = *get_operation;
IntermediateMessageSender intermediate(_sentMessageMap, std::move(get_operation), sender);
_replicas_at_get_send_time = op.replicas_in_db(); // Populated at construction time, not at start()-time
- op.start(intermediate, _node_ctx.clock().getTimeInMillis());
+ op.start(intermediate, _node_ctx.clock().getSystemTime());
transitionTo(_use_initial_cheap_metadata_fetch_phase
? SendState::METADATA_GETS_SENT
@@ -322,7 +322,7 @@ TwoPhaseUpdateOperation::schedulePutsWithUpdatedDocument(std::shared_ptr<documen
auto putOperation = std::make_shared<PutOperation>(_node_ctx, _op_ctx, _bucketSpace, std::move(put), _putMetric);
PutOperation & op = *putOperation;
IntermediateMessageSender intermediate(_sentMessageMap, std::move(putOperation), sender);
- op.start(intermediate, _node_ctx.clock().getTimeInMillis());
+ op.start(intermediate, _node_ctx.clock().getSystemTime());
transitionTo(SendState::PUTS_SENT);
LOG(debug, "Update(%s): sending Puts at timestamp %" PRIu64, update_doc_id().c_str(), putTimestamp);
@@ -601,8 +601,7 @@ bool TwoPhaseUpdateOperation::replica_set_unchanged_after_get_operation() const
_bucketSpace.getBucketDatabase().getParents(_updateDocBucketId, entries);
std::vector<std::pair<document::BucketId, uint16_t>> replicas_in_db_now;
- for (uint32_t j = 0; j < entries.size(); ++j) {
- const auto& e = entries[j];
+ for (const auto & e : entries) {
for (uint32_t i = 0; i < e->getNodeCount(); i++) {
const auto& copy = e->getNodeRef(i);
replicas_in_db_now.emplace_back(e.getBucketId(), copy.getNode());
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
index 6aa243d5e99..fee891cb69e 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
@@ -13,6 +13,8 @@
#include <vespa/log/bufferedlogger.h>
LOG_SETUP(".distributor.operation.idealstate.merge");
+using vespalib::to_utc;
+using vespalib::to_string;
namespace storage::distributor {
MergeOperation::~MergeOperation() = default;
@@ -23,7 +25,7 @@ MergeOperation::getStatus() const
return
Operation::getStatus() +
vespalib::make_string(" . Sent MergeBucketCommand at %s",
- _sentMessageTime.toString().c_str());
+ to_string(to_utc(_sentMessageTime)).c_str());
}
void
@@ -33,11 +35,11 @@ MergeOperation::addIdealNodes(
std::vector<MergeMetaData>& result)
{
// Add all ideal nodes first. These are never marked source-only.
- for (uint32_t i = 0; i < idealNodes.size(); i++) {
+ for (unsigned short idealNode : idealNodes) {
const MergeMetaData* entry = nullptr;
- for (uint32_t j = 0; j < nodes.size(); j++) {
- if (idealNodes[i] == nodes[j]._nodeIndex) {
- entry = &nodes[j];
+ for (const auto & node : nodes) {
+ if (idealNode == node._nodeIndex) {
+ entry = &node;
break;
}
}
@@ -50,21 +52,20 @@ MergeOperation::addIdealNodes(
}
void
-MergeOperation::addCopiesNotAlreadyAdded(
- uint16_t redundancy,
- const std::vector<MergeMetaData>& nodes,
- std::vector<MergeMetaData>& result)
+MergeOperation::addCopiesNotAlreadyAdded(uint16_t redundancy,
+ const std::vector<MergeMetaData>& nodes,
+ std::vector<MergeMetaData>& result)
{
- for (uint32_t i = 0; i < nodes.size(); i++) {
+ for (auto node : nodes) {
bool found = false;
- for (uint32_t j = 0; j < result.size(); j++) {
- if (result[j]._nodeIndex == nodes[i]._nodeIndex) {
+ for (const auto & mergeData : result) {
+ if (mergeData._nodeIndex == node._nodeIndex) {
found = true;
}
}
if (!found) {
- result.push_back(nodes[i]);
+ result.push_back(node);
result.back()._sourceOnly = (result.size() > redundancy);
}
}
@@ -78,8 +79,7 @@ MergeOperation::generateSortedNodeList(
MergeLimiter& limiter,
std::vector<MergeMetaData>& nodes)
{
- std::vector<uint16_t> idealNodes(
- distribution.getIdealStorageNodes(state, bucketId, "ui"));
+ std::vector<uint16_t> idealNodes(distribution.getIdealStorageNodes(state, bucketId, "ui"));
std::vector<MergeMetaData> result;
const uint16_t redundancy = distribution.getRedundancy();
@@ -123,13 +123,13 @@ MergeOperation::onStart(DistributorStripeMessageSender& sender)
std::vector<std::unique_ptr<BucketCopy> > newCopies;
std::vector<MergeMetaData> nodes;
- for (uint32_t i = 0; i < getNodes().size(); ++i) {
- const BucketCopy* copy = entry->getNode(getNodes()[i]);
+ for (unsigned short node : getNodes()) {
+ const BucketCopy* copy = entry->getNode(node);
if (copy == nullptr) { // New copies?
- newCopies.emplace_back(std::make_unique<BucketCopy>(BucketCopy::recentlyCreatedCopy(0, getNodes()[i])));
+ newCopies.emplace_back(std::make_unique<BucketCopy>(BucketCopy::recentlyCreatedCopy(0, node)));
copy = newCopies.back().get();
}
- nodes.emplace_back(getNodes()[i], *copy);
+ nodes.emplace_back(node, *copy);
}
_infoBefore = entry.getBucketInfo();
@@ -169,7 +169,7 @@ MergeOperation::onStart(DistributorStripeMessageSender& sender)
sender.sendToNode(lib::NodeType::STORAGE, _mnodes[0].index, msg);
- _sentMessageTime = _manager->node_context().clock().getTimeInSeconds();
+ _sentMessageTime = _manager->node_context().clock().getMonotonicTime();
} else {
LOGBP(debug,
"Unable to merge bucket %s, since only one copy is available. System state %s",
@@ -184,26 +184,26 @@ MergeOperation::sourceOnlyCopyChangedDuringMerge(
const BucketDatabase::Entry& currentState) const
{
assert(currentState.valid());
- for (size_t i = 0; i < _mnodes.size(); ++i) {
- const BucketCopy* copyBefore(_infoBefore.getNode(_mnodes[i].index));
+ for (auto _mnode : _mnodes) {
+ const BucketCopy* copyBefore(_infoBefore.getNode(_mnode.index));
if (!copyBefore) {
continue;
}
- const BucketCopy* copyAfter(currentState->getNode(_mnodes[i].index));
+ const BucketCopy* copyAfter(currentState->getNode(_mnode.index));
if (!copyAfter) {
LOG(debug, "Copy of %s on node %u removed during merge. Was %s",
getBucketId().toString().c_str(),
- _mnodes[i].index,
+ _mnode.index,
copyBefore->toString().c_str());
continue;
}
- if (_mnodes[i].sourceOnly
+ if (_mnode.sourceOnly
&& !copyBefore->consistentWith(*copyAfter))
{
LOG(debug, "Source-only copy of %s on node %u changed from "
"%s to %s during the course of the merge. Failing it.",
getBucketId().toString().c_str(),
- _mnodes[i].index,
+ _mnode.index,
copyBefore->toString().c_str(),
copyAfter->toString().c_str());
return true;
@@ -220,13 +220,13 @@ MergeOperation::deleteSourceOnlyNodes(
{
assert(currentState.valid());
std::vector<uint16_t> sourceOnlyNodes;
- for (uint32_t i = 0; i < _mnodes.size(); ++i) {
- const uint16_t nodeIndex = _mnodes[i].index;
+ for (auto & _mnode : _mnodes) {
+ const uint16_t nodeIndex = _mnode.index;
const BucketCopy* copy = currentState->getNode(nodeIndex);
if (!copy) {
continue; // No point in deleting what's not even there now.
}
- if (_mnodes[i].sourceOnly) {
+ if (_mnode.sourceOnly) {
sourceOnlyNodes.push_back(nodeIndex);
}
}
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.h b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.h
index 5416df3a43d..44449633559 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.h
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.h
@@ -20,7 +20,7 @@ class MergeOperation : public IdealStateOperation
protected:
bool sourceOnlyCopyChangedDuringMerge(const BucketDatabase::Entry&) const;
- framework::SecondTime _sentMessageTime;
+ vespalib::steady_time _sentMessageTime;
std::vector<api::MergeBucketCommand::Node> _mnodes;
std::unique_ptr<RemoveBucketOperation> _removeOperation;
BucketInfo _infoBefore;
@@ -30,7 +30,7 @@ public:
MergeOperation(const BucketAndNodes& nodes, uint16_t maxNodes = 16)
: IdealStateOperation(nodes),
- _sentMessageTime(0),
+ _sentMessageTime(),
_limiter(maxNodes)
{}
diff --git a/storage/src/vespa/storage/distributor/operations/operation.cpp b/storage/src/vespa/storage/distributor/operations/operation.cpp
index a48fb53a7ce..4d82de170ae 100644
--- a/storage/src/vespa/storage/distributor/operations/operation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/operation.cpp
@@ -12,7 +12,7 @@ LOG_SETUP(".distributor.callback");
namespace storage::distributor {
Operation::Operation()
- : _startTime(0)
+ : _startTime()
{
}
@@ -21,19 +21,23 @@ Operation::~Operation() = default;
std::string
Operation::getStatus() const
{
- return vespalib::make_string("%s (started %s)",
- getName(), _startTime.toString().c_str());
+ return vespalib::make_string("%s (started %s)", getName(), vespalib::to_string(_startTime).c_str());
}
void
-Operation::start(DistributorStripeMessageSender& sender,
- framework::MilliSecTime startTime)
+Operation::start(DistributorStripeMessageSender& sender, vespalib::system_time startTime)
{
_startTime = startTime;
onStart(sender);
}
void
+Operation::start(DistributorStripeMessageSender& sender)
+{
+ start(sender, vespalib::system_time());
+}
+
+void
Operation::copyMessageSettings(const api::StorageCommand& source, api::StorageCommand& target)
{
target.getTrace().setLevel(source.getTrace().getLevel());
diff --git a/storage/src/vespa/storage/distributor/operations/operation.h b/storage/src/vespa/storage/distributor/operations/operation.h
index e24aa976221..8bb81b8d365 100644
--- a/storage/src/vespa/storage/distributor/operations/operation.h
+++ b/storage/src/vespa/storage/distributor/operations/operation.h
@@ -45,24 +45,25 @@ public:
onReceive(sender, msg);
}
- virtual const char* getName() const noexcept = 0;
+ [[nodiscard]] virtual const char* getName() const noexcept = 0;
- virtual std::string getStatus() const;
+ [[nodiscard]] virtual std::string getStatus() const;
- virtual std::string toString() const {
+ [[nodiscard]] virtual std::string toString() const {
return std::string(getName());
}
/**
Starts the callback, sending any messages etc. Sets _startTime to current time
*/
- virtual void start(DistributorStripeMessageSender& sender, framework::MilliSecTime startTime);
+ virtual void start(DistributorStripeMessageSender& sender, vespalib::system_time startTime);
+ void start(DistributorStripeMessageSender& sender);
/**
* Returns true if we are blocked to start this operation given
* the pending messages.
*/
- virtual bool isBlocked(const DistributorStripeOperationContext&, const OperationSequencer&) const {
+ [[nodiscard]] virtual bool isBlocked(const DistributorStripeOperationContext&, const OperationSequencer&) const {
return false;
}
@@ -77,11 +78,6 @@ public:
virtual void on_throttled();
/**
- Returns the timestamp on which the first message was sent from this callback.
- */
- framework::MilliSecTime getStartTime() const { return _startTime; }
-
- /**
Transfers message settings such as priority, timeout, etc. from one message to another.
*/
static void copyMessageSettings(const api::StorageCommand& source,
@@ -97,7 +93,7 @@ private:
const std::shared_ptr<api::StorageReply> & msg) = 0;
protected:
- framework::MilliSecTime _startTime;
+ vespalib::system_time _startTime;
};
}
diff --git a/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp b/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp
index 533493a79a2..6b186c54fbf 100644
--- a/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp
+++ b/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp
@@ -3,7 +3,6 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <map>
-#include <algorithm>
#include <vespa/log/log.h>
LOG_SETUP(".pendingmessages");
diff --git a/storage/src/vespa/storage/distributor/pendingmessagetracker.h b/storage/src/vespa/storage/distributor/pendingmessagetracker.h
index 93238b5a83f..7adf9d4a43e 100644
--- a/storage/src/vespa/storage/distributor/pendingmessagetracker.h
+++ b/storage/src/vespa/storage/distributor/pendingmessagetracker.h
@@ -74,7 +74,7 @@ public:
* semantically correct to use std::chrono::time_point, but it is bound
* to specific chrono clock types, their epochs and duration resolution.
*/
- using TimePoint = std::chrono::milliseconds;
+ using TimePoint = vespalib::duration;
PendingMessageTracker(framework::ComponentRegister&, uint32_t stripe_index);
~PendingMessageTracker() override;
diff --git a/storage/src/vespa/storage/distributor/throttlingoperationstarter.h b/storage/src/vespa/storage/distributor/throttlingoperationstarter.h
index a0613c60fa4..8b6ade7e7d1 100644
--- a/storage/src/vespa/storage/distributor/throttlingoperationstarter.h
+++ b/storage/src/vespa/storage/distributor/throttlingoperationstarter.h
@@ -13,9 +13,9 @@ class ThrottlingOperationStarter : public OperationStarter, public PendingWindow
class ThrottlingOperation : public Operation
{
public:
- ThrottlingOperation(const Operation::SP& operation,
+ ThrottlingOperation(Operation::SP operation,
ThrottlingOperationStarter& operationStarter)
- : _operation(operation),
+ : _operation(std::move(operation)),
_operationStarter(operationStarter)
{}
@@ -30,24 +30,21 @@ class ThrottlingOperationStarter : public OperationStarter, public PendingWindow
void onClose(DistributorStripeMessageSender& sender) override {
_operation->onClose(sender);
}
- const char* getName() const noexcept override {
+ [[nodiscard]] const char* getName() const noexcept override {
return _operation->getName();
}
- std::string getStatus() const override {
+ [[nodiscard]] std::string getStatus() const override {
return _operation->getStatus();
}
- std::string toString() const override {
+ [[nodiscard]] std::string toString() const override {
return _operation->toString();
}
- void start(DistributorStripeMessageSender& sender, framework::MilliSecTime startTime) override {
+ void start(DistributorStripeMessageSender& sender, vespalib::system_time startTime) override {
_operation->start(sender, startTime);
}
void receive(DistributorStripeMessageSender& sender, const std::shared_ptr<api::StorageReply> & msg) override {
_operation->receive(sender, msg);
}
- framework::MilliSecTime getStartTime() const {
- return _operation->getStartTime();
- }
void onStart(DistributorStripeMessageSender&) override {
// Should never be called directly on the throttled operation
// instance, but rather on its wrapped implementation.
@@ -61,7 +58,7 @@ class ThrottlingOperationStarter : public OperationStarter, public PendingWindow
OperationStarter& _starterImpl;
public:
- ThrottlingOperationStarter(OperationStarter& starterImpl)
+ explicit ThrottlingOperationStarter(OperationStarter& starterImpl)
: _starterImpl(starterImpl),
_minPending(0),
_maxPending(UINT32_MAX),
@@ -71,9 +68,9 @@ public:
bool start(const std::shared_ptr<Operation>& operation, Priority priority) override;
- bool may_allow_operation_with_priority(Priority priority) const noexcept override;
+ [[nodiscard]] bool may_allow_operation_with_priority(Priority priority) const noexcept override;
- bool canStart(uint32_t currentOperationCount, Priority priority) const;
+ [[nodiscard]] bool canStart(uint32_t currentOperationCount, Priority priority) const;
void setMaxPendingRange(uint32_t minPending, uint32_t maxPending) {
_minPending = minPending;
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
index 0680c10ab29..ec22d7c064e 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
@@ -9,7 +9,6 @@
#include <vespa/slobrok/sbmirror.h>
#include <vespa/storage/common/bucket_resolver.h>
#include <vespa/storage/common/nodestateupdater.h>
-#include <vespa/storage/config/config-stor-server.h>
#include <vespa/storage/storageserver/configurable_bucket_resolver.h>
#include <vespa/storage/storageserver/rpc/shared_rpc_resources.h>
#include <vespa/storage/storageserver/rpc/cluster_controller_api_rpc_service.h>
@@ -49,13 +48,14 @@ CommunicationManager::receiveStorageReply(const std::shared_ptr<api::StorageRepl
}
namespace {
- vespalib::string getNodeId(StorageComponent& sc) {
- vespalib::asciistream ost;
- ost << sc.cluster_context().cluster_name() << "/" << sc.getNodeType() << "/" << sc.getIndex();
- return ost.str();
- }
- framework::SecondTime TEN_MINUTES(600);
+vespalib::string getNodeId(StorageComponent& sc) {
+ vespalib::asciistream ost;
+ ost << sc.cluster_context().cluster_name() << "/" << sc.getNodeType() << "/" << sc.getIndex();
+ return ost.str();
+}
+
+vespalib::duration TEN_MINUTES = 600s;
}
@@ -151,8 +151,7 @@ CommunicationManager::handleReply(std::unique_ptr<mbus::Reply> reply)
std::shared_ptr<api::StorageCommand> originalCommand;
{
std::lock_guard lock(_messageBusSentLock);
- using MessageMap = std::map<api::StorageMessage::Id, api::StorageCommand::SP>;
- MessageMap::iterator iter(_messageBusSent.find(reply->getContext().value.UINT64));
+ auto iter(_messageBusSent.find(reply->getContext().value.UINT64));
if (iter != _messageBusSent.end()) {
originalCommand.swap(iter->second);
_messageBusSent.erase(iter);
@@ -193,13 +192,13 @@ void CommunicationManager::fail_with_unresolvable_bucket_space(
namespace {
struct PlaceHolderBucketResolver : public BucketResolver {
- document::Bucket bucketFromId(const document::DocumentId &) const override {
- return document::Bucket(FixedBucketSpaces::default_space(), document::BucketId(0));
+ [[nodiscard]] document::Bucket bucketFromId(const document::DocumentId &) const override {
+ return {FixedBucketSpaces::default_space(), document::BucketId(0)};
}
- document::BucketSpace bucketSpaceFromName(const vespalib::string &) const override {
+ [[nodiscard]] document::BucketSpace bucketSpaceFromName(const vespalib::string &) const override {
return FixedBucketSpaces::default_space();
}
- vespalib::string nameFromBucketSpace(const document::BucketSpace &bucketSpace) const override {
+ [[nodiscard]] vespalib::string nameFromBucketSpace(const document::BucketSpace &bucketSpace) const override {
assert(bucketSpace == FixedBucketSpaces::default_space());
return FixedBucketSpaces::to_string(bucketSpace);
}
@@ -438,7 +437,7 @@ CommunicationManager::process(const std::shared_ptr<api::StorageMessage>& msg)
void CommunicationManager::dispatch_sync(std::shared_ptr<api::StorageMessage> msg) {
LOG(spam, "Direct dispatch of storage message %s, priority %d", msg->toString().c_str(), msg->getPriority());
- process(std::move(msg));
+ process(msg);
}
void CommunicationManager::dispatch_async(std::shared_ptr<api::StorageMessage> msg) {
@@ -451,7 +450,7 @@ CommunicationManager::onUp(const std::shared_ptr<api::StorageMessage> & msg)
{
MBUS_TRACE(msg->getTrace(), 6, "Communication manager: Sending " + msg->toString());
if (msg->getType().isReply()) {
- const api::StorageReply & m = static_cast<const api::StorageReply&>(*msg);
+ const auto & m = static_cast<const api::StorageReply&>(*msg);
if (m.getResult().failed()) {
LOG(debug, "Request %s failed: %s", msg->getType().toString().c_str(), m.getResult().toString().c_str());
}
@@ -604,7 +603,7 @@ CommunicationManager::sendDirectRPCReply(
request.addReturnString(m.data(), m.size());
if (reply->getType() == api::MessageType::GETNODESTATE_REPLY) {
- api::GetNodeStateReply& gns(static_cast<api::GetNodeStateReply&>(*reply));
+ auto& gns(static_cast<api::GetNodeStateReply&>(*reply));
std::ostringstream ns;
serializeNodeState(gns, ns, false);
request.addReturnString(ns.str().c_str());
@@ -693,9 +692,9 @@ CommunicationManager::run(framework::ThreadHandle& thread)
process(msg);
}
std::lock_guard<std::mutex> guard(_earlierGenerationsLock);
- for (EarlierProtocols::iterator it(_earlierGenerations.begin());
+ for (auto it(_earlierGenerations.begin());
!_earlierGenerations.empty() &&
- ((it->first + TEN_MINUTES) < _component.getClock().getTimeInSeconds());
+ ((it->first + TEN_MINUTES) < _component.getClock().getMonotonicTime());
it = _earlierGenerations.begin())
{
_earlierGenerations.erase(it);
@@ -718,10 +717,10 @@ CommunicationManager::print(std::ostream& out, bool verbose, const std::string&
void CommunicationManager::updateMessagebusProtocol(const std::shared_ptr<const document::DocumentTypeRepo>& repo) {
if (_mbus) {
- framework::SecondTime now(_component.getClock().getTimeInSeconds());
+ vespalib::steady_time now(_component.getClock().getMonotonicTime());
auto newDocumentProtocol = std::make_shared<documentapi::DocumentProtocol>(repo);
std::lock_guard<std::mutex> guard(_earlierGenerationsLock);
- _earlierGenerations.push_back(std::make_pair(now, _mbus->getMessageBus().putProtocol(newDocumentProtocol)));
+ _earlierGenerations.emplace_back(now, _mbus->getMessageBus().putProtocol(newDocumentProtocol));
}
if (_message_codec_provider) {
_message_codec_provider->update_atomically(repo);
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.h b/storage/src/vespa/storage/storageserver/communicationmanager.h
index 6f953411cac..e83a6517c45 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.h
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.h
@@ -72,9 +72,6 @@ class CommunicationManager final
public MessageDispatcher
{
private:
- CommunicationManager(const CommunicationManager&);
- CommunicationManager& operator=(const CommunicationManager&);
-
StorageComponent _component;
CommunicationManagerMetrics _metrics;
@@ -85,7 +82,7 @@ private:
Queue _eventQueue;
// XXX: Should perhaps use a configsubscriber and poll from StorageComponent ?
std::unique_ptr<config::ConfigFetcher> _configFetcher;
- using EarlierProtocol = std::pair<framework::SecondTime, mbus::IProtocol::SP>;
+ using EarlierProtocol = std::pair<vespalib::steady_time , mbus::IProtocol::SP>;
using EarlierProtocols = std::vector<EarlierProtocol>;
std::mutex _earlierGenerationsLock;
EarlierProtocols _earlierGenerations;
@@ -126,6 +123,8 @@ private:
friend struct CommunicationManagerTest;
public:
+ CommunicationManager(const CommunicationManager&) = delete;
+ CommunicationManager& operator=(const CommunicationManager&) = delete;
CommunicationManager(StorageComponentRegister& compReg,
const config::ConfigUri & configUri);
~CommunicationManager() override;
diff --git a/storage/src/vespa/storage/storageserver/opslogger.cpp b/storage/src/vespa/storage/storageserver/opslogger.cpp
index 03322cb55fd..e5785968eb1 100644
--- a/storage/src/vespa/storage/storageserver/opslogger.cpp
+++ b/storage/src/vespa/storage/storageserver/opslogger.cpp
@@ -77,7 +77,7 @@ OpsLogger::onPutReply(const std::shared_ptr<api::PutReply>& msg)
{
if (_targetFile == nullptr) return false;
std::ostringstream ost;
- ost << _component.getClock().getTimeInSeconds().getTime()
+ ost << vespalib::to_string(_component.getClock().getSystemTime())
<< "\tPUT\t" << msg->getDocumentId() << "\t"
<< msg->getResult() << "\n";
{
@@ -94,7 +94,7 @@ OpsLogger::onUpdateReply(const std::shared_ptr<api::UpdateReply>& msg)
{
if (_targetFile == nullptr) return false;
std::ostringstream ost;
- ost << _component.getClock().getTimeInSeconds().getTime()
+ ost << vespalib::to_string(_component.getClock().getSystemTime())
<< "\tUPDATE\t" << msg->getDocumentId() << "\t"
<< msg->getResult() << "\n";
{
@@ -111,7 +111,7 @@ OpsLogger::onRemoveReply(const std::shared_ptr<api::RemoveReply>& msg)
{
if (_targetFile == nullptr) return false;
std::ostringstream ost;
- ost << _component.getClock().getTimeInSeconds().getTime()
+ ost << vespalib::to_string(_component.getClock().getSystemTime())
<< "\tREMOVE\t" << msg->getDocumentId() << "\t"
<< msg->getResult() << "\n";
{
@@ -128,7 +128,7 @@ OpsLogger::onGetReply(const std::shared_ptr<api::GetReply>& msg)
{
if (_targetFile == nullptr) return false;
std::ostringstream ost;
- ost << _component.getClock().getTimeInSeconds().getTime()
+ ost << vespalib::to_string(_component.getClock().getSystemTime())
<< "\tGET\t" << msg->getDocumentId() << "\t"
<< msg->getResult() << "\n";
{
diff --git a/storage/src/vespa/storage/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp
index 81961370ed3..124655f6eaf 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>" << 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
diff --git a/storage/src/vespa/storage/storageserver/statereporter.cpp b/storage/src/vespa/storage/storageserver/statereporter.cpp
index b2337ae1223..373cd186708 100644
--- a/storage/src/vespa/storage/storageserver/statereporter.cpp
+++ b/storage/src/vespa/storage/storageserver/statereporter.cpp
@@ -29,9 +29,7 @@ StateReporter::StateReporter(
_component.registerStatusPage(*this);
}
-StateReporter::~StateReporter()
-{
-}
+StateReporter::~StateReporter() = default;
vespalib::string
StateReporter::getReportContentType(
@@ -84,7 +82,7 @@ StateReporter::getMetrics(const vespalib::string &consumer)
snapshot.reset(0);
_manager.getMetricSnapshot(guard, interval).addToSnapshot(
- snapshot, _component.getClock().getTimeInSeconds().getTime());
+ snapshot, vespalib::count_s(_component.getClock().getSystemTime().time_since_epoch()));
vespalib::asciistream json;
vespalib::JsonStream stream(json);
@@ -106,7 +104,7 @@ StateReporter::getHealth() const
lib::NodeState cns(*_component.getStateUpdater().getCurrentNodeState());
bool up = cns.getState().oneOf("u");
std::string message = up ? "" : "Node state: " + cns.toString(true);
- return vespalib::HealthProducer::Health(up, message);
+ return { up, message };
}
void
diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp
index 3987827a264..5ece2a12f71 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.cpp
+++ b/storage/src/vespa/storage/storageserver/storagenode.cpp
@@ -372,7 +372,7 @@ StorageNode::shutdown()
_chain->flush();
}
- if (_pidFile != "") {
+ if ( !_pidFile.empty() ) {
LOG(debug, "Removing pid file");
removePidFile(_pidFile);
}
@@ -510,10 +510,8 @@ StorageNode::updateMetrics(const MetricLockGuard &) {
}
void
-StorageNode::waitUntilInitialized(uint32_t timeout) {
- framework::defaultimplementation::RealClock clock;
- framework::MilliSecTime endTime(
- clock.getTimeInMillis() + framework::MilliSecTime(1000 * timeout));
+StorageNode::waitUntilInitialized(vespalib::duration timeout) {
+ vespalib::steady_time doom = vespalib::steady_clock::now();
while (true) {
{
NodeStateUpdater::Lock::SP lock(_component->getStateUpdater().grabStateChangeLock());
@@ -521,7 +519,7 @@ StorageNode::waitUntilInitialized(uint32_t timeout) {
if (nodeState.getState() == lib::State::UP) break;
}
std::this_thread::sleep_for(10ms);
- if (clock.getTimeInMillis() >= endTime) {
+ if (vespalib::steady_clock::now() >= doom) {
std::ostringstream ost;
ost << "Storage server not initialized after waiting timeout of "
<< timeout << " seconds.";
diff --git a/storage/src/vespa/storage/storageserver/storagenode.h b/storage/src/vespa/storage/storageserver/storagenode.h
index 0e420f206e2..19b930c184f 100644
--- a/storage/src/vespa/storage/storageserver/storagenode.h
+++ b/storage/src/vespa/storage/storageserver/storagenode.h
@@ -78,7 +78,7 @@ public:
virtual const lib::NodeType& getNodeType() const = 0;
bool attemptedStopped() const;
void notifyDoneInitializing() override;
- void waitUntilInitialized(uint32_t timeoutSeconds = 15);
+ void waitUntilInitialized(vespalib::duration timeout = 15s);
void updateMetrics(const MetricLockGuard & guard) override;
/** Updates the document type repo. */
diff --git a/storage/src/vespa/storage/visiting/visitormanager.cpp b/storage/src/vespa/storage/visiting/visitormanager.cpp
index a03b9a9a8a3..07938002746 100644
--- a/storage/src/vespa/storage/visiting/visitormanager.cpp
+++ b/storage/src/vespa/storage/visiting/visitormanager.cpp
@@ -187,9 +187,8 @@ VisitorManager::configure(std::unique_ptr<vespa::config::content::core::StorVisi
for (int32_t i=0; i<config->visitorthreads; ++i) {
_visitorThread.emplace_back(
// Naked new due to a lot of private inheritance in VisitorThread and VisitorManager
- std::shared_ptr<VisitorThread>(
- new VisitorThread(i, _componentRegister, _messageSessionFactory,
- _visitorFactories, *_metrics->threads[i], *this)),
+ std::shared_ptr<VisitorThread>(new VisitorThread(i, _componentRegister, _messageSessionFactory,
+ _visitorFactories, *_metrics->threads[i], *this)),
std::map<api::VisitorId, std::string>());
}
}
@@ -450,8 +449,7 @@ VisitorManager::processReply(const std::shared_ptr<api::StorageReply>& reply)
}
void
-VisitorManager::send(const std::shared_ptr<api::StorageCommand>& cmd,
- Visitor& visitor)
+VisitorManager::send(const std::shared_ptr<api::StorageCommand>& cmd, Visitor& visitor)
{
assert(cmd->getType() == api::MessageType::INTERNAL);
// Only add to internal state if not destroy iterator command, as
@@ -460,7 +458,7 @@ VisitorManager::send(const std::shared_ptr<api::StorageCommand>& cmd,
if (static_cast<const api::InternalCommand&>(*cmd).getType() != DestroyIteratorCommand::ID) {
MessageInfo inf;
inf.id = visitor.getVisitorId();
- inf.timestamp = _component.getClock().getTimeInSeconds().getTime();
+ inf.timestamp = _component.getClock().getSystemTime();
inf.timeout = cmd->getTimeout();
if (cmd->getAddress()) {
@@ -623,7 +621,7 @@ VisitorManager::reportHtmlStatus(std::ostream& out,
out << "<tr>"
<< "<td>" << entry.first << "</td>"
<< "<td>" << entry.second.id << "</td>"
- << "<td>" << entry.second.timestamp << "</td>"
+ << "<td>" << vespalib::to_string(entry.second.timestamp) << "</td>"
<< "<td>" << vespalib::count_ms(entry.second.timeout) << "</td>"
<< "<td>" << xml_content_escaped(entry.second.destination) << "</td>"
<< "</tr>\n";
diff --git a/storage/src/vespa/storage/visiting/visitormanager.h b/storage/src/vespa/storage/visiting/visitormanager.h
index 33703b392bc..8d8a0fe5b6d 100644
--- a/storage/src/vespa/storage/visiting/visitormanager.h
+++ b/storage/src/vespa/storage/visiting/visitormanager.h
@@ -57,7 +57,7 @@ private:
struct MessageInfo {
api::VisitorId id;
- time_t timestamp;
+ vespalib::system_time timestamp;
vespalib::duration timeout;
std::string destination;
};
diff --git a/storage/src/vespa/storage/visiting/visitorthread.cpp b/storage/src/vespa/storage/visiting/visitorthread.cpp
index 55ef83ba658..f8f2ccd32e9 100644
--- a/storage/src/vespa/storage/visiting/visitorthread.cpp
+++ b/storage/src/vespa/storage/visiting/visitorthread.cpp
@@ -290,7 +290,7 @@ VisitorThread::close()
} else {
_metrics.completedVisitors.inc(1);
}
- framework::SecondTime currentTime(_component.getClock().getTimeInSeconds());
+ vespalib::steady_time currentTime(_component.getClock().getMonotonicTime());
trimRecentlyCompletedList(currentTime);
_recentlyCompleted.emplace_back(_currentlyRunningVisitor->first, currentTime);
_visitors.erase(_currentlyRunningVisitor);
@@ -298,9 +298,9 @@ VisitorThread::close()
}
void
-VisitorThread::trimRecentlyCompletedList(framework::SecondTime currentTime)
+VisitorThread::trimRecentlyCompletedList(vespalib::steady_time currentTime)
{
- framework::SecondTime recentLimit(currentTime - framework::SecondTime(30));
+ vespalib::steady_time recentLimit(currentTime - 30s);
// Dump all elements that aren't recent anymore
while (!_recentlyCompleted.empty()
&& _recentlyCompleted.front().second < recentLimit)
@@ -313,8 +313,7 @@ void
VisitorThread::handleNonExistingVisitorCall(const Event& entry, ReturnCode& code)
{
// Get current time. Set the time that is the oldest still recent.
- framework::SecondTime currentTime(_component.getClock().getTimeInSeconds());
- trimRecentlyCompletedList(currentTime);
+ trimRecentlyCompletedList(_component.getClock().getMonotonicTime());
// Go through all recent visitors. Ignore request if recent
for (const auto& e : _recentlyCompleted) {
@@ -344,7 +343,7 @@ VisitorThread::createVisitor(vespalib::stringref libName,
auto it = _visitorFactories.find(str);
if (it == _visitorFactories.end()) {
error << "Visitor library " << str << " not found.";
- return std::shared_ptr<Visitor>();
+ return {};
}
auto libIter = _libs.find(str);
@@ -363,7 +362,7 @@ VisitorThread::createVisitor(vespalib::stringref libName,
} catch (std::exception& e) {
error << "Failed to create visitor instance of type " << libName
<< ": " << e.what();
- return std::shared_ptr<Visitor>();
+ return {};
}
}
@@ -690,7 +689,7 @@ VisitorThread::getStatus(vespalib::asciistream& out,
}
for (const auto& cv : _recentlyCompleted) {
out << "<li> Visitor " << cv.first << " done at "
- << cv.second.getTime() << "\n";
+ << vespalib::to_string(vespalib::to_utc(cv.second)) << "\n";
}
out << "</ul>\n";
out << "<h3>Current queue size: " << _queue.size() << "</h3>\n";
@@ -736,12 +735,10 @@ VisitorThread::getStatus(vespalib::asciistream& out,
if (_visitors.empty()) {
out << "None\n";
}
- for (VisitorMap::const_iterator it = _visitors.begin();
- it != _visitors.end(); ++it)
- {
- out << "<a href=\"?visitor=" << it->first
+ for (const auto & v : _visitors) {
+ out << "<a href=\"?visitor=" << v.first
<< (verbose ? "&verbose" : "") << "\">Visitor "
- << it->first << "</a><br>\n";
+ << v.first << "</a><br>\n";
}
}
}
diff --git a/storage/src/vespa/storage/visiting/visitorthread.h b/storage/src/vespa/storage/visiting/visitorthread.h
index 226e7c0631b..56e40328fda 100644
--- a/storage/src/vespa/storage/visiting/visitorthread.h
+++ b/storage/src/vespa/storage/visiting/visitorthread.h
@@ -38,7 +38,7 @@ class VisitorThread : public framework::Runnable,
using VisitorMap = std::map<api::VisitorId, std::shared_ptr<Visitor>>;
VisitorMap _visitors;
- std::deque<std::pair<api::VisitorId, framework::SecondTime>> _recentlyCompleted;
+ std::deque<std::pair<api::VisitorId, vespalib::steady_time>> _recentlyCompleted;
struct Event {
enum class Type {
@@ -118,7 +118,7 @@ private:
*/
Event popNextQueuedEventIfAvailable();
void tick();
- void trimRecentlyCompletedList(framework::SecondTime currentTime);
+ void trimRecentlyCompletedList(vespalib::steady_time currentTime);
void handleNonExistingVisitorCall(const Event& entry, api::ReturnCode& code);
std::shared_ptr<Visitor> createVisitor(vespalib::stringref libName,
diff --git a/storage/src/vespa/storageframework/defaultimplementation/clock/fakeclock.h b/storage/src/vespa/storageframework/defaultimplementation/clock/fakeclock.h
index 0ca28f8114d..d234f432f2b 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/clock/fakeclock.h
+++ b/storage/src/vespa/storageframework/defaultimplementation/clock/fakeclock.h
@@ -67,9 +67,13 @@ public:
framework::SecondTime getTimeInSeconds() const override {
return getTimeInMicros().getSeconds();
}
- framework::MonotonicTimePoint getMonotonicTime() const override {
+ vespalib::system_time getSystemTime() const override {
// For simplicity, assume fake monotonic time follows fake wall clock.
- return MonotonicTimePoint(std::chrono::microseconds(getTimeInMicros().getTime()));
+ return vespalib::system_time(std::chrono::microseconds(getTimeInMicros().getTime()));
+ }
+ vespalib::steady_time getMonotonicTime() const override {
+ // For simplicity, assume fake monotonic time follows fake wall clock.
+ return vespalib::steady_time(std::chrono::microseconds(getTimeInMicros().getTime()));
}
};
diff --git a/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.cpp b/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.cpp
index 0303481feb5..df6115aa416 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.cpp
+++ b/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.cpp
@@ -5,27 +5,36 @@
namespace storage::framework::defaultimplementation {
-MicroSecTime RealClock::getTimeInMicros() const {
+MicroSecTime
+RealClock::getTimeInMicros() const {
struct timeval mytime;
gettimeofday(&mytime, 0);
return MicroSecTime(mytime.tv_sec * 1000000llu + mytime.tv_usec);
}
-MilliSecTime RealClock::getTimeInMillis() const {
+MilliSecTime
+RealClock::getTimeInMillis() const {
struct timeval mytime;
gettimeofday(&mytime, 0);
return MilliSecTime(
mytime.tv_sec * 1000llu + mytime.tv_usec / 1000);
}
-SecondTime RealClock::getTimeInSeconds() const {
+SecondTime
+RealClock::getTimeInSeconds() const {
struct timeval mytime;
gettimeofday(&mytime, 0);
return SecondTime(mytime.tv_sec);
}
-MonotonicTimePoint RealClock::getMonotonicTime() const {
- return std::chrono::steady_clock::now();
+vespalib::steady_time
+RealClock::getMonotonicTime() const {
+ return vespalib::steady_clock::now();
+}
+
+vespalib::system_time
+RealClock::getSystemTime() const {
+ return vespalib::system_clock::now();
}
}
diff --git a/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.h b/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.h
index a4b80a990c9..de176a3e402 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.h
+++ b/storage/src/vespa/storageframework/defaultimplementation/clock/realclock.h
@@ -17,7 +17,8 @@ struct RealClock : public Clock {
MicroSecTime getTimeInMicros() const override;
MilliSecTime getTimeInMillis() const override;
SecondTime getTimeInSeconds() const override;
- MonotonicTimePoint getMonotonicTime() const override;
+ vespalib::steady_time getMonotonicTime() const override;
+ vespalib::system_time getSystemTime() const override;
};
}
diff --git a/storage/src/vespa/storageframework/generic/clock/clock.h b/storage/src/vespa/storageframework/generic/clock/clock.h
index c9b8f652bfe..e1f8419f069 100644
--- a/storage/src/vespa/storageframework/generic/clock/clock.h
+++ b/storage/src/vespa/storageframework/generic/clock/clock.h
@@ -28,7 +28,8 @@ struct Clock {
virtual SecondTime getTimeInSeconds() const = 0;
// Time point resolution is intentionally not defined here.
- virtual MonotonicTimePoint getMonotonicTime() const = 0;
+ virtual vespalib::steady_time getMonotonicTime() const = 0;
+ virtual vespalib::system_time getSystemTime() const = 0;
};
}
diff --git a/storage/src/vespa/storageframework/generic/clock/time.h b/storage/src/vespa/storageframework/generic/clock/time.h
index 372110a1374..882ff58fb74 100644
--- a/storage/src/vespa/storageframework/generic/clock/time.h
+++ b/storage/src/vespa/storageframework/generic/clock/time.h
@@ -10,8 +10,8 @@ namespace vespalib {
namespace storage::framework {
-using MonotonicTimePoint = std::chrono::steady_clock::time_point;
-using MonotonicDuration = std::chrono::steady_clock::duration;
+using MonotonicTimePoint = vespalib::steady_time;
+using MonotonicDuration = vespalib::duration;
struct Clock;
@@ -111,9 +111,6 @@ struct SecondTime : public Time<SecondTime, 1000000> {
explicit SecondTime(uint64_t t = 0) : Time<SecondTime, 1000000>(t) {}
explicit SecondTime(const Clock& clock)
: Time<SecondTime, 1000000>(getRawMicroTime(clock) / 1000000) {}
-
- [[nodiscard]] MilliSecTime getMillis() const;
- [[nodiscard]] MicroSecTime getMicros() const;
};
/**
@@ -131,7 +128,6 @@ struct MilliSecTime : public Time<MilliSecTime, 1000> {
explicit MilliSecTime(const Clock& clock)
: Time<MilliSecTime, 1000>(getRawMicroTime(clock) / 1000) {}
- [[nodiscard]] SecondTime getSeconds() const { return SecondTime(getTime() / 1000); }
[[nodiscard]] MicroSecTime getMicros() const;
};
@@ -154,14 +150,6 @@ struct MicroSecTime : public Time<MicroSecTime, 1> {
[[nodiscard]] SecondTime getSeconds() const { return SecondTime(getTime() / 1000000); }
};
-inline MilliSecTime SecondTime::getMillis() const {
- return MilliSecTime(getTime() * 1000);
-}
-
-inline MicroSecTime SecondTime::getMicros() const {
- return MicroSecTime(getTime() * 1000 * 1000);
-}
-
inline MicroSecTime MilliSecTime::getMicros() const {
return MicroSecTime(getTime() * 1000);
}
@@ -180,13 +168,6 @@ operator + (MilliSecTime a, MilliSecTime b) {
return result;
}
-inline SecondTime
-operator + (SecondTime a, SecondTime b) {
- SecondTime result(a);
- result += b;
- return result;
-}
-
inline MicroSecTime
operator - (MicroSecTime a, MicroSecTime b) {
MicroSecTime result(a);
@@ -194,11 +175,4 @@ operator - (MicroSecTime a, MicroSecTime b) {
return result;
}
-inline SecondTime
-operator - (SecondTime a, SecondTime b) {
- SecondTime result(a);
- result -= b;
- return result;
-}
-
}
diff --git a/vdslib/src/tests/state/nodestatetest.cpp b/vdslib/src/tests/state/nodestatetest.cpp
index 000542e77fe..c854adf3915 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(uint64_t(4), ns.getStartTimestamp());
+ EXPECT_EQ(4s, ns.getStartTimestamp().time_since_epoch());
}
{
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 a7c5476456a..0dd7f5abb4c 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.cpp
+++ b/vdslib/src/vespa/vdslib/state/nodestate.cpp
@@ -8,9 +8,8 @@
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <sstream>
-#include <cmath>
-#include <vespa/log/log.h>
+#include <vespa/log/log.h>
LOG_SETUP(".vdslib.nodestate");
namespace storage::lib {
@@ -19,16 +18,16 @@ NodeState::NodeState(const NodeState &) = default;
NodeState & NodeState::operator = (const NodeState &) = default;
NodeState::NodeState(NodeState &&) noexcept = default;
NodeState & NodeState::operator = (NodeState &&) noexcept = default;
-NodeState::~NodeState() { }
+NodeState::~NodeState() = default;
NodeState::NodeState()
- : _type(0),
- _state(0),
+ : _type(nullptr),
+ _state(nullptr),
_description(""),
_capacity(1.0),
_initProgress(0.0),
_minUsedBits(16),
- _startTimestamp(0)
+ _startTimestamp()
{
setState(State::UP);
}
@@ -36,12 +35,12 @@ NodeState::NodeState()
NodeState::NodeState(const NodeType& type, const State& state,
vespalib::stringref description, double capacity)
: _type(&type),
- _state(0),
+ _state(nullptr),
_description(description),
_capacity(1.0),
_initProgress(0.0),
_minUsedBits(16),
- _startTimestamp(0)
+ _startTimestamp()
{
setState(state);
if (type == NodeType::STORAGE) {
@@ -56,25 +55,24 @@ NodeState::NodeState(vespalib::stringref serialized, const NodeType* type)
_capacity(1.0),
_initProgress(0.0),
_minUsedBits(16),
- _startTimestamp(0)
+ _startTimestamp()
{
vespalib::StringTokenizer st(serialized, " \t\f\r\n");
st.removeEmptyTokens();
- for (vespalib::StringTokenizer::Iterator it = st.begin();
- it != st.end(); ++it)
+ for (auto it : st)
{
- std::string::size_type index = it->find(':');
+ std::string::size_type index = it.find(':');
if (index == std::string::npos) {
throw vespalib::IllegalArgumentException(
- "Token " + *it + " does not contain ':': " + serialized,
+ "Token " + it + " does not contain ':': " + serialized,
VESPA_STRLOC);
}
- std::string key = it->substr(0, index);
- std::string value = it->substr(index + 1);
- if (key.size() > 0) switch (key[0]) {
+ std::string key = it.substr(0, index);
+ std::string value = it.substr(index + 1);
+ if (!key.empty()) switch (key[0]) {
case 'b':
- if (_type != 0 && *type != NodeType::STORAGE) break;
+ if (_type != nullptr && *type != NodeType::STORAGE) break;
if (key.size() > 1) break;
try{
setMinUsedBits(boost::lexical_cast<uint32_t>(value));
@@ -91,7 +89,7 @@ NodeState::NodeState(vespalib::stringref serialized, const NodeType* type)
continue;
case 'c':
if (key.size() > 1) break;
- if (_type != 0 && *type != NodeType::STORAGE) break;
+ if (_type != nullptr && *type != NodeType::STORAGE) break;
try{
setCapacity(boost::lexical_cast<double>(value));
} catch (...) {
@@ -115,7 +113,7 @@ NodeState::NodeState(vespalib::stringref serialized, const NodeType* type)
case 't':
if (key.size() > 1) break;
try{
- setStartTimestamp(boost::lexical_cast<uint64_t>(value));
+ setStartTimestamp(vespalib::system_time(std::chrono::seconds(boost::lexical_cast<uint64_t>(value))));
} catch (...) {
throw vespalib::IllegalArgumentException(
"Illegal start timestamp '" + value + "'. Start "
@@ -165,7 +163,7 @@ NodeState::serialize(vespalib::asciistream & out, vespalib::stringref prefix,
SeparatorPrinter sep;
// Always give node state if not part of a system state
// to prevent empty serialization
- if (*_state != State::UP || prefix.size() == 0) {
+ if (*_state != State::UP || prefix.empty()) {
out << sep << prefix << "s:";
out << _state->serialize();
}
@@ -178,8 +176,8 @@ NodeState::serialize(vespalib::asciistream & out, vespalib::stringref prefix,
if (*_state == State::INITIALIZING) {
out << sep << prefix << "i:" << _initProgress;
}
- if (_startTimestamp != 0) {
- out << sep << prefix << "t:" << _startTimestamp;
+ if (_startTimestamp != vespalib::system_time()) {
+ out << sep << prefix << "t:" << vespalib::count_s(_startTimestamp.time_since_epoch());
}
if (includeDescription && ! _description.empty()) {
out << sep << prefix << "m:"
@@ -190,7 +188,7 @@ NodeState::serialize(vespalib::asciistream & out, vespalib::stringref prefix,
void
NodeState::setState(const State& state)
{
- if (_type != 0) {
+ if (_type != nullptr) {
// We don't know whether you want to store reported, wanted or
// current node state, so we must accept any.
if (!state.validReportedNodeState(*_type)
@@ -225,7 +223,7 @@ NodeState::setCapacity(vespalib::Double capacity)
"must be a positive floating point number";
throw vespalib::IllegalArgumentException(ost.str(), VESPA_STRLOC);
}
- if (_type != 0 && *_type != NodeType::STORAGE) {
+ if (_type != nullptr && *_type != NodeType::STORAGE) {
throw vespalib::IllegalArgumentException(
"Capacity only make sense for storage nodes.", VESPA_STRLOC);
}
@@ -245,7 +243,7 @@ NodeState::setInitProgress(vespalib::Double initProgress)
}
void
-NodeState::setStartTimestamp(uint64_t startTimestamp)
+NodeState::setStartTimestamp(vespalib::system_time startTimestamp)
{
_startTimestamp = startTimestamp;
}
@@ -270,10 +268,10 @@ NodeState::print(std::ostream& out, bool verbose,
if (*_state == State::INITIALIZING) {
out << ", init progress " << _initProgress;
}
- if (_startTimestamp != 0) {
- out << ", start timestamp " << _startTimestamp;
+ if (_startTimestamp != vespalib::system_time()) {
+ out << ", start timestamp " << vespalib::to_string(_startTimestamp);
}
- if (_description.size() > 0) {
+ if (!_description.empty()) {
out << ": " << _description;
}
}
@@ -317,7 +315,7 @@ NodeState::similarTo(const NodeState& other) const
void
NodeState::verifySupportForNodeType(const NodeType& type) const
{
- if (_type != 0 && *_type == type) return;
+ if (_type != nullptr && *_type == type) return;
if (!_state->validReportedNodeState(type)
&& !_state->validWantedNodeState(type))
{
@@ -357,8 +355,8 @@ NodeState::getTextualDifference(const NodeState& other) const {
}
}
if (_startTimestamp != other._startTimestamp) {
- source << ", start timestamp " << _startTimestamp;
- target << ", start timestamp " << other._startTimestamp;
+ source << ", start timestamp " << vespalib::to_string(_startTimestamp);
+ target << ", start timestamp " << vespalib::to_string(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 541395e15cb..4fb035b6dcd 100644
--- a/vdslib/src/vespa/vdslib/state/nodestate.h
+++ b/vdslib/src/vespa/vdslib/state/nodestate.h
@@ -13,6 +13,7 @@
#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 {
@@ -25,7 +26,7 @@ class NodeState : public document::Printable
vespalib::Double _capacity;
vespalib::Double _initProgress;
uint32_t _minUsedBits;
- uint64_t _startTimestamp;
+ vespalib::system_time _startTimestamp;
public:
using CSP = std::shared_ptr<const NodeState>;
@@ -43,8 +44,8 @@ public:
vespalib::stringref description = "",
double capacity = 1.0);
/** Set type if you want to verify that content fit with the given type. */
- NodeState(vespalib::stringref serialized, const NodeType* nodeType = 0);
- ~NodeState();
+ explicit NodeState(vespalib::stringref serialized, const NodeType* nodeType = nullptr);
+ ~NodeState() override;
/**
* Setting prefix to something implies using this function to write a
@@ -54,26 +55,27 @@ public:
void serialize(vespalib::asciistream & out, vespalib::stringref prefix = "",
bool includeDescription = true) const;
- const State& getState() const { return *_state; }
- vespalib::Double getCapacity() const { return _capacity; }
- uint32_t getMinUsedBits() const { return _minUsedBits; }
- vespalib::Double getInitProgress() const { return _initProgress; }
- const vespalib::string& getDescription() const { return _description; }
- uint64_t getStartTimestamp() const { return _startTimestamp; }
+ [[nodiscard]] const State& getState() const { return *_state; }
+ [[nodiscard]] vespalib::Double getCapacity() const { return _capacity; }
+ [[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; }
void setState(const State& state);
void setCapacity(vespalib::Double capacity);
void setMinUsedBits(uint32_t usedBits);
void setInitProgress(vespalib::Double initProgress);
- void setStartTimestamp(uint64_t startTimestamp);
+ void setStartTimestamp(vespalib::system_time startTimestamp);
void setDescription(vespalib::stringref desc) { _description = desc; }
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)); }
- bool similarTo(const NodeState& other) const;
+ bool operator!=(const NodeState& other) const {
+ return !(operator==(other));
+ }
+ [[nodiscard]] bool similarTo(const NodeState& other) const;
/**
* Verify that the contents of this object fits with the given nodetype.