Skip to content

Commit

Permalink
Merge pull request #25178 from vespa-engine/balder/provide-sessionman…
Browse files Browse the repository at this point in the history
…ager-via-idocumentsubdbowner

Wire SessionManager via IDocumentSubDBOwner
  • Loading branch information
baldersheim authored Dec 8, 2022
2 parents c08e5c5 + e4c5580 commit 0f15b40
Show file tree
Hide file tree
Showing 31 changed files with 161 additions and 155 deletions.
26 changes: 12 additions & 14 deletions searchcore/src/apps/tests/persistenceconformance_test.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/testkit/testapp.h>

#include <tests/proton/common/dummydbowner.h>
#include <vespa/config-attributes.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/config-imported-fields.h>
#include <vespa/config-indexschema.h>
#include <vespa/config-rank-profiles.h>
#include <vespa/config-summary.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/document/base/testdocman.h>
#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/fastos/file.h>
#include <vespa/persistence/conformancetest/conformancetest.h>
#include <vespa/searchcore/proton/test/dummydbowner.h>
#include <vespa/searchcore/proton/common/alloc_config.h>
#include <vespa/searchcore/proton/common/hw_info.h>
#include <vespa/searchcore/proton/matching/querylimiter.h>
Expand All @@ -36,6 +23,17 @@
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/transactionlog/translogserver.h>
#include <vespa/searchsummary/config/config-juniperrc.h>
#include <vespa/config-attributes.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/config-imported-fields.h>
#include <vespa/config-indexschema.h>
#include <vespa/config-rank-profiles.h>
#include <vespa/config-summary.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/document/base/testdocman.h>
#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/vespalib/util/size_literals.h>
#include <filesystem>

