diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-11-28 21:16:26 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-12 02:55:40 +0100 |
commit | e1a678feb2deddeab5a78be77e16f3cdf0a614a9 (patch) | |
tree | 342fdd803d4597d05e2cef34d667fba2541f9f50 /searchcore | |
parent | e7195ab5e2d76848c1d3ac1004f54edf19dfb72d (diff) |
Loosen up the metrics stuff further.
Diffstat (limited to 'searchcore')
4 files changed, 44 insertions, 32 deletions
diff --git a/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.h b/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.h index f4fa80a77ab..1def71604fb 100644 --- a/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.h +++ b/searchcore/src/vespa/searchcore/fdispatch/program/fdispatch.h @@ -9,6 +9,8 @@ #include <vespa/searchlib/engine/transportserver.h> #include <vespa/searchcore/config/config-fdispatchrc.h> #include <vespa/config/subscription/configuri.h> +#include <vespa/config/helper/ifetchercallback.h> +#include <vespa/config/helper/configfetcher.h> #include <vespa/vespalib/net/simple_component_config_producer.h> #include <vespa/vespalib/util/random.h> diff --git a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp index c5581822e9d..be39398163f 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.cpp @@ -1,18 +1,19 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.server.metricsengine"); #include "metrics_engine.h" #include <vespa/metrics/jsonwriter.h> +#include <vespa/metrics/metricmanager.h> +#include <vespa/log/log.h> +LOG_SETUP(".proton.server.metricsengine"); namespace proton { MetricsEngine::MetricsEngine() : _root(), _legacyRoot(), - _manager(), - _metrics_producer(_manager) + _manager(std::make_unique<metrics::MetricManager>()), + _metrics_producer(*_manager) { } @@ -24,15 +25,15 @@ void MetricsEngine::start(const config::ConfigUri &) { { - metrics::MetricLockGuard guard(_manager.getMetricLock()); - _manager.registerMetric(guard, _root); - _manager.registerMetric(guard, _legacyRoot); + metrics::MetricLockGuard guard(_manager->getMetricLock()); + _manager->registerMetric(guard, _root); + _manager->registerMetric(guard, _legacyRoot); } // Storage doesnt snapshot unset metrics to save memory. Currently // feature seems a bit bugged. Disabling this optimalization for search. // Can enable it later when it is confirmed to be working well. - _manager.snapshotUnsetMetrics(true); + _manager->snapshotUnsetMetrics(true); // Currently, when injecting a metric manager into the content layer, // the content layer require to be the one initializing and starting it. @@ -41,28 +42,28 @@ MetricsEngine::start(const config::ConfigUri &) } void -MetricsEngine::addMetricsHook(metrics::MetricManager::UpdateHook &hook) +MetricsEngine::addMetricsHook(metrics::UpdateHook &hook) { - _manager.addMetricUpdateHook(hook, 5); + _manager->addMetricUpdateHook(hook, 5); } void -MetricsEngine::removeMetricsHook(metrics::MetricManager::UpdateHook &hook) +MetricsEngine::removeMetricsHook(metrics::UpdateHook &hook) { - _manager.removeMetricUpdateHook(hook); + _manager->removeMetricUpdateHook(hook); } void MetricsEngine::addExternalMetrics(metrics::Metric &child) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); _legacyRoot.registerMetric(child); } void MetricsEngine::removeExternalMetrics(metrics::Metric &child) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); _legacyRoot.unregisterMetric(child); } @@ -109,7 +110,7 @@ removeLegacyDocumentDBMetrics(LegacyProtonMetrics &legacyRoot, void MetricsEngine::addDocumentDBMetrics(DocumentDBMetricsCollection &child) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); addLegacyDocumentDBMetrics(_legacyRoot, child.getMetrics()); _root.registerMetric(child.getTaggedMetrics()); @@ -118,7 +119,7 @@ MetricsEngine::addDocumentDBMetrics(DocumentDBMetricsCollection &child) void MetricsEngine::removeDocumentDBMetrics(DocumentDBMetricsCollection &child) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); removeLegacyDocumentDBMetrics(_legacyRoot, child.getMetrics()); _root.unregisterMetric(child.getTaggedMetrics()); @@ -170,7 +171,7 @@ MetricsEngine::addAttribute(AttributeMetrics &subAttributes, AttributeMetrics *totalAttributes, const std::string &name) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); doAddAttribute(subAttributes, name); if (totalAttributes != NULL) { doAddAttribute(*totalAttributes, name); @@ -182,7 +183,7 @@ MetricsEngine::removeAttribute(AttributeMetrics &subAttributes, AttributeMetrics *totalAttributes, const std::string &name) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); doRemoveAttribute(subAttributes, name); if (totalAttributes != NULL) { doRemoveAttribute(*totalAttributes, name); @@ -193,7 +194,7 @@ void MetricsEngine::cleanAttributes(AttributeMetrics &subAttributes, AttributeMetrics *totalAttributes) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); doCleanAttributes(subAttributes); if (totalAttributes != NULL) { doCleanAttributes(*totalAttributes); @@ -203,7 +204,7 @@ MetricsEngine::cleanAttributes(AttributeMetrics &subAttributes, void MetricsEngine::addRankProfile(LegacyDocumentDBMetrics &owner, const std::string &name, size_t numDocIdPartitions) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMetrics::LP &entry = owner.matching.rank_profiles[name]; if (entry.get()) { @@ -216,7 +217,7 @@ void MetricsEngine::addRankProfile(LegacyDocumentDBMetrics &owner, } void MetricsEngine::cleanRankProfiles(LegacyDocumentDBMetrics &owner) { - metrics::MetricLockGuard guard(_manager.getMetricLock()); + metrics::MetricLockGuard guard(_manager->getMetricLock()); LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMap metrics; owner.matching.rank_profiles.swap(metrics); for (LegacyDocumentDBMetrics::MatchingMetrics::RankProfileMap::const_iterator @@ -228,7 +229,7 @@ void MetricsEngine::cleanRankProfiles(LegacyDocumentDBMetrics &owner) { void MetricsEngine::stop() { - _manager.stop(); + _manager->stop(); } } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h index 7c8fa0627e8..d85f7e52f17 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/metrics_engine.h @@ -12,15 +12,23 @@ #include <vespa/metrics/state_api_adapter.h> #include <vespa/vespalib/net/metrics_producer.h> +namespace metrics { + class Metricmanager; + class UpdateHook; +} + +namespace config { + class ConfigUri; +} namespace proton { class MetricsEngine : public MetricsWireService { private: - ContentProtonMetrics _root; - LegacyProtonMetrics _legacyRoot; - metrics::MetricManager _manager; - metrics::StateApiAdapter _metrics_producer; + ContentProtonMetrics _root; + LegacyProtonMetrics _legacyRoot; + std::unique_ptr<metrics::MetricManager> _manager; + metrics::StateApiAdapter _metrics_producer; public: typedef std::unique_ptr<MetricsEngine> UP; @@ -30,8 +38,8 @@ public: ContentProtonMetrics &root() { return _root; } LegacyProtonMetrics &legacyRoot() { return _legacyRoot; } void start(const config::ConfigUri & configUri); - void addMetricsHook(metrics::MetricManager::UpdateHook &hook); - void removeMetricsHook(metrics::MetricManager::UpdateHook &hook); + void addMetricsHook(metrics::UpdateHook &hook); + void removeMetricsHook(metrics::UpdateHook &hook); void addExternalMetrics(metrics::Metric &child); void removeExternalMetrics(metrics::Metric &child); void addDocumentDBMetrics(DocumentDBMetricsCollection &child); @@ -51,7 +59,7 @@ public: void stop(); vespalib::MetricsProducer &metrics_producer() { return _metrics_producer; } - metrics::MetricManager &getManager() { return _manager; } + metrics::MetricManager &getManager() { return *_manager; } }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h index efc26510268..07c3cd7f946 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h @@ -37,6 +37,7 @@ #include <vespa/vespalib/util/varholder.h> #include <vespa/searchcore/proton/attribute/attribute_usage_filter.h> #include "disk_mem_usage_forwarder.h" +#include <vespa/metrics/updatehook.h> using vespa::config::search::core::ProtonConfig; @@ -72,12 +73,12 @@ class DocumentDB : public IDocumentDBConfigOwner, public search::transactionlog::SyncProxy { private: - class MetricsUpdateHook : public metrics::MetricManager::UpdateHook { + class MetricsUpdateHook : public metrics::UpdateHook { DocumentDBMetricsCollection _metrics; DocumentDB &_db; public: MetricsUpdateHook(DocumentDB &s, const std::string &doc_type, size_t maxNumThreads) - : metrics::MetricManager::UpdateHook("documentdb-hook"), + : metrics::UpdateHook("documentdb-hook"), _metrics(doc_type, maxNumThreads), _db(s) {} void updateMetrics(const MetricLockGuard & ) override { _db.updateMetrics(_metrics); } @@ -316,7 +317,7 @@ public: * * @return metrics update hook **/ - metrics::MetricManager::UpdateHook & getMetricsUpdateHook(void) { + metrics::UpdateHook & getMetricsUpdateHook(void) { return _metricsHook; } |