diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-02-06 11:36:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-06 11:36:47 +0100 |
commit | 32ab2f56be3f2ad470ecba11f3130d6bf43df904 (patch) | |
tree | 1bde734db559867f37c7d95a24cc81d08a500da2 | |
parent | 6e6e9c71e11268a7badd2297341a0937cbad2d1f (diff) | |
parent | 71ddace81b783ca788d88b8f1936c54d1faea7c9 (diff) |
Merge pull request #4920 from vespa-engine/balder/init-metric-manager-a-bit-earlier
Metric manager must be initialized too, not only metric engine.
-rw-r--r-- | metrics/src/vespa/metrics/metricmanager.cpp | 14 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricmanager.h | 2 | ||||
-rw-r--r-- | searchcore/src/apps/proton/proton.cpp | 7 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/server/proton.cpp | 3 | ||||
-rw-r--r-- | storage/src/vespa/storage/storageserver/storagenode.cpp | 4 |
5 files changed, 20 insertions, 10 deletions
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp index 5530e468007..39a9fdefc39 100644 --- a/metrics/src/vespa/metrics/metricmanager.cpp +++ b/metrics/src/vespa/metrics/metricmanager.cpp @@ -150,11 +150,16 @@ MetricManager::removeMetricUpdateHook(UpdateHook& hook) LOG(warning, "Update hook not registered"); } +bool +MetricManager::isInitialized() const { + return static_cast<bool>(_configHandle); +} + void MetricManager::init(const config::ConfigUri & uri, FastOS_ThreadPool& pool, bool startThread) { - if (_configHandle.get()) { + if (isInitialized()) { throw vespalib::IllegalStateException( "The metric manager have already been initialized. " "It can only be initialized once.", VESPA_STRLOC); @@ -164,12 +169,11 @@ MetricManager::init(const config::ConfigUri & uri, FastOS_ThreadPool& pool, _configHandle = _configSubscriber->subscribe<Config>(uri.getConfigId()); _configSubscriber->nextConfig(); configure(getMetricLock(), _configHandle->getConfig()); - LOG(debug, "Starting worker thread, waiting for first " - "iteration to complete."); + LOG(debug, "Starting worker thread, waiting for first iteration to complete."); if (startThread) { Runnable::start(pool); - // Wait for first iteration to have completed, such that it is safe - // to access snapshots afterwards. + // Wait for first iteration to have completed, such that it is safe + // to access snapshots afterwards. vespalib::MonitorGuard sync(_waiter); while (_lastProcessedTime == 0) { sync.wait(1); diff --git a/metrics/src/vespa/metrics/metricmanager.h b/metrics/src/vespa/metrics/metricmanager.h index 7aeca264328..423eb41a787 100644 --- a/metrics/src/vespa/metrics/metricmanager.h +++ b/metrics/src/vespa/metrics/metricmanager.h @@ -273,6 +273,8 @@ public: MemoryConsumption::UP getMemoryConsumption(const MetricLockGuard & guard) const; + bool isInitialized() const; + private: void takeSnapshots(const MetricLockGuard &, time_t timeToProcess); diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index 5cdc8e04eb4..70cd8d8a7ad 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -208,6 +208,11 @@ App::Main() } sigBusHandler.reset(new search::SigBusHandler(stateFile.get())); ioErrorHandler.reset(new search::IOErrorHandler(stateFile.get())); + if ( ! params.serviceidentity.empty()) { + proton.getMetricManager().init(params.serviceidentity, proton.getThreadPool()); + } else { + proton.getMetricManager().init(params.identity, proton.getThreadPool()); + } if (!downPersistence) { proton.init(configSnapshot); } @@ -218,8 +223,6 @@ App::Main() spiProton->setupConfig(params.subscribeTimeout); spiProton->createNode(); EV_STARTED("servicelayer"); - } else { - proton.getMetricManager().init(params.identity, proton.getThreadPool()); } EV_STARTED("proton"); while (!(SIG::INT.check() || SIG::TERM.check() || (spiProton && spiProton->getNode().attemptedStopped()))) { diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index 65a47e1ded8..49f8d50d9d4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -165,7 +165,7 @@ Proton::Proton(const config::ConfigUri & configUri, _configUri(configUri), _mutex(), _metricsHook(*this), - _metricsEngine(), + _metricsEngine(std::make_unique<MetricsEngine>()), _fileHeaderContext(*this, progName), _tls(), _diskMemUsageSampler(), @@ -235,7 +235,6 @@ Proton::init(const BootstrapConfig::SP & configSnapshot) (protonConfig.basedir, diskMemUsageSamplerConfig(protonConfig, hwInfo)); - _metricsEngine.reset(new MetricsEngine()); _metricsEngine->addMetricsHook(_metricsHook); _fileHeaderContext.setClusterName(protonConfig.clustername, protonConfig.basedir); _tls.reset(new TLS(_configUri.createWithNewId(protonConfig.tlsconfigid), _fileHeaderContext)); diff --git a/storage/src/vespa/storage/storageserver/storagenode.cpp b/storage/src/vespa/storage/storageserver/storagenode.cpp index 6be8f0a5ec8..aa5475df823 100644 --- a/storage/src/vespa/storage/storageserver/storagenode.cpp +++ b/storage/src/vespa/storage/storageserver/storagenode.cpp @@ -215,7 +215,9 @@ StorageNode::initialize() // and the like. Note that at this time, all metrics should hopefully // have been created, such that we don't need to pay the extra cost of // reinitializing metric manager often. - _context.getComponentRegister().getMetricManager().init(_configUri, _context.getThreadPool()); + if ( ! _context.getComponentRegister().getMetricManager().isInitialized() ) { + _context.getComponentRegister().getMetricManager().init(_configUri, _context.getThreadPool()); + } if (_chain) { LOG(debug, "Storage chain configured. Calling open()"); |