diff options
author | Henning Baldersheim <balder@oath.com> | 2018-02-05 15:22:48 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-02-05 15:22:48 +0100 |
commit | 5bae15eab779110e85b77890511ca4c4de63fd7f (patch) | |
tree | d72d98fc1ec7328d5428ea41c45a2fd97bb18f79 /metrics | |
parent | 24094168ea91eb1663d9fe2f40b8ba62b552ce19 (diff) |
Metric manager must be initialized too, not only metric engine.
Diffstat (limited to 'metrics')
-rw-r--r-- | metrics/src/vespa/metrics/metricmanager.cpp | 14 | ||||
-rw-r--r-- | metrics/src/vespa/metrics/metricmanager.h | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/metrics/src/vespa/metrics/metricmanager.cpp b/metrics/src/vespa/metrics/metricmanager.cpp index 5530e468007..e2e118a87ff 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 (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); |