Expand Down
58 changes: 29 additions & 29 deletions searchcore/src/tests/proton/docsummary/docsummary.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <tests/proton/common/dummydbowner.h>
#include <vespa/searchcore/proton/test/dummydbowner.h>
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/docsummary/docsumcontext.h>
#include <vespa/searchcore/proton/docsummary/documentstoreadapter.h>
#include <vespa/searchcore/proton/documentmetastore/documentmetastore.h>
#include <vespa/searchcore/proton/feedoperation/putoperation.h>
#include <vespa/searchcore/proton/matching/querylimiter.h>
#include <vespa/searchcore/proton/metrics/metricswireservice.h>
#include <vespa/searchcore/proton/server/bootstrapconfig.h>
#include <vespa/searchcore/proton/server/documentdb.h>
#include <vespa/searchcore/proton/server/documentdbconfigmanager.h>
#include <vespa/searchcore/proton/server/feedhandler.h>
#include <vespa/searchcore/proton/server/idocumentsubdb.h>
#include <vespa/searchcore/proton/server/memoryconfigstore.h>
#include <vespa/searchcore/proton/server/searchview.h>
#include <vespa/searchcore/proton/server/summaryadapter.h>
#include <vespa/searchcore/proton/test/bucketfactory.h>
#include <vespa/searchcore/proton/test/mock_shared_threading_service.h>
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/engine/docsumapi.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/tensor/tensor_attribute.h>
#include <vespa/searchlib/test/doc_builder.h>
#include <vespa/searchlib/transactionlog/nosyncproxy.h>
#include <vespa/searchlib/transactionlog/translogserver.h>
#include <vespa/searchsummary/docsummary/i_docsum_field_writer_factory.h>
#include <vespa/searchsummary/docsummary/i_docsum_store_document.h>
#include <vespa/searchsummary/docsummary/i_juniper_converter.h>
#include <vespa/searchsummary/docsummary/linguisticsannotation.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/document/annotation/annotation.h>
Expand Down Expand Up @@ -31,34 +59,6 @@
#include <vespa/eval/eval/tensor_spec.h>
#include <vespa/eval/eval/test/value_compare.h>
#include <vespa/eval/eval/value.h>
#include <vespa/searchcore/proton/attribute/attribute_writer.h>
#include <vespa/searchcore/proton/docsummary/docsumcontext.h>
#include <vespa/searchcore/proton/docsummary/documentstoreadapter.h>
#include <vespa/searchcore/proton/documentmetastore/documentmetastore.h>
#include <vespa/searchcore/proton/feedoperation/putoperation.h>
#include <vespa/searchcore/proton/matching/querylimiter.h>
#include <vespa/searchcore/proton/metrics/metricswireservice.h>
#include <vespa/searchcore/proton/server/bootstrapconfig.h>
#include <vespa/searchcore/proton/server/documentdb.h>
#include <vespa/searchcore/proton/server/documentdbconfigmanager.h>
#include <vespa/searchcore/proton/server/feedhandler.h>
#include <vespa/searchcore/proton/server/idocumentsubdb.h>
#include <vespa/searchcore/proton/server/memoryconfigstore.h>
#include <vespa/searchcore/proton/server/searchview.h>
#include <vespa/searchcore/proton/server/summaryadapter.h>
#include <vespa/searchcore/proton/test/bucketfactory.h>
#include <vespa/searchcore/proton/test/mock_shared_threading_service.h>
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/engine/docsumapi.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
#include <vespa/searchlib/tensor/tensor_attribute.h>
#include <vespa/searchlib/test/doc_builder.h>
#include <vespa/searchlib/transactionlog/nosyncproxy.h>
#include <vespa/searchlib/transactionlog/translogserver.h>
#include <vespa/searchsummary/docsummary/i_docsum_field_writer_factory.h>
#include <vespa/searchsummary/docsummary/i_docsum_store_document.h>
#include <vespa/searchsummary/docsummary/i_juniper_converter.h>
#include <vespa/searchsummary/docsummary/linguisticsannotation.h>
#include <vespa/vespalib/data/simple_buffer.h>
#include <vespa/vespalib/data/slime/json_format.h>
#include <vespa/vespalib/data/slime/slime.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct Fixture
RankingAssetsRepo _constantValueRepo;
vespalib::ThreadStackExecutor _summaryExecutor;
std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit;
SessionManager _sessionMgr;
ViewSet _views;
MyDocumentDBReferenceResolver _resolver;
ConfigurerUP _configurer;
Expand All @@ -170,6 +171,7 @@ Fixture::Fixture()
_constantValueRepo(_constantValueFactory),
_summaryExecutor(8, 128_Ki),
_pendingLidsForCommit(std::make_shared<PendingLidTracker>()),
_sessionMgr(100),
_views(),
_resolver(),
_configurer()
Expand Down Expand Up @@ -197,7 +199,6 @@ Fixture::initViewSet(ViewSet &views)
auto summaryMgr = make_shared<SummaryManager>
(_summaryExecutor, search::LogDocumentStore::Config(), search::GrowStrategy(), BASE_DIR,
TuneFileSummary(), views._fileHeaderContext,views._noTlSyncer, search::IBucketizer::SP());
auto sesMgr = make_shared<SessionManager>(100);
auto metaStore = make_shared<DocumentMetaStoreContext>(make_shared<bucketdb::BucketDBOwner>());
auto indexWriter = std::make_shared<IndexWriter>(indexMgr);
auto attrWriter = std::make_shared<AttributeWriter>(attrMgr);
Expand All @@ -207,7 +208,7 @@ Fixture::initViewSet(ViewSet &views)
views._summaryMgr = summaryMgr;
views._dmsc = metaStore;
IndexSearchable::SP indexSearchable;
auto matchView = std::make_shared<MatchView>(matchers, indexSearchable, attrMgr, sesMgr, metaStore, views._docIdLimit);
auto matchView = std::make_shared<MatchView>(matchers, indexSearchable, attrMgr, _sessionMgr, metaStore, views._docIdLimit);
views.searchView.set(SearchView::create
(summaryMgr->createSummarySetup(SummaryConfig(),
JuniperrcConfig(), views.repo, attrMgr),
Expand Down Expand Up @@ -349,9 +350,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());
}
Expand Down Expand Up @@ -436,7 +435,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
Expand Down Expand Up @@ -471,7 +469,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
Expand Down Expand Up @@ -587,7 +584,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -354,8 +361,7 @@ struct FixtureBase
vespalib::ThreadStackExecutor executor(1, 1_Mi);
initializer::TaskRunner taskRunner(executor);
taskRunner.runTask(task);
auto sessionMgr = std::make_shared<SessionManager>(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()); });
Expand Down
35 changes: 10 additions & 25 deletions searchcore/src/tests/proton/documentdb/documentdb_test.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <tests/proton/common/dummydbowner.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/fnet/transport.h>
#include <vespa/searchcore/proton/test/dummydbowner.h>
#include <vespa/searchcore/proton/attribute/flushableattribute.h>
#include <vespa/searchcore/proton/common/statusreport.h>
#include <vespa/searchcore/proton/docsummary/summaryflushtarget.h>
Expand All @@ -18,6 +11,7 @@
#include <vespa/searchcore/proton/metrics/job_tracked_flush_target.h>
#include <vespa/searchcore/proton/metrics/metricswireservice.h>
#include <vespa/searchcore/proton/reference/i_document_db_reference.h>
#include <vespa/searchcore/proton/reference/i_document_db_reference_registry.h>
#include <vespa/searchcore/proton/server/bootstrapconfig.h>
#include <vespa/searchcore/proton/server/document_db_explorer.h>
#include <vespa/searchcore/proton/server/documentdb.h>
Expand All @@ -27,6 +21,13 @@
#include <vespa/searchcore/proton/server/memoryconfigstore.h>
#include <vespa/searchcore/proton/test/mock_shared_threading_service.h>
#include <vespa/searchcorespi/index/indexflushtarget.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/config/subscription/sourcespec.h>
#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/fnet/transport.h>
#include <vespa/searchlib/attribute/attribute_read_guard.h>
#include <vespa/searchlib/attribute/interlock.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
Expand Down Expand Up @@ -78,22 +79,6 @@ config_subdir(SerialNum serialNum)
return os.str();
}

struct MyDBOwner : public DummyDBOwner
{
std::shared_ptr<DocumentDBReferenceRegistry> _registry;
MyDBOwner();
~MyDBOwner() override;
std::shared_ptr<IDocumentDBReferenceRegistry> getDocumentDBReferenceRegistry() const override {
return _registry;
}
};

MyDBOwner::MyDBOwner()
: DummyDBOwner(),
_registry(std::make_shared<DocumentDBReferenceRegistry>())
{}
MyDBOwner::~MyDBOwner() = default;

struct FixtureBase {
bool _cleanup;
bool _file_config;
Expand All @@ -119,7 +104,7 @@ FixtureBase::~FixtureBase()

struct Fixture : public FixtureBase {
DummyWireService _dummy;
MyDBOwner _myDBOwner;
DummyDBOwner _myDBOwner;
vespalib::ThreadStackExecutor _summaryExecutor;
MockSharedThreadingService _shared_service;
HwInfo _hwInfo;
Expand Down
44 changes: 22 additions & 22 deletions searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,7 @@
#include "bm_storage_link_context.h"
#include "i_bm_distribution.h"
#include "storage_api_rpc_bm_feed_handler.h"
#include <tests/proton/common/dummydbowner.h>
#include <vespa/config-attributes.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/config-imported-fields.h>
#include <vespa/config-indexschema.h>
#include <vespa/config-persistence.h>
#include <vespa/config-rank-profiles.h>
#include <vespa/config-slobroks.h>
#include <vespa/config-stor-distribution.h>
#include <vespa/config-stor-filestor.h>
#include <vespa/config-summary.h>
#include <vespa/config-upgrading.h>
#include <vespa/config/common/configcontext.h>
#include <vespa/document/bucket/bucketspace.h>
#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/document_type_repo_factory.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/messagebus/config-messagebus.h>
#include <vespa/messagebus/testlib/slobrok.h>
#include <vespa/metrics/config-metricsmanager.h>
#include <vespa/searchcore/proton/test/dummydbowner.h>
#include <vespa/searchcore/proton/common/alloc_config.h>
#include <vespa/searchcore/proton/matching/querylimiter.h>
#include <vespa/searchcore/proton/metrics/metricswireservice.h>
Expand Down Expand Up @@ -70,6 +49,27 @@
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/config-attributes.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/config-imported-fields.h>
#include <vespa/config-indexschema.h>
#include <vespa/config-persistence.h>
#include <vespa/config-rank-profiles.h>
#include <vespa/config-slobroks.h>
#include <vespa/config-stor-distribution.h>
#include <vespa/config-stor-filestor.h>
#include <vespa/config-summary.h>
#include <vespa/config-upgrading.h>
#include <vespa/config/common/configcontext.h>
#include <vespa/document/bucket/bucketspace.h>
#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/document_type_repo_factory.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/test/make_bucket_space.h>
#include <vespa/messagebus/config-messagebus.h>
#include <vespa/messagebus/testlib/slobrok.h>
#include <vespa/metrics/config-metricsmanager.h>
#include <filesystem>

#include <vespa/log/log.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "documentdb_tagged_metrics.h"
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/exceptions.h>

#include <vespa/log/log.h>
LOG_SETUP(".proton.metrics.documentdb_tagged_metrics");
Expand Down
7 changes: 6 additions & 1 deletion searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -1120,4 +1120,9 @@ DocumentDB::set_attribute_usage_listener(std::unique_ptr<IAttributeUsageListener
_writeFilter.set_listener(std::move(listener));
}

matching::SessionManager &
DocumentDB::session_manager() {
return *_sessionManager;
}

} // namespace proton
9 changes: 1 addition & 8 deletions searchcore/src/vespa/searchcore/proton/server/documentdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ class DocumentDB : public DocumentDBConfigOwner,
InitializeThreads initializeThreads,
const HwInfo &hwInfo);

/**
* Expose a cost view of the session manager. This is used by the
* document db explorer.
**/
const matching::SessionManager &session_manager() const {
return *_sessionManager;
}

/**
* Frees any allocated resources. This will also stop the internal thread
* and wait for it to finish. All pending tasks are deleted.
Expand Down Expand Up @@ -392,6 +384,7 @@ class DocumentDB : public DocumentDBConfigOwner,
document::BucketSpace getBucketSpace() const override;
vespalib::string getName() const override;
uint32_t getDistributionKey() const override;
matching::SessionManager &session_manager() override;

/**
* Implements IFeedHandlerOwner
Expand Down
Loading

0 comments on commit 0f15b40

Please sign in to comment.