diff options
author | Tor Egge <Tor.Egge@online.no> | 2021-10-18 14:29:11 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2021-10-18 14:29:11 +0200 |
commit | b8cf8c2dd0ab117ae68cae60f6ef71373e98da48 (patch) | |
tree | b2f3635f6243b5a40412cee1001cb9a5918ff825 /searchcore | |
parent | a6784673e65b55a7812d208c06f76ad903b81cab (diff) |
Move MonitoredRefCount and RetainGuard to vespalib.
Diffstat (limited to 'searchcore')
25 files changed, 62 insertions, 148 deletions
diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp index e2f2f21f596..2c21a30396d 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp @@ -23,6 +23,8 @@ using storage::spi::BucketInfo; using BlockedReason = IBlockableMaintenanceJob::BlockedReason; using MoveOperationVector = std::vector<MoveOperation>; using storage::spi::dummy::DummyBucketExecutor; +using vespalib::MonitoredRefCount; +using vespalib::RetainGuard; using vespalib::ThreadStackExecutor; struct ControllerFixtureBase : public ::testing::Test diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp index c9b009e4a17..13955953eb5 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.cpp @@ -6,6 +6,8 @@ #include <vespa/persistence/dummyimpl/dummy_bucket_executor.h> #include <vespa/vespalib/util/threadstackexecutor.h> +using vespalib::RetainGuard; + using BlockedReason = IBlockableMaintenanceJob::BlockedReason; struct MyDirectJobRunner : public IMaintenanceJobRunner { diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h index 774acd0071a..14f2ff42dbe 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_jobtest.h @@ -2,14 +2,14 @@ #include "lid_space_common.h" #include <vespa/searchcore/proton/server/blockable_maintenance_job.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> #include <vespa/persistence/spi/bucketexecutor.h> #include <vespa/searchcorespi/index/i_thread_service.h> +#include <vespa/vespalib/util/monitored_refcount.h> #include <vespa/vespalib/gtest/gtest.h> namespace storage::spi::dummy { class DummyBucketExecutor; } struct JobTestBase : public ::testing::Test { - MonitoredRefCount _refCount; + vespalib::MonitoredRefCount _refCount; test::ClusterStateHandler _clusterStateHandler; test::DiskMemUsageNotifier _diskMemUsageNotifier; std::unique_ptr<storage::spi::dummy::DummyBucketExecutor> _bucketExecutor; diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index 1463be8cdbd..71ae26180ad 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -6,7 +6,6 @@ #include <vespa/searchcore/proton/attribute/i_attribute_manager.h> #include <vespa/searchcore/proton/bucketdb/bucket_create_notifier.h> #include <vespa/searchcore/proton/common/doctypename.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> #include <vespa/searchcore/proton/common/transient_resource_usage_provider.h> #include <vespa/searchcore/proton/documentmetastore/operation_listener.h> #include <vespa/searchcore/proton/documentmetastore/documentmetastore.h> @@ -42,6 +41,7 @@ #include <vespa/vespalib/util/destructor_callbacks.h> #include <vespa/vespalib/util/gate.h> #include <vespa/vespalib/util/lambdatask.h> +#include <vespa/vespalib/util/monitored_refcount.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/fastos/thread.h> @@ -68,6 +68,7 @@ using search::SerialNum; using search::CommitParam; using storage::spi::BucketInfo; using storage::spi::Timestamp; +using vespalib::MonitoredRefCount; using vespalib::Slime; using vespalib::makeLambdaTask; using vespa::config::search::AttributesConfigBuilder; diff --git a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp index a76c375bbfc..061a3fd4c32 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp +++ b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp @@ -6,7 +6,6 @@ #include <vespa/document/datatype/referencedatatype.h> #include <vespa/log/log.h> #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> #include <vespa/searchcore/proton/reference/document_db_reference_resolver.h> #include <vespa/searchcore/proton/reference/gid_to_lid_change_listener.h> #include <vespa/searchcore/proton/reference/i_document_db_reference.h> @@ -19,6 +18,7 @@ #include <vespa/searchlib/attribute/reference_attribute.h> #include <vespa/searchlib/common/i_gid_to_lid_mapper.h> #include <vespa/searchlib/common/i_gid_to_lid_mapper_factory.h> +#include <vespa/vespalib/util/monitored_refcount.h> #include <vespa/vespalib/util/sequencedtaskexecutor.h> #include <vespa/searchlib/test/mock_attribute_manager.h> #include <vespa/vespalib/test/insertion_operators.h> @@ -33,6 +33,7 @@ using proton::test::MockDocumentDBReference; using search::attribute::test::MockAttributeManager; using vespa::config::search::ImportedFieldsConfig; using vespa::config::search::ImportedFieldsConfigBuilder; +using vespalib::MonitoredRefCount; using vespalib::SequencedTaskExecutor; using vespalib::ISequencedTaskExecutor; diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp index 668be4c2c2d..15281563b93 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp @@ -2,12 +2,12 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/document/base/documentid.h> -#include <vespa/vespalib/util/sequencedtaskexecutor.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> #include <vespa/searchcore/proton/reference/gid_to_lid_change_listener.h> #include <vespa/searchlib/common/i_gid_to_lid_mapper_factory.h> #include <vespa/vespalib/util/destructor_callbacks.h> #include <vespa/vespalib/util/gate.h> +#include <vespa/vespalib/util/monitored_refcount.h> +#include <vespa/vespalib/util/sequencedtaskexecutor.h> #include <vespa/searchlib/test/mock_gid_to_lid_mapping.h> #include <map> #include <vespa/log/log.h> @@ -16,12 +16,13 @@ LOG_SETUP("gid_to_lid_change_listener_test"); using document::GlobalId; using document::BucketId; using document::DocumentId; -using vespalib::GenerationHandler; using search::attribute::Config; using search::attribute::BasicType; using search::attribute::Reference; using search::attribute::ReferenceAttribute; using search::attribute::test::MockGidToLidMapperFactory; +using vespalib::MonitoredRefCount; +using vespalib::GenerationHandler; namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt index 07d749d8c4f..219a2ea43a4 100644 --- a/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/common/CMakeLists.txt @@ -16,7 +16,6 @@ vespa_add_library(searchcore_pcommon STATIC hw_info_sampler.cpp indexschema_inspector.cpp ipendinglidtracker.cpp - monitored_refcount.cpp operation_rate_tracker.cpp pendinglidtracker.cpp select_utils.cpp diff --git a/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp b/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp deleted file mode 100644 index 97615abba31..00000000000 --- a/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "monitored_refcount.h" -#include <cassert> - -namespace proton { - -MonitoredRefCount::MonitoredRefCount() - : _lock(), - _cv(), - _refCount(0u) -{ -} - -MonitoredRefCount::~MonitoredRefCount() -{ - assert(_refCount == 0u); -} - -void -MonitoredRefCount::retain() noexcept -{ - std::lock_guard<std::mutex> guard(_lock); - ++_refCount; -} - -void -MonitoredRefCount::release() noexcept -{ - std::lock_guard<std::mutex> guard(_lock); - --_refCount; - if (_refCount == 0u) { - _cv.notify_all(); - } -} - -void -MonitoredRefCount::waitForZeroRefCount() -{ - std::unique_lock<std::mutex> guard(_lock); - _cv.wait(guard, [this] { return (_refCount == 0u); }); -} - -} // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.h b/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.h deleted file mode 100644 index 9eb713b1220..00000000000 --- a/searchcore/src/vespa/searchcore/proton/common/monitored_refcount.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <mutex> -#include <condition_variable> - -namespace proton { - -class RetainGuard; -/* - * Class containing a reference count that can be waited on to become zero. - * Typically ancestor or member of a class that has to be careful of when - * portions object can be properly torn down before destruction itself. - */ -class MonitoredRefCount -{ - std::mutex _lock; - std::condition_variable _cv; - uint32_t _refCount; - void retain() noexcept; - void release() noexcept; - friend RetainGuard; -public: - MonitoredRefCount(); - virtual ~MonitoredRefCount(); - void waitForZeroRefCount(); -}; - -class RetainGuard { -public: - RetainGuard(MonitoredRefCount & refCount) noexcept - : _refCount(&refCount) - { - _refCount->retain(); - } - RetainGuard(const RetainGuard & rhs) = delete; - RetainGuard & operator=(const RetainGuard & rhs) = delete; - RetainGuard(RetainGuard && rhs) noexcept - : _refCount(rhs._refCount) - { - rhs._refCount = nullptr; - } - RetainGuard & operator=(RetainGuard && rhs) noexcept { - release(); - _refCount = rhs._refCount; - rhs._refCount = nullptr; - return *this; - } - ~RetainGuard() { release(); } -private: - void release() noexcept{ - if (_refCount != nullptr) { - _refCount->release(); - _refCount = nullptr; - } - } - MonitoredRefCount * _refCount; -}; - -} // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp index 4cc5fb0b5db..5d1e1318b04 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.cpp @@ -29,6 +29,8 @@ using search::AttributeVector; using search::IAttributeManager; using search::NotImplementedAttribute; using vespalib::ISequencedTaskExecutor; +using vespalib::MonitoredRefCount; +using vespalib::RetainGuard; using vespa::config::search::ImportedFieldsConfig; namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h index 761b9407fe5..522cdf83477 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h +++ b/searchcore/src/vespa/searchcore/proton/reference/document_db_reference_resolver.h @@ -21,15 +21,17 @@ namespace search::attribute { namespace vespa::config::search::internal { class InternalImportedFieldsType; } namespace vespalib { - class ISequencedTaskExecutor; + +class ISequencedTaskExecutor; +class MonitoredRefCount; } + namespace proton { class IDocumentDBReference; class IDocumentDBReferenceRegistry; class ImportedAttributesRepo; class GidToLidChangeRegistrator; -class MonitoredRefCount; /** * Class that for a given document db resolves all references to parent document dbs: @@ -42,7 +44,7 @@ private: const document::DocumentType &_thisDocType; const ImportedFieldsConfig &_importedFieldsCfg; const document::DocumentType &_prevThisDocType; - MonitoredRefCount &_refCount; + vespalib::MonitoredRefCount &_refCount; vespalib::ISequencedTaskExecutor &_attributeFieldWriter; bool _useReferences; std::map<vespalib::string, std::unique_ptr<GidToLidChangeRegistrator>> _registrators; @@ -61,7 +63,7 @@ public: const document::DocumentType &thisDocType, const ImportedFieldsConfig &importedFieldsCfg, const document::DocumentType &prevThisDocType, - MonitoredRefCount &refCount, + vespalib::MonitoredRefCount &refCount, vespalib::ISequencedTaskExecutor &attributeFieldWriter, bool useReferences); ~DocumentDBReferenceResolver() override; diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp index c7e716b4173..427cbab2a14 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.cpp @@ -3,6 +3,8 @@ #include "gid_to_lid_change_listener.h" #include <future> +using vespalib::RetainGuard; + namespace proton { GidToLidChangeListener::GidToLidChangeListener(vespalib::ISequencedTaskExecutor &attributeFieldWriter, diff --git a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h index 23bb32af87a..28e9684ed86 100644 --- a/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h +++ b/searchcore/src/vespa/searchcore/proton/reference/gid_to_lid_change_listener.h @@ -4,8 +4,8 @@ #include "i_gid_to_lid_change_listener.h" #include <vespa/searchlib/attribute/reference_attribute.h> +#include <vespa/vespalib/util/retain_guard.h> #include <vespa/vespalib/util/sequencedtaskexecutor.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> namespace proton { @@ -18,14 +18,14 @@ class GidToLidChangeListener : public IGidToLidChangeListener vespalib::ISequencedTaskExecutor &_attributeFieldWriter; vespalib::ISequencedTaskExecutor::ExecutorId _executorId; std::shared_ptr<search::attribute::ReferenceAttribute> _attr; - RetainGuard _retainGuard; + vespalib::RetainGuard _retainGuard; vespalib::string _name; vespalib::string _docTypeName; public: GidToLidChangeListener(vespalib::ISequencedTaskExecutor &attributeFieldWriter, std::shared_ptr<search::attribute::ReferenceAttribute> attr, - RetainGuard refCount, + vespalib::RetainGuard refCount, const vespalib::string &name, const vespalib::string &docTypeName); ~GidToLidChangeListener() override; diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp index c70928cd5e8..386d8367e52 100644 --- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.cpp @@ -25,6 +25,7 @@ using document::BucketId; using storage::spi::BucketInfo; using storage::spi::Bucket; using proton::bucketdb::BucketMover; +using vespalib::RetainGuard; using vespalib::makeLambdaTask; using vespalib::Trinary; diff --git a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h index 66d24efb466..d4438fcd411 100644 --- a/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h +++ b/searchcore/src/vespa/searchcore/proton/server/bucketmovejob.h @@ -10,7 +10,7 @@ #include "maintenancedocumentsubdb.h" #include <vespa/searchcore/proton/bucketdb/bucketscaniterator.h> #include <vespa/searchcore/proton/bucketdb/i_bucket_create_listener.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> +#include <vespa/vespalib/util/retain_guard.h> namespace storage::spi { struct BucketExecutor; } @@ -59,7 +59,7 @@ private: using Movers = std::vector<BucketMoverSP>; using GuardedMoveOps = BucketMover::GuardedMoveOps; std::shared_ptr<IBucketStateCalculator> _calc; - RetainGuard _dbRetainer; + vespalib::RetainGuard _dbRetainer; IDocumentMoveHandler &_moveHandler; IBucketModifiedHandler &_modifiedHandler; IThreadService &_master; @@ -80,7 +80,7 @@ private: IDiskMemUsageNotifier &_diskMemUsageNotifier; BucketMoveJob(const std::shared_ptr<IBucketStateCalculator> &calc, - RetainGuard dbRetainer, + vespalib::RetainGuard dbRetainer, IDocumentMoveHandler &moveHandler, IBucketModifiedHandler &modifiedHandler, IThreadService & master, @@ -115,7 +115,7 @@ private: public: static std::shared_ptr<BucketMoveJob> create(const std::shared_ptr<IBucketStateCalculator> &calc, - RetainGuard dbRetainer, + vespalib::RetainGuard dbRetainer, IDocumentMoveHandler &moveHandler, IBucketModifiedHandler &modifiedHandler, IThreadService & master, diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index 936ba812a44..014bba11f83 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -19,13 +19,13 @@ #include "threading_service_config.h" #include <vespa/searchcore/proton/attribute/attribute_usage_filter.h> #include <vespa/searchcore/proton/common/doctypename.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> #include <vespa/searchcore/proton/metrics/documentdb_job_trackers.h> #include <vespa/searchcore/proton/metrics/documentdb_tagged_metrics.h> #include <vespa/searchcore/proton/persistenceengine/i_resource_write_filter.h> #include <vespa/searchcore/proton/index/indexmanager.h> #include <vespa/searchlib/docstore/cachestats.h> #include <vespa/searchlib/transactionlog/syncproxy.h> +#include <vespa/vespalib/util/retain_guard.h> #include <vespa/vespalib/util/varholder.h> #include <mutex> #include <condition_variable> @@ -111,7 +111,7 @@ private: DocumentDBTaggedMetrics _metrics; std::unique_ptr<metrics::UpdateHook> _metricsHook; vespalib::VarHolder<IFeedView::SP> _feedView; - MonitoredRefCount _refCount; + vespalib::MonitoredRefCount _refCount; bool _syncFeedViewEnabled; IDocumentDBOwner &_owner; storage::spi::BucketExecutor &_bucketExecutor; @@ -381,7 +381,7 @@ public: /** * Reference counting */ - RetainGuard retain() { return RetainGuard(_refCount); } + vespalib::RetainGuard retain() { return vespalib::RetainGuard(_refCount); } bool getDelayedConfig() const { return _state.getDelayedConfig(); } void replayConfig(SerialNum serialNum) override; diff --git a/searchcore/src/vespa/searchcore/proton/server/flushhandlerproxy.h b/searchcore/src/vespa/searchcore/proton/server/flushhandlerproxy.h index fe937a35db7..2098466a2c0 100644 --- a/searchcore/src/vespa/searchcore/proton/server/flushhandlerproxy.h +++ b/searchcore/src/vespa/searchcore/proton/server/flushhandlerproxy.h @@ -3,7 +3,7 @@ #pragma once #include <vespa/searchcore/proton/flushengine/iflushhandler.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> +#include <vespa/vespalib/util/retain_guard.h> namespace proton { @@ -13,7 +13,7 @@ class FlushHandlerProxy : public IFlushHandler { private: std::shared_ptr<DocumentDB> _documentDB; - RetainGuard _retainGuard; + vespalib::RetainGuard _retainGuard; public: FlushHandlerProxy(const std::shared_ptr<DocumentDB> &documentDB); diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp index efe92a11f02..a5c1d1fc2c9 100644 --- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.cpp @@ -26,6 +26,7 @@ using search::DocumentMetaData; using search::LidUsageStats; using storage::spi::makeBucketTask; using storage::spi::Bucket; +using vespalib::RetainGuard; using vespalib::makeLambdaTask; namespace proton::lidspace { diff --git a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.h b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.h index 717c19f093d..917ff12be4a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.h +++ b/searchcore/src/vespa/searchcore/proton/server/lid_space_compaction_job.h @@ -6,9 +6,9 @@ #include "document_db_maintenance_config.h" #include "i_disk_mem_usage_listener.h" #include "iclusterstatechangedhandler.h" -#include <vespa/searchlib/common/idocumentmetastore.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> #include <vespa/document/bucket/bucketspace.h> +#include <vespa/searchlib/common/idocumentmetastore.h> +#include <vespa/vespalib/util/retain_guard.h> #include <atomic> namespace storage::spi { struct BucketExecutor; } @@ -50,7 +50,7 @@ private: bool _shouldCompactLidSpace; IThreadService &_master; BucketExecutor &_bucketExecutor; - RetainGuard _dbRetainer; + vespalib::RetainGuard _dbRetainer; document::BucketSpace _bucketSpace; bool hasTooMuchLidBloat(const search::LidUsageStats &stats) const; @@ -68,7 +68,7 @@ private: class MoveTask; CompactionJob(const DocumentDBLidSpaceCompactionConfig &config, - RetainGuard dbRetainer, + vespalib::RetainGuard dbRetainer, std::shared_ptr<ILidSpaceCompactionHandler> handler, IOperationStorer &opStorer, IThreadService & master, @@ -81,7 +81,7 @@ private: public: static std::shared_ptr<CompactionJob> create(const DocumentDBLidSpaceCompactionConfig &config, - RetainGuard dbRetainer, + vespalib::RetainGuard dbRetainer, std::shared_ptr<ILidSpaceCompactionHandler> handler, IOperationStorer &opStorer, IThreadService & master, diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp index 2adcdbab217..c4826bba8ea 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.cpp @@ -14,6 +14,7 @@ LOG_SETUP(".proton.server.maintenancecontroller"); using document::BucketId; using vespalib::Executor; +using vespalib::MonitoredRefCount; using vespalib::makeLambdaTask; namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h index bddd58a349a..8c8cc3e2d43 100644 --- a/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h +++ b/searchcore/src/vespa/searchcore/proton/server/maintenancecontroller.h @@ -5,14 +5,17 @@ #include "maintenancedocumentsubdb.h" #include "i_maintenance_job.h" #include <vespa/searchcore/proton/common/doctypename.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> +#include <vespa/vespalib/util/retain_guard.h> #include <vespa/vespalib/util/scheduledexecutor.h> #include <mutex> namespace vespalib { - class Timer; - class Executor; + +class Executor; +class MonitoredRefCount; +class Timer; + } namespace searchcorespi::index { struct IThreadService; } @@ -20,7 +23,6 @@ namespace proton { class MaintenanceJobRunner; class DocumentDBMaintenanceConfig; -class MonitoredRefCount; /** * Class that controls the bucket moving between ready and notready sub databases @@ -36,7 +38,7 @@ public: using UP = std::unique_ptr<MaintenanceController>; enum class State {INITIALIZING, STARTED, PAUSED, STOPPING}; - MaintenanceController(IThreadService &masterThread, vespalib::Executor & defaultExecutor, MonitoredRefCount & refCount, const DocTypeName &docTypeName); + MaintenanceController(IThreadService &masterThread, vespalib::Executor & defaultExecutor, vespalib::MonitoredRefCount & refCount, const DocTypeName &docTypeName); ~MaintenanceController(); void registerJobInMasterThread(IMaintenanceJob::UP job); @@ -70,14 +72,14 @@ public: const MaintenanceDocumentSubDB & getNotReadySubDB() const { return _notReadySubDB; } IThreadService & masterThread() { return _masterThread; } const DocTypeName & getDocTypeName() const { return _docTypeName; } - RetainGuard retainDB() { return RetainGuard(_refCount); } + vespalib::RetainGuard retainDB() { return vespalib::RetainGuard(_refCount); } private: using Mutex = std::mutex; using Guard = std::lock_guard<Mutex>; IThreadService &_masterThread; vespalib::Executor &_defaultExecutor; - MonitoredRefCount &_refCount; + vespalib::MonitoredRefCount &_refCount; MaintenanceDocumentSubDB _readySubDB; MaintenanceDocumentSubDB _remSubDB; MaintenanceDocumentSubDB _notReadySubDB; diff --git a/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h b/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h index 96bfbe18423..50e83a31e58 100644 --- a/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h +++ b/searchcore/src/vespa/searchcore/proton/server/persistencehandlerproxy.h @@ -3,7 +3,7 @@ #pragma once #include <vespa/searchcore/proton/persistenceengine/ipersistencehandler.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> +#include <vespa/vespalib/util/retain_guard.h> namespace proton { @@ -18,7 +18,7 @@ private: FeedHandler &_feedHandler; BucketHandler &_bucketHandler; ClusterStateHandler &_clusterStateHandler; - RetainGuard _retainGuard; + vespalib::RetainGuard _retainGuard; public: explicit PersistenceHandlerProxy(std::shared_ptr<DocumentDB> documentDB); diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp index c266a604e33..6fe1947bd1d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp @@ -16,6 +16,7 @@ using document::BucketId; using storage::spi::Timestamp; using storage::spi::Bucket; using vespalib::IDestructorCallback; +using vespalib::RetainGuard; using vespalib::makeLambdaTask; namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h index 5c52991d0c3..6198f588a32 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h +++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h @@ -3,9 +3,9 @@ #include "blockable_maintenance_job.h" #include "document_db_maintenance_config.h" -#include <vespa/searchcore/proton/common/monitored_refcount.h> #include <persistence/spi/types.h> #include <vespa/document/bucket/bucketspace.h> +#include <vespa/vespalib/util/retain_guard.h> #include <atomic> namespace storage::spi { struct BucketExecutor; } @@ -36,7 +36,7 @@ private: IThreadService &_master; BucketExecutor &_bucketExecutor; const vespalib::string _docTypeName; - RetainGuard _dbRetainer; + vespalib::RetainGuard _dbRetainer; const vespalib::duration _cfgAgeLimit; const uint32_t _subDbId; const document::BucketSpace _bucketSpace; @@ -45,14 +45,14 @@ private: void remove(uint32_t lid, const RawDocumentMetaData & meta); - PruneRemovedDocumentsJob(const DocumentDBPruneConfig &config, RetainGuard dbRetainer, const IDocumentMetaStore &metaStore, + PruneRemovedDocumentsJob(const DocumentDBPruneConfig &config, vespalib::RetainGuard dbRetainer, const IDocumentMetaStore &metaStore, uint32_t subDbId, document::BucketSpace bucketSpace, const vespalib::string &docTypeName, IPruneRemovedDocumentsHandler &handler, IThreadService & master, BucketExecutor & bucketExecutor); bool run() override; public: static std::shared_ptr<PruneRemovedDocumentsJob> - create(const Config &config, RetainGuard dbRetainer, const IDocumentMetaStore &metaStore, uint32_t subDbId, + create(const Config &config, vespalib::RetainGuard dbRetainer, const IDocumentMetaStore &metaStore, uint32_t subDbId, document::BucketSpace bucketSpace, const vespalib::string &docTypeName, IPruneRemovedDocumentsHandler &handler, IThreadService & master, BucketExecutor & bucketExecutor) { diff --git a/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h b/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h index 4eaf15b3b1c..f7c52ed4baa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchhandlerproxy.h @@ -3,7 +3,7 @@ #pragma once #include <vespa/searchcore/proton/summaryengine/isearchhandler.h> -#include <vespa/searchcore/proton/common/monitored_refcount.h> +#include <vespa/vespalib/util/retain_guard.h> namespace proton { @@ -13,7 +13,7 @@ class SearchHandlerProxy : public ISearchHandler { private: std::shared_ptr<DocumentDB> _documentDB; - RetainGuard _retainGuard; + vespalib::RetainGuard _retainGuard; public: SearchHandlerProxy(std::shared_ptr<DocumentDB> documentDB); |