diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-11-02 23:40:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-02 23:40:17 +0100 |
commit | e8549e60e461ff73e6cc1b6db72eee85b7afb87e (patch) | |
tree | 19eb1615218b80546b3747fb260a135b380397d7 /searchcore | |
parent | cdd248b3a9224f1ade19b7e88d70f85b2ae36ebd (diff) | |
parent | 31fd3e8170ec253082e6a62b9667724f30e83d38 (diff) |
Merge pull request #3925 from vespa-engine/balder/enable-metrics-reporting-earlier-in-proton
Balder/enable metrics reporting earlier in proton
Diffstat (limited to 'searchcore')
18 files changed, 112 insertions, 179 deletions
diff --git a/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp b/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp index b50fcd083bc..1aaeb1707b3 100644 --- a/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp +++ b/searchcore/src/tests/proton/metrics/metrics_engine/metrics_engine_test.cpp @@ -1,14 +1,18 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Unit tests for metrics_engine. -#include <vespa/log/log.h> -LOG_SETUP("metrics_engine_test"); - #include <vespa/metrics/metricset.h> #include <vespa/searchcore/proton/metrics/attribute_metrics_collection.h> +#include <vespa/searchcore/proton/metrics/attribute_metrics.h> +#include <vespa/searchcore/proton/metrics/documentdb_metrics_collection.h> + + #include <vespa/searchcore/proton/metrics/metrics_engine.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/log/log.h> +LOG_SETUP("metrics_engine_test"); + using namespace proton; struct DummyMetricSet : public metrics::MetricSet { diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h index 66f12a4952c..04f3982c07c 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastorecontext.h @@ -22,7 +22,7 @@ public: search::AttributeGuard _activeLidsGuard; public: ReadGuard(const search::AttributeVector::SP &metaStoreAttr); - virtual const search::IDocumentMetaStore &get() const override { return _store; } + const search::IDocumentMetaStore &get() const override { return _store; } }; private: search::AttributeVector::SP _metaStoreAttr; @@ -45,12 +45,10 @@ public: */ DocumentMetaStoreContext(const search::AttributeVector::SP &metaStoreAttr); - // Implements IDocumentMetaStoreContext proton::IDocumentMetaStore::SP getSP() const override { return _metaStore; } proton::IDocumentMetaStore & get() override { return *_metaStore; } - IReadGuard::UP getReadGuard() const override { - return IReadGuard::UP(new ReadGuard(_metaStoreAttr)); + return std::make_unique<ReadGuard>(_metaStoreAttr); } void constructFreeList() override; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.cpp index ce9828a8a23..c5296aa3b1f 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.cpp @@ -20,6 +20,6 @@ ExecutorMetrics::ExecutorMetrics(const std::string &name, metrics::MetricSet *pa { } -ExecutorMetrics::~ExecutorMetrics() {} +ExecutorMetrics::~ExecutorMetrics() = default; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h index 6462264ac11..a347edffd4b 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/executor_metrics.h @@ -2,7 +2,9 @@ #pragma once -#include <vespa/metrics/metrics.h> +#include <vespa/metrics/metricset.h> +#include <vespa/metrics/countmetric.h> +#include <vespa/metrics/valuemetric.h> #include <vespa/vespalib/util/threadstackexecutorbase.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp index 2eaabe59569..25dfb3d71ab 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.cpp @@ -61,7 +61,7 @@ LegacyAttributeMetrics::List::List(metrics::MetricSet *parent) { } -LegacyAttributeMetrics::List::~List() {} +LegacyAttributeMetrics::List::~List() = default; LegacyAttributeMetrics::LegacyAttributeMetrics(metrics::MetricSet *parent) : metrics::MetricSet("attributes", "", "Attribute metrics", parent), @@ -71,6 +71,6 @@ LegacyAttributeMetrics::LegacyAttributeMetrics(metrics::MetricSet *parent) { } -LegacyAttributeMetrics::~LegacyAttributeMetrics() {} +LegacyAttributeMetrics::~LegacyAttributeMetrics() = default; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h index bddb1a6a64e..073acabf614 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_attribute_metrics.h @@ -2,7 +2,9 @@ #pragma once -#include <vespa/metrics/metrics.h> +#include <vespa/metrics/metricset.h> +#include <vespa/metrics/valuemetric.h> +#include <map> namespace proton { @@ -27,7 +29,7 @@ struct LegacyAttributeMetrics : metrics::MetricSet { // per attribute metrics will be wired in here (by the metrics engine) List(metrics::MetricSet *parent); - ~List(); + ~List() override; private: std::map<std::string, Entry::UP> metrics; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h index 0abad83a3a6..2c66428aabd 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/legacy_documentdb_metrics.h @@ -4,8 +4,8 @@ #include "legacy_attribute_metrics.h" #include "executor_metrics.h" -#include <vespa/metrics/metrics.h> #include "sessionmanager_metrics.h" +#include <vespa/metrics/summetric.h> #include <vespa/searchcore/proton/matching/matching_stats.h> namespace proton { diff --git a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp index 13ce39ad755..94414e99c05 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp @@ -2,6 +2,7 @@ #include "metrics_engine.h" #include "attribute_metrics_collection.h" +#include "documentdb_metrics_collection.h" #include <vespa/metrics/jsonwriter.h> #include <vespa/metrics/metricmanager.h> @@ -15,12 +16,9 @@ MetricsEngine::MetricsEngine() _legacyRoot(), _manager(std::make_unique<metrics::MetricManager>()), _metrics_producer(*_manager) -{ -} +{ } -MetricsEngine::~MetricsEngine() -{ -} +MetricsEngine::~MetricsEngine() = default; void MetricsEngine::start(const config::ConfigUri &) @@ -236,9 +234,8 @@ MetricsEngine::cleanAttributes(const AttributeMetricsCollection &subAttributes, } } -void MetricsEngine::addRankProfile(LegacyDocumentDBMetrics &owner, - const std::string &name, - size_t numDocIdPartitions) { +void +MetricsEngine::addRankProfile(LegacyDocumentDBMetrics &owner, const std::string &name, size_t numDocIdPartitions) { metrics::MetricLockGuard guard(_manager->getMetricLock()); auto &entry = owner.matching.rank_profiles[name]; if (entry.get()) { @@ -250,13 +247,13 @@ void MetricsEngine::addRankProfile(LegacyDocumentDBMetrics &owner, } } -void MetricsEngine::cleanRankProfiles(LegacyDocumentDBMetrics &owner) { +void +MetricsEngine::cleanRankProfiles(LegacyDocumentDBMetrics &owner) { metrics::MetricLockGuard guard(_manager->getMetricLock()); LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMap metrics; owner.matching.rank_profiles.swap(metrics); - for (LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMap::const_iterator - it = metrics.begin(); it != metrics.end(); ++it) { - owner.matching.unregisterMetric(*it->second); + for (auto & metric : metrics) { + owner.matching.unregisterMetric(*metric.second); } } diff --git a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h index a306b33bcdd..83d04cccef0 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h @@ -3,14 +3,9 @@ #pragma once #include "content_proton_metrics.h" -#include "documentdb_metrics_collection.h" #include "legacy_proton_metrics.h" #include "metricswireservice.h" -#include <algorithm> -#include <vespa/fastlib/net/httpserver.h> -#include <vespa/metrics/metrics.h> #include <vespa/metrics/state_api_adapter.h> -#include <vespa/vespalib/net/metrics_producer.h> namespace metrics { class Metricmanager; @@ -22,6 +17,8 @@ namespace config { } namespace proton { +class DocumentDBMetricsCollection; + class MetricsEngine : public MetricsWireService { private: @@ -44,18 +41,16 @@ public: void removeExternalMetrics(metrics::Metric &child); void addDocumentDBMetrics(DocumentDBMetricsCollection &child); void removeDocumentDBMetrics(DocumentDBMetricsCollection &child); - virtual void addAttribute(const AttributeMetricsCollection &subAttributes, - LegacyAttributeMetrics *totalAttributes, - const std::string &name) override; - virtual void removeAttribute(const AttributeMetricsCollection &subAttributes, - LegacyAttributeMetrics *totalAttributes, - const std::string &name) override; - virtual void cleanAttributes(const AttributeMetricsCollection &subAttributes, - LegacyAttributeMetrics *totalAttributes) override; - virtual void addRankProfile(LegacyDocumentDBMetrics &owner, - const std::string &name, - size_t numDocIdPartitions) override; - virtual void cleanRankProfiles(LegacyDocumentDBMetrics &owner) override; + void addAttribute(const AttributeMetricsCollection &subAttributes, + LegacyAttributeMetrics *totalAttributes, + const std::string &name) override; + void removeAttribute(const AttributeMetricsCollection &subAttributes, + LegacyAttributeMetrics *totalAttributes, + const std::string &name) override; + void cleanAttributes(const AttributeMetricsCollection &subAttributes, + LegacyAttributeMetrics *totalAttributes) override; + void addRankProfile(LegacyDocumentDBMetrics &owner, const std::string &name, size_t numDocIdPartitions) override; + void cleanRankProfiles(LegacyDocumentDBMetrics &owner) override; void stop(); vespalib::MetricsProducer &metrics_producer() { return _metrics_producer; } diff --git a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.cpp index acad6150ef8..f609b850876 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.cpp @@ -2,13 +2,10 @@ #include "sessionmanager_metrics.h" -namespace search { -namespace grouping { +namespace search::grouping { SessionManagerMetrics::SessionManagerMetrics(metrics::MetricSet *parent) - : metrics::MetricSet("sessionmanager", "", - "Grouping session manager metrics", - parent), + : metrics::MetricSet("sessionmanager", "", "Grouping session manager metrics", parent), numInsert("numinsert", "", "Number of inserted sessions", this), numPick("numpick", "", "Number if picked sessions", this), numDropped("numdropped", "", "Number of dropped cached sessions", this), @@ -17,11 +14,10 @@ SessionManagerMetrics::SessionManagerMetrics(metrics::MetricSet *parent) { } -SessionManagerMetrics::~SessionManagerMetrics() {} +SessionManagerMetrics::~SessionManagerMetrics() = default; void -SessionManagerMetrics::update( - const proton::matching::SessionManager::Stats &stats) +SessionManagerMetrics::update(const proton::matching::SessionManager::Stats &stats) { numInsert.inc(stats.numInsert); numPick.inc(stats.numPick); @@ -31,5 +27,4 @@ SessionManagerMetrics::update( } -} // namespace grouping -} // namespace search +} diff --git a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h index 2ee8deb4082..37e070c9e04 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/sessionmanager_metrics.h @@ -2,11 +2,12 @@ #pragma once -#include <vespa/metrics/metrics.h> #include <vespa/searchcore/proton/matching/sessionmanager.h> +#include <vespa/metrics/metricset.h> +#include <vespa/metrics/countmetric.h> +#include <vespa/metrics/valuemetric.h> -namespace search { -namespace grouping { +namespace search::grouping { struct SessionManagerMetrics : metrics::MetricSet { @@ -21,6 +22,4 @@ struct SessionManagerMetrics : metrics::MetricSet ~SessionManagerMetrics(); }; -} // namespace grouping -} // namespace search - +} diff --git a/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h b/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h index 222bec3a345..b69c66ec7ad 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_db_explorer.h @@ -19,10 +19,9 @@ public: DocumentDBExplorer(const DocumentDB::SP &docDb); ~DocumentDBExplorer(); - // Implements vespalib::StateExplorer - virtual void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; - virtual std::vector<vespalib::string> get_children_names() const override; - virtual std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override; + void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; + std::vector<vespalib::string> get_children_names() const override; + std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp index 27253e9a420..2335cd01ec8 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.cpp @@ -12,6 +12,6 @@ DocumentMetaStoreReadGuards::DocumentMetaStoreReadGuards(DocumentSubDBCollection remdms(subDBs.getRemSubDB()->getDocumentMetaStoreContext().getReadGuard()) { } -DocumentMetaStoreReadGuards::~DocumentMetaStoreReadGuards() { } +DocumentMetaStoreReadGuards::~DocumentMetaStoreReadGuards() = default; } diff --git a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h index b5d28f6048b..8dc39d1415d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h +++ b/searchcore/src/vespa/searchcore/proton/server/document_meta_store_read_guards.h @@ -22,16 +22,16 @@ struct DocumentMetaStoreReadGuards ~DocumentMetaStoreReadGuards(); uint32_t numActiveDocs() const { - return readydms->get().getNumActiveLids(); + return readydms ? readydms->get().getNumActiveLids() : 0; } uint32_t numIndexedDocs() const { - return readydms->get().getNumUsedLids(); + return readydms ? readydms->get().getNumUsedLids() : 0; } uint32_t numStoredDocs() const { - return numIndexedDocs() + notreadydms->get().getNumUsedLids(); + return numIndexedDocs() + (notreadydms ? notreadydms->get().getNumUsedLids() : 0); } uint32_t numRemovedDocs() const { - return remdms->get().getNumUsedLids(); + return remdms ? remdms->get().getNumUsedLids() : 0; } }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 5babacfc4b6..4dbff7c8e58 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -1007,8 +1007,7 @@ DocumentDB::notifyAllBucketsChanged() namespace { void -updateIndexMetrics(DocumentDBMetricsCollection &metrics, - const search::SearchableStats &stats) +updateIndexMetrics(DocumentDBMetricsCollection &metrics, const search::SearchableStats &stats) { DocumentDBTaggedMetrics::IndexMetrics &indexMetrics = metrics.getTaggedMetrics().index; indexMetrics.diskUsage.set(stats.sizeOnDisk()); @@ -1051,10 +1050,8 @@ isNotReadySubDB(const IDocumentSubDB *subDb, const DocumentSubDBCollection &subD } void -fillTempAttributeMetrics(TempAttributeMetrics &metrics, - const vespalib::string &attrName, - const MemoryUsage &memoryUsage, - uint32_t bitVectors) +fillTempAttributeMetrics(TempAttributeMetrics &metrics, const vespalib::string &attrName, + const MemoryUsage &memoryUsage, uint32_t bitVectors) { metrics._total._memoryUsage.merge(memoryUsage); metrics._total._bitVectors += bitVectors; @@ -1071,7 +1068,7 @@ fillTempAttributeMetrics(TempAttributeMetrics &totalMetrics, { for (const auto subDb : subDbs) { proton::IAttributeManager::SP attrMgr(subDb->getAttributeManager()); - if (attrMgr.get()) { + if (attrMgr) { TempAttributeMetrics *subMetrics = (isReadySubDB(subDb, subDbs) ? &readyMetrics : (isNotReadySubDB(subDb, subDbs) ? ¬ReadyMetrics : nullptr)); @@ -1091,8 +1088,7 @@ fillTempAttributeMetrics(TempAttributeMetrics &totalMetrics, } void -updateLegacyAttributeMetrics(LegacyAttributeMetrics &metrics, - const TempAttributeMetrics &tmpMetrics) +updateLegacyAttributeMetrics(LegacyAttributeMetrics &metrics, const TempAttributeMetrics &tmpMetrics) { for (const auto &attr : tmpMetrics._attrs) { LegacyAttributeMetrics::List::Entry *entry = metrics.list.get(attr.first); @@ -1108,20 +1104,18 @@ updateLegacyAttributeMetrics(LegacyAttributeMetrics &metrics, } void -updateAttributeMetrics(AttributeMetrics &metrics, - const TempAttributeMetrics &tmpMetrics) +updateAttributeMetrics(AttributeMetrics &metrics, const TempAttributeMetrics &tmpMetrics) { for (const auto &attr : tmpMetrics._attrs) { auto entry = metrics.get(attr.first); - if (entry.get()) { + if (entry) { entry->memoryUsage.update(attr.second._memoryUsage); } } } void -updateAttributeMetrics(DocumentDBMetricsCollection &metrics, - const DocumentSubDBCollection &subDbs) +updateAttributeMetrics(DocumentDBMetricsCollection &metrics, const DocumentSubDBCollection &subDbs) { TempAttributeMetrics totalMetrics; TempAttributeMetrics readyMetrics; @@ -1137,8 +1131,7 @@ updateAttributeMetrics(DocumentDBMetricsCollection &metrics, } void -updateMatchingMetrics(LegacyDocumentDBMetrics::MatchingMetrics &metrics, - const IDocumentSubDB &ready) +updateMatchingMetrics(LegacyDocumentDBMetrics::MatchingMetrics &metrics, const IDocumentSubDB &ready) { MatchingStats stats; for (const auto &kv : metrics.rank_profiles) { @@ -1158,8 +1151,10 @@ updateDocstoreMetrics(LegacyDocumentDBMetrics::DocstoreMetrics &metrics, CacheStats cache_stats; for (const auto subDb : sub_dbs) { const ISummaryManager::SP &summaryMgr = subDb->getSummaryManager(); - cache_stats += summaryMgr->getBackingStore().getCacheStats(); - memoryUsage += summaryMgr->getBackingStore().memoryUsed(); + if (summaryMgr) { + cache_stats += summaryMgr->getBackingStore().getCacheStats(); + memoryUsage += summaryMgr->getBackingStore().memoryUsed(); + } } metrics.memoryUsage.set(memoryUsage); size_t lookups = cache_stats.hits + cache_stats.misses; @@ -1204,8 +1199,7 @@ updateDocumentStoreMetrics(DocumentDBTaggedMetrics::SubDBMetrics:: template <typename MetricSetType> void -updateLidSpaceMetrics(MetricSetType &metrics, - const search::IDocumentMetaStore &metaStore) +updateLidSpaceMetrics(MetricSetType &metrics, const search::IDocumentMetaStore &metaStore) { LidUsageStats stats = metaStore.getLidUsageStats(); metrics.lidLimit.set(stats.getLidLimit()); @@ -1257,13 +1251,10 @@ DocumentDB:: updateMetrics(DocumentDBTaggedMetrics::AttributeMetrics &metrics) { AttributeUsageFilter &writeFilter(_writeFilter); - AttributeUsageStats attributeUsageStats = - writeFilter.getAttributeUsageStats(); + AttributeUsageStats attributeUsageStats = writeFilter.getAttributeUsageStats(); bool feedBlocked = !writeFilter.acceptWriteOperation(); - double enumStoreUsed = - attributeUsageStats.enumStoreUsage().getUsage().usage(); - double multiValueUsed = - attributeUsageStats.multiValueUsage().getUsage().usage(); + double enumStoreUsed = attributeUsageStats.enumStoreUsage().getUsage().usage(); + double multiValueUsed = attributeUsageStats.multiValueUsage().getUsage().usage(); metrics.resourceUsage.enumStore.set(enumStoreUsed); metrics.resourceUsage.multiValue.set(multiValueUsed); metrics.resourceUsage.feedingBlocked.set(feedBlocked ? 1 : 0); diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index 09890ae41ef..aa1c8483c8d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -26,7 +26,6 @@ #include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/host_name.h> #include <vespa/vespalib/util/random.h> -#include <dirent.h> #include <vespa/searchlib/aggregation/forcelink.hpp> #include <vespa/searchlib/expression/forcelink.hpp> @@ -312,14 +311,14 @@ Proton::init(const BootstrapConfig::SP & configSnapshot) RPCHooks::Params rpcParams(*this, protonConfig.rpcport, _configUri.getConfigId()); rpcParams.slobrok_config = _configUri.createWithNewId(protonConfig.slobrokconfigid); _rpcHooks.reset(new RPCHooks(rpcParams)); - - waitForInitDone(); - + _metricsEngine->start(_configUri); _stateServer.reset(new vespalib::StateServer(protonConfig.httpport, _healthAdapter, _metricsEngine->metrics_producer(), *this)); _customComponentBindToken = _stateServer->repo().bind(CUSTOM_COMPONENT_API_PATH, _genericStateHandler); _customComponentRootToken = _stateServer->repo().add_root_resource(CUSTOM_COMPONENT_API_PATH); + waitForInitDone(); + _executor.sync(); waitForOnlineState(); _isReplayDone = true; @@ -497,28 +496,13 @@ Proton::getStatusReports() const { StatusReport::List reports; std::shared_lock<std::shared_timed_mutex> guard(_mutex); - reports.push_back(StatusReport::SP(_matchEngine-> - reportStatus().release())); + reports.push_back(StatusReport::SP(_matchEngine->reportStatus())); for (const auto &kv : _documentDBMap) { - reports.push_back(StatusReport::SP(kv.second-> - reportStatus().release())); + reports.push_back(StatusReport::SP(kv.second->reportStatus())); } return reports; } - -DocumentDB::SP -Proton::getDocumentDB(const document::DocumentType &docType) -{ - std::shared_lock<std::shared_timed_mutex> guard(_mutex); - DocTypeName docTypeName(docType.getName()); - DocumentDBMap::iterator it = _documentDBMap.find(docTypeName); - if (it != _documentDBMap.end()) { - return it->second; - } - return DocumentDB::SP(); -} - DocumentDB::SP Proton::addDocumentDB(const document::DocumentType &docType, document::BucketSpace bucketSpace, @@ -537,17 +521,15 @@ Proton::addDocumentDB(const document::DocumentType &docType, vespalib::string db_dir = config.basedir + "/documents/" + docTypeName.toString(); vespalib::mkdir(db_dir, false); // Assume parent is created. - ConfigStore::UP config_store( - new FileConfigManager(db_dir + "/config", - documentDBConfig->getConfigId(), - docTypeName.getName())); + auto config_store = std::make_unique<FileConfigManager>(db_dir + "/config", + documentDBConfig->getConfigId(), + docTypeName.getName()); config_store->setProtonConfig(bootstrapConfig->getProtonConfigSP()); if (!initializeThreads) { // If configured value for initialize threads was 0, or we // are performing a reconfig after startup has completed, then use // 1 thread per document type. - initializeThreads = std::make_shared<vespalib::ThreadStackExecutor> - (1, 128 * 1024); + initializeThreads = std::make_shared<vespalib::ThreadStackExecutor>(1, 128 * 1024); } DocumentDB::SP ret(new DocumentDB(config.basedir + "/documents", documentDBConfig, diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.h b/searchcore/src/vespa/searchcore/proton/server/proton.h index 67f3662549d..532c6651cfa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.h +++ b/searchcore/src/vespa/searchcore/proton/server/proton.h @@ -57,10 +57,9 @@ private: typedef search::engine::MonitorClient MonitorClient; typedef std::map<DocTypeName, DocumentDB::SP> DocumentDBMap; typedef BootstrapConfig::ProtonConfigSP ProtonConfigSP; - typedef std::shared_ptr<FastOS_DynamicLibrary> DynamicLibrarySP; - typedef std::map<vespalib::string, DynamicLibrarySP> LibraryMap; using InitializeThreads = std::shared_ptr<vespalib::ThreadStackExecutorBase>; using lock_guard = std::lock_guard<std::mutex>; + using BucketSpace = document::BucketSpace; struct MetricsUpdateHook : metrics::UpdateHook { @@ -81,21 +80,14 @@ private: pid_t _pid; public: - ProtonFileHeaderContext(const Proton &proton_, - const vespalib::string &creator); - ~ProtonFileHeaderContext(); + ProtonFileHeaderContext(const Proton &proton_, const vespalib::string &creator); + ~ProtonFileHeaderContext() override; - virtual void - addTags(vespalib::GenericHeader &header, - const vespalib::string &name) const override; - - void - setClusterName(const vespalib::string &clusterName, - const vespalib::string &baseDir); + void addTags(vespalib::GenericHeader &header, const vespalib::string &name) const override; + void setClusterName(const vespalib::string &clusterName, const vespalib::string &baseDir); }; const config::ConfigUri _configUri; - vespalib::string _dbFile; mutable std::shared_timed_mutex _mutex; MetricsUpdateHook _metricsHook; MetricsEngine::UP _metricsEngine; @@ -103,7 +95,7 @@ private: TLS::UP _tls; std::unique_ptr<DiskMemUsageSampler> _diskMemUsageSampler; PersistenceEngine::UP _persistenceEngine; - DocumentDBMap _documentDBMap; + DocumentDBMap _documentDBMap; MatchEngine::UP _matchEngine; SummaryEngine::UP _summaryEngine; DocsumBySlime::UP _docsumBySlime; @@ -137,17 +129,15 @@ private: std::unique_ptr<HwInfoSampler> _hwInfoSampler; std::shared_ptr<IDocumentDBReferenceRegistry> _documentDBReferenceRegistry; - virtual IDocumentDBConfigOwner *addDocumentDB(const DocTypeName & docTypeName, - document::BucketSpace bucketSpace, - const vespalib::string & configid, - const BootstrapConfig::SP & bootstrapConfig, - const std::shared_ptr<DocumentDBConfig> &documentDBConfig, - InitializeThreads initializeThreads) override; + IDocumentDBConfigOwner * + addDocumentDB(const DocTypeName & docTypeName, BucketSpace bucketSpace, const vespalib::string & configid, + const BootstrapConfig::SP & bootstrapConfig, const std::shared_ptr<DocumentDBConfig> &documentDBConfig, + InitializeThreads initializeThreads) override; - virtual void removeDocumentDB(const DocTypeName &docTypeName) override; + void removeDocumentDB(const DocTypeName &docTypeName) override; - virtual void applyConfig(const BootstrapConfig::SP & configSnapshot) override; - virtual MonitorReply::UP ping(MonitorRequest::UP request, MonitorClient &client) override; + void applyConfig(const BootstrapConfig::SP & configSnapshot) override; + MonitorReply::UP ping(MonitorRequest::UP request, MonitorClient &client) override; /** * Called by the metrics update hook (typically in the context of @@ -155,14 +145,11 @@ private: * threads at once. **/ void updateMetrics(const vespalib::MonitorGuard &guard); - void waitForInitDone(); void waitForOnlineState(); uint32_t getDistributionKey() const override { return _distributionKey; } BootstrapConfig::SP getActiveConfigSnapshot() const; - virtual std::shared_ptr<IDocumentDBReferenceRegistry> getDocumentDBReferenceRegistry() const override; - - + std::shared_ptr<IDocumentDBReferenceRegistry> getDocumentDBReferenceRegistry() const override; public: typedef std::unique_ptr<Proton> UP; typedef std::shared_ptr<Proton> SP; @@ -170,7 +157,7 @@ public: Proton(const config::ConfigUri & configUri, const vespalib::string &progName, uint64_t subscribeTimeout); - virtual ~Proton(); + ~Proton() override; /** * This method must be called after the constructor and before the destructor. @@ -181,20 +168,12 @@ public: */ BootstrapConfig::SP init(); - /* - * 2nd phase init: setup data structures. - */ + // 2nd phase init: setup data structures. void init(const BootstrapConfig::SP & configSnapshot); - - DocumentDB::SP getDocumentDB(const document::DocumentType &docType); - DocumentDB::SP - addDocumentDB(const document::DocumentType &docType, - document::BucketSpace bucketSpace, - const BootstrapConfig::SP &configSnapshot, - const std::shared_ptr<DocumentDBConfig> &documentDBConfig, - InitializeThreads initializeThreads); + addDocumentDB(const document::DocumentType &docType, BucketSpace bucketSpace, const BootstrapConfig::SP &configSnapshot, + const std::shared_ptr<DocumentDBConfig> &documentDBConfig, InitializeThreads initializeThreads); metrics::MetricManager & getMetricManager() { return _metricsEngine->getManager(); } FastOS_ThreadPool & getThreadPool() { return _threadPool; } @@ -202,15 +181,10 @@ public: bool triggerFlush(); bool prepareRestart(); - // implements ComponentConfigProducer interface - virtual void getComponentConfig(Consumer &consumer) override; - - // implements IPersistenceEngineOwner interface - virtual void setClusterState(const storage::spi::ClusterState &calc) override; + void getComponentConfig(Consumer &consumer) override; + void setClusterState(const storage::spi::ClusterState &calc) override; - /** - * Return the oldest active config generation used by proton. - */ + // Return the oldest active config generation used by proton. int64_t getConfigGeneration(); size_t getNumDocs() const; @@ -219,24 +193,19 @@ public: vespalib::string getDelayedConfigs() const; - virtual StatusReport::List getStatusReports() const override; + StatusReport::List getStatusReports() const override; MatchEngine & getMatchEngine() { return *_matchEngine; } vespalib::ThreadStackExecutorBase & getExecutor() { return _executor; } - bool isReplayDone() const { return _isReplayDone; } - - virtual bool isInitializing() const override { - return _isInitializing; - } + bool isInitializing() const override { return _isInitializing; } bool hasAbortedInit() const { return _abortInit; } storage::spi::PersistenceProvider & getPersistence() { return *_persistenceEngine; } - // Implements vespalib::StateExplorer - virtual void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; - virtual std::vector<vespalib::string> get_children_names() const override; - virtual std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override; + void get_state(const vespalib::slime::Inserter &inserter, bool full) const override; + std::vector<vespalib::string> get_children_names() const override; + std::unique_ptr<vespalib::StateExplorer> get_child(vespalib::stringref name) const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp index 0b67698524b..4069a871210 100644 --- a/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/searchabledocsubdb.cpp @@ -301,7 +301,7 @@ SearchableDocSubDB::getNumActiveDocs() const search::SearchableStats SearchableDocSubDB::getSearchableStats() const { - return _indexMgr->getSearchableStats(); + return _indexMgr ? _indexMgr->getSearchableStats() : search::SearchableStats(); } IDocumentRetriever::UP |