From 11d358a64324317b3f63dae3be4cbe37f735473d Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 8 Dec 2022 17:17:33 +0000 Subject: Wire SessionManager via IDocumentSubDBOwner --- .../tests/proton/documentdb/configurer/configurer_test.cpp | 11 ++++------- .../documentdb/document_subdbs/document_subdbs_test.cpp | 10 ++++++++-- searchcore/src/vespa/searchcore/proton/server/documentdb.cpp | 7 ++++++- searchcore/src/vespa/searchcore/proton/server/documentdb.h | 9 +-------- .../searchcore/proton/server/documentsubdbcollection.cpp | 6 ++---- .../vespa/searchcore/proton/server/documentsubdbcollection.h | 8 ++------ .../vespa/searchcore/proton/server/fast_access_doc_subdb.cpp | 3 +-- .../vespa/searchcore/proton/server/fast_access_doc_subdb.h | 3 +-- .../vespa/searchcore/proton/server/i_document_subdb_owner.h | 4 ++++ .../src/vespa/searchcore/proton/server/idocumentsubdb.h | 3 ++- searchcore/src/vespa/searchcore/proton/server/matchview.cpp | 6 +++--- searchcore/src/vespa/searchcore/proton/server/matchview.h | 8 ++++---- .../src/vespa/searchcore/proton/server/searchabledocsubdb.cpp | 6 ++---- .../src/vespa/searchcore/proton/server/searchabledocsubdb.h | 2 +- searchcore/src/vespa/searchcore/proton/server/searchview.cpp | 3 +-- searchcore/src/vespa/searchcore/proton/server/searchview.h | 4 ++-- .../src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp | 3 +-- .../src/vespa/searchcore/proton/server/storeonlydocsubdb.h | 2 +- .../src/vespa/searchcore/proton/test/dummy_document_sub_db.h | 2 +- 19 files changed, 47 insertions(+), 53 deletions(-) diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 53ea1b3542f..e1f6e14e922 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -155,6 +155,7 @@ struct Fixture RankingAssetsRepo _constantValueRepo; vespalib::ThreadStackExecutor _summaryExecutor; std::shared_ptr _pendingLidsForCommit; + SessionManager _sessionMgr; ViewSet _views; MyDocumentDBReferenceResolver _resolver; ConfigurerUP _configurer; @@ -170,6 +171,7 @@ Fixture::Fixture() _constantValueRepo(_constantValueFactory), _summaryExecutor(8, 128_Ki), _pendingLidsForCommit(std::make_shared()), + _sessionMgr(100), _views(), _resolver(), _configurer() @@ -207,7 +209,7 @@ Fixture::initViewSet(ViewSet &views) views._summaryMgr = summaryMgr; views._dmsc = metaStore; IndexSearchable::SP indexSearchable; - auto matchView = std::make_shared(matchers, indexSearchable, attrMgr, sesMgr, metaStore, views._docIdLimit); + auto matchView = std::make_shared(matchers, indexSearchable, attrMgr, _sessionMgr, metaStore, views._docIdLimit); views.searchView.set(SearchView::create (summaryMgr->createSummarySetup(SummaryConfig(), JuniperrcConfig(), views.repo, attrMgr), @@ -349,9 +351,7 @@ struct SearchViewComparer void expect_not_equal_attribute_manager() { EXPECT_NOT_EQUAL(_old->getAttributeManager().get(), _new->getAttributeManager().get()); } - void expect_equal_session_manager() { - EXPECT_EQUAL(_old->getSessionManager().get(), _new->getSessionManager().get()); - } + void expect_equal_document_meta_store() { EXPECT_EQUAL(_old->getDocumentMetaStore().get(), _new->getDocumentMetaStore().get()); } @@ -436,7 +436,6 @@ TEST_F("require that we can reconfigure index searchable", Fixture) cmp.expect_equal_matchers(); cmp.expect_not_equal_index_searchable(); cmp.expect_equal_attribute_manager(); - cmp.expect_equal_session_manager(); cmp.expect_equal_document_meta_store(); } { // verify feed view @@ -471,7 +470,6 @@ TEST_F("require that we can reconfigure attribute manager", Fixture) cmp.expect_not_equal_matchers(); cmp.expect_equal_index_searchable(); cmp.expect_not_equal_attribute_manager(); - cmp.expect_equal_session_manager(); cmp.expect_equal_document_meta_store(); } { // verify feed view @@ -587,7 +585,6 @@ TEST_F("require that we can reconfigure matchers", Fixture) cmp.expect_not_equal_matchers(); cmp.expect_equal_index_searchable(); cmp.expect_equal_attribute_manager(); - cmp.expect_equal_session_manager(); cmp.expect_equal_document_meta_store(); } { // verify feed view diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 43717fc724f..dd402a6e637 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -93,11 +93,18 @@ struct ConfigDir4 { static vespalib::string dir() { return TEST_PATH("cfg4"); } struct MySubDBOwner : public IDocumentSubDBOwner { + SessionManager _sessionMgr; + MySubDBOwner(); + ~MySubDBOwner() override; document::BucketSpace getBucketSpace() const override { return makeBucketSpace(); } vespalib::string getName() const override { return "owner"; } uint32_t getDistributionKey() const override { return -1; } + SessionManager & session_manager() override { return _sessionMgr; } }; +MySubDBOwner::MySubDBOwner() : _sessionMgr(1) {} +MySubDBOwner::~MySubDBOwner() = default; + struct MySyncProxy : public SyncProxy { void sync(SerialNum) override {} @@ -354,8 +361,7 @@ struct FixtureBase vespalib::ThreadStackExecutor executor(1, 1_Mi); initializer::TaskRunner taskRunner(executor); taskRunner.runTask(task); - auto sessionMgr = std::make_shared(1); - runInMasterAndSync([&]() { _subDb.initViews(*_snapshot->_cfg, sessionMgr); }); + runInMasterAndSync([&]() { _subDb.initViews(*_snapshot->_cfg); }); } void basicReconfig(SerialNum serialNum) { runInMasterAndSync([&]() { performReconfig(serialNum, make_all_attr_schema(two_attr_schema), ConfigDir2::dir()); }); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 1b91f9ec0c2..427f40d6116 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -340,7 +340,7 @@ DocumentDB::initFinish(DocumentDBConfig::SP configSnapshot) // Called by executor thread assert(_writeService.master().isCurrentThread()); _bucketHandler.setReadyBucketHandler(_subDBs.getReadySubDB()->getDocumentMetaStoreContext().get()); - _subDBs.initViews(*configSnapshot, _sessionManager); + _subDBs.initViews(*configSnapshot); syncFeedView(); // Check that feed view has been activated. assert(_feedView.get()); @@ -1120,4 +1120,9 @@ DocumentDB::set_attribute_usage_listener(std::unique_ptr #include -using proton::matching::SessionManager; using search::GrowStrategy; using search::SerialNum; using search::index::Schema; @@ -184,11 +183,10 @@ DocumentSubDBCollection::createInitializer(const DocumentDBConfig &configSnapsho void -DocumentSubDBCollection::initViews(const DocumentDBConfig &configSnapshot, - const SessionManager::SP &sessionManager) +DocumentSubDBCollection::initViews(const DocumentDBConfig &configSnapshot) { for (auto subDb : _subDBs) { - subDb->initViews(configSnapshot, sessionManager); + subDb->initViews(configSnapshot); } } diff --git a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h index 8c1e670454c..a5ab1b5971c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentsubdbcollection.h @@ -46,10 +46,7 @@ struct IBucketStateCalculator; struct IDocumentDBReferenceResolver; struct MetricsWireService; -namespace matching { - class QueryLimiter; - class SessionManager; -} +namespace matching { class QueryLimiter; } namespace initializer { class InitializerTask; } @@ -65,7 +62,6 @@ public: private: using IFeedViewSP = std::shared_ptr; using IBucketStateCalculatorSP = std::shared_ptr; - using SessionManagerSP = std::shared_ptr; using IFlushTargetList = std::vector>; SubDBVector _subDBs; IDocumentSubDBOwner &_owner; @@ -131,7 +127,7 @@ public: createInitializer(const DocumentDBConfig &configSnapshot, SerialNum configSerialNum, const index::IndexConfig & indexCfg); - void initViews(const DocumentDBConfig &configSnapshot, const SessionManagerSP &sessionManager); + void initViews(const DocumentDBConfig &configSnapshot); void clearViews(); void onReplayDone(); void onReprocessDone(SerialNum serialNum); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp index 7fd54f111e1..6c684ce4c99 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.cpp @@ -230,8 +230,7 @@ FastAccessDocSubDB::setup(const DocumentSubDbInitializerResult &initResult) } void -FastAccessDocSubDB::initViews(const DocumentDBConfig &configSnapshot, - const SessionManager::SP &) +FastAccessDocSubDB::initViews(const DocumentDBConfig &configSnapshot) { // Called by executor thread _iSearchView.set(std::make_shared()); diff --git a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h index 94fca94c75d..2d00a2a412c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/fast_access_doc_subdb.h @@ -84,7 +84,6 @@ private: protected: using Parent = StoreOnlyDocSubDB; - using SessionManagerSP = std::shared_ptr; const bool _addMetrics; MetricsWireService &_metricsWireService; @@ -108,7 +107,7 @@ public: const IndexConfig &indexCfg) const override; void setup(const DocumentSubDbInitializerResult &initResult) override; - void initViews(const DocumentDBConfig &configSnapshot, const SessionManagerSP &sessionManager) override; + void initViews(const DocumentDBConfig &configSnapshot) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, diff --git a/searchcore/src/vespa/searchcore/proton/server/i_document_subdb_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_document_subdb_owner.h index 4bd143a077e..e170840e252 100644 --- a/searchcore/src/vespa/searchcore/proton/server/i_document_subdb_owner.h +++ b/searchcore/src/vespa/searchcore/proton/server/i_document_subdb_owner.h @@ -7,6 +7,8 @@ namespace proton { +namespace matching { class SessionManager; } + /** * Interface defining the communication needed with the owner of the * document sub db. @@ -14,10 +16,12 @@ namespace proton { class IDocumentSubDBOwner { public: + using SessionManager = matching::SessionManager; virtual ~IDocumentSubDBOwner() {} virtual document::BucketSpace getBucketSpace() const = 0; virtual vespalib::string getName() const = 0; virtual uint32_t getDistributionKey() const = 0; + virtual SessionManager & session_manager() = 0; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h index b945c67660b..c6410073c09 100644 --- a/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/idocumentsubdb.h @@ -63,6 +63,7 @@ public: using IFlushTargetList = std::vector>; using IndexConfig = index::IndexConfig; using OnDone = std::shared_ptr; + using SessionManager = matching::SessionManager; public: IDocumentSubDB() { } virtual ~IDocumentSubDB() { } @@ -75,7 +76,7 @@ public: // Called by master thread virtual void setup(const DocumentSubDbInitializerResult &initResult) = 0; - virtual void initViews(const DocumentDBConfig &configSnapshot, const std::shared_ptr &sessionManager) = 0; + virtual void initViews(const DocumentDBConfig &configSnapshot) = 0; virtual IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp index bd9c927e94e..532c2e868b6 100644 --- a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp @@ -36,13 +36,13 @@ using matching::SessionManager; MatchView::MatchView(Matchers::SP matchers, IndexSearchable::SP indexSearchable, IAttributeManager::SP attrMgr, - SessionManagerSP sessionMgr, + SessionManager & sessionMgr, IDocumentMetaStoreContext::SP metaStore, DocIdLimit &docIdLimit) : _matchers(std::move(matchers)), _indexSearchable(std::move(indexSearchable)), _attrMgr(std::move(attrMgr)), - _sessionMgr(std::move(sessionMgr)), + _sessionMgr(sessionMgr), _metaStore(std::move(metaStore)), _docIdLimit(docIdLimit) { } @@ -75,7 +75,7 @@ MatchView::match(std::shared_ptr searchHandler, const Sear const search::IDocumentMetaStore & dms = owned_objects.readGuard->get(); const bucketdb::BucketDBOwner & bucketDB = _metaStore->get().getBucketDB(); return matcher->match(req, threadBundle, ctx->getSearchContext(), ctx->getAttributeContext(), - *_sessionMgr, dms, bucketDB, std::move(owned_objects)); + _sessionMgr, dms, bucketDB, std::move(owned_objects)); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.h b/searchcore/src/vespa/searchcore/proton/server/matchview.h index f7bf0abff39..603d929b407 100644 --- a/searchcore/src/vespa/searchcore/proton/server/matchview.h +++ b/searchcore/src/vespa/searchcore/proton/server/matchview.h @@ -18,11 +18,11 @@ namespace matching { } class MatchView { - using SessionManagerSP = std::shared_ptr; + using SessionManager = matching::SessionManager; Matchers::SP _matchers; searchcorespi::IndexSearchable::SP _indexSearchable; IAttributeManager::SP _attrMgr; - SessionManagerSP _sessionMgr; + SessionManager & _sessionMgr; IDocumentMetaStoreContext::SP _metaStore; DocIdLimit &_docIdLimit; @@ -38,7 +38,7 @@ public: MatchView(Matchers::SP matchers, searchcorespi::IndexSearchable::SP indexSearchable, IAttributeManager::SP attrMgr, - SessionManagerSP sessionMgr, + SessionManager & sessionMgr, IDocumentMetaStoreContext::SP metaStore, DocIdLimit &docIdLimit); ~MatchView(); @@ -46,7 +46,7 @@ public: const Matchers::SP & getMatchers() const { return _matchers; } const searchcorespi::IndexSearchable::SP & getIndexSearchable() const { return _indexSearchable; } const IAttributeManager::SP & getAttributeManager() const { return _attrMgr; } - const SessionManagerSP & getSessionManager() const { return _sessionMgr; } + SessionManager & getSessionManager() const { return _sessionMgr; } const IDocumentMetaStoreContext::SP & getDocumentMetaStore() const { return _metaStore; } DocIdLimit & getDocIdLimit() const { return _docIdLimit; } diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 043e9cd5d3f..3d87e7dc7c3 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,6 @@ using vespa::config::search::RankProfilesConfig; using proton::matching::MatchingStats; -using proton::matching::SessionManager; using search::GrowStrategy; using search::index::Schema; using search::SerialNum; @@ -187,7 +185,7 @@ SearchableDocSubDB::setBucketStateCalculator(const std::shared_ptr(std::move(matchers), indexMgr->getSearchable(), attrMgr, - sessionManager, _metaStoreCtx, _docIdLimit); + _owner.session_manager(), _metaStoreCtx, _docIdLimit); _rSearchView.set(SearchView::create( getSummaryManager()->createSummarySetup( configSnapshot.getSummaryConfig(), diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h index c628d9a96b7..dcfe0b32f4a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.h @@ -100,7 +100,7 @@ public: const IndexConfig &indexCfg) const override; void setup(const DocumentSubDbInitializerResult &initResult) override; - void initViews(const DocumentDBConfig &configSnapshot, const SessionManagerSP &sessionManager) override; + void initViews(const DocumentDBConfig &configSnapshot) override; IReprocessingTask::List applyConfig(const DocumentDBConfig &newConfigSnapshot, const DocumentDBConfig &oldConfigSnapshot, diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp index a17415db474..7a909bbebd8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.cpp @@ -34,7 +34,6 @@ convertGidsToLids(const DocsumRequest & request, const search::IDocumentMetaStore &metaStore, uint32_t docIdLimit) { - document::GlobalId empty; uint32_t lid = 0; for (size_t i = 0; i < request.hits.size(); ++i) { const DocsumRequest::Hit & h = request.hits[i]; @@ -128,7 +127,7 @@ SearchView::getDocsumsInternal(const DocsumRequest & req) MatchContext::UP mctx = _matchView->createContext(); auto ctx = std::make_unique(req, _summarySetup->getDocsumWriter(), *store, _matchView->getMatcher(req.ranking), mctx->getSearchContext(), mctx->getAttributeContext(), - *_summarySetup->getAttributeManager(), *getSessionManager()); + *_summarySetup->getAttributeManager(), getSessionManager()); SearchView::InternalDocsumReply reply(ctx->getDocsums(), true); uint64_t endGeneration = readGuard->get().getCurrentGeneration(); if (startGeneration != endGeneration) { diff --git a/searchcore/src/vespa/searchcore/proton/server/searchview.h b/searchcore/src/vespa/searchcore/proton/server/searchview.h index c8174c0a9a6..8c9f6cffa94 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchview.h +++ b/searchcore/src/vespa/searchcore/proton/server/searchview.h @@ -11,7 +11,7 @@ namespace proton { class SearchView : public ISearchHandler, public std::enable_shared_from_this { public: - using SessionManagerSP = std::shared_ptr; + using SessionManager = matching::SessionManager; using IndexSearchable = searchcorespi::IndexSearchable; using InternalDocsumReply = std::pair, bool>; typedef std::shared_ptr SP; @@ -28,7 +28,7 @@ public: const Matchers::SP & getMatchers() const { return _matchView->getMatchers(); } const IndexSearchable::SP & getIndexSearchable() const { return _matchView->getIndexSearchable(); } const IAttributeManager::SP & getAttributeManager() const { return _matchView->getAttributeManager(); } - const SessionManagerSP & getSessionManager() const { return _matchView->getSessionManager(); } + SessionManager & getSessionManager() const { return _matchView->getSessionManager(); } const IDocumentMetaStoreContext::SP & getDocumentMetaStore() const { return _matchView->getDocumentMetaStore(); } DocIdLimit &getDocIdLimit() const { return _matchView->getDocIdLimit(); } matching::MatchingStats getMatcherStats(const vespalib::string &rankProfile) const { return _matchView->getMatcherStats(rankProfile); } diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index 9419dfa1c90..e95c98e2740 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -356,7 +356,7 @@ StoreOnlyDocSubDB::getFeedViewPersistentParams() } void -StoreOnlyDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const SessionManager::SP &sessionManager) +StoreOnlyDocSubDB::initViews(const DocumentDBConfig &configSnapshot) { assert(_writeService.master().isCurrentThread()); _iSearchView.set(std::make_shared()); @@ -364,7 +364,6 @@ StoreOnlyDocSubDB::initViews(const DocumentDBConfig &configSnapshot, const Sessi std::lock_guard guard(_configMutex); initFeedView(configSnapshot); } - (void) sessionManager; } void diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h index f694cc7298f..5a8db23e345 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.h @@ -196,7 +196,7 @@ public: const IndexConfig & indexCfg) const override; void setup(const DocumentSubDbInitializerResult &initResult) override; - void initViews(const DocumentDBConfig &configSnapshot, const std::shared_ptr &sessionManager) override; + void initViews(const DocumentDBConfig &configSnapshot) override; void validateDocStore(FeedHandler & feedHandler, SerialNum serialNum) const override; diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h index 6c142c97aaf..c29af41cdd3 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_sub_db.h @@ -51,7 +51,7 @@ struct DummyDocumentSubDb : public IDocumentSubDB (const_cast(*this), _service.write().master()); } void setup(const DocumentSubDbInitializerResult &) override {} - void initViews(const DocumentDBConfig &, const proton::matching::SessionManager::SP &) override {} + void initViews(const DocumentDBConfig &) override {} IReprocessingTask::List applyConfig(const DocumentDBConfig &, const DocumentDBConfig &, SerialNum, const ReconfigParams &, IDocumentDBReferenceResolver &) override { -- cgit v1.2.3 From 8e910e3977c4522f3c99764f79fa8f374271c224 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 8 Dec 2022 17:40:48 +0000 Subject: Add SessionManager in IDocumentDBOwner, but only use in mocks in tests for now. --- .../src/apps/tests/persistenceconformance_test.cpp | 26 +++++----- searchcore/src/tests/proton/common/dummydbowner.h | 27 ---------- .../src/tests/proton/docsummary/docsummary.cpp | 58 +++++++++++----------- .../tests/proton/documentdb/documentdb_test.cpp | 35 ++++--------- .../src/vespa/searchcore/bmcluster/bm_node.cpp | 44 ++++++++-------- .../proton/metrics/documentdb_tagged_metrics.cpp | 1 - .../proton/server/documentdb_metrics_updater.cpp | 2 - .../searchcore/proton/server/idocumentdbowner.h | 3 ++ .../src/vespa/searchcore/proton/server/proton.cpp | 6 +++ .../src/vespa/searchcore/proton/server/proton.h | 1 + .../vespa/searchcore/proton/test/CMakeLists.txt | 1 + .../vespa/searchcore/proton/test/dummydbowner.cpp | 25 ++++++++++ .../vespa/searchcore/proton/test/dummydbowner.h | 24 +++++++++ 13 files changed, 133 insertions(+), 120 deletions(-) delete mode 100644 searchcore/src/tests/proton/common/dummydbowner.h create mode 100644 searchcore/src/vespa/searchcore/proton/test/dummydbowner.cpp create mode 100644 searchcore/src/vespa/searchcore/proton/test/dummydbowner.h diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp index 0db14538630..52e2a314fd2 100644 --- a/searchcore/src/apps/tests/persistenceconformance_test.cpp +++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp @@ -1,21 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include #include #include @@ -36,6 +23,17 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/searchcore/src/tests/proton/common/dummydbowner.h b/searchcore/src/tests/proton/common/dummydbowner.h deleted file mode 100644 index 1fa9c17257c..00000000000 --- a/searchcore/src/tests/proton/common/dummydbowner.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include -#include -#include - -namespace proton { - -struct DummyDBOwner : IDocumentDBOwner { - std::shared_ptr _registry; - - DummyDBOwner() - : _registry(std::make_shared()) - {} - ~DummyDBOwner() {} - - bool isInitializing() const override { return false; } - - uint32_t getDistributionKey() const override { return -1; } - std::shared_ptr getDocumentDBReferenceRegistry() const override { - return _registry; - } -}; - -} // namespace proton diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index 5b081fb5b51..9709530f2c2 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -1,6 +1,34 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -31,34 +59,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index 916f3106923..7aa18513f73 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -1,13 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include @@ -18,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +21,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -78,22 +79,6 @@ config_subdir(SerialNum serialNum) return os.str(); } -struct MyDBOwner : public DummyDBOwner -{ - std::shared_ptr _registry; - MyDBOwner(); - ~MyDBOwner() override; - std::shared_ptr getDocumentDBReferenceRegistry() const override { - return _registry; - } -}; - -MyDBOwner::MyDBOwner() - : DummyDBOwner(), - _registry(std::make_shared()) -{} -MyDBOwner::~MyDBOwner() = default; - struct FixtureBase { bool _cleanup; bool _file_config; @@ -119,7 +104,7 @@ FixtureBase::~FixtureBase() struct Fixture : public FixtureBase { DummyWireService _dummy; - MyDBOwner _myDBOwner; + DummyDBOwner _myDBOwner; vespalib::ThreadStackExecutor _summaryExecutor; MockSharedThreadingService _shared_service; HwInfo _hwInfo; diff --git a/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp b/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp index a33d9682973..5e392b12f67 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp +++ b/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp @@ -9,28 +9,7 @@ #include "bm_storage_link_context.h" #include "i_bm_distribution.h" #include "storage_api_rpc_bm_feed_handler.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include @@ -70,6 +49,27 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp index 2535b518335..f333af19ed3 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/documentdb_tagged_metrics.cpp @@ -2,7 +2,6 @@ #include "documentdb_tagged_metrics.h" #include -#include #include LOG_SETUP(".proton.metrics.documentdb_tagged_metrics"); diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp index 3fe7fd6cfde..6b97d41e459 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "documentdb_metrics_updater.h" -#include "ddbstate.h" #include "document_meta_store_read_guards.h" #include "documentsubdbcollection.h" #include "executorthreadingservice.h" @@ -12,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/searchcore/src/vespa/searchcore/proton/server/idocumentdbowner.h b/searchcore/src/vespa/searchcore/proton/server/idocumentdbowner.h index dc060f6a84b..36ac3427e66 100644 --- a/searchcore/src/vespa/searchcore/proton/server/idocumentdbowner.h +++ b/searchcore/src/vespa/searchcore/proton/server/idocumentdbowner.h @@ -8,14 +8,17 @@ namespace proton { class IDocumentDBReferenceRegistry; +namespace matching { class SessionManager; } class IDocumentDBOwner { public: + using SessionManager = matching::SessionManager; virtual ~IDocumentDBOwner(); virtual bool isInitializing() const = 0; virtual uint32_t getDistributionKey() const = 0; + virtual SessionManager & session_manager() = 0; virtual std::shared_ptr getDocumentDBReferenceRegistry() const = 0; }; diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index 3635aba9e10..3b1a88774b7 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -997,6 +997,12 @@ Proton::getDocumentDBReferenceRegistry() const return _documentDBReferenceRegistry; } +matching::SessionManager & +Proton::session_manager() { + // Temporary and will not be called used yet + abort(); +} + storage::spi::PersistenceProvider & Proton::getPersistence() { diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index 0d4b067eea1..235bd120821 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -141,6 +141,7 @@ private: uint32_t getDistributionKey() const override { return _distributionKey; } BootstrapConfig::SP getActiveConfigSnapshot() const; std::shared_ptr getDocumentDBReferenceRegistry() const override; + SessionManager & session_manager() override; // Returns true if the node is up in _any_ bucket space bool updateNodeUp(BucketSpace bucketSpace, bool nodeUpInBucketSpace); void closeDocumentDBs(vespalib::ThreadStackExecutorBase & executor); diff --git a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt index ad86ce64d8e..79b0582e1d0 100644 --- a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt @@ -10,6 +10,7 @@ vespa_add_library(searchcore_test STATIC documentdb_config_builder.cpp dummy_feed_view.cpp dummy_flush_target.cpp + dummydbowner.cpp mock_index_manager.cpp mock_shared_threading_service.cpp userdocumentsbuilder.cpp diff --git a/searchcore/src/vespa/searchcore/proton/test/dummydbowner.cpp b/searchcore/src/vespa/searchcore/proton/test/dummydbowner.cpp new file mode 100644 index 00000000000..d91d0261006 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/dummydbowner.cpp @@ -0,0 +1,25 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "dummydbowner.h" +#include +#include + +namespace proton { + +DummyDBOwner::DummyDBOwner() + : _registry(std::make_shared()), + _sessionManager(std::make_unique(10)) +{} +DummyDBOwner::~DummyDBOwner() = default; + +std::shared_ptr +DummyDBOwner::getDocumentDBReferenceRegistry() const { + return _registry; +} + +matching::SessionManager & +DummyDBOwner::session_manager() { + return *_sessionManager; +} + +} diff --git a/searchcore/src/vespa/searchcore/proton/test/dummydbowner.h b/searchcore/src/vespa/searchcore/proton/test/dummydbowner.h new file mode 100644 index 00000000000..99ccb0ab56d --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/dummydbowner.h @@ -0,0 +1,24 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include +#include + +namespace proton { + +struct DummyDBOwner : IDocumentDBOwner { + std::shared_ptr _registry; + std::unique_ptr _sessionManager; + + DummyDBOwner(); + ~DummyDBOwner() override; + + bool isInitializing() const override { return false; } + + uint32_t getDistributionKey() const override { return -1; } + std::shared_ptr getDocumentDBReferenceRegistry() const override; + SessionManager & session_manager() override; +}; + +} // namespace proton -- cgit v1.2.3 From e4c5580f64be5934d6b7690efc719d542c5be526 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 8 Dec 2022 22:36:55 +0000 Subject: GC unused session manager --- searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index e1f6e14e922..600e4981c0f 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -199,7 +199,6 @@ Fixture::initViewSet(ViewSet &views) auto summaryMgr = make_shared (_summaryExecutor, search::LogDocumentStore::Config(), search::GrowStrategy(), BASE_DIR, TuneFileSummary(), views._fileHeaderContext,views._noTlSyncer, search::IBucketizer::SP()); - auto sesMgr = make_shared(100); auto metaStore = make_shared(make_shared()); auto indexWriter = std::make_shared(indexMgr); auto attrWriter = std::make_shared(attrMgr); -- cgit v1.2.3