summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-06 18:44:10 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-02-06 19:00:22 +0000
commitd8f940006c4fbe941371a6e2dfedfa4fe0c7b169 (patch)
treec0d4c12c0482b25e1808bcbd52a94dc52d5c5a3f /storage
parent1a37850993a673e79182eb62220d063878d48410 (diff)
- Include only the parts from the storageframework that you really need.
- Avoid default values to virtual method registerTick.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/distributor/top_level_distributor_test.cpp2
-rw-r--r--storage/src/tests/visiting/visitormanagertest.cpp35
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketmanager.cpp1
-rw-r--r--storage/src/vespa/storage/bucketdb/bucketmanager.h2
-rw-r--r--storage/src/vespa/storage/common/statusmetricconsumer.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/distributor_stripe.h2
-rw-r--r--storage/src/vespa/storage/distributor/distributor_stripe_component.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/operations/operation.h4
-rw-r--r--storage/src/vespa/storage/distributor/pending_bucket_space_db_transition.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/pendingmessagetracker.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/statecheckers.cpp1
-rw-r--r--storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h1
-rw-r--r--storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp4
-rw-r--r--storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp14
-rw-r--r--storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h2
-rw-r--r--storage/src/vespa/storage/persistence/apply_bucket_diff_state.h1
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp7
-rw-r--r--storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h7
-rw-r--r--storage/src/vespa/storage/persistence/persistencethread.cpp1
-rw-r--r--storage/src/vespa/storage/storageserver/bouncer.cpp1
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.cpp3
-rw-r--r--storage/src/vespa/storage/storageserver/communicationmanager.h3
-rw-r--r--storage/src/vespa/storage/storageserver/mergethrottler.cpp2
-rw-r--r--storage/src/vespa/storage/storageserver/mergethrottler.h3
-rw-r--r--storage/src/vespa/storage/storageserver/opslogger.cpp1
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.cpp4
-rw-r--r--storage/src/vespa/storage/storageserver/statemanager.h3
-rw-r--r--storage/src/vespa/storage/storageserver/statereporter.cpp1
-rw-r--r--storage/src/vespa/storage/visiting/visitor.h5
-rw-r--r--storage/src/vespa/storage/visiting/visitormanager.cpp19
-rw-r--r--storage/src/vespa/storage/visiting/visitormanager.h11
-rw-r--r--storage/src/vespa/storage/visiting/visitorthread.cpp2
-rw-r--r--storage/src/vespa/storage/visiting/visitorthread.h3
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp3
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp5
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.h5
-rw-r--r--storage/src/vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h9
-rw-r--r--storage/src/vespa/storageframework/generic/clock/timer.h6
-rw-r--r--storage/src/vespa/storageframework/generic/component/component.cpp4
-rw-r--r--storage/src/vespa/storageframework/generic/component/component.h15
-rw-r--r--storage/src/vespa/storageframework/generic/component/managedcomponent.h1
-rw-r--r--storage/src/vespa/storageframework/generic/metric/metricregistrator.h2
-rw-r--r--storage/src/vespa/storageframework/generic/thread/runnable.h17
-rw-r--r--storage/src/vespa/storageframework/generic/thread/thread_properties.h11
-rw-r--r--storage/src/vespa/storageframework/generic/thread/threadpool.h13
-rw-r--r--storage/src/vespa/storageframework/generic/thread/tickingthread.cpp6
-rw-r--r--storage/src/vespa/storageframework/generic/thread/tickingthread.h4
-rw-r--r--storage/src/vespa/storageframework/storageframework.h15
50 files changed, 140 insertions, 127 deletions
diff --git a/storage/src/tests/distributor/top_level_distributor_test.cpp b/storage/src/tests/distributor/top_level_distributor_test.cpp
index 2ab37a21ec4..dad6f477d83 100644
--- a/storage/src/tests/distributor/top_level_distributor_test.cpp
+++ b/storage/src/tests/distributor/top_level_distributor_test.cpp
@@ -6,6 +6,8 @@
#include <vespa/storageapi/message/visitor.h>
#include <vespa/storageapi/message/removelocation.h>
#include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h>
+#include <vespa/storageframework/generic/thread/runnable.h>
+#include <vespa/storageframework/generic/thread/thread.h>
#include <tests/distributor/top_level_distributor_test_util.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
#include <vespa/document/test/make_document_bucket.h>
diff --git a/storage/src/tests/visiting/visitormanagertest.cpp b/storage/src/tests/visiting/visitormanagertest.cpp
index a82514acb03..4add005f78d 100644
--- a/storage/src/tests/visiting/visitormanagertest.cpp
+++ b/storage/src/tests/visiting/visitormanagertest.cpp
@@ -47,10 +47,10 @@ protected:
std::unique_ptr<TestVisitorMessageSessionFactory> _messageSessionFactory;
std::unique_ptr<TestServiceLayerApp> _node;
std::unique_ptr<DummyStorageLink> _top;
- VisitorManager* _manager;
+ VisitorManager* _manager{};
- VisitorManagerTest() : _node() {}
- ~VisitorManagerTest();
+ VisitorManagerTest() : _node(), _top(), _manager(nullptr) {}
+ ~VisitorManagerTest() override;
// Not using setUp since can't throw exception out of it.
void initializeTest(bool defer_manager_thread_start = false);
@@ -184,8 +184,8 @@ VisitorManagerTest::addSomeRemoves(bool removeAll)
for (uint32_t i=0; i<docCount; i += (removeAll ? 1 : 4)) {
// Add it to the database
document::BucketId bid(16, i % 10);
- auto cmd = std::make_shared<api::RemoveCommand>(
- makeDocumentBucket(bid), _documents[i]->getId(), clock.getTimeInMicros().getTime() + docCount + i + 1);
+ auto cmd = std::make_shared<api::RemoveCommand>(makeDocumentBucket(bid), _documents[i]->getId(),
+ vespalib::count_us(clock.getSystemTime().time_since_epoch()) + docCount + i + 1);
cmd->setAddress(_Address);
_top->sendDown(cmd);
_top->waitForMessages(1, 60);
@@ -254,10 +254,10 @@ VisitorManagerTest::getMessagesAndReply(
switch (session.sentMessages[i]->getType()) {
case documentapi::DocumentProtocol::MESSAGE_PUTDOCUMENT:
- docs.push_back(static_cast<documentapi::PutDocumentMessage&>(*session.sentMessages[i]).getDocumentSP());
+ docs.push_back(dynamic_cast<documentapi::PutDocumentMessage&>(*session.sentMessages[i]).getDocumentSP());
break;
case documentapi::DocumentProtocol::MESSAGE_REMOVEDOCUMENT:
- docIds.push_back(static_cast<documentapi::RemoveDocumentMessage&>(*session.sentMessages[i]).getDocumentId());
+ docIds.push_back(dynamic_cast<documentapi::RemoveDocumentMessage&>(*session.sentMessages[i]).getDocumentId());
break;
default:
break;
@@ -287,7 +287,7 @@ VisitorManagerTest::verifyCreateVisitorReply(
const msg_ptr_vector replies = _top->getRepliesOnce();
ASSERT_EQ(1, replies.size());
- std::shared_ptr<api::StorageMessage> msg(replies[0]);
+ const std::shared_ptr<api::StorageMessage>& msg(replies[0]);
ASSERT_EQ(api::MessageType::VISITOR_CREATE_REPLY, msg->getType());
@@ -312,11 +312,9 @@ VisitorManagerTest::verifyCreateVisitorReply(
uint32_t
VisitorManagerTest::getMatchingDocuments(std::vector<document::Document::SP >& docs) {
uint32_t equalCount = 0;
- for (uint32_t i=0; i<docs.size(); ++i) {
- for (uint32_t j=0; j<_documents.size(); ++j) {
- if (docs[i]->getId() == _documents[j]->getId()
- && *docs[i] == *_documents[j])
- {
+ for (auto & doc : docs) {
+ for (auto & _document : _documents) {
+ if (doc->getId() == _document->getId() && *doc == *_document) {
equalCount++;
}
}
@@ -330,8 +328,8 @@ namespace {
int getTotalSerializedSize(const std::vector<document::Document::SP>& docs)
{
int total = 0;
- for (size_t i = 0; i < docs.size(); ++i) {
- total += int(docs[i]->serialize().size());
+ for (const auto & doc : docs) {
+ total += int(doc->serialize().size());
}
return total;
}
@@ -625,7 +623,7 @@ TEST_F(VisitorManagerTest, visitor_cleanup) {
int busy = 0;
for (uint32_t i=0; i< expected_total; ++i) {
- std::shared_ptr<api::StorageMessage> msg(replies[i]);
+ const std::shared_ptr<api::StorageMessage>& msg(replies[i]);
ASSERT_EQ(api::MessageType::VISITOR_CREATE_REPLY, msg->getType());
auto reply = std::dynamic_pointer_cast<api::CreateVisitorReply>(msg);
ASSERT_TRUE(reply.get());
@@ -688,8 +686,7 @@ TEST_F(VisitorManagerTest, visitor_cleanup) {
const msg_ptr_vector replies = _top->getRepliesOnce();
ASSERT_EQ(8, replies.size());
- for (uint32_t i=0; i< replies.size(); ++i) {
- std::shared_ptr<api::StorageMessage> msg(replies[i]);
+ for (const auto & msg : replies) {
ASSERT_EQ(api::MessageType::VISITOR_CREATE_REPLY, msg->getType());
auto reply = std::dynamic_pointer_cast<api::CreateVisitorReply>(msg);
ASSERT_TRUE(reply.get());
@@ -770,7 +767,7 @@ TEST_F(VisitorManagerTest, visitor_queue_timeout) {
// Don't answer any messages. Make sure we timeout anyways.
_top->waitForMessages(1, 60);
const msg_ptr_vector replies = _top->getRepliesOnce();
- std::shared_ptr<api::StorageMessage> msg(replies[0]);
+ const std::shared_ptr<api::StorageMessage>& msg(replies[0]);
ASSERT_EQ(api::MessageType::VISITOR_CREATE_REPLY, msg->getType());
auto reply = std::dynamic_pointer_cast<api::CreateVisitorReply>(msg);
diff --git a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
index cf98585bc82..c264bbf422a 100644
--- a/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
+++ b/storage/src/vespa/storage/bucketdb/bucketmanager.cpp
@@ -11,6 +11,7 @@
#include <vespa/storage/storageutil/distributorstatecache.h>
#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
#include <vespa/storageframework/generic/status/xmlstatusreporter.h>
+#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/storageframework/generic/clock/timer.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storageapi/message/state.h>
diff --git a/storage/src/vespa/storage/bucketdb/bucketmanager.h b/storage/src/vespa/storage/bucketdb/bucketmanager.h
index fda13e09c45..ce60ec88bff 100644
--- a/storage/src/vespa/storage/bucketdb/bucketmanager.h
+++ b/storage/src/vespa/storage/bucketdb/bucketmanager.h
@@ -67,7 +67,7 @@ private:
size_t _requestsCurrentlyProcessing;
ServiceLayerComponent _component;
std::shared_ptr<BucketManagerMetrics> _metrics;
- framework::Thread::UP _thread;
+ std::unique_ptr<framework::Thread> _thread;
std::chrono::milliseconds _simulated_processing_delay;
class ScopedQueueDispatchGuard {
diff --git a/storage/src/vespa/storage/common/statusmetricconsumer.cpp b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
index e9360c35f3c..8eb3e9f3ab6 100644
--- a/storage/src/vespa/storage/common/statusmetricconsumer.cpp
+++ b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "statusmetricconsumer.h"
+#include <vespa/storageframework/generic/clock/clock.h>
#include <boost/lexical_cast.hpp>
#include <vespa/metrics/jsonwriter.h>
#include <vespa/metrics/textwriter.h>
diff --git a/storage/src/vespa/storage/distributor/distributor_stripe.h b/storage/src/vespa/storage/distributor/distributor_stripe.h
index ccd7ab9c21d..801efa0ff73 100644
--- a/storage/src/vespa/storage/distributor/distributor_stripe.h
+++ b/storage/src/vespa/storage/distributor/distributor_stripe.h
@@ -21,6 +21,8 @@
#include <vespa/storageapi/message/state.h>
#include <vespa/storageframework/generic/metric/metricupdatehook.h>
#include <vespa/storageframework/generic/thread/tickingthread.h>
+#include <vespa/storageframework/generic/clock/timer.h>
+
#include <atomic>
#include <mutex>
#include <queue>
diff --git a/storage/src/vespa/storage/distributor/distributor_stripe_component.cpp b/storage/src/vespa/storage/distributor/distributor_stripe_component.cpp
index aa0a2289727..2a4b63ecee2 100644
--- a/storage/src/vespa/storage/distributor/distributor_stripe_component.cpp
+++ b/storage/src/vespa/storage/distributor/distributor_stripe_component.cpp
@@ -5,6 +5,7 @@
#include "distributor_bucket_space.h"
#include "pendingmessagetracker.h"
#include "storage_node_up_states.h"
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/document/select/parser.h>
#include <vespa/vdslib/state/cluster_state_bundle.h>
#include <vespa/vdslib/state/clusterstate.h>
diff --git a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
index 667afbf67a0..14fa90b50f9 100644
--- a/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
+++ b/storage/src/vespa/storage/distributor/operations/idealstate/mergeoperation.cpp
@@ -6,6 +6,7 @@
#include <vespa/storage/distributor/distributor_bucket_space.h>
#include <vespa/storage/distributor/node_supported_features_repo.h>
#include <vespa/storage/distributor/pendingmessagetracker.h>
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <array>
diff --git a/storage/src/vespa/storage/distributor/operations/operation.h b/storage/src/vespa/storage/distributor/operations/operation.h
index 8bb81b8d365..e61429449b3 100644
--- a/storage/src/vespa/storage/distributor/operations/operation.h
+++ b/storage/src/vespa/storage/distributor/operations/operation.h
@@ -3,7 +3,7 @@
#include <vespa/vdslib/state/nodetype.h>
#include <vespa/storage/distributor/distributormessagesender.h>
-#include <vespa/storageframework/generic/clock/time.h>
+#include <vespa/vespalib/util/time.h>
namespace storage {
@@ -50,7 +50,7 @@ public:
[[nodiscard]] virtual std::string getStatus() const;
[[nodiscard]] virtual std::string toString() const {
- return std::string(getName());
+ return getName();
}
/**
diff --git a/storage/src/vespa/storage/distributor/pending_bucket_space_db_transition.cpp b/storage/src/vespa/storage/distributor/pending_bucket_space_db_transition.cpp
index 591f2a41b62..f09ef468441 100644
--- a/storage/src/vespa/storage/distributor/pending_bucket_space_db_transition.cpp
+++ b/storage/src/vespa/storage/distributor/pending_bucket_space_db_transition.cpp
@@ -5,6 +5,7 @@
#include "pending_bucket_space_db_transition.h"
#include "pendingclusterstate.h"
#include "stripe_access_guard.h"
+#include <vespa/storageframework/generic/clock/time.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <algorithm>
diff --git a/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp b/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp
index 8618d570685..5b8fa6b69e3 100644
--- a/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp
+++ b/storage/src/vespa/storage/distributor/pendingmessagetracker.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "pendingmessagetracker.h"
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <map>
diff --git a/storage/src/vespa/storage/distributor/statecheckers.cpp b/storage/src/vespa/storage/distributor/statecheckers.cpp
index 9730a5f621b..14cc2509cab 100644
--- a/storage/src/vespa/storage/distributor/statecheckers.cpp
+++ b/storage/src/vespa/storage/distributor/statecheckers.cpp
@@ -10,6 +10,7 @@
#include <vespa/storage/distributor/operations/idealstate/setbucketstateoperation.h>
#include <vespa/storage/distributor/operations/idealstate/mergeoperation.h>
#include <vespa/storage/distributor/operations/idealstate/garbagecollectionoperation.h>
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vespalib/stllike/asciistream.h>
diff --git a/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h b/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h
index 6339283f963..4b25c9c6fcb 100644
--- a/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h
+++ b/storage/src/vespa/storage/distributor/stripe_bucket_db_updater.h
@@ -12,7 +12,6 @@
#include <vespa/storage/common/message_guard.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/storageapi/messageapi/messagehandler.h>
-#include <vespa/storageframework/generic/clock/timer.h>
#include <vespa/storageframework/generic/status/statusreporter.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <atomic>
diff --git a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
index 4d7c9dceb12..8690f6e122d 100644
--- a/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
+++ b/storage/src/vespa/storage/frameworkimpl/status/statuswebserver.cpp
@@ -1,7 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "statuswebserver.h"
-#include <vespa/storageframework/storageframework.h>
+#include <vespa/storageframework/generic/component/component.h>
+#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
+#include <vespa/storageframework/generic/status/statusreportermap.h>
#include <vespa/vespalib/util/host_name.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/size_literals.h>
diff --git a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp
index 5acc2e4d14d..79a2e354c96 100644
--- a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp
+++ b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.cpp
@@ -5,6 +5,7 @@
#include <vespa/storage/bucketdb/storbucketdb.h>
#include <vespa/storage/common/content_bucket_space_repo.h>
#include <vespa/storageframework/generic/thread/thread.h>
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/log/bufferedlogger.h>
@@ -252,15 +253,9 @@ namespace {
struct ThreadStatusWriter : public DeadLockDetector::ThreadVisitor {
ThreadTable& _table;
vespalib::steady_time _time;
- vespalib::duration _processSlack;
- vespalib::duration _waitSlack;
- ThreadStatusWriter(ThreadTable& table,
- vespalib::steady_time time,
- vespalib::duration processSlack,
- vespalib::duration waitSlack)
- : _table(table), _time(time),
- _processSlack(processSlack), _waitSlack(waitSlack) {}
+ ThreadStatusWriter(ThreadTable& table, vespalib::steady_time time)
+ : _table(table), _time(time) {}
template<typename T>
vespalib::string toS(const T& val) {
@@ -293,8 +288,7 @@ DeadLockDetector::reportHtmlStatus(std::ostream& os,
out << "<h2>Overview of latest thread ticks</h2>\n";
ThreadTable threads;
std::lock_guard guard(_lock);
- ThreadStatusWriter writer(threads, _component->getClock().getMonotonicTime(),
- getProcessSlack(), getWaitSlack());
+ ThreadStatusWriter writer(threads, _component->getClock().getMonotonicTime());
visitThreads(writer);
std::ostringstream ost;
threads._table.print(ost);
diff --git a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h
index e2a2278a727..93487baa71d 100644
--- a/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h
+++ b/storage/src/vespa/storage/frameworkimpl/thread/deadlockdetector.h
@@ -17,6 +17,8 @@
#include <vespa/storage/common/servicelayercomponent.h>
#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
#include <vespa/storageframework/generic/thread/threadpool.h>
+#include <vespa/storageframework/generic/thread/runnable.h>
+#include <vespa/storageframework/generic/thread/thread.h>
#include <atomic>
#include <map>
diff --git a/storage/src/vespa/storage/persistence/apply_bucket_diff_state.h b/storage/src/vespa/storage/persistence/apply_bucket_diff_state.h
index 49625bbf8b5..230f1cb76f9 100644
--- a/storage/src/vespa/storage/persistence/apply_bucket_diff_state.h
+++ b/storage/src/vespa/storage/persistence/apply_bucket_diff_state.h
@@ -17,7 +17,6 @@ namespace storage::spi { class Result; }
namespace storage {
-class ApplyBucketDiffEntryResult;
struct MessageSender;
class MessageTracker;
class MergeBucketInfoSyncer;
diff --git a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
index 4a36d36425a..c0f4041e284 100644
--- a/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/filestormanager.cpp
@@ -2,6 +2,7 @@
#include "filestormanager.h"
#include "filestorhandlerimpl.h"
+#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/storage/bucketdb/minimumusedbitstracker.h>
#include <vespa/storage/common/bucketmessages.h>
#include <vespa/storage/common/content_bucket_space_repo.h>
diff --git a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
index 040ace55c52..0e8ab412b16 100644
--- a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
+++ b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.cpp
@@ -2,6 +2,7 @@
#include "modifiedbucketchecker.h"
#include "filestormanager.h"
+#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/persistence/spi/persistenceprovider.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/subscription/configuri.h>
@@ -16,8 +17,8 @@ using document::BucketSpace;
namespace storage {
ModifiedBucketChecker::CyclicBucketSpaceIterator::
-CyclicBucketSpaceIterator(const ContentBucketSpaceRepo::BucketSpaces &bucketSpaces)
- : _bucketSpaces(bucketSpaces),
+CyclicBucketSpaceIterator(ContentBucketSpaceRepo::BucketSpaces bucketSpaces)
+ : _bucketSpaces(std::move(bucketSpaces)),
_idx(0)
{
std::sort(_bucketSpaces.begin(), _bucketSpaces.end());
@@ -117,7 +118,7 @@ ModifiedBucketChecker::run(framework::ThreadHandle& thread)
LOG(debug, "Started modified bucket checker thread with pid %d", getpid());
while (!thread.interrupted()) {
- thread.registerTick();
+ thread.registerTick(framework::UNKNOWN_CYCLE);
bool ok = tick();
diff --git a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h
index 0695c35c7ad..53da2b66dc3 100644
--- a/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h
+++ b/storage/src/vespa/storage/persistence/filestorage/modifiedbucketchecker.h
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include <vespa/storageframework/generic/thread/runnable.h>
#include <vespa/storage/common/content_bucket_space_repo.h>
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/storage/common/servicelayercomponent.h>
@@ -32,7 +33,7 @@ public:
ModifiedBucketChecker(ServiceLayerComponentRegister& compReg,
spi::PersistenceProvider& provide,
const config::ConfigUri& configUri);
- ~ModifiedBucketChecker();
+ ~ModifiedBucketChecker() override;
void configure(std::unique_ptr<vespa::config::content::core::StorServerConfig>) override;
@@ -63,7 +64,7 @@ private:
size_t _idx;
public:
using UP = std::unique_ptr<CyclicBucketSpaceIterator>;
- CyclicBucketSpaceIterator(const ContentBucketSpaceRepo::BucketSpaces &bucketSpaces);
+ explicit CyclicBucketSpaceIterator(ContentBucketSpaceRepo::BucketSpaces bucketSpaces);
document::BucketSpace next() {
return _bucketSpaces[(_idx++)%_bucketSpaces.size()];
}
@@ -86,7 +87,7 @@ private:
spi::PersistenceProvider & _provider;
ServiceLayerComponent::UP _component;
- framework::Thread::UP _thread;
+ std::unique_ptr<framework::Thread> _thread;
std::unique_ptr<config::ConfigFetcher> _configFetcher;
std::mutex _monitor;
std::condition_variable _cond;
diff --git a/storage/src/vespa/storage/persistence/persistencethread.cpp b/storage/src/vespa/storage/persistence/persistencethread.cpp
index 8e1fdb06ded..ee7e7bcbca2 100644
--- a/storage/src/vespa/storage/persistence/persistencethread.cpp
+++ b/storage/src/vespa/storage/persistence/persistencethread.cpp
@@ -2,6 +2,7 @@
#include "persistencethread.h"
#include "persistencehandler.h"
+#include <vespa/storageframework/generic/thread/thread.h>
#include <thread>
#include <vespa/log/log.h>
diff --git a/storage/src/vespa/storage/storageserver/bouncer.cpp b/storage/src/vespa/storage/storageserver/bouncer.cpp
index 0324891243b..63f1cd674f8 100644
--- a/storage/src/vespa/storage/storageserver/bouncer.cpp
+++ b/storage/src/vespa/storage/storageserver/bouncer.cpp
@@ -3,6 +3,7 @@
#include "bouncer.h"
#include "bouncer_metrics.h"
#include "config_logging.h"
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/vdslib/state/cluster_state_bundle.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/persistence/spi/bucket_limits.h>
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.cpp b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
index ec22d7c064e..a00b55971f1 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.cpp
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.cpp
@@ -16,6 +16,7 @@
#include <vespa/storage/storageserver/rpc/storage_api_rpc_service.h>
#include <vespa/storageapi/message/state.h>
#include <vespa/storageframework/generic/clock/timer.h>
+#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
@@ -686,7 +687,7 @@ void
CommunicationManager::run(framework::ThreadHandle& thread)
{
while (!thread.interrupted()) {
- thread.registerTick();
+ thread.registerTick(framework::UNKNOWN_CYCLE);
std::shared_ptr<api::StorageMessage> msg;
if (_eventQueue.getNext(msg, 100ms)) {
process(msg);
diff --git a/storage/src/vespa/storage/storageserver/communicationmanager.h b/storage/src/vespa/storage/storageserver/communicationmanager.h
index e83a6517c45..593640e7d03 100644
--- a/storage/src/vespa/storage/storageserver/communicationmanager.h
+++ b/storage/src/vespa/storage/storageserver/communicationmanager.h
@@ -17,6 +17,7 @@
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/storage/config/config-stor-communicationmanager.h>
#include <vespa/storageframework/generic/metric/metricupdatehook.h>
+#include <vespa/storageframework/generic/thread/runnable.h>
#include <vespa/storageapi/mbusprot/storagecommand.h>
#include <vespa/storageapi/mbusprot/storagereply.h>
#include <vespa/messagebus/imessagehandler.h>
@@ -115,7 +116,7 @@ private:
config::ConfigUri _configUri;
std::atomic<bool> _closed;
DocumentApiConverter _docApiConverter;
- framework::Thread::UP _thread;
+ std::unique_ptr<framework::Thread> _thread;
void updateMetrics(const MetricLockGuard &) override;
diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.cpp b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
index 2dea5681b85..189438650ae 100644
--- a/storage/src/vespa/storage/storageserver/mergethrottler.cpp
+++ b/storage/src/vespa/storage/storageserver/mergethrottler.cpp
@@ -1,6 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "mergethrottler.h"
+#include <vespa/storageframework/generic/thread/thread.h>
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/storageapi/message/state.h>
#include <vespa/storage/common/nodestateupdater.h>
#include <vespa/storage/common/dummy_mbus_messages.h>
diff --git a/storage/src/vespa/storage/storageserver/mergethrottler.h b/storage/src/vespa/storage/storageserver/mergethrottler.h
index 76a25c0cf22..0adfb209e66 100644
--- a/storage/src/vespa/storage/storageserver/mergethrottler.h
+++ b/storage/src/vespa/storage/storageserver/mergethrottler.h
@@ -12,6 +12,7 @@
#include <vespa/storage/common/storagelink.h>
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
+#include <vespa/storageframework/generic/thread/runnable.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/document/bucket/bucket.h>
#include <vespa/vespalib/util/document_runnable.h>
@@ -178,7 +179,7 @@ private:
std::vector<api::StorageMessage::SP> _messagesUp;
std::unique_ptr<Metrics> _metrics;
StorageComponent _component;
- framework::Thread::UP _thread;
+ std::unique_ptr<framework::Thread> _thread;
RendezvousState _rendezvous;
mutable std::chrono::steady_clock::time_point _throttle_until_time;
std::chrono::steady_clock::duration _backpressure_duration;
diff --git a/storage/src/vespa/storage/storageserver/opslogger.cpp b/storage/src/vespa/storage/storageserver/opslogger.cpp
index e5785968eb1..dcf7ddf4a92 100644
--- a/storage/src/vespa/storage/storageserver/opslogger.cpp
+++ b/storage/src/vespa/storage/storageserver/opslogger.cpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "opslogger.h"
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/storageapi/message/persistence.h>
#include <vespa/config/helper/configfetcher.hpp>
#include <vespa/config/subscription/configuri.h>
diff --git a/storage/src/vespa/storage/storageserver/statemanager.cpp b/storage/src/vespa/storage/storageserver/statemanager.cpp
index 647cba52bfc..a963159e8a6 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.cpp
+++ b/storage/src/vespa/storage/storageserver/statemanager.cpp
@@ -2,6 +2,8 @@
#include "statemanager.h"
#include "storagemetricsset.h"
+#include <vespa/storageframework/generic/clock/clock.h>
+#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/defaults.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
#include <vespa/metrics/jsonwriter.h>
@@ -473,7 +475,7 @@ void
StateManager::run(framework::ThreadHandle& thread)
{
while (true) {
- thread.registerTick();
+ thread.registerTick(framework::UNKNOWN_CYCLE);
if (thread.interrupted()) {
break;
}
diff --git a/storage/src/vespa/storage/storageserver/statemanager.h b/storage/src/vespa/storage/storageserver/statemanager.h
index 3605a0b1605..6e3daa96979 100644
--- a/storage/src/vespa/storage/storageserver/statemanager.h
+++ b/storage/src/vespa/storage/storageserver/statemanager.h
@@ -18,6 +18,7 @@
#include <vespa/storage/common/storagelink.h>
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
+#include <vespa/storageframework/generic/thread/runnable.h>
#include <vespa/storageapi/message/state.h>
#include <vespa/storageapi/messageapi/storagemessage.h>
#include <vespa/vespalib/objects/floatingpointtype.h>
@@ -65,7 +66,7 @@ class StateManager : public NodeStateUpdater,
std::deque<TimeSysStatePair> _systemStateHistory;
uint32_t _systemStateHistorySize;
std::unique_ptr<HostInfo> _hostInfo;
- framework::Thread::UP _thread;
+ std::unique_ptr<framework::Thread> _thread;
// Controllers that have observed a GetNodeState response sent _after_
// immediately_send_get_node_state_replies() has been invoked.
std::unordered_set<uint16_t> _controllers_observed_explicit_node_state;
diff --git a/storage/src/vespa/storage/storageserver/statereporter.cpp b/storage/src/vespa/storage/storageserver/statereporter.cpp
index 373cd186708..205a2d710a6 100644
--- a/storage/src/vespa/storage/storageserver/statereporter.cpp
+++ b/storage/src/vespa/storage/storageserver/statereporter.cpp
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "statereporter.h"
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/metrics/jsonwriter.h>
#include <vespa/metrics/metricmanager.h>
#include <vespa/storage/common/nodestateupdater.h>
diff --git a/storage/src/vespa/storage/visiting/visitor.h b/storage/src/vespa/storage/visiting/visitor.h
index 9b6d8e348b9..d152e1b721b 100644
--- a/storage/src/vespa/storage/visiting/visitor.h
+++ b/storage/src/vespa/storage/visiting/visitor.h
@@ -15,6 +15,7 @@
#include "memory_bounded_trace.h"
#include <vespa/storageapi/messageapi/storagemessage.h>
#include <vespa/storageapi/message/visitor.h>
+#include <vespa/storageframework/generic/clock/time.h>
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/storage/common/visitorfactory.h>
#include <vespa/documentapi/messagebus/messages/documentmessage.h>
@@ -38,9 +39,7 @@ namespace documentapi {
namespace storage {
-namespace spi {
- class DocEntry;
-}
+namespace spi { class DocEntry; }
namespace api {
class ReturnCode;
diff --git a/storage/src/vespa/storage/visiting/visitormanager.cpp b/storage/src/vespa/storage/visiting/visitormanager.cpp
index 07938002746..ef5b7680f0a 100644
--- a/storage/src/vespa/storage/visiting/visitormanager.cpp
+++ b/storage/src/vespa/storage/visiting/visitormanager.cpp
@@ -7,6 +7,7 @@
#include "testvisitor.h"
#include "recoveryvisitor.h"
#include "reindexing_visitor.h"
+#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/config/subscription/configuri.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/config/helper/configfetcher.hpp>
@@ -23,7 +24,7 @@ namespace storage {
VisitorManager::VisitorManager(const config::ConfigUri & configUri,
StorageComponentRegister& componentRegister,
VisitorMessageSessionFactory& messageSF,
- const VisitorFactory::Map& externalFactories,
+ VisitorFactory::Map externalFactories,
bool defer_manager_thread_start)
: StorageLink("Visitor Manager"),
framework::HtmlStatusReporter("visitorman", "Visitor Manager"),
@@ -43,12 +44,12 @@ VisitorManager::VisitorManager(const config::ConfigUri & configUri,
_component(componentRegister, "visitormanager"),
_visitorQueue(_component.getClock()),
_recentlyDeletedVisitors(),
- _recentlyDeletedMaxTime(5 * 1000 * 1000),
+ _recentlyDeletedMaxTime(5s),
_statusLock(),
_statusCond(),
_statusRequest(),
_enforceQueueUse(false),
- _visitorFactories(externalFactories)
+ _visitorFactories(std::move(externalFactories))
{
_configFetcher->subscribe<vespa::config::content::core::StorVisitorConfig>(configUri.getConfigId(), this);
_configFetcher->start();
@@ -524,11 +525,11 @@ VisitorManager::closed(api::VisitorId id)
"same visitor. This was not intended.");
return;
}
- framework::MicroSecTime time(_component.getClock().getTimeInMicros());
- _recentlyDeletedVisitors.emplace_back(it->second, time);
+ vespalib::steady_time now(_component.getClock().getMonotonicTime());
+ _recentlyDeletedVisitors.emplace_back(it->second, now);
_nameToId.erase(it->second);
usedIds.erase(it);
- while ((_recentlyDeletedVisitors.front().second + _recentlyDeletedMaxTime) < time) {
+ while ((_recentlyDeletedVisitors.front().second + _recentlyDeletedMaxTime) < now) {
_recentlyDeletedVisitors.pop_front();
}
@@ -653,9 +654,9 @@ VisitorManager::reportHtmlStatus(std::ostream& out,
std::sort(_statusRequest.begin(), _statusRequest.end(), StatusReqSorter());
// Create output
- for (uint32_t i=0; i<_statusRequest.size(); ++i) {
- out << "<h2>" << _statusRequest[i]->getSortToken()
- << "</h2>\n" << _statusRequest[i]->getStatus() << "\n";
+ for (auto & request : _statusRequest) {
+ out << "<h2>" << request->getSortToken()
+ << "</h2>\n" << request->getStatus() << "\n";
}
_statusRequest.clear();
}
diff --git a/storage/src/vespa/storage/visiting/visitormanager.h b/storage/src/vespa/storage/visiting/visitormanager.h
index 3e331e1c9a2..0c5ec08fb4c 100644
--- a/storage/src/vespa/storage/visiting/visitormanager.h
+++ b/storage/src/vespa/storage/visiting/visitormanager.h
@@ -52,8 +52,7 @@ private:
StorageComponentRegister& _componentRegister;
VisitorMessageSessionFactory& _messageSessionFactory;
std::vector<std::pair<std::shared_ptr<VisitorThread>,
- std::map<api::VisitorId, std::string>
- > > _visitorThread;
+ std::map<api::VisitorId, std::string>> > _visitorThread;
struct MessageInfo {
api::VisitorId id;
@@ -73,10 +72,10 @@ private:
uint32_t _maxVisitorQueueSize;
std::map<std::string, api::VisitorId> _nameToId;
StorageComponent _component;
- framework::Thread::UP _thread;
+ std::unique_ptr<framework::Thread> _thread;
CommandQueue<api::CreateVisitorCommand> _visitorQueue;
- std::deque<std::pair<std::string, framework::MicroSecTime> > _recentlyDeletedVisitors;
- framework::MicroSecTime _recentlyDeletedMaxTime;
+ std::deque<std::pair<std::string, vespalib::steady_time> > _recentlyDeletedVisitors;
+ vespalib::duration _recentlyDeletedMaxTime;
mutable std::mutex _statusLock; // Only one can get status at a time
mutable std::condition_variable _statusCond;// Notify when done
@@ -87,7 +86,7 @@ public:
VisitorManager(const config::ConfigUri & configUri,
StorageComponentRegister&,
VisitorMessageSessionFactory&,
- const VisitorFactory::Map& external = VisitorFactory::Map(),
+ VisitorFactory::Map external = VisitorFactory::Map(),
bool defer_manager_thread_start = false);
~VisitorManager() override;
diff --git a/storage/src/vespa/storage/visiting/visitorthread.cpp b/storage/src/vespa/storage/visiting/visitorthread.cpp
index e3ebef3a3ef..ed26ae59bcc 100644
--- a/storage/src/vespa/storage/visiting/visitorthread.cpp
+++ b/storage/src/vespa/storage/visiting/visitorthread.cpp
@@ -2,6 +2,8 @@
#include "visitorthread.h"
#include "messages.h"
+#include <vespa/storageframework/generic/thread/thread.h>
+#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/document/base/exceptions.h>
#include <vespa/document/select/bodyfielddetector.h>
#include <vespa/document/select/parser.h>
diff --git a/storage/src/vespa/storage/visiting/visitorthread.h b/storage/src/vespa/storage/visiting/visitorthread.h
index 56e40328fda..23a4a81d6a6 100644
--- a/storage/src/vespa/storage/visiting/visitorthread.h
+++ b/storage/src/vespa/storage/visiting/visitorthread.h
@@ -19,6 +19,7 @@
#include <vespa/storage/persistence/messages.h>
#include <vespa/storage/common/storagecomponent.h>
#include <vespa/storageframework/generic/metric/metricupdatehook.h>
+#include <vespa/storageframework/generic/thread/runnable.h>
#include <vespa/storageapi/messageapi/messagehandler.h>
#include <vespa/metrics/metrictimer.h>
#include <vespa/vespalib/util/document_runnable.h>
@@ -86,7 +87,7 @@ class VisitorThread : public framework::Runnable,
framework::MilliSecTime _defaultVisitorInfoTimeout;
std::atomic<uint32_t> _timeBetweenTicks;
StorageComponent _component;
- framework::Thread::UP _thread;
+ std::unique_ptr<framework::Thread> _thread;
VisitorMessageSessionFactory& _messageSessionFactory;
VisitorFactory::Map& _visitorFactories;
diff --git a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
index 1c33fa453bd..40c2cc3b111 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
+++ b/storage/src/vespa/storageframework/defaultimplementation/component/componentregisterimpl.cpp
@@ -1,7 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "componentregisterimpl.h"
-#include <vespa/storageframework/storageframework.h>
+#include <vespa/storageframework/generic/status/statusreporter.h>
+#include <vespa/storageframework/generic/metric/metricupdatehook.h>
#include <vespa/metrics/metricmanager.h>
#include <vespa/vespalib/util/exceptions.h>
#include <cassert>
diff --git a/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp b/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp
index 179f315b65a..925c9cda248 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp
+++ b/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp
@@ -86,6 +86,11 @@ ThreadImpl::get_live_thread_stack_trace() const
}
void
+ThreadImpl::registerTick(CycleType cycleType) {
+ registerTick(cycleType, _pool.getClock().getMonotonicTime());
+}
+
+void
ThreadImpl::registerTick(CycleType cycleType, vespalib::steady_time now)
{
if (now.time_since_epoch() == vespalib::duration::zero()) now = _pool.getClock().getMonotonicTime();
diff --git a/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.h b/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.h
index 8bbf64efcc4..d95ba2a37ef 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.h
+++ b/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/storageframework/generic/thread/threadpool.h>
+#include <vespa/storageframework/generic/thread/thread.h>
#include <vespa/vespalib/util/cpu_usage.h>
#include <vespa/vespalib/util/document_runnable.h>
#include <array>
@@ -17,7 +17,7 @@ class ThreadImpl final : public Thread
{
struct BackendThread : public document::Runnable {
ThreadImpl& _impl;
- BackendThread(ThreadImpl& impl) : _impl(impl) {}
+ explicit BackendThread(ThreadImpl& impl) : _impl(impl) {}
void run() override { _impl.run(); }
};
@@ -71,6 +71,7 @@ public:
vespalib::string get_live_thread_stack_trace() const override;
void registerTick(CycleType, vespalib::steady_time) override;
+ void registerTick(CycleType cycleType) override;
vespalib::duration getWaitTime() const override {
return _properties.getWaitTime();
}
diff --git a/storage/src/vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h b/storage/src/vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h
index c351eb2ddd0..b788a3eed78 100644
--- a/storage/src/vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h
+++ b/storage/src/vespa/storageframework/defaultimplementation/thread/threadpoolimpl.h
@@ -6,6 +6,9 @@
class FastOS_ThreadPool;
+namespace storage::framework {
+ struct Clock;
+}
namespace storage::framework::defaultimplementation {
class ThreadImpl;
@@ -22,9 +25,9 @@ public:
ThreadPoolImpl(Clock&);
~ThreadPoolImpl() override;
- Thread::UP startThread(Runnable&, vespalib::stringref id, vespalib::duration waitTime,
- vespalib::duration maxProcessTime, int ticksBeforeWait,
- std::optional<vespalib::CpuUsage::Category> cpu_category) override;
+ std::unique_ptr<Thread> startThread(Runnable&, vespalib::stringref id, vespalib::duration waitTime,
+ vespalib::duration maxProcessTime, int ticksBeforeWait,
+ std::optional<vespalib::CpuUsage::Category> cpu_category) override;
void visitThreads(ThreadVisitor&) const override;
void unregisterThread(ThreadImpl&);
FastOS_ThreadPool& getThreadPool() { return *_backendThreadPool; }
diff --git a/storage/src/vespa/storageframework/generic/clock/timer.h b/storage/src/vespa/storageframework/generic/clock/timer.h
index 2642a6decc4..82b2fcc448e 100644
--- a/storage/src/vespa/storageframework/generic/clock/timer.h
+++ b/storage/src/vespa/storageframework/generic/clock/timer.h
@@ -17,7 +17,7 @@ class MilliSecTimer {
MonotonicTimePoint _startTime;
public:
- MilliSecTimer(const Clock& clock)
+ explicit MilliSecTimer(const Clock& clock)
: _clock(&clock), _startTime(_clock->getMonotonicTime()) {}
// Copy construction makes the most sense when creating a timer that is
@@ -26,11 +26,11 @@ public:
MilliSecTimer(const MilliSecTimer&) = default;
MilliSecTimer& operator=(const MilliSecTimer&) = default;
- MonotonicDuration getElapsedTime() const {
+ [[nodiscard]] MonotonicDuration getElapsedTime() const {
return _clock->getMonotonicTime() - _startTime;
}
- double getElapsedTimeAsDouble() const {
+ [[nodiscard]] double getElapsedTimeAsDouble() const {
using ToDuration = std::chrono::duration<double, std::milli>;
return std::chrono::duration_cast<ToDuration>(getElapsedTime()).count();
}
diff --git a/storage/src/vespa/storageframework/generic/component/component.cpp b/storage/src/vespa/storageframework/generic/component/component.cpp
index 17e521a99ac..0f08503852c 100644
--- a/storage/src/vespa/storageframework/generic/component/component.cpp
+++ b/storage/src/vespa/storageframework/generic/component/component.cpp
@@ -4,6 +4,8 @@
#include "componentregister.h"
#include <vespa/storageframework/generic/metric/metricregistrator.h>
#include <vespa/storageframework/generic/thread/threadpool.h>
+#include <vespa/storageframework/generic/thread/thread.h>
+
#include <cassert>
namespace storage::framework {
@@ -78,7 +80,7 @@ Component::getThreadPool() const
}
// Helper functions for components wanting to start a single thread.
-Thread::UP
+std::unique_ptr<Thread>
Component::startThread(Runnable& runnable, vespalib::duration waitTime, vespalib::duration maxProcessTime,
int ticksBeforeWait, std::optional<vespalib::CpuUsage::Category> cpu_category) const
{
diff --git a/storage/src/vespa/storageframework/generic/component/component.h b/storage/src/vespa/storageframework/generic/component/component.h
index df1aea09653..9a5e524e504 100644
--- a/storage/src/vespa/storageframework/generic/component/component.h
+++ b/storage/src/vespa/storageframework/generic/component/component.h
@@ -68,9 +68,6 @@
#pragma once
#include "managedcomponent.h"
-#include <vespa/storageframework/generic/thread/runnable.h>
-#include <vespa/storageframework/generic/thread/thread.h>
-#include <vespa/storageframework/generic/clock/clock.h>
#include <vespa/vespalib/util/cpu_usage.h>
#include <atomic>
#include <optional>
@@ -78,6 +75,8 @@
namespace storage::framework {
struct ComponentRegister;
+struct Runnable;
+class Thread;
class Component : private ManagedComponent
{
@@ -152,11 +151,11 @@ public:
* If max process time is not set, deadlock detector cannot detect deadlocks
* in this thread. (Thus one is not required to call registerTick())
*/
- Thread::UP startThread(Runnable&,
- vespalib::duration maxProcessTime = vespalib::duration::zero(),
- vespalib::duration waitTime = vespalib::duration::zero(),
- int ticksBeforeWait = 1,
- std::optional<vespalib::CpuUsage::Category> cpu_category = std::nullopt) const;
+ std::unique_ptr<Thread> startThread(Runnable&,
+ vespalib::duration maxProcessTime = vespalib::duration::zero(),
+ vespalib::duration waitTime = vespalib::duration::zero(),
+ int ticksBeforeWait = 1,
+ std::optional<vespalib::CpuUsage::Category> cpu_category = std::nullopt) const;
void requestShutdown(vespalib::stringref reason);
diff --git a/storage/src/vespa/storageframework/generic/component/managedcomponent.h b/storage/src/vespa/storageframework/generic/component/managedcomponent.h
index aba6d6bd4eb..dfddaaa8641 100644
--- a/storage/src/vespa/storageframework/generic/component/managedcomponent.h
+++ b/storage/src/vespa/storageframework/generic/component/managedcomponent.h
@@ -12,7 +12,6 @@
*/
#pragma once
-#include <vespa/storageframework/generic/clock/time.h>
#include <vespa/vespalib/stllike/string.h>
namespace metrics {
diff --git a/storage/src/vespa/storageframework/generic/metric/metricregistrator.h b/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
index 11ce53b3d5b..6daca1213a8 100644
--- a/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
+++ b/storage/src/vespa/storageframework/generic/metric/metricregistrator.h
@@ -10,7 +10,7 @@
*/
#pragma once
-#include <vespa/storageframework/generic/clock/time.h>
+#include <vespa/vespalib/util/time.h>
namespace metrics {
class Metric;
diff --git a/storage/src/vespa/storageframework/generic/thread/runnable.h b/storage/src/vespa/storageframework/generic/thread/runnable.h
index b1fd2eae237..5cd2f981612 100644
--- a/storage/src/vespa/storageframework/generic/thread/runnable.h
+++ b/storage/src/vespa/storageframework/generic/thread/runnable.h
@@ -9,7 +9,7 @@
*/
#pragma once
-#include <vespa/storageframework/generic/clock/time.h>
+#include <vespa/vespalib/util/time.h>
namespace storage::framework {
@@ -21,13 +21,12 @@ namespace storage::framework {
* the thread is waiting for 1000 ms when it is idle.
*/
enum CycleType { UNKNOWN_CYCLE, WAIT_CYCLE, PROCESS_CYCLE };
-const char* getCycleTypeName(CycleType);
struct ThreadHandle {
- virtual ~ThreadHandle() {}
+ virtual ~ThreadHandle() = default;
/** Check whether thread have been interrupted or not. */
- virtual bool interrupted() const = 0;
+ [[nodiscard]] virtual bool interrupted() const = 0;
/**
* Register a tick. Useful such that a deadlock detector can detect that
@@ -42,20 +41,20 @@ struct ThreadHandle {
* not need to calculate clock. (Too avoid additional
* clock fetches if client already knows current time)
*/
- virtual void registerTick(CycleType = UNKNOWN_CYCLE,
- vespalib::steady_time = vespalib::steady_time()) = 0;
+ virtual void registerTick(CycleType cycleType, vespalib::steady_time time) = 0;
+ virtual void registerTick(CycleType cycleType) = 0;
- virtual vespalib::duration getWaitTime() const = 0;
+ [[nodiscard]] virtual vespalib::duration getWaitTime() const = 0;
/**
* The number of ticks done before wait is called when no more work is
* reported.
*/
- virtual int getTicksBeforeWait() const = 0;
+ [[nodiscard]] virtual int getTicksBeforeWait() const = 0;
};
struct Runnable {
- virtual ~Runnable() {}
+ virtual ~Runnable() = default;
virtual void run(ThreadHandle&) = 0;
};
diff --git a/storage/src/vespa/storageframework/generic/thread/thread_properties.h b/storage/src/vespa/storageframework/generic/thread/thread_properties.h
index 2f45cf331e8..9b92ed2cd6c 100644
--- a/storage/src/vespa/storageframework/generic/thread/thread_properties.h
+++ b/storage/src/vespa/storageframework/generic/thread/thread_properties.h
@@ -1,8 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/storageframework/generic/clock/time.h>
-#include <cstdint>
+#include <vespa/vespalib/util/time.h>
namespace storage::framework {
@@ -37,11 +36,11 @@ public:
vespalib::duration maxProcessTime,
int ticksBeforeWait);
- vespalib::duration getMaxProcessTime() const { return _maxProcessTime; }
- vespalib::duration getWaitTime() const { return _waitTime; }
- int getTicksBeforeWait() const { return _ticksBeforeWait; }
+ [[nodiscard]] vespalib::duration getMaxProcessTime() const { return _maxProcessTime; }
+ [[nodiscard]] vespalib::duration getWaitTime() const { return _waitTime; }
+ [[nodiscard]] int getTicksBeforeWait() const { return _ticksBeforeWait; }
- vespalib::duration getMaxCycleTime() const {
+ [[nodiscard]] vespalib::duration getMaxCycleTime() const {
return std::max(_maxProcessTime, _waitTime);
}
};
diff --git a/storage/src/vespa/storageframework/generic/thread/threadpool.h b/storage/src/vespa/storageframework/generic/thread/threadpool.h
index 927a6ca35df..932036e1859 100644
--- a/storage/src/vespa/storageframework/generic/thread/threadpool.h
+++ b/storage/src/vespa/storageframework/generic/thread/threadpool.h
@@ -13,15 +13,15 @@
#pragma once
#include <atomic>
-#include <vespa/storageframework/generic/thread/runnable.h>
-#include <vespa/storageframework/generic/thread/thread.h>
-#include <vespa/storageframework/generic/clock/time.h>
#include <vespa/vespalib/util/cpu_usage.h>
#include <optional>
#include <vector>
namespace storage::framework {
+class Thread;
+struct Runnable;
+
/** Interface used to access data for the existing threads. */
struct ThreadVisitor {
virtual ~ThreadVisitor() = default;
@@ -31,11 +31,8 @@ struct ThreadVisitor {
struct ThreadPool {
virtual ~ThreadPool() = default;
- virtual Thread::UP startThread(Runnable&,
- vespalib::stringref id,
- vespalib::duration waitTime,
- vespalib::duration maxProcessTime,
- int ticksBeforeWait,
+ virtual std::unique_ptr<Thread> startThread(Runnable&, vespalib::stringref id, vespalib::duration waitTime,
+ vespalib::duration maxProcessTime, int ticksBeforeWait,
std::optional<vespalib::CpuUsage::Category> cpu_category) = 0;
virtual void visitThreads(ThreadVisitor&) const = 0;
diff --git a/storage/src/vespa/storageframework/generic/thread/tickingthread.cpp b/storage/src/vespa/storageframework/generic/thread/tickingthread.cpp
index 9045e989c27..a62224bafe6 100644
--- a/storage/src/vespa/storageframework/generic/thread/tickingthread.cpp
+++ b/storage/src/vespa/storageframework/generic/thread/tickingthread.cpp
@@ -1,6 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "tickingthread.h"
#include "threadpool.h"
+#include "runnable.h"
+#include "thread.h"
#include <vespa/vespalib/stllike/asciistream.h>
#include <cassert>
@@ -37,7 +39,7 @@ public:
TickingThread& ticker,
uint32_t threadIndex) noexcept
: _monitor(m), _cond(cond), _tickingThread(ticker),
- _threadIndex(threadIndex), _wantToFreeze(false), _frozen(false) {}
+ _threadIndex(threadIndex), _wantToFreeze(false), _frozen(false), _state('n') {}
/**
* Call to freeze this thread. Returns then the thread has done executing
@@ -62,7 +64,7 @@ public:
_cond.notify_all();
}
- char getState() const { return _state; }
+ [[nodiscard]] char getState() const { return _state; }
private:
void run(ThreadHandle& handle) override {
diff --git a/storage/src/vespa/storageframework/generic/thread/tickingthread.h b/storage/src/vespa/storageframework/generic/thread/tickingthread.h
index 9ddc47c8f3a..646dbf0099c 100644
--- a/storage/src/vespa/storageframework/generic/thread/tickingthread.h
+++ b/storage/src/vespa/storageframework/generic/thread/tickingthread.h
@@ -19,7 +19,7 @@
#pragma once
#include <memory>
-#include <vespa/storageframework/generic/clock/time.h>
+#include <vespa/vespalib/util/time.h>
#include <vespa/vespalib/stllike/string.h>
namespace storage::framework {
@@ -40,7 +40,7 @@ public:
static ThreadWaitInfo NO_MORE_CRITICAL_WORK_KNOWN;
void merge(const ThreadWaitInfo& other);
- bool waitWanted() const noexcept { return _waitWanted; }
+ [[nodiscard]] bool waitWanted() const noexcept { return _waitWanted; }
};
/**
diff --git a/storage/src/vespa/storageframework/storageframework.h b/storage/src/vespa/storageframework/storageframework.h
deleted file mode 100644
index 12d4f504d30..00000000000
--- a/storage/src/vespa/storageframework/storageframework.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-/**
- *
- * This file includes the most common parts used by the framework.
- */
-
-#include <vespa/storageframework/generic/clock/clock.h>
-#include <vespa/storageframework/generic/clock/timer.h>
-#include <vespa/storageframework/generic/component/component.h>
-#include <vespa/storageframework/generic/metric/metricupdatehook.h>
-#include <vespa/storageframework/generic/status/htmlstatusreporter.h>
-#include <vespa/storageframework/generic/status/statusreportermap.h>
-#include <vespa/storageframework/generic/status/xmlstatusreporter.h>
-#include <vespa/storageframework/generic/thread/threadpool.h>
